upguard 0.0.3 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/lib/upguard.rb +25 -0
  3. data/lib/upguard/Account.rb +374 -129
  4. data/lib/upguard/BaseObject.rb +23 -22
  5. data/lib/upguard/ChangeRequest.rb +42 -0
  6. data/lib/upguard/ChangeRequestList.rb +52 -0
  7. data/lib/upguard/ConnectionManager.rb +18 -3
  8. data/lib/upguard/ConnectionManagerGroup.rb +31 -9
  9. data/lib/upguard/ConnectionManagerGroupList.rb +52 -0
  10. data/lib/upguard/ConnectionManagerList.rb +52 -0
  11. data/lib/upguard/Environment.rb +34 -11
  12. data/lib/upguard/EnvironmentList.rb +52 -0
  13. data/lib/upguard/Event.rb +6 -3
  14. data/lib/upguard/EventAction.rb +8 -2
  15. data/lib/upguard/EventActionList.rb +52 -0
  16. data/lib/upguard/EventList.rb +52 -0
  17. data/lib/upguard/EventVariables.rb +43 -0
  18. data/lib/upguard/ExternalEvent.rb +30 -0
  19. data/lib/upguard/Incident.rb +2 -2
  20. data/lib/upguard/IncidentList.rb +52 -0
  21. data/lib/upguard/Job.rb +60 -0
  22. data/lib/upguard/JobList.rb +52 -0
  23. data/lib/upguard/MediumType.rb +5 -2
  24. data/lib/upguard/Node.rb +63 -9
  25. data/lib/upguard/NodeGroup.rb +80 -8
  26. data/lib/upguard/NodeGroupList.rb +63 -0
  27. data/lib/upguard/NodeGroupUser.rb +21 -0
  28. data/lib/upguard/NodeGroupUserList.rb +63 -0
  29. data/lib/upguard/NodeList.rb +52 -0
  30. data/lib/upguard/NodeMediumInfo.rb +49 -0
  31. data/lib/upguard/NodeType.rb +12 -2
  32. data/lib/upguard/OperatingSystem.rb +3 -3
  33. data/lib/upguard/OperatingSystemFamily.rb +8 -8
  34. data/lib/upguard/OperatingSystemFamilyList.rb +52 -0
  35. data/lib/upguard/OperatingSystemList.rb +52 -0
  36. data/lib/upguard/Policy.rb +79 -0
  37. data/lib/upguard/PolicyList.rb +52 -0
  38. data/lib/upguard/ScheduledJob.rb +6 -3
  39. data/lib/upguard/ScheduledJobList.rb +52 -0
  40. data/lib/upguard/SystemMetric.rb +2 -2
  41. data/lib/upguard/SystemMetricList.rb +52 -0
  42. data/lib/upguard/User.rb +26 -2
  43. data/lib/upguard/UserList.rb +74 -0
  44. data/lib/upguard/Version.rb +21 -0
  45. metadata +35 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 84863a2eb3a24e4e56d9f29c18c23017058b037f
4
- data.tar.gz: 74c848cc0e8289fdd8f7f65e2f41f60cf01af0f7
2
+ SHA256:
3
+ metadata.gz: 02c8e4f7f0d117e6f9f7e396b7188c7f0a75221dd4ba8bea61633e3405e3e56a
4
+ data.tar.gz: 610294a9da4ecbd52eacba9b92c0b6eed17e38a10d0531955e9dd435fed5b53c
5
5
  SHA512:
6
- metadata.gz: 49064d986ecd8fa1124fda08af64eb0266436149458fddf3612c806e5d37dae6e7c33bc2568bb03d6422b3b247f6b6835d7f9c6bc07c4c64ea641e88a6dd7fe2
7
- data.tar.gz: e9de7224ab8cd38f0a00ae75d234b263be9db5ee211330bc66c60aff9acd1279d2b73ba3fc803a0cce3eabf0a48b7b4fdbd50f929ee25358422ec4234ace4e17
6
+ metadata.gz: 80857243f93931a9d59229f966a3c997a790c03a923112d3b26425106cae64832eb0778cbf3c70ffb24464f74f0f715ae31f22138744acf45add1877435d1aa7
7
+ data.tar.gz: 6cdb09dffdeeb6c662442b676c14fe94b85648d9bf9df928689860a268f08171f94105585434792e62632e06eaf82467a05a373dbfcebddcad7efa5db96d08f9
@@ -1,17 +1,42 @@
1
1
  require_relative 'upguard/BaseObject'
2
+ require_relative 'upguard/Version'
2
3
  require_relative 'upguard/Account'
4
+ require_relative 'upguard/ChangeRequest'
5
+ require_relative 'upguard/ChangeRequestList'
3
6
  require_relative 'upguard/ConnectionManager'
7
+ require_relative 'upguard/ConnectionManagerList'
4
8
  require_relative 'upguard/ConnectionManagerGroup'
9
+ require_relative 'upguard/ConnectionManagerGroupList'
5
10
  require_relative 'upguard/Environment'
11
+ require_relative 'upguard/EnvironmentList'
12
+ require_relative 'upguard/ExternalEvent'
6
13
  require_relative 'upguard/Event'
14
+ require_relative 'upguard/EventList'
15
+ require_relative 'upguard/EventVariables'
7
16
  require_relative 'upguard/EventAction'
17
+ require_relative 'upguard/EventActionList'
8
18
  require_relative 'upguard/Incident'
19
+ require_relative 'upguard/IncidentList'
20
+ require_relative 'upguard/Job'
21
+ require_relative 'upguard/JobList'
9
22
  require_relative 'upguard/MediumType'
10
23
  require_relative 'upguard/Node'
24
+ require_relative 'upguard/NodeList'
11
25
  require_relative 'upguard/NodeGroup'
26
+ require_relative 'upguard/NodeGroupList'
27
+ require_relative 'upguard/NodeGroupUser'
28
+ require_relative 'upguard/NodeGroupUserList'
29
+ require_relative 'upguard/NodeMediumInfo'
12
30
  require_relative 'upguard/NodeType'
13
31
  require_relative 'upguard/OperatingSystem'
32
+ require_relative 'upguard/OperatingSystemList'
14
33
  require_relative 'upguard/OperatingSystemFamily'
34
+ require_relative 'upguard/OperatingSystemFamilyList'
35
+ require_relative 'upguard/Policy'
36
+ require_relative 'upguard/PolicyList'
15
37
  require_relative 'upguard/ScheduledJob'
38
+ require_relative 'upguard/ScheduledJobList'
16
39
  require_relative 'upguard/SystemMetric'
40
+ require_relative 'upguard/SystemMetricList'
17
41
  require_relative 'upguard/User'
42
+ require_relative 'upguard/UserList'
@@ -12,221 +12,488 @@ module UpGuard
12
12
  h['name'] = self.name
13
13
  return h
14
14
  end
15
- def to_json
15
+ def to_json(options = nil)
16
16
  h = to_hash
17
- return h.to_json
17
+ return h.to_json(options)
18
18
  end
19
19
 
20
+ def change_request_by_id(id)
21
+ obj = http_get("/api/v2/change_requests/#{id}.json")
22
+ elem = ChangeRequest.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
23
+ elem.external_id = obj["external_id"]
24
+ elem.id = obj["id"]
25
+ elem.planned_end_date = obj["planned_end_date"]
26
+ elem.planned_start_date = obj["planned_start_date"]
27
+ elem.short_description = obj["short_description"]
28
+ elem.started_at = obj["started_at"]
29
+ elem.ended_at = obj["ended_at"]
30
+ return elem
31
+ end
32
+
33
+
34
+ def change_requests
35
+ obj = http_get("/api/v2/change_requests.json")
36
+ the_list = ChangeRequestList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
37
+ obj.each do |x|
38
+ elem = ChangeRequest.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
39
+ elem.external_id = x["external_id"] if x.include?("external_id")
40
+ elem.id = x["id"] if x.include?("id")
41
+ elem.planned_end_date = x["planned_end_date"] if x.include?("planned_end_date")
42
+ elem.planned_start_date = x["planned_start_date"] if x.include?("planned_start_date")
43
+ elem.short_description = x["short_description"] if x.include?("short_description")
44
+ elem.started_at = x["started_at"] if x.include?("started_at")
45
+ elem.ended_at = x["ended_at"] if x.include?("ended_at")
46
+ the_list << elem
47
+ end
48
+ return the_list
49
+ end
50
+
51
+ def new_connection_manager_group
52
+ return ConnectionManagerGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
53
+ end
54
+
55
+
20
56
  def connection_managers
21
57
  obj = http_get("/api/v2/connection_managers.json")
22
- list = []
58
+ the_list = ConnectionManagerList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
23
59
  obj.each do |x|
24
- elem = ConnectionManager.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
25
- elem.id = x["id"]
26
- elem.hostname = x["hostname"]
27
- elem.last_contact = x["last_contact"]
28
- list << elem
60
+ elem = ConnectionManager.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
61
+ elem.channels = x["channels"] if x.include?("channels")
62
+ elem.connection_manager_group_id = x["connection_manager_group_id"] if x.include?("connection_manager_group_id")
63
+ elem.created_at = x["created_at"] if x.include?("created_at")
64
+ elem.hostname = x["hostname"] if x.include?("hostname")
65
+ elem.id = x["id"] if x.include?("id")
66
+ elem.last_contact = x["last_contact"] if x.include?("last_contact")
67
+ elem.stats = x["stats"] if x.include?("stats")
68
+ elem.updated_at = x["updated_at"] if x.include?("updated_at")
69
+ the_list << elem
29
70
  end
30
- return list
71
+ return the_list
31
72
  end
32
73
 
33
74
 
34
75
  def connection_manager_groups
35
76
  obj = http_get("/api/v2/connection_manager_groups.json")
36
- list = []
77
+ the_list = ConnectionManagerGroupList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
37
78
  obj.each do |x|
38
- elem = ConnectionManagerGroup.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
39
- elem.id = x["id"]
40
- elem.name = x["name"]
41
- list << elem
79
+ elem = ConnectionManagerGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
80
+ elem.id = x["id"] if x.include?("id")
81
+ elem.name = x["name"] if x.include?("name")
82
+ elem.organisation_id = x["organisation_id"] if x.include?("organisation_id")
83
+ elem.status = x["status"] if x.include?("status")
84
+ the_list << elem
42
85
  end
43
- return list
86
+ return the_list
44
87
  end
45
88
 
46
89
  def new_environment
47
- return Environment.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
90
+ return Environment.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
91
+ end
92
+
93
+
94
+ def environment_by_id(id)
95
+ obj = http_get("/api/v2/environments/#{id}.json")
96
+ elem = Environment.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
97
+ elem.id = obj["id"]
98
+ elem.name = obj["name"]
99
+ return elem
48
100
  end
49
101
 
50
102
 
51
103
  def environments
52
104
  obj = http_get("/api/v2/environments.json")
53
- list = []
105
+ the_list = EnvironmentList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
54
106
  obj.each do |x|
55
- elem = Environment.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
56
- elem.id = x["id"]
57
- elem.name = x["name"]
58
- list << elem
107
+ elem = Environment.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
108
+ elem.description = x["description"] if x.include?("description")
109
+ elem.id = x["id"] if x.include?("id")
110
+ elem.name = x["name"] if x.include?("name")
111
+ elem.node_rules = x["node_rules"] if x.include?("node_rules")
112
+ elem.short_description = x["short_description"] if x.include?("short_description")
113
+ the_list << elem
59
114
  end
60
- return list
115
+ return the_list
116
+ end
117
+
118
+ def new_external_event
119
+ return ExternalEvent.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
61
120
  end
62
121
 
63
122
  def events_with_view_name(view_name)
64
123
  url = "/api/v2/events.json?view_name=#{view_name}"
65
124
  obj = http_get(url)
66
- list = []
125
+ the_list = EventList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure
67
126
  obj.each do |x|
68
- elem = Event.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
127
+ elem = Event.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
69
128
  elem.id = x["id"]
70
129
  elem.type_id = x["type_id"]
71
130
  elem.environment_id = x["environment_id"]
72
131
  elem.created_at = x["created_at"]
73
- list << elem
132
+ the_list << elem
74
133
  end
75
- return list
134
+ return the_list
76
135
  end
77
136
 
78
137
  def events_with_query(query)
79
138
  url = "/api/v2/events.json?query=#{query}"
80
139
  obj = http_get(url)
81
- list = []
140
+ the_list = EventList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure
82
141
  obj.each do |x|
83
- elem = Event.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
142
+ elem = Event.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
84
143
  elem.id = x["id"]
85
144
  elem.type_id = x["type_id"]
86
145
  elem.environment_id = x["environment_id"]
87
146
  elem.created_at = x["created_at"]
88
- list << elem
147
+ the_list << elem
89
148
  end
90
- return list
149
+ return the_list
150
+ end
151
+
152
+
153
+ def event_action_by_id(id)
154
+ obj = http_get("/api/v2/event_actions/#{id}.json")
155
+ elem = EventAction.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
156
+ elem.id = obj["id"]
157
+ elem.name = obj["name"]
158
+ return elem
159
+ end
160
+
161
+
162
+ def event_types
163
+ obj = http_get("/api/v2/events/types.json")
164
+ the_list = EventTypeList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
165
+ obj.each do |x|
166
+ elem = EventType.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
167
+ elem.id = x["id"] if x.include?("id")
168
+ elem.name = x["name"] if x.include?("name")
169
+ the_list << elem
170
+ end
171
+ return the_list
91
172
  end
92
173
 
93
174
 
94
175
  def event_actions
95
176
  obj = http_get("/api/v2/event_actions.json")
96
- list = []
177
+ the_list = EventActionList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
97
178
  obj.each do |x|
98
- elem = EventAction.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
99
- elem.id = x["id"]
100
- elem.name = x["name"]
101
- elem.status = x["status"]
102
- elem.type = x["type"]
103
- list << elem
179
+ elem = EventAction.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
180
+ elem.id = x["id"] if x.include?("id")
181
+ elem.name = x["name"] if x.include?("name")
182
+ elem.status = x["status"] if x.include?("status")
183
+ elem.type = x["type"] if x.include?("type")
184
+ elem.variables = x["variables"] if x.include?("variables")
185
+ elem.view = x["view"] if x.include?("view")
186
+ the_list << elem
104
187
  end
105
- return list
188
+ return the_list
106
189
  end
107
190
 
108
191
 
109
192
  def incidents
110
193
  obj = http_get("/api/v2/incidents.json")
111
- list = []
194
+ the_list = IncidentList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
112
195
  obj.each do |x|
113
- elem = Incident.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
114
- elem.id = x["id"]
115
- elem.external_id = x["external_id"]
116
- elem.short_description = x["short_description"]
117
- elem.started_at = x["started_at"]
118
- elem.ended_at = x["ended_at"]
119
- elem.url = x["url"]
120
- list << elem
196
+ elem = Incident.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
197
+ elem.id = x["id"] if x.include?("id")
198
+ elem.external_id = x["external_id"] if x.include?("external_id")
199
+ elem.short_description = x["short_description"] if x.include?("short_description")
200
+ elem.started_at = x["started_at"] if x.include?("started_at")
201
+ elem.ended_at = x["ended_at"] if x.include?("ended_at")
202
+ elem.url = x["url"] if x.include?("url")
203
+ the_list << elem
121
204
  end
122
- return list
205
+ return the_list
206
+ end
207
+
208
+
209
+ def incident_by_id(id)
210
+ obj = http_get("/api/v2/incidents/#{id}.json")
211
+ elem = Incident.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
212
+ elem.id = obj["id"]
213
+ elem.external_id = obj["external_id"]
214
+ elem.short_description = obj["short_description"]
215
+ elem.started_at = obj["started_at"]
216
+ elem.ended_at = obj["ended_at"]
217
+ elem.url = obj["url"]
218
+ return elem
123
219
  end
124
220
 
125
221
 
126
222
  def jobs
127
223
  obj = http_get("/api/v2/jobs.json")
128
- list = []
224
+ the_list = JobList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
129
225
  obj.each do |x|
130
- elem = Job.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
131
- elem.id = x["id"]
132
- elem.organisation_id = x["organisation_id"]
133
- elem.source_id = x["source_id"]
134
- elem.source_type = x["source_type"]
135
- elem.status = x["status"]
136
- list << elem
226
+ elem = Job.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
227
+ elem.id = x["id"] if x.include?("id")
228
+ elem.source_id = x["source_id"] if x.include?("source_id")
229
+ elem.source_name = x["source_name"] if x.include?("source_name")
230
+ elem.source_type = x["source_type"] if x.include?("source_type")
231
+ elem.status = x["status"] if x.include?("status")
232
+ the_list << elem
137
233
  end
138
- return list
234
+ return the_list
235
+ end
236
+
237
+
238
+ def job_by_id(id)
239
+ obj = http_get("/api/v2/jobs/#{id}.json")
240
+ elem = Job.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
241
+ elem.id = obj["id"]
242
+ elem.source_id = obj["source_id"]
243
+ elem.source_name = obj["source_name"]
244
+ elem.source_type = obj["source_type"]
245
+ elem.status = obj["status"]
246
+ return elem
139
247
  end
140
248
 
141
249
  def new_node
142
- return Node.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
250
+ return Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
143
251
  end
144
252
 
145
253
 
146
254
  def nodes
147
255
  obj = http_get("/api/v2/nodes.json")
148
- list = []
256
+ the_list = NodeList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
149
257
  obj.each do |x|
150
- elem = Node.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
151
- elem.id = x["id"]
152
- elem.name = x["name"]
153
- elem.external_id = x["external_id"]
154
- elem.environment_id = x["environment_id"]
155
- elem.operating_system_family_id = x["operating_system_family_id"]
156
- elem.operating_system_id = x["operating_system_id"]
157
- list << elem
258
+ elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
259
+ elem.connection_manager_group_id = x["connection_manager_group_id"] if x.include?("connection_manager_group_id")
260
+ elem.external_id = x["external_id"] if x.include?("external_id")
261
+ elem.environment_id = x["environment_id"] if x.include?("environment_id")
262
+ elem.id = x["id"] if x.include?("id")
263
+ elem.ip_address = x["ip_address"] if x.include?("ip_address")
264
+ elem.last_scan_status = x["last_scan_status"] if x.include?("last_scan_status")
265
+ elem.last_scan_status_string = x["last_scan_status_string"] if x.include?("last_scan_status_string")
266
+ elem.mac_address = x["mac_address"] if x.include?("mac_address")
267
+ elem.medium_hostname = x["medium_hostname"] if x.include?("medium_hostname")
268
+ elem.medium_port = x["medium_port"] if x.include?("medium_port")
269
+ elem.medium_type = x["medium_type"] if x.include?("medium_type")
270
+ elem.medium_username = x["medium_username"] if x.include?("medium_username")
271
+ elem.name = x["name"] if x.include?("name")
272
+ elem.node_type = x["node_type"] if x.include?("node_type")
273
+ elem.online = x["online"] if x.include?("online")
274
+ elem.operating_system_family_id = x["operating_system_family_id"] if x.include?("operating_system_family_id")
275
+ elem.operating_system_id = x["operating_system_id"] if x.include?("operating_system_id")
276
+ elem.short_description = x["short_description"] if x.include?("short_description")
277
+ elem.medium_info.from_dict(x["medium_info"]) if x.include?("medium_info")
278
+ the_list << elem
158
279
  end
159
- return list
280
+ return the_list
281
+ end
282
+
283
+ def node_by_external_id(external_id)
284
+ url = "/api/v2/nodes/lookup.json?external_id=#{external_id}"
285
+ obj = http_get(url)
286
+ id = obj["node_id"]
287
+ elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
288
+ elem.id = id
289
+ elem.load
290
+ return elem
291
+ end
292
+
293
+ def node_by_name(name)
294
+ url = "/api/v2/nodes/lookup.json?name=#{name}"
295
+ obj = http_get(url)
296
+ id = obj["node_id"]
297
+ elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
298
+ elem.id = id
299
+ elem.load
300
+ return elem
301
+ end
302
+
303
+
304
+ def node_by_id(id)
305
+ obj = http_get("/api/v2/nodes/#{id}.json")
306
+ elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
307
+ elem.id = obj["id"]
308
+ elem.name = obj["name"]
309
+ return elem
310
+ end
311
+
312
+ def new_node_group
313
+ return NodeGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
160
314
  end
161
315
 
162
316
 
163
317
  def node_groups
164
318
  obj = http_get("/api/v2/node_groups.json")
165
- list = []
319
+ the_list = NodeGroupList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
166
320
  obj.each do |x|
167
- elem = Node.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
168
- elem.id = x["id"]
169
- elem.name = x["name"]
170
- list << elem
321
+ elem = NodeGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
322
+ elem.description = x["description"] if x.include?("description")
323
+ elem.id = x["id"] if x.include?("id")
324
+ elem.name = x["name"] if x.include?("name")
325
+ elem.node_rules = x["node_rules"] if x.include?("node_rules")
326
+ elem.search_query = x["search_query"] if x.include?("search_query")
327
+ the_list << elem
171
328
  end
172
- return list
329
+ return the_list
330
+ end
331
+
332
+
333
+ def node_group_by_id(id)
334
+ obj = http_get("/api/v2/node_groups/#{id}.json")
335
+ elem = NodeGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
336
+ elem.id = obj["id"]
337
+ elem.name = obj["name"]
338
+ return elem
339
+ end
340
+
341
+ def node_group_by_name(name)
342
+ url = "/api/v2/node_groups/lookup.json?name=#{name}"
343
+ obj = http_get(url)
344
+ id = obj["node_group_id"]
345
+ elem = NodeGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
346
+ elem.id = id
347
+ elem.load
348
+ return elem
349
+ end
350
+
351
+
352
+ def node_scan_by_id(id)
353
+ obj = http_get("/api/v2/node_scans/#{id}.json")
354
+ elem = NodeScan.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
355
+ elem.id = obj["id"]
356
+ elem.node_id = obj["node_id"]
357
+ elem.data = obj["data"]
358
+ elem.scan_options = obj["scan_options"]
359
+ elem.created_at = obj["created_at"]
360
+ elem.updated_at = obj["updated_at"]
361
+ elem.task_id = obj["task_id"]
362
+ elem.associated_id = obj["associated_id"]
363
+ elem.category = obj["category"]
364
+ elem.label = obj["label"]
365
+ elem.tsv = obj["tsv"]
366
+ return elem
173
367
  end
174
368
 
175
369
 
176
370
  def operating_system_families
177
371
  obj = http_get("/api/v2/operating_system_families.json")
178
- list = []
372
+ the_list = OperatingSystemFamilyList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
179
373
  obj.each do |x|
180
- elem = OperatingSystemFamily.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
181
- elem.id = x["id"]
182
- elem.name = x["name"]
183
- list << elem
374
+ elem = OperatingSystemFamily.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
375
+ elem.id = x["id"] if x.include?("id")
376
+ elem.name = x["name"] if x.include?("name")
377
+ the_list << elem
184
378
  end
185
- return list
379
+ return the_list
186
380
  end
187
381
 
188
382
 
189
383
  def operating_systems
190
384
  obj = http_get("/api/v2/operating_systems.json")
191
- list = []
385
+ the_list = OperatingSystemList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
192
386
  obj.each do |x|
193
- elem = OperatingSystem.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
194
- elem.id = x["id"]
195
- elem.name = x["name"]
196
- elem.operating_system_family_id = x["operating_system_family_id"]
197
- list << elem
387
+ elem = OperatingSystem.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
388
+ elem.id = x["id"] if x.include?("id")
389
+ elem.name = x["name"] if x.include?("name")
390
+ elem.operating_system_family_id = x["operating_system_family_id"] if x.include?("operating_system_family_id")
391
+ elem.description = x["description"] if x.include?("description")
392
+ the_list << elem
198
393
  end
199
- return list
394
+ return the_list
395
+ end
396
+
397
+ def new_policy
398
+ return Policy.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
399
+ end
400
+
401
+
402
+ def policies
403
+ obj = http_get("/api/v2/policies.json")
404
+ the_list = PolicyList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
405
+ obj.each do |x|
406
+ elem = Policy.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
407
+ elem.description = x["description"] if x.include?("description")
408
+ elem.id = x["id"] if x.include?("id")
409
+ elem.name = x["name"] if x.include?("name")
410
+ elem.short_description = x["short_description"] if x.include?("short_description")
411
+ the_list << elem
412
+ end
413
+ return the_list
414
+ end
415
+
416
+
417
+ def scheduled_jobs
418
+ obj = http_get("/api/v2/scheduled_jobs.json")
419
+ the_list = ScheduledJobList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
420
+ obj.each do |x|
421
+ elem = ScheduledJob.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
422
+ elem.data = x["data"] if x.include?("data")
423
+ elem.id = x["id"] if x.include?("id")
424
+ elem.source_id = x["source_id"] if x.include?("source_id")
425
+ elem.source_name = x["source_name"] if x.include?("source_name")
426
+ elem.source_type = x["source_type"] if x.include?("source_type")
427
+ elem.status = x["status"] if x.include?("status")
428
+ the_list << elem
429
+ end
430
+ return the_list
200
431
  end
201
432
 
202
433
 
203
434
  def system_metrics
204
435
  obj = http_get("/api/v2/system_metrics.json")
205
- list = []
436
+ the_list = SystemMetricList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
206
437
  obj.each do |x|
207
- elem = SystemMetric.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
208
- elem.metric = x["metric"]
209
- elem.value = x["value"]
210
- elem.timestamp = x["timestamp"]
211
- list << elem
438
+ elem = SystemMetric.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
439
+ elem.metric = x["metric"] if x.include?("metric")
440
+ elem.value = x["value"] if x.include?("value")
441
+ elem.timestamp = x["timestamp"] if x.include?("timestamp")
442
+ the_list << elem
212
443
  end
213
- return list
444
+ return the_list
445
+ end
446
+
447
+
448
+ def text_file_by_id(id)
449
+ obj = http_get("/api/v2/text_files/#{id}.json")
450
+ elem = TextFile.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
451
+ elem.category = obj["category"]
452
+ elem.checksum = obj["checksum"]
453
+ elem.created_at = obj["created_at"]
454
+ elem.data = obj["data"]
455
+ elem.id = obj["id"]
456
+ elem.name = obj["name"]
457
+ elem.updated_at = obj["updated_at"]
458
+ return elem
214
459
  end
215
460
 
216
461
 
217
462
  def users
218
463
  obj = http_get("/api/v2/users.json")
219
- list = []
464
+ the_list = UserList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
220
465
  obj.each do |x|
221
- elem = User.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
222
- elem.id = x["id"]
223
- elem.name = x["name"]
224
- elem.surname = x["surname"]
225
- elem.email = x["email"]
226
- elem.role = x["role"]
227
- list << elem
466
+ elem = User.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
467
+ elem.email = x["email"] if x.include?("email")
468
+ elem.id = x["id"] if x.include?("id")
469
+ elem.last_sign_in_at = x["last_sign_in_at"] if x.include?("last_sign_in_at")
470
+ elem.name = x["name"] if x.include?("name")
471
+ elem.role = x["role"] if x.include?("role")
472
+ elem.surname = x["surname"] if x.include?("surname")
473
+ elem.external_id = x["external_id"] if x.include?("external_id")
474
+ the_list << elem
228
475
  end
229
- return list
476
+ return the_list
477
+ end
478
+
479
+
480
+ def users_and_invitees
481
+ obj = http_get("/api/v2/users.json?invited=true")
482
+ the_list = UserList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
483
+ obj.each do |x|
484
+ elem = User.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
485
+ elem.email = x["email"] if x.include?("email")
486
+ elem.expiry = x["expiry"] if x.include?("expiry")
487
+ elem.id = x["id"] if x.include?("id")
488
+ elem.invited = x["invited"] if x.include?("invited")
489
+ elem.last_sign_in_at = x["last_sign_in_at"] if x.include?("last_sign_in_at")
490
+ elem.name = x["name"] if x.include?("name")
491
+ elem.role = x["role"] if x.include?("role")
492
+ elem.surname = x["surname"] if x.include?("surname")
493
+ elem.external_id = x["external_id"] if x.include?("external_id")
494
+ the_list << elem
495
+ end
496
+ return the_list
230
497
  end
231
498
 
232
499
  def invite_user(email, role)
@@ -235,32 +502,10 @@ module UpGuard
235
502
  return obj
236
503
  end
237
504
 
238
- def find_node_by_external_id(external_id)
239
- url = "/api/v2/nodes/lookup.json?external_id=#{external_id}"
240
- obj = http_get(url)
241
- id = obj["node_id"]
242
- elem = Node.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
243
- elem.id = id
244
- elem.load
245
- return elem
246
- end
247
-
248
- def find_node_by_name(name)
249
- url = "/api/v2/nodes/lookup.json?name=#{name}"
250
- obj = http_get(url)
251
- id = obj["node_id"]
252
- elem = Node.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
253
- elem.id = id
254
- elem.load
255
- return elem
256
- end
257
-
258
- def find_node_by_id(id)
259
- url = "/api/v2/nodes/#{self.id}.json?id=#{id}"
260
- obj = http_get(url)
261
- elem = Node.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
262
- elem.from_hash(obj)
263
- return elem
505
+ def remove_user(email)
506
+ url = "/api/v2/users/remove.json?email=#{email}"
507
+ obj = http_put(url, nil)
508
+ return obj
264
509
  end
265
510
 
266
511