Module: SfCli::Sf::Data::UpsertResume

Included in:
Core
Defined in:
lib/sf_cli/sf/data/upsert_resume.rb

Instance Method Summary collapse

Instance Method Details

#upsert_resume(job_id:, wait: nil, target_org: nil, api_version: nil) ⇒ JobInfo, BulkResultV2

Resume a bulk upsert job you previously started with Bulk API 2.0 and return a bulk result object.

Examples:

# start a upsert job
jobinfo = sf.data.upsert_bulk sobject: :TestCustomObject__c, file: 'upsert.csv' # this returns immediately
jobinfo.id  # => "750J4000003g1OaIAI" it's job ID

# the job has already started asynchronously.
# So you should check its progress.
# if you want to wait for the job complete the task, try 'wait' option.
result = sf.data.upsert_resume job_id: jobinfo.id

puts 'yey!' if result.job_info.completed? # the job has completed

Parameters:

  • job_id (String)

    job ID you want to resume

  • wait (Integer) (defaults to: nil)

    max minutes to wait for the job complete the task

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

    an alias of paticular org, or username can be used

  • api_version (Numeric) (defaults to: nil)

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

Returns:

See Also:



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/sf_cli/sf/data/upsert_resume.rb', line 27

def upsert_resume(job_id:, wait: nil, target_org: nil, api_version: nil)
  flags = {
    :"job-id"     => job_id,
    :"wait"       => wait,
    :"target-org" => target_org,
    :"api-version"  => api_version,
  }
  action = __method__.to_s.tr('_', ' ')
  json = exec(action, flags: flags, redirection: :null_stderr)

  job_info =  ::SfCli::Sf::Data::JobInfo.new(**json['result']['jobInfo'])
  return job_info unless json['result']['records']

  ::SfCli::Sf::Data::BulkResultV2.new(
    job_info: job_info,
    records:  ::SfCli::Sf::Data::BulkRecordsV2.new(**json['result']['records'])
  )
end