Module: Idcf::Ilb::ClientExtensions::Job

Included in:
Idcf::Ilb::Client
Defined in:
lib/idcf/ilb/client_extensions/job.rb

Overview

SDK APIs for job resource

Instance Method Summary collapse

Instance Method Details

#check_job(id, headers = {}, callback_and_args = [], specify_res_id = true) ⇒ Response

Check job result Get a resource data

Parameters:

  • id (String)

    ID of target job

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/idcf/ilb/client_extensions/job.rb', line 34

def check_job(id, headers = {}, callback_and_args = [], specify_res_id = true)
  flag = success?(id, headers)
  return if "DELETE" == @res.body["method"]
  if flag == true
    if specify_res_id == true
      res_id = @res.body["resource_id"]
      callback_and_args << res_id
    end
    callback_and_args.empty? ? true : __send__(*callback_and_args, headers)
  else
    raise(
      ApiError,
      "JOB Timeout."
    )
  end
end

#get_job(id, headers = {}) ⇒ Response

Get a job

Parameters:

  • id (String)

    ID of target job

  • headers (Hash) (defaults to: {})

    HTTP request headers

Returns:



25
26
27
# File 'lib/idcf/ilb/client_extensions/job.rb', line 25

def get_job(id, headers = {})
  get!("jobs/#{id}", {}, headers)
end

#jobs(headers = {}) ⇒ Array<Resources::Job>

Get an array of existing job objects.

Parameters:

  • headers (Hash) (defaults to: {})

    HTTP request headers

Returns:



55
56
57
58
59
# File 'lib/idcf/ilb/client_extensions/job.rb', line 55

def jobs(headers = {})
  list_jobs({}, headers).resources.map do |job|
    Resources::Job.new(self, job)
  end
end

#list_jobs(attributes = {}, headers = {}) ⇒ Response

Get list of existing jobs

Parameters:

  • attributes (Hash) (defaults to: {})

    request attributes

  • headers (Hash) (defaults to: {})

    HTTP request headers

Options Hash (attributes):

  • :resource (String)

    name of resource (optional)

  • :method (String)

    name of http method (optional)

  • :limit (Integer)

    value of limit (optional)

  • :offset (Integer)

    value of offset (optional)

Returns:



15
16
17
18
# File 'lib/idcf/ilb/client_extensions/job.rb', line 15

def list_jobs(attributes = {}, headers = {})
  Validators::Job.validate_attributes!(attributes, :list)
  get!("jobs", attributes, headers)
end