Class: CloudhouseGuardian::ScheduledJob
- Inherits:
-
BaseObject
- Object
- BaseObject
- CloudhouseGuardian::ScheduledJob
- Defined in:
- lib/cloudhouse_guardian/ScheduledJob.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#id ⇒ Object
Returns the value of attribute id.
-
#source_id ⇒ Object
Returns the value of attribute source_id.
-
#source_name ⇒ Object
Returns the value of attribute source_name.
-
#source_type ⇒ Object
Returns the value of attribute source_type.
-
#status ⇒ Object
Returns the value of attribute status.
Attributes inherited from BaseObject
#appliance_api_key, #appliance_url, #insecure, #sec_key
Instance Method Summary collapse
- #cancel_jobs ⇒ Object
- #create ⇒ Object
- #delete ⇒ Object
- #from_hash(h) ⇒ Object
-
#initialize(appliance_url, appliance_api_key, sec_key, insecure = false) ⇒ ScheduledJob
constructor
A new instance of ScheduledJob.
- #load ⇒ Object
- #save ⇒ Object
- #to_hash ⇒ Object
- #to_json(options = nil) ⇒ Object
- #update ⇒ Object
Methods inherited from BaseObject
#http_delete, #http_get, #http_post, #http_put, #make_headers
Constructor Details
#initialize(appliance_url, appliance_api_key, sec_key, insecure = false) ⇒ ScheduledJob
Returns a new instance of ScheduledJob.
9 10 11 12 13 14 15 16 17 |
# File 'lib/cloudhouse_guardian/ScheduledJob.rb', line 9 def initialize(appliance_url, appliance_api_key, sec_key, insecure = false) super(appliance_url, appliance_api_key, sec_key, insecure) self.data = nil self.id = nil self.source_id = nil self.source_name = nil self.source_type = nil self.status = nil end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
3 4 5 |
# File 'lib/cloudhouse_guardian/ScheduledJob.rb', line 3 def data @data end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/cloudhouse_guardian/ScheduledJob.rb', line 4 def id @id end |
#source_id ⇒ Object
Returns the value of attribute source_id.
5 6 7 |
# File 'lib/cloudhouse_guardian/ScheduledJob.rb', line 5 def source_id @source_id end |
#source_name ⇒ Object
Returns the value of attribute source_name.
6 7 8 |
# File 'lib/cloudhouse_guardian/ScheduledJob.rb', line 6 def source_name @source_name end |
#source_type ⇒ Object
Returns the value of attribute source_type.
7 8 9 |
# File 'lib/cloudhouse_guardian/ScheduledJob.rb', line 7 def source_type @source_type end |
#status ⇒ Object
Returns the value of attribute status.
8 9 10 |
# File 'lib/cloudhouse_guardian/ScheduledJob.rb', line 8 def status @status end |
Instance Method Details
#cancel_jobs ⇒ Object
73 74 75 76 77 |
# File 'lib/cloudhouse_guardian/ScheduledJob.rb', line 73 def cancel_jobs url = "/api/v2/scheduled_jobs/#{self.id}/cancel_jobs.json" obj = http_post(url, nil) return obj end |
#create ⇒ Object
57 58 59 60 61 |
# File 'lib/cloudhouse_guardian/ScheduledJob.rb', line 57 def create h = to_hash out = http_post("/api/v2/scheduled_jobs.json", h) from_hash(out) end |
#delete ⇒ Object
69 70 71 |
# File 'lib/cloudhouse_guardian/ScheduledJob.rb', line 69 def delete http_delete("/api/v2/scheduled_jobs/#{self.id}.json") end |
#from_hash(h) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/cloudhouse_guardian/ScheduledJob.rb', line 19 def from_hash(h) self.data = h['data'] if h.include?('data') self.id = h['id'] if h.include?('id') self.source_id = h['source_id'] if h.include?('source_id') self.source_name = h['source_name'] if h.include?('source_name') self.source_type = h['source_type'] if h.include?('source_type') self.status = h['status'] if h.include?('status') end |
#load ⇒ Object
42 43 44 45 |
# File 'lib/cloudhouse_guardian/ScheduledJob.rb', line 42 def load obj = http_get("/api/v2/scheduled_jobs/#{self.id}.json") from_hash(obj) end |
#save ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/cloudhouse_guardian/ScheduledJob.rb', line 48 def save if self.id.to_i == 0 return create else return update end end |
#to_hash ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/cloudhouse_guardian/ScheduledJob.rb', line 27 def to_hash h = {} h['data'] = self.data h['id'] = self.id h['source_id'] = self.source_id h['source_name'] = self.source_name h['source_type'] = self.source_type h['status'] = self.status return h end |
#to_json(options = nil) ⇒ Object
37 38 39 40 |
# File 'lib/cloudhouse_guardian/ScheduledJob.rb', line 37 def to_json( = nil) h = to_hash return h.to_json() end |
#update ⇒ Object
64 65 66 67 |
# File 'lib/cloudhouse_guardian/ScheduledJob.rb', line 64 def update h = to_hash http_put("/api/v2/scheduled_jobs/#{self.id}.json", h) end |