Class: Kasabi::Jobs::Client

Inherits:
BaseClient show all
Defined in:
lib/kasabi/api/jobs.rb

Instance Attribute Summary

Attributes inherited from BaseClient

#apikey, #client, #endpoint

Instance Method Summary collapse

Methods inherited from BaseClient

#client_options, #get, #post, #validate_response

Constructor Details

#initialize(endpoint, options = {}) ⇒ Client

Initialize the jobs client to work with a specific endpoint

The options hash can contain the following values:

  • :apikey: required. apikey authorized to use the API

  • :client: HTTPClient object instance



11
12
13
# File 'lib/kasabi/api/jobs.rb', line 11

def initialize(endpoint, options={})
  super(endpoint, options)
end

Instance Method Details

#reset(t = Time.now()) ⇒ Object



15
16
17
18
19
# File 'lib/kasabi/api/jobs.rb', line 15

def reset(t=Time.now())
  time = t.getutc.strftime("%Y-%m-%dT%H:%M:%SZ")
  type = "reset"
  return submit_job(type, time)
end

#submit_job(type, time) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/kasabi/api/jobs.rb', line 21

def submit_job(type, time)
  response = post( @endpoint, {:jobType=>type, :startTime=>time}, {"Content-Type" => "application/x-www-form-urlencoded"} )
  if response.status != 202
    raise "Failed to submit job request. Status: #{response.status}. Message: #{response.content}"
  end
  
  return response.content                         
end