Class: CloudhouseGuardian::OperatingSystem

Inherits:
BaseObject
  • Object
show all
Defined in:
lib/cloudhouse_guardian/OperatingSystem.rb

Instance Attribute Summary collapse

Attributes inherited from BaseObject

#appliance_api_key, #appliance_url, #insecure, #sec_key

Instance Method Summary collapse

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) ⇒ OperatingSystem

Returns a new instance of OperatingSystem.



7
8
9
10
11
12
13
# File 'lib/cloudhouse_guardian/OperatingSystem.rb', line 7

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.operating_system_family_id = nil
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/cloudhouse_guardian/OperatingSystem.rb', line 3

def description
  @description
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/cloudhouse_guardian/OperatingSystem.rb', line 4

def id
  @id
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/cloudhouse_guardian/OperatingSystem.rb', line 5

def name
  @name
end

#operating_system_family_idObject

Returns the value of attribute operating_system_family_id.



6
7
8
# File 'lib/cloudhouse_guardian/OperatingSystem.rb', line 6

def operating_system_family_id
  @operating_system_family_id
end

Instance Method Details

#from_hash(h) ⇒ Object



15
16
17
18
19
20
# File 'lib/cloudhouse_guardian/OperatingSystem.rb', line 15

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.operating_system_family_id = h['operating_system_family_id'] if h.include?('operating_system_family_id')
end

#operating_system_familyObject



34
35
36
37
38
39
40
# File 'lib/cloudhouse_guardian/OperatingSystem.rb', line 34

def operating_system_family
  obj = http_get("/api/v2/operating_system_families/#{self.operating_system_family_id}.json")
  elem = OperatingSystemFamily.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
    elem.id = obj["id"]
    elem.name = obj["name"]
  return elem
end

#to_hashObject



21
22
23
24
25
26
27
28
# File 'lib/cloudhouse_guardian/OperatingSystem.rb', line 21

def to_hash
  h = {}
  h['description'] = self.description
  h['id'] = self.id
  h['name'] = self.name
  h['operating_system_family_id'] = self.operating_system_family_id
  return h
end

#to_json(options = nil) ⇒ Object



29
30
31
32
# File 'lib/cloudhouse_guardian/OperatingSystem.rb', line 29

def to_json(options = nil)
  h = to_hash
  return h.to_json(options)
end