Module: SfCli::Sf::Project::RetrieveStart

Defined in:
lib/sf_cli/sf/project/retrieve_start.rb

Constant Summary collapse

Result =
Data.define(:done, :file_properties, :id, :status, :success, :messages, :files) do
  def success?
    success
  end
end
FileProperty =
Data.define(:created_by_id, :created_by_name, :created_date, :file_name, :full_name, :id,
:last_modified_by_id, :last_modified_by_name, :last_modified_date, :manageable_state, :type)
RetrievedFile =
Data.define(:full_name, :type, :state, :file_path)

Instance Method Summary collapse

Instance Method Details

#retrieve_start(metadata: nil, manifest: nil, source_dir: nil, package_name: nil, target_org: nil, output_dir: nil, raw_output: false, api_version: nil, wait: nil, target_metadata_dir: nil, zip_file_name: nil, ignore_conflicts: false, single_package: false, unzip: false) ⇒ Result

Retrieve metadata from an org to your local project.

Parameters:

  • manifest (String) (defaults to: nil)

    path of the manifest file(package.xml) that specifies the components to retrieve

  • metadata (Array) (defaults to: nil)

    metadata names that specifies the components to retrieve

  • source_dir (String) (defaults to: nil)

    file or directory path to retrieve from the org.

  • package_name (Array) (defaults to: nil)

    package names to retrieve

  • target_org (Symbol, String) (defaults to: nil)

    an alias of paticular org, or username can be used

  • output_dir (String) (defaults to: nil)

    directory root for the retrieved source files

  • api_version (Numeric) (defaults to: nil)

    override the api version used for api requests made by this command

  • wait (Integer) (defaults to: nil)

    number of minutes to wait for command to complete

  • ignore_conflicts (Boolean) (defaults to: false)

    ignore conflicts and retrieve and save files to your local filesystem

  • single_package (Boolean) (defaults to: false)

    indicates that the zip file points to a directory structure for a single package

  • unzip (Boolian) (defaults to: false)

    number of minutes to wait for command to complete

  • target_metadata_dir (String) (defaults to: nil)

    indicates that the zip file points to a directory structure for a single package

  • zip_file_name (String) (defaults to: nil)

    file name to use for the retrieved zip file

  • raw_output (Boolian) (defaults to: false)

    output what original command shows

Returns:

  • (Result)

    the retsult of the command

See Also:



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/sf_cli/sf/project/retrieve_start.rb', line 32

def retrieve_start(metadata: nil, manifest: nil,  source_dir: nil, package_name: nil, target_org: nil, output_dir: nil, raw_output: false,
  api_version: nil, wait: nil, target_metadata_dir: nil, zip_file_name: nil, ignore_conflicts: false, single_package: false, unzip: false)

  flags = {
    :manifest              => manifest,
    :metadata              => &.join(' '),
    :"source-dir"          => source_dir,
    :"package-name"        => package_name&.join(' '),
    :"target-org"          => target_org,
    :"output-dir"          => output_dir,
    :"api-version"         => api_version,
    :"wait"                => wait,
    :"target-metadata-dir" => ,
    :"zip-file-name"       => zip_file_name,
  }
  switches = {
    :"ignore-conflicts" => ignore_conflicts,
    :"single-package" => single_package,
    :"unzip" => unzip,
  }
  action = __method__.to_s.tr('_', ' ')
  command_output_format = raw_output ? :human : :json
  redirect_type = raw_output ? nil : :null_stderr
  output = exec(action, flags: flags, switches: switches, redirection: redirect_type, raw_output: raw_output, format: command_output_format)
  return output if raw_output

  Result.new(
    done:            output['result']['done'],
    file_properties: output['result']['fileProperties'].map{|fp| create_file_property(fp)},
    id:              output['result']['id'],
    status:          output['result']['status'],
    success:         output['result']['success'],
    messages:        output['result']['messages'],
    files:           output['result']['files'].map{|f| create_retrieved_file(f)}
  )
end