Class: UpGuard::ConnectionManagerGroup

Inherits:
BaseObject
  • Object
show all
Defined in:
lib/upguard/ConnectionManagerGroup.rb

Constant Summary collapse

STATUS_DISABLED =
0
STATUS_ACTIVE =
1

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

Returns a new instance of ConnectionManagerGroup.



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

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

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



3
4
5
# File 'lib/upguard/ConnectionManagerGroup.rb', line 3

def api_key
  @api_key
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/upguard/ConnectionManagerGroup.rb', line 4

def id
  @id
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/upguard/ConnectionManagerGroup.rb', line 5

def name
  @name
end

#statusObject

Returns the value of attribute status.



6
7
8
# File 'lib/upguard/ConnectionManagerGroup.rb', line 6

def status
  @status
end

Instance Method Details

#connection_managersObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/upguard/ConnectionManagerGroup.rb', line 36

def connection_managers
  obj = http_get("/api/v2/connection_manager_groups/#{self.id}/connection_managers.json")
  the_list = ConnectionManagerList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
  obj.each do |x|
    elem = ConnectionManager.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

#createObject



58
59
60
61
62
# File 'lib/upguard/ConnectionManagerGroup.rb', line 58

def create
  h = to_hash
  out = http_post("/api/v2/connection_manager_groups.json", h)
  from_hash(out)
end

#from_hash(h) ⇒ Object



15
16
17
18
19
20
# File 'lib/upguard/ConnectionManagerGroup.rb', line 15

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

#saveObject



49
50
51
52
53
54
55
# File 'lib/upguard/ConnectionManagerGroup.rb', line 49

def save
  if self.id.to_i == 0
    return create
  else
    raise "Cannot update a ConnectionManagerGroup"
  end
end

#to_hashObject



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

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

#to_json(options = nil) ⇒ Object



29
30
31
32
# File 'lib/upguard/ConnectionManagerGroup.rb', line 29

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