Class: UpGuard::Node
- Inherits:
-
BaseObject
- Object
- BaseObject
- UpGuard::Node
- Defined in:
- lib/upguard/Node.rb
Instance Attribute Summary collapse
-
#connection_manager_group_id ⇒ Object
Returns the value of attribute connection_manager_group_id.
-
#environment_id ⇒ Object
Returns the value of attribute environment_id.
-
#external_id ⇒ Object
Returns the value of attribute external_id.
-
#id ⇒ Object
Returns the value of attribute id.
-
#ip_address ⇒ Object
Returns the value of attribute ip_address.
-
#last_scan_status ⇒ Object
Returns the value of attribute last_scan_status.
-
#last_scan_status_string ⇒ Object
Returns the value of attribute last_scan_status_string.
-
#mac_address ⇒ Object
Returns the value of attribute mac_address.
-
#medium_hostname ⇒ Object
Returns the value of attribute medium_hostname.
-
#medium_info ⇒ Object
Returns the value of attribute medium_info.
-
#medium_port ⇒ Object
Returns the value of attribute medium_port.
-
#medium_type ⇒ Object
Returns the value of attribute medium_type.
-
#medium_username ⇒ Object
Returns the value of attribute medium_username.
-
#name ⇒ Object
Returns the value of attribute name.
-
#node_type ⇒ Object
Returns the value of attribute node_type.
-
#online ⇒ Object
Returns the value of attribute online.
-
#operating_system_family_id ⇒ Object
Returns the value of attribute operating_system_family_id.
-
#operating_system_id ⇒ Object
Returns the value of attribute operating_system_id.
-
#short_description ⇒ Object
Returns the value of attribute short_description.
Attributes inherited from BaseObject
#appliance_api_key, #appliance_url, #insecure, #sec_key
Instance Method Summary collapse
- #connection_manager_group ⇒ Object
- #create ⇒ Object
- #delete ⇒ Object
- #environment ⇒ Object
- #from_hash(h) ⇒ Object
-
#initialize(appliance_url, appliance_api_key, sec_key, insecure = false) ⇒ Node
constructor
A new instance of Node.
- #load ⇒ Object
- #node_groups ⇒ Object
- #node_scans ⇒ Object
- #operating_system ⇒ Object
- #operating_system_family ⇒ Object
- #raw_files ⇒ Object
- #save ⇒ Object
- #start_scan ⇒ Object
- #to_hash ⇒ Object
- #to_json(options = nil) ⇒ Object
- #update ⇒ 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) ⇒ Node
Returns a new instance of Node.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/upguard/Node.rb', line 22 def initialize(appliance_url, appliance_api_key, sec_key, insecure = false) super(appliance_url, appliance_api_key, sec_key, insecure) self.connection_manager_group_id = nil self.environment_id = nil self.external_id = nil self.id = nil self.ip_address = nil self.last_scan_status = nil self.last_scan_status_string = nil self.mac_address = nil self.medium_hostname = nil self.medium_info = NodeMediumInfo.new(appliance_url, appliance_api_key, sec_key, insecure) self.medium_port = nil self.medium_type = nil self.medium_username = nil self.name = nil self.node_type = nil self.online = nil self. = nil self. = nil self.short_description = nil end |
Instance Attribute Details
#connection_manager_group_id ⇒ Object
Returns the value of attribute connection_manager_group_id.
3 4 5 |
# File 'lib/upguard/Node.rb', line 3 def connection_manager_group_id @connection_manager_group_id end |
#environment_id ⇒ Object
Returns the value of attribute environment_id.
4 5 6 |
# File 'lib/upguard/Node.rb', line 4 def environment_id @environment_id end |
#external_id ⇒ Object
Returns the value of attribute external_id.
5 6 7 |
# File 'lib/upguard/Node.rb', line 5 def external_id @external_id end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/upguard/Node.rb', line 6 def id @id end |
#ip_address ⇒ Object
Returns the value of attribute ip_address.
7 8 9 |
# File 'lib/upguard/Node.rb', line 7 def ip_address @ip_address end |
#last_scan_status ⇒ Object
Returns the value of attribute last_scan_status.
8 9 10 |
# File 'lib/upguard/Node.rb', line 8 def last_scan_status @last_scan_status end |
#last_scan_status_string ⇒ Object
Returns the value of attribute last_scan_status_string.
9 10 11 |
# File 'lib/upguard/Node.rb', line 9 def last_scan_status_string @last_scan_status_string end |
#mac_address ⇒ Object
Returns the value of attribute mac_address.
10 11 12 |
# File 'lib/upguard/Node.rb', line 10 def mac_address @mac_address end |
#medium_hostname ⇒ Object
Returns the value of attribute medium_hostname.
11 12 13 |
# File 'lib/upguard/Node.rb', line 11 def medium_hostname @medium_hostname end |
#medium_info ⇒ Object
Returns the value of attribute medium_info.
12 13 14 |
# File 'lib/upguard/Node.rb', line 12 def medium_info @medium_info end |
#medium_port ⇒ Object
Returns the value of attribute medium_port.
13 14 15 |
# File 'lib/upguard/Node.rb', line 13 def medium_port @medium_port end |
#medium_type ⇒ Object
Returns the value of attribute medium_type.
14 15 16 |
# File 'lib/upguard/Node.rb', line 14 def medium_type @medium_type end |
#medium_username ⇒ Object
Returns the value of attribute medium_username.
15 16 17 |
# File 'lib/upguard/Node.rb', line 15 def medium_username @medium_username end |
#name ⇒ Object
Returns the value of attribute name.
16 17 18 |
# File 'lib/upguard/Node.rb', line 16 def name @name end |
#node_type ⇒ Object
Returns the value of attribute node_type.
17 18 19 |
# File 'lib/upguard/Node.rb', line 17 def node_type @node_type end |
#online ⇒ Object
Returns the value of attribute online.
18 19 20 |
# File 'lib/upguard/Node.rb', line 18 def online @online end |
#operating_system_family_id ⇒ Object
Returns the value of attribute operating_system_family_id.
19 20 21 |
# File 'lib/upguard/Node.rb', line 19 def @operating_system_family_id end |
#operating_system_id ⇒ Object
Returns the value of attribute operating_system_id.
20 21 22 |
# File 'lib/upguard/Node.rb', line 20 def @operating_system_id end |
#short_description ⇒ Object
Returns the value of attribute short_description.
21 22 23 |
# File 'lib/upguard/Node.rb', line 21 def short_description @short_description end |
Instance Method Details
#connection_manager_group ⇒ Object
127 128 129 130 131 132 133 |
# File 'lib/upguard/Node.rb', line 127 def connection_manager_group obj = http_get("/api/v2/connection_manager_groups/{connection_manager_group_id}.json") elem = ConnectionManagerGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure) elem.id = obj["id"] elem.name = obj["name"] return elem end |
#create ⇒ Object
109 110 111 112 113 |
# File 'lib/upguard/Node.rb', line 109 def create h = to_hash out = http_post("/api/v2/nodes.json", h) from_hash(out) end |
#delete ⇒ Object
122 123 124 |
# File 'lib/upguard/Node.rb', line 122 def delete http_delete("/api/v2/nodes/#{self.id}.json") end |
#environment ⇒ Object
136 137 138 139 140 141 142 |
# File 'lib/upguard/Node.rb', line 136 def environment obj = http_get("/api/v2/environments/#{self.environment_id}.json") elem = Environment.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure) elem.id = obj["id"] elem.name = obj["name"] return elem end |
#from_hash(h) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/upguard/Node.rb', line 45 def from_hash(h) self.connection_manager_group_id = h['connection_manager_group_id'] if h.include?('connection_manager_group_id') self.environment_id = h['environment_id'] if h.include?('environment_id') self.external_id = h['external_id'] if h.include?('external_id') self.id = h['id'] if h.include?('id') self.ip_address = h['ip_address'] if h.include?('ip_address') self.last_scan_status = h['last_scan_status'] if h.include?('last_scan_status') self.last_scan_status_string = h['last_scan_status_string'] if h.include?('last_scan_status_string') self.mac_address = h['mac_address'] if h.include?('mac_address') self.medium_hostname = h['medium_hostname'] if h.include?('medium_hostname') self.medium_info = h['medium_info'] if h.include?('medium_info') self.medium_port = h['medium_port'] if h.include?('medium_port') self.medium_type = h['medium_type'] if h.include?('medium_type') self.medium_username = h['medium_username'] if h.include?('medium_username') self.name = h['name'] if h.include?('name') self.node_type = h['node_type'] if h.include?('node_type') self.online = h['online'] if h.include?('online') self. = h['operating_system_family_id'] if h.include?('operating_system_family_id') self. = h['operating_system_id'] if h.include?('operating_system_id') self.short_description = h['short_description'] if h.include?('short_description') end |
#load ⇒ Object
94 95 96 97 |
# File 'lib/upguard/Node.rb', line 94 def load obj = http_get("/api/v2/nodes/#{self.id}.json") from_hash(obj) end |
#node_groups ⇒ Object
186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/upguard/Node.rb', line 186 def node_groups obj = http_get("/api/v2/nodes/#{self.id}/node_groups.json") the_list = NodeGroupList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure) obj.each do |x| elem = NodeGroup.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.description = x["description"] if x.include?("description") elem.node_rules = x["node_rules"] if x.include?("node_rules") the_list << elem end return the_list end |
#node_scans ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/upguard/Node.rb', line 168 def node_scans url = "/api/v2/node_scans.json?node_id=#{self.id}&per_page=5000" obj = http_get(url) the_list = NodeScanList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure) obj.each do |x| elem = NodeScan.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure) elem.id = x["id"] elem.node_id = x["node_id"] elem.created_at = x["created_at"] elem.updated_at = x["updated_at"] elem. = x["scan_options"] the_list << elem end return the_list end |
#operating_system ⇒ Object
145 146 147 148 149 150 151 |
# File 'lib/upguard/Node.rb', line 145 def obj = http_get("/api/v2/operating_systems/#{self.}.json") elem = OperatingSystem.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure) elem.id = obj["id"] elem.name = obj["name"] return elem end |
#operating_system_family ⇒ Object
154 155 156 157 158 159 160 |
# File 'lib/upguard/Node.rb', line 154 def obj = http_get("/api/v2/operating_system_families/#{self.}.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 |
#raw_files ⇒ Object
201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/upguard/Node.rb', line 201 def raw_files obj = http_get("/api/v2/nodes/#{self.id}/raw_files.json") the_list = RawFileList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure) obj.each do |x| elem = RawFile.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure) elem.id = x["id"] if x.include?("id") elem.node_scan_id = x["node_scan_id"] if x.include?("node_scan_id") elem.created_at = x["created_at"] if x.include?("created_at") elem.updated_at = x["updated_at"] if x.include?("updated_at") the_list << elem end return the_list end |
#save ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/upguard/Node.rb', line 100 def save if self.id.to_i == 0 return create else return update end end |
#start_scan ⇒ Object
162 163 164 165 166 |
# File 'lib/upguard/Node.rb', line 162 def start_scan url = "/api/v2/nodes/#{self.id}/start_scan.json" obj = http_post(url, nil) return obj end |
#to_hash ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/upguard/Node.rb', line 66 def to_hash h = {} h['connection_manager_group_id'] = self.connection_manager_group_id h['environment_id'] = self.environment_id h['external_id'] = self.external_id h['id'] = self.id h['ip_address'] = self.ip_address h['last_scan_status'] = self.last_scan_status h['last_scan_status_string'] = self.last_scan_status_string h['mac_address'] = self.mac_address h['medium_hostname'] = self.medium_hostname h['medium_info'] = self.medium_info h['medium_port'] = self.medium_port h['medium_type'] = self.medium_type h['medium_username'] = self.medium_username h['name'] = self.name h['node_type'] = self.node_type h['online'] = self.online h['operating_system_family_id'] = self. h['operating_system_id'] = self. h['short_description'] = self.short_description return h end |
#to_json(options = nil) ⇒ Object
89 90 91 92 |
# File 'lib/upguard/Node.rb', line 89 def to_json( = nil) h = to_hash return h.to_json() end |
#update ⇒ Object
116 117 118 119 120 |
# File 'lib/upguard/Node.rb', line 116 def update h = to_hash h.delete("id") http_put("/api/v2/nodes/#{self.id}.json", h) end |