Class: CloudhouseGuardian::Pluggable
- Inherits:
-
BaseObject
- Object
- BaseObject
- CloudhouseGuardian::Pluggable
- Defined in:
- lib/cloudhouse_guardian/Pluggable.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#operating_system_family ⇒ Object
Returns the value of attribute operating_system_family.
-
#operating_system_family_id ⇒ Object
Returns the value of attribute operating_system_family_id.
-
#operating_system_id ⇒ Object
Returns the value of attribute operating_system_id.
-
#script ⇒ Object
Returns the value of attribute script.
Attributes inherited from BaseObject
#appliance_api_key, #appliance_url, #insecure, #sec_key
Instance Method Summary collapse
- #create ⇒ Object
- #delete ⇒ Object
- #from_hash(h) ⇒ Object
-
#initialize(appliance_url, appliance_api_key, sec_key, insecure = false) ⇒ Pluggable
constructor
A new instance of Pluggable.
- #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) ⇒ Pluggable
Returns a new instance of Pluggable.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/cloudhouse_guardian/Pluggable.rb', line 10 def initialize(appliance_url, appliance_api_key, sec_key, insecure = false) super(appliance_url, appliance_api_key, sec_key, insecure) self.description = nil self.id = nil self.name = nil self. = nil self. = nil self. = nil self.script = nil end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/cloudhouse_guardian/Pluggable.rb', line 3 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/cloudhouse_guardian/Pluggable.rb', line 4 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/cloudhouse_guardian/Pluggable.rb', line 5 def name @name end |
#operating_system_family ⇒ Object
Returns the value of attribute operating_system_family.
6 7 8 |
# File 'lib/cloudhouse_guardian/Pluggable.rb', line 6 def @operating_system_family end |
#operating_system_family_id ⇒ Object
Returns the value of attribute operating_system_family_id.
7 8 9 |
# File 'lib/cloudhouse_guardian/Pluggable.rb', line 7 def @operating_system_family_id end |
#operating_system_id ⇒ Object
Returns the value of attribute operating_system_id.
8 9 10 |
# File 'lib/cloudhouse_guardian/Pluggable.rb', line 8 def @operating_system_id end |
#script ⇒ Object
Returns the value of attribute script.
9 10 11 |
# File 'lib/cloudhouse_guardian/Pluggable.rb', line 9 def script @script end |
Instance Method Details
#create ⇒ Object
61 62 63 64 65 |
# File 'lib/cloudhouse_guardian/Pluggable.rb', line 61 def create h = to_hash out = http_post("/api/v2/pluggables.json", h) from_hash(out) end |
#delete ⇒ Object
75 76 77 |
# File 'lib/cloudhouse_guardian/Pluggable.rb', line 75 def delete http_delete("/api/v2/pluggables/#{self.}.json") end |
#from_hash(h) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/cloudhouse_guardian/Pluggable.rb', line 21 def from_hash(h) self.description = h['description'] if h.include?('description') self.id = h['id'] if h.include?('id') self.name = h['name'] if h.include?('name') self. = h['operating_system_family'] if h.include?('operating_system_family') self. = h['operating_system_family_id'] if h.include?('operating_system_family_id') self. = h['operating_system_id'] if h.include?('operating_system_id') self.script = h['script'] if h.include?('script') end |
#load ⇒ Object
46 47 48 49 |
# File 'lib/cloudhouse_guardian/Pluggable.rb', line 46 def load obj = http_get("/api/v2/pluggables/#{self.}.json") from_hash(obj) end |
#save ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/cloudhouse_guardian/Pluggable.rb', line 52 def save if self.id.to_i == 0 return create else return update end end |
#to_hash ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cloudhouse_guardian/Pluggable.rb', line 30 def to_hash h = {} h['description'] = self.description h['id'] = self.id h['name'] = self.name h['operating_system_family'] = self. h['operating_system_family_id'] = self. h['operating_system_id'] = self. h['script'] = self.script return h end |
#to_json(options = nil) ⇒ Object
41 42 43 44 |
# File 'lib/cloudhouse_guardian/Pluggable.rb', line 41 def to_json( = nil) h = to_hash return h.to_json() end |
#update ⇒ Object
68 69 70 71 72 73 |
# File 'lib/cloudhouse_guardian/Pluggable.rb', line 68 def update h = to_hash h.delete("operating_system_family_id") h.delete("operating_system_id") http_put("/api/v2/pluggables/#{self.}.json", h) end |