Class: CloudhouseGuardian::OperatingSystemFamily

Inherits:
BaseObject
  • Object
show all
Defined in:
lib/cloudhouse_guardian/OperatingSystemFamily.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) ⇒ OperatingSystemFamily

Returns a new instance of OperatingSystemFamily.



5
6
7
8
9
# File 'lib/cloudhouse_guardian/OperatingSystemFamily.rb', line 5

def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
  super(appliance_url, appliance_api_key, sec_key, insecure)
  self.id = nil
  self.name = nil
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#from_hash(h) ⇒ Object



11
12
13
14
# File 'lib/cloudhouse_guardian/OperatingSystemFamily.rb', line 11

def from_hash(h)
  self.id = h['id'] if h.include?('id')
  self.name = h['name'] if h.include?('name')
end

#operating_systemsObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cloudhouse_guardian/OperatingSystemFamily.rb', line 26

def operating_systems
  obj = http_get("/api/v2/operating_system_families/#{self.id}/operating_systems.json")
  the_list = OperatingSystemList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
  obj.each do |x|
    elem = OperatingSystem.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
    elem.id = x["id"] if x.include?("id")
    elem.name = x["name"] if x.include?("name")
    the_list << elem
  end
  return the_list
end

#to_hashObject



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

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

#to_json(options = nil) ⇒ Object



21
22
23
24
# File 'lib/cloudhouse_guardian/OperatingSystemFamily.rb', line 21

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