Module: TreasureData::API::Export

Included in:
TreasureData::API
Defined in:
lib/td/client/api/export.rb

Instance Method Summary collapse

Instance Method Details

#export(db, table, storage_type, opts = {}) ⇒ String

> jobId:String

Parameters:

  • db (String)
  • table (String)
  • storage_type (String)
  • opts (Hash) (defaults to: {})

Returns:

  • (String)

    job_id



14
15
16
17
18
19
20
21
22
23
# File 'lib/td/client/api/export.rb', line 14

def export(db, table, storage_type, opts={})
  params = opts.dup
  params['storage_type'] = storage_type
  code, body, res = post("/v3/export/run/#{e db}/#{e table}", params)
  if code != "200"
    raise_error("Export failed", res)
  end
  js = checked_json(body, %w[job_id])
  return js['job_id'].to_s
end

#result_export(target_job_id, opts = {}) ⇒ String

> jobId:String

Parameters:

  • target_job_id (String)
  • opts (Hash) (defaults to: {})

Returns:

  • (String)

    job_id



29
30
31
32
33
34
35
36
# File 'lib/td/client/api/export.rb', line 29

def result_export(target_job_id, opts={})
  code, body, res = post("/v3/job/result_export/#{target_job_id}", opts)
  if code[0] != ?2
    raise_error("Result Export failed", res)
  end
  js = checked_json(body, %w[job_id])
  return js['job_id'].to_s
end