Class: CloudhouseGuardian::NodeGroup
- Inherits:
-
BaseObject
- Object
- BaseObject
- CloudhouseGuardian::NodeGroup
- Defined in:
- lib/cloudhouse_guardian/NodeGroup.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#created_by ⇒ Object
Returns the value of attribute created_by.
-
#description ⇒ Object
Returns the value of attribute description.
-
#diff_notify ⇒ Object
Returns the value of attribute diff_notify.
-
#external_id ⇒ Object
Returns the value of attribute external_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#node_rules ⇒ Object
Returns the value of attribute node_rules.
-
#scan_options ⇒ Object
Returns the value of attribute scan_options.
-
#search_query ⇒ Object
Returns the value of attribute search_query.
-
#status ⇒ Object
Returns the value of attribute status.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
-
#updated_by ⇒ Object
Returns the value of attribute updated_by.
Attributes inherited from BaseObject
#appliance_api_key, #appliance_url, #insecure, #sec_key
Instance Method Summary collapse
- #add_user(user_id) ⇒ Object
- #create ⇒ Object
- #delete ⇒ Object
- #from_hash(h) ⇒ Object
-
#initialize(appliance_url, appliance_api_key, sec_key, insecure = false) ⇒ NodeGroup
constructor
A new instance of NodeGroup.
- #load ⇒ Object
- #nodes ⇒ Object
- #policy_versions ⇒ Object
- #remove_user(user_id) ⇒ Object
- #save ⇒ Object
- #to_hash ⇒ Object
- #to_json(options = nil) ⇒ Object
- #update ⇒ Object
- #users ⇒ 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) ⇒ NodeGroup
Returns a new instance of NodeGroup.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 16 def initialize(appliance_url, appliance_api_key, sec_key, insecure = false) super(appliance_url, appliance_api_key, sec_key, insecure) self.created_at = nil self.created_by = nil self.description = nil self.diff_notify = nil self.external_id = nil self.id = nil self.name = nil self.node_rules = nil self. = nil self.search_query = nil self.status = nil self.updated_at = nil self.updated_by = nil end |
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at.
3 4 5 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 3 def created_at @created_at end |
#created_by ⇒ Object
Returns the value of attribute created_by.
4 5 6 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 4 def created_by @created_by end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 5 def description @description end |
#diff_notify ⇒ Object
Returns the value of attribute diff_notify.
6 7 8 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 6 def diff_notify @diff_notify end |
#external_id ⇒ Object
Returns the value of attribute external_id.
7 8 9 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 7 def external_id @external_id end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 8 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 9 def name @name end |
#node_rules ⇒ Object
Returns the value of attribute node_rules.
10 11 12 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 10 def node_rules @node_rules end |
#scan_options ⇒ Object
Returns the value of attribute scan_options.
11 12 13 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 11 def @scan_options end |
#search_query ⇒ Object
Returns the value of attribute search_query.
12 13 14 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 12 def search_query @search_query end |
#status ⇒ Object
Returns the value of attribute status.
13 14 15 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 13 def status @status end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
14 15 16 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 14 def updated_at @updated_at end |
#updated_by ⇒ Object
Returns the value of attribute updated_by.
15 16 17 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 15 def updated_by @updated_by end |
Instance Method Details
#add_user(user_id) ⇒ Object
141 142 143 144 145 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 141 def add_user(user_id) url = "/api/v2/node_groups/#{self.id}/add_users.json?user_id=#{user_id}" obj = http_post(url, nil) return obj end |
#create ⇒ Object
85 86 87 88 89 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 85 def create h = to_hash out = http_post("/api/v2/node_groups.json", h) from_hash(out) end |
#delete ⇒ Object
97 98 99 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 97 def delete http_delete("/api/v2/node_groups/#{self.id}.json") end |
#from_hash(h) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 33 def from_hash(h) self.created_at = h['created_at'] if h.include?('created_at') self.created_by = h['created_by'] if h.include?('created_by') self.description = h['description'] if h.include?('description') self.diff_notify = h['diff_notify'] if h.include?('diff_notify') self.external_id = h['external_id'] if h.include?('external_id') self.id = h['id'] if h.include?('id') self.name = h['name'] if h.include?('name') self.node_rules = h['node_rules'] if h.include?('node_rules') self. = h['scan_options'] if h.include?('scan_options') self.search_query = h['search_query'] if h.include?('search_query') self.status = h['status'] if h.include?('status') self.updated_at = h['updated_at'] if h.include?('updated_at') self.updated_by = h['updated_by'] if h.include?('updated_by') end |
#load ⇒ Object
70 71 72 73 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 70 def load obj = http_get("/api/v2/node_groups/#{self.id}.json") from_hash(obj) end |
#nodes ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 102 def nodes obj = http_get("/api/v2/node_groups/#{self.id}/nodes.json") the_list = NodeList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure) obj.each do |x| elem = Node.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 |
#policy_versions ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 115 def policy_versions obj = http_get("/api/v2/node_groups/#{self.id}/policy_versions.json") the_list = PolicyVersionList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure) obj.each do |x| elem = PolicyVersion.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") elem.version = x["version"] if x.include?("version") the_list << elem end return the_list end |
#remove_user(user_id) ⇒ Object
147 148 149 150 151 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 147 def remove_user(user_id) url = "/api/v2/node_groups/#{self.id}/remove_user.json?user_id=#{user_id}" obj = http_put(url, nil) return obj end |
#save ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 76 def save if self.id.to_i == 0 return create else return update end end |
#to_hash ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 48 def to_hash h = {} h['created_at'] = self.created_at h['created_by'] = self.created_by h['description'] = self.description h['diff_notify'] = self.diff_notify h['external_id'] = self.external_id h['id'] = self.id h['name'] = self.name h['node_rules'] = self.node_rules h['scan_options'] = self. h['search_query'] = self.search_query h['status'] = self.status h['updated_at'] = self.updated_at h['updated_by'] = self.updated_by return h end |
#to_json(options = nil) ⇒ Object
65 66 67 68 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 65 def to_json( = nil) h = to_hash return h.to_json() end |
#update ⇒ Object
92 93 94 95 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 92 def update h = to_hash http_put("/api/v2/node_groups/#{self.id}.json", h) end |
#users ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/cloudhouse_guardian/NodeGroup.rb', line 129 def users obj = http_get("/api/v2/node_groups/#{self.id}/users.json") the_list = NodeGroupUserList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure) obj.each do |x| elem = NodeGroupUser.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure) elem.email = x["email"] if x.include?("email") elem.user_id = x["user_id"] if x.include?("user_id") the_list << elem end return the_list end |