Class: UpGuard::ConnectionManagerGroup
- Inherits:
-
BaseObject
- Object
- BaseObject
- UpGuard::ConnectionManagerGroup
- Defined in:
- lib/upguard/ConnectionManagerGroup.rb
Constant Summary collapse
- STATUS_DISABLED =
0
- STATUS_ACTIVE =
1
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#status ⇒ Object
Returns the value of attribute status.
Attributes inherited from BaseObject
#appliance_api_key, #appliance_url, #insecure, #sec_key
Instance Method Summary collapse
- #connection_managers ⇒ Object
- #create ⇒ Object
- #from_hash(h) ⇒ Object
-
#initialize(appliance_url, appliance_api_key, sec_key, insecure = false) ⇒ ConnectionManagerGroup
constructor
A new instance of ConnectionManagerGroup.
- #save ⇒ Object
- #to_hash ⇒ Object
- #to_json(options = nil) ⇒ 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) ⇒ 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_key ⇒ Object
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/upguard/ConnectionManagerGroup.rb', line 3 def api_key @api_key end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/upguard/ConnectionManagerGroup.rb', line 4 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/upguard/ConnectionManagerGroup.rb', line 5 def name @name end |
#status ⇒ Object
Returns the value of attribute status.
6 7 8 |
# File 'lib/upguard/ConnectionManagerGroup.rb', line 6 def status @status end |
Instance Method Details
#connection_managers ⇒ Object
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 |
#create ⇒ Object
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 |
#save ⇒ Object
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_hash ⇒ Object
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( = nil) h = to_hash return h.to_json() end |