Class: Cloudhdr::Job

Inherits:
Base
  • Object
show all
Defined in:
lib/cloudhdr/job.rb

Class Method Summary collapse

Methods inherited from Base

api_key, base_url, decode, #decode, encode, #encode

Class Method Details

.cancel(job_id, options = {}) ⇒ Object


34
35
36
37
# File 'lib/cloudhdr/job.rb', line 34

def self.cancel(job_id, options={})
  params = {:api_key => options.delete(:api_key) || api_key}
  HTTP.get("#{options[:base_url] || base_url}/api/v1/jobs/#{job_id}/cancel.#{pick_format options}", merge_params(options, params))
end

.create(params = {}, options = {}) ⇒ Object


8
9
10
11
12
13
# File 'lib/cloudhdr/job.rb', line 8

def self.create(params={}, options={})
  params = apply_api_key(params, options[:format])
  HTTP.post("#{options[:base_url] || base_url}/api/v1/jobs.#{pick_format options}",
                       encode(params, options[:format]),
                       options)
end

.delete(job_id, options = {}) ⇒ Object


39
40
41
42
# File 'lib/cloudhdr/job.rb', line 39

def self.delete(job_id, options={})
  params = {:api_key => options.delete(:api_key) || api_key}
  HTTP.delete("#{options[:base_url] || base_url}/api/v1/jobs/#{job_id}.#{pick_format options}", merge_params(options, params))
end

.details(job_id, options = {}) ⇒ Object


24
25
26
27
# File 'lib/cloudhdr/job.rb', line 24

def self.details(job_id, options={})
  params = {:api_key => options.delete(:api_key) || api_key}
  HTTP.get("#{options[:base_url] || base_url}/api/v1/jobs/#{job_id}.#{pick_format options}", merge_params(options, params))
end

.list(options = {}) ⇒ Object


15
16
17
18
19
20
21
22
# File 'lib/cloudhdr/job.rb', line 15

def self.list(options={})
  params = {:api_key  => options.delete(:api_key) || api_key,
            :page     => options.delete(:page) || 1,
            :per_page => options.delete(:per_page) || 50,
            :state    => options.delete(:state) }

  HTTP.get("#{options[:base_url] || base_url}/api/v1/jobs.#{pick_format options}", merge_params(options, params))
end

.pick_format(options) ⇒ Object


4
5
6
# File 'lib/cloudhdr/job.rb', line 4

def self.pick_format(options)
  options[:format] || "json" 
end

.resubmit(job_id, options = {}) ⇒ Object


29
30
31
32
# File 'lib/cloudhdr/job.rb', line 29

def self.resubmit(job_id, options={})
  params = {:api_key => options.delete(:api_key) || api_key}
  HTTP.get("#{options[:base_url] || base_url}/api/v1/jobs/#{job_id}/resubmit.#{pick_format options}", merge_params(options, params))
end