upguard 0.0.1 → 0.0.9

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 (38) hide show
  1. checksums.yaml +2 -5
  2. data/lib/upguard.rb +19 -0
  3. data/lib/upguard/Account.rb +346 -102
  4. data/lib/upguard/BaseObject.rb +23 -22
  5. data/lib/upguard/ConnectionManager.rb +18 -3
  6. data/lib/upguard/ConnectionManagerGroup.rb +31 -9
  7. data/lib/upguard/ConnectionManagerGroupList.rb +47 -0
  8. data/lib/upguard/ConnectionManagerList.rb +47 -0
  9. data/lib/upguard/Environment.rb +34 -11
  10. data/lib/upguard/EnvironmentList.rb +47 -0
  11. data/lib/upguard/Event.rb +3 -3
  12. data/lib/upguard/EventAction.rb +8 -2
  13. data/lib/upguard/EventActionList.rb +47 -0
  14. data/lib/upguard/Incident.rb +33 -0
  15. data/lib/upguard/IncidentList.rb +47 -0
  16. data/lib/upguard/Job.rb +60 -0
  17. data/lib/upguard/JobList.rb +47 -0
  18. data/lib/upguard/MediumType.rb +2 -2
  19. data/lib/upguard/Node.rb +54 -18
  20. data/lib/upguard/NodeGroup.rb +80 -8
  21. data/lib/upguard/NodeGroupList.rb +47 -0
  22. data/lib/upguard/NodeGroupUser.rb +21 -0
  23. data/lib/upguard/NodeGroupUserList.rb +58 -0
  24. data/lib/upguard/NodeList.rb +47 -0
  25. data/lib/upguard/NodeType.rb +2 -2
  26. data/lib/upguard/OperatingSystem.rb +3 -3
  27. data/lib/upguard/OperatingSystemFamily.rb +8 -8
  28. data/lib/upguard/OperatingSystemFamilyList.rb +47 -0
  29. data/lib/upguard/OperatingSystemList.rb +47 -0
  30. data/lib/upguard/Policy.rb +79 -0
  31. data/lib/upguard/PolicyList.rb +47 -0
  32. data/lib/upguard/ScheduledJob.rb +6 -3
  33. data/lib/upguard/ScheduledJobList.rb +47 -0
  34. data/lib/upguard/SystemMetric.rb +2 -2
  35. data/lib/upguard/SystemMetricList.rb +47 -0
  36. data/lib/upguard/User.rb +2 -2
  37. data/lib/upguard/UserList.rb +58 -0
  38. metadata +23 -4
checksums.yaml CHANGED
@@ -1,7 +1,4 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3f08c82c76dbfb5e63bbd7cdae0066ff208f8c66
4
- data.tar.gz: a8d41839e02f2d2235f4fd398ddf4ec28ab70656
5
2
  SHA512:
6
- metadata.gz: 02b0df7adae2a5b54f2f212396d83eb29ba881a5ba241fee1c650ca9ef221e306dc21793234cb3248bc04beb76b96021aafdc261a2ec2c84d31f9316c91c2ea1
7
- data.tar.gz: b8da5aeb26b21b6b85d1fb916b15094e3bd57f5ccb66fdd742445c10d526352c6d717b9812471a5d31f0ddde4a1d8b959c1e3110d6059fd643f7dfa27aa1f87c
3
+ metadata.gz: bc7ad7ee10a1cc327b0b9d7573b7fdbe430ed0fa9e99d88c954409f528db607e88285f4192ea4b9bb6263f4ece1c0e0c2b0c3a1da789ef65ef90d919f69abafe
4
+ data.tar.gz: 8507ab1d252f8c03c9c93779e25fda91f7127760ab845ff4e6e7dd5ab99383133a953fe10a5b5f37c20a3944d09b4a3d64d7b49863872b4ae2d06bff1be80cb7
@@ -1,16 +1,35 @@
1
1
  require_relative 'upguard/BaseObject'
2
2
  require_relative 'upguard/Account'
3
3
  require_relative 'upguard/ConnectionManager'
4
+ require_relative 'upguard/ConnectionManagerList'
4
5
  require_relative 'upguard/ConnectionManagerGroup'
6
+ require_relative 'upguard/ConnectionManagerGroupList'
5
7
  require_relative 'upguard/Environment'
8
+ require_relative 'upguard/EnvironmentList'
6
9
  require_relative 'upguard/Event'
7
10
  require_relative 'upguard/EventAction'
11
+ require_relative 'upguard/EventActionList'
12
+ require_relative 'upguard/Incident'
13
+ require_relative 'upguard/IncidentList'
14
+ require_relative 'upguard/Job'
15
+ require_relative 'upguard/JobList'
8
16
  require_relative 'upguard/MediumType'
9
17
  require_relative 'upguard/Node'
18
+ require_relative 'upguard/NodeList'
10
19
  require_relative 'upguard/NodeGroup'
20
+ require_relative 'upguard/NodeGroupList'
21
+ require_relative 'upguard/NodeGroupUser'
22
+ require_relative 'upguard/NodeGroupUserList'
11
23
  require_relative 'upguard/NodeType'
12
24
  require_relative 'upguard/OperatingSystem'
25
+ require_relative 'upguard/OperatingSystemList'
13
26
  require_relative 'upguard/OperatingSystemFamily'
27
+ require_relative 'upguard/OperatingSystemFamilyList'
28
+ require_relative 'upguard/Policy'
29
+ require_relative 'upguard/PolicyList'
14
30
  require_relative 'upguard/ScheduledJob'
31
+ require_relative 'upguard/ScheduledJobList'
15
32
  require_relative 'upguard/SystemMetric'
33
+ require_relative 'upguard/SystemMetricList'
16
34
  require_relative 'upguard/User'
35
+ require_relative 'upguard/UserList'
@@ -12,188 +12,446 @@ 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
61
116
  end
62
117
 
63
118
  def events_with_view_name(view_name)
64
119
  url = "/api/v2/events.json?view_name=#{view_name}"
65
120
  obj = http_get(url)
66
- list = []
121
+ the_list = []
67
122
  obj.each do |x|
68
- elem = Event.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
123
+ elem = Event.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
69
124
  elem.id = x["id"]
70
125
  elem.type_id = x["type_id"]
71
126
  elem.environment_id = x["environment_id"]
72
127
  elem.created_at = x["created_at"]
73
- list << elem
128
+ the_list << elem
74
129
  end
75
- return list
130
+ return the_list
76
131
  end
77
132
 
78
133
  def events_with_query(query)
79
134
  url = "/api/v2/events.json?query=#{query}"
80
135
  obj = http_get(url)
81
- list = []
136
+ the_list = []
82
137
  obj.each do |x|
83
- elem = Event.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
138
+ elem = Event.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
84
139
  elem.id = x["id"]
85
140
  elem.type_id = x["type_id"]
86
141
  elem.environment_id = x["environment_id"]
87
142
  elem.created_at = x["created_at"]
88
- list << elem
143
+ the_list << elem
144
+ end
145
+ return the_list
146
+ end
147
+
148
+
149
+ def event_action_by_id(id)
150
+ obj = http_get("/api/v2/event_actions/#{id}.json")
151
+ elem = EventAction.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
152
+ elem.id = obj["id"]
153
+ elem.name = obj["name"]
154
+ return elem
155
+ end
156
+
157
+
158
+ def event_types
159
+ obj = http_get("/api/v2/events/types.json")
160
+ the_list = EventTypeList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
161
+ obj.each do |x|
162
+ elem = EventType.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
163
+ elem.id = x["id"] if x.include?("id")
164
+ elem.name = x["name"] if x.include?("name")
165
+ the_list << elem
89
166
  end
90
- return list
167
+ return the_list
91
168
  end
92
169
 
93
170
 
94
171
  def event_actions
95
172
  obj = http_get("/api/v2/event_actions.json")
96
- list = []
173
+ the_list = EventActionList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
97
174
  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
175
+ elem = EventAction.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
176
+ elem.id = x["id"] if x.include?("id")
177
+ elem.name = x["name"] if x.include?("name")
178
+ elem.status = x["status"] if x.include?("status")
179
+ elem.type = x["type"] if x.include?("type")
180
+ elem.variables = x["variables"] if x.include?("variables")
181
+ elem.view = x["view"] if x.include?("view")
182
+ the_list << elem
104
183
  end
105
- return list
184
+ return the_list
185
+ end
186
+
187
+
188
+ def incidents
189
+ obj = http_get("/api/v2/incidents.json")
190
+ the_list = IncidentList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
191
+ obj.each do |x|
192
+ elem = Incident.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
193
+ elem.id = x["id"] if x.include?("id")
194
+ elem.external_id = x["external_id"] if x.include?("external_id")
195
+ elem.short_description = x["short_description"] if x.include?("short_description")
196
+ elem.started_at = x["started_at"] if x.include?("started_at")
197
+ elem.ended_at = x["ended_at"] if x.include?("ended_at")
198
+ elem.url = x["url"] if x.include?("url")
199
+ the_list << elem
200
+ end
201
+ return the_list
202
+ end
203
+
204
+
205
+ def incident_by_id(id)
206
+ obj = http_get("/api/v2/incidents/#{id}.json")
207
+ elem = Incident.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
208
+ elem.id = obj["id"]
209
+ elem.external_id = obj["external_id"]
210
+ elem.short_description = obj["short_description"]
211
+ elem.started_at = obj["started_at"]
212
+ elem.ended_at = obj["ended_at"]
213
+ elem.url = obj["url"]
214
+ return elem
215
+ end
216
+
217
+
218
+ def jobs
219
+ obj = http_get("/api/v2/jobs.json")
220
+ the_list = JobList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
221
+ obj.each do |x|
222
+ elem = Job.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
223
+ elem.id = x["id"] if x.include?("id")
224
+ elem.source_id = x["source_id"] if x.include?("source_id")
225
+ elem.source_name = x["source_name"] if x.include?("source_name")
226
+ elem.source_type = x["source_type"] if x.include?("source_type")
227
+ elem.status = x["status"] if x.include?("status")
228
+ the_list << elem
229
+ end
230
+ return the_list
231
+ end
232
+
233
+
234
+ def job_by_id(id)
235
+ obj = http_get("/api/v2/jobs/#{id}.json")
236
+ elem = Job.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
237
+ elem.id = obj["id"]
238
+ elem.source_id = obj["source_id"]
239
+ elem.source_name = obj["source_name"]
240
+ elem.source_type = obj["source_type"]
241
+ elem.status = obj["status"]
242
+ return elem
106
243
  end
107
244
 
108
245
  def new_node
109
- return Node.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
246
+ return Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
110
247
  end
111
248
 
112
249
 
113
250
  def nodes
114
251
  obj = http_get("/api/v2/nodes.json")
115
- list = []
252
+ the_list = NodeList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
116
253
  obj.each do |x|
117
- elem = Node.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
118
- elem.id = x["id"]
119
- elem.name = x["name"]
120
- elem.external_id = x["external_id"]
121
- elem.environment_id = x["environment_id"]
122
- elem.operating_system_family_id = x["operating_system_family_id"]
123
- elem.operating_system_id = x["operating_system_id"]
124
- list << elem
254
+ elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
255
+ elem.external_id = x["external_id"] if x.include?("external_id")
256
+ elem.environment_id = x["environment_id"] if x.include?("environment_id")
257
+ elem.id = x["id"] if x.include?("id")
258
+ elem.last_scan_status = x["last_scan_status"] if x.include?("last_scan_status")
259
+ elem.last_scan_status_string = x["last_scan_status_string"] if x.include?("last_scan_status_string")
260
+ elem.mac_address = x["mac_address"] if x.include?("mac_address")
261
+ elem.name = x["name"] if x.include?("name")
262
+ elem.node_type = x["node_type"] if x.include?("node_type")
263
+ elem.online = x["online"] if x.include?("online")
264
+ elem.operating_system_family_id = x["operating_system_family_id"] if x.include?("operating_system_family_id")
265
+ elem.operating_system_id = x["operating_system_id"] if x.include?("operating_system_id")
266
+ elem.short_description = x["short_description"] if x.include?("short_description")
267
+ the_list << elem
125
268
  end
126
- return list
269
+ return the_list
270
+ end
271
+
272
+ def node_by_external_id(external_id)
273
+ url = "/api/v2/nodes/lookup.json?external_id=#{external_id}"
274
+ obj = http_get(url)
275
+ id = obj["node_id"]
276
+ elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
277
+ elem.id = id
278
+ elem.load
279
+ return elem
280
+ end
281
+
282
+ def node_by_name(name)
283
+ url = "/api/v2/nodes/lookup.json?name=#{name}"
284
+ obj = http_get(url)
285
+ id = obj["node_id"]
286
+ elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
287
+ elem.id = id
288
+ elem.load
289
+ return elem
290
+ end
291
+
292
+
293
+ def node_by_id(id)
294
+ obj = http_get("/api/v2/nodes/#{id}.json")
295
+ elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
296
+ elem.id = obj["id"]
297
+ elem.name = obj["name"]
298
+ return elem
299
+ end
300
+
301
+ def new_node_group
302
+ return NodeGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
127
303
  end
128
304
 
129
305
 
130
306
  def node_groups
131
307
  obj = http_get("/api/v2/node_groups.json")
132
- list = []
308
+ the_list = NodeGroupList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
133
309
  obj.each do |x|
134
- elem = Node.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
135
- elem.id = x["id"]
136
- elem.name = x["name"]
137
- list << elem
310
+ elem = NodeGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
311
+ elem.description = x["description"] if x.include?("description")
312
+ elem.id = x["id"] if x.include?("id")
313
+ elem.name = x["name"] if x.include?("name")
314
+ elem.node_rules = x["node_rules"] if x.include?("node_rules")
315
+ elem.search_query = x["search_query"] if x.include?("search_query")
316
+ the_list << elem
138
317
  end
139
- return list
318
+ return the_list
319
+ end
320
+
321
+
322
+ def node_group_by_id(id)
323
+ obj = http_get("/api/v2/node_groups/#{id}.json")
324
+ elem = NodeGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
325
+ elem.id = obj["id"]
326
+ elem.name = obj["name"]
327
+ return elem
328
+ end
329
+
330
+
331
+ def node_scan_by_id(id)
332
+ obj = http_get("/api/v2/node_scans/#{id}.json")
333
+ elem = NodeScan.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
334
+ elem.id = obj["id"]
335
+ elem.node_id = obj["node_id"]
336
+ elem.data = obj["data"]
337
+ elem.scan_options = obj["scan_options"]
338
+ elem.created_at = obj["created_at"]
339
+ elem.updated_at = obj["updated_at"]
340
+ elem.task_id = obj["task_id"]
341
+ elem.associated_id = obj["associated_id"]
342
+ elem.category = obj["category"]
343
+ elem.label = obj["label"]
344
+ elem.tsv = obj["tsv"]
345
+ return elem
140
346
  end
141
347
 
142
348
 
143
349
  def operating_system_families
144
350
  obj = http_get("/api/v2/operating_system_families.json")
145
- list = []
351
+ the_list = OperatingSystemFamilyList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
146
352
  obj.each do |x|
147
- elem = OperatingSystemFamily.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
148
- elem.id = x["id"]
149
- elem.name = x["name"]
150
- list << elem
353
+ elem = OperatingSystemFamily.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
354
+ elem.id = x["id"] if x.include?("id")
355
+ elem.name = x["name"] if x.include?("name")
356
+ the_list << elem
151
357
  end
152
- return list
358
+ return the_list
153
359
  end
154
360
 
155
361
 
156
362
  def operating_systems
157
363
  obj = http_get("/api/v2/operating_systems.json")
158
- list = []
364
+ the_list = OperatingSystemList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
159
365
  obj.each do |x|
160
- elem = OperatingSystem.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
161
- elem.id = x["id"]
162
- elem.name = x["name"]
163
- elem.operating_system_family_id = x["operating_system_family_id"]
164
- list << elem
366
+ elem = OperatingSystem.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
367
+ elem.id = x["id"] if x.include?("id")
368
+ elem.name = x["name"] if x.include?("name")
369
+ elem.operating_system_family_id = x["operating_system_family_id"] if x.include?("operating_system_family_id")
370
+ elem.description = x["description"] if x.include?("description")
371
+ the_list << elem
372
+ end
373
+ return the_list
374
+ end
375
+
376
+ def new_policy
377
+ return Policy.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
378
+ end
379
+
380
+
381
+ def policies
382
+ obj = http_get("/api/v2/policies.json")
383
+ the_list = PolicyList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
384
+ obj.each do |x|
385
+ elem = Policy.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
386
+ elem.description = x["description"] if x.include?("description")
387
+ elem.id = x["id"] if x.include?("id")
388
+ elem.name = x["name"] if x.include?("name")
389
+ elem.short_description = x["short_description"] if x.include?("short_description")
390
+ the_list << elem
391
+ end
392
+ return the_list
393
+ end
394
+
395
+
396
+ def scheduled_jobs
397
+ obj = http_get("/api/v2/scheduled_jobs.json")
398
+ the_list = ScheduledJobList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
399
+ obj.each do |x|
400
+ elem = ScheduledJob.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
401
+ elem.data = x["data"] if x.include?("data")
402
+ elem.id = x["id"] if x.include?("id")
403
+ elem.source_id = x["source_id"] if x.include?("source_id")
404
+ elem.source_name = x["source_name"] if x.include?("source_name")
405
+ elem.source_type = x["source_type"] if x.include?("source_type")
406
+ elem.status = x["status"] if x.include?("status")
407
+ the_list << elem
165
408
  end
166
- return list
409
+ return the_list
167
410
  end
168
411
 
169
412
 
170
413
  def system_metrics
171
414
  obj = http_get("/api/v2/system_metrics.json")
172
- list = []
415
+ the_list = SystemMetricList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
173
416
  obj.each do |x|
174
- elem = SystemMetric.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
175
- elem.metric = x["metric"]
176
- elem.value = x["value"]
177
- elem.timestamp = x["timestamp"]
178
- list << elem
417
+ elem = SystemMetric.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
418
+ elem.metric = x["metric"] if x.include?("metric")
419
+ elem.value = x["value"] if x.include?("value")
420
+ elem.timestamp = x["timestamp"] if x.include?("timestamp")
421
+ the_list << elem
179
422
  end
180
- return list
423
+ return the_list
424
+ end
425
+
426
+
427
+ def text_file_by_id(id)
428
+ obj = http_get("/api/v2/text_files/#{id}.json")
429
+ elem = TextFile.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
430
+ elem.category = obj["category"]
431
+ elem.checksum = obj["checksum"]
432
+ elem.created_at = obj["created_at"]
433
+ elem.data = obj["data"]
434
+ elem.id = obj["id"]
435
+ elem.name = obj["name"]
436
+ elem.updated_at = obj["updated_at"]
437
+ return elem
181
438
  end
182
439
 
183
440
 
184
441
  def users
185
442
  obj = http_get("/api/v2/users.json")
186
- list = []
443
+ the_list = UserList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
187
444
  obj.each do |x|
188
- elem = User.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
189
- elem.id = x["id"]
190
- elem.name = x["name"]
191
- elem.surname = x["surname"]
192
- elem.email = x["email"]
193
- elem.role = x["role"]
194
- list << elem
445
+ elem = User.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
446
+ elem.email = x["email"] if x.include?("email")
447
+ elem.id = x["id"] if x.include?("id")
448
+ elem.last_sign_in_at = x["last_sign_in_at"] if x.include?("last_sign_in_at")
449
+ elem.name = x["name"] if x.include?("name")
450
+ elem.role = x["role"] if x.include?("role")
451
+ elem.surname = x["surname"] if x.include?("surname")
452
+ the_list << elem
195
453
  end
196
- return list
454
+ return the_list
197
455
  end
198
456
 
199
457
  def invite_user(email, role)
@@ -202,24 +460,10 @@ module UpGuard
202
460
  return obj
203
461
  end
204
462
 
205
- def find_node_by_external_id(external_id)
206
- url = "/api/v2/nodes/lookup.json?external_id=#{external_id}"
207
- obj = http_get(url)
208
- id = obj["node_id"]
209
- elem = Node.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
210
- elem.id = id
211
- elem.load
212
- return elem
213
- end
214
-
215
- def find_node_by_name(name)
216
- url = "/api/v2/nodes/lookup.json?name=#{name}"
217
- obj = http_get(url)
218
- id = obj["node_id"]
219
- elem = Node.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
220
- elem.id = id
221
- elem.load
222
- return elem
463
+ def remove_user(email)
464
+ url = "/api/v2/users/remove.json?email=#{email}"
465
+ obj = http_put(url, nil)
466
+ return obj
223
467
  end
224
468
 
225
469