upguard 0.0.6 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,4 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a48de6f627011308b5e15643cf59434dc4a5165a
4
- data.tar.gz: fe28ac17cb16733dfa0770a32b828f00080ba490
5
2
  SHA512:
6
- metadata.gz: 7539d483e269ef662af049a551144768d28dfbc2fa3a3a1c59ae3ae28ec38a6af0c9cec9a3134fb7267fab45d667a046b1ae9aa36e54b0f19f09298e589f31f0
7
- data.tar.gz: fd669c2bc3a8897092cfc8aef5c913f1af4976c1756739eb12d47e7e8a594e523b2d1f27daf75b498e647f3e5162dfe476ef314d59f6910b9edcad64dc907539
3
+ metadata.gz: bc7ad7ee10a1cc327b0b9d7573b7fdbe430ed0fa9e99d88c954409f528db607e88285f4192ea4b9bb6263f4ece1c0e0c2b0c3a1da789ef65ef90d919f69abafe
4
+ data.tar.gz: 8507ab1d252f8c03c9c93779e25fda91f7127760ab845ff4e6e7dd5ab99383133a953fe10a5b5f37c20a3944d09b4a3d64d7b49863872b4ae2d06bff1be80cb7
@@ -18,6 +18,8 @@ require_relative 'upguard/Node'
18
18
  require_relative 'upguard/NodeList'
19
19
  require_relative 'upguard/NodeGroup'
20
20
  require_relative 'upguard/NodeGroupList'
21
+ require_relative 'upguard/NodeGroupUser'
22
+ require_relative 'upguard/NodeGroupUserList'
21
23
  require_relative 'upguard/NodeType'
22
24
  require_relative 'upguard/OperatingSystem'
23
25
  require_relative 'upguard/OperatingSystemList'
@@ -19,7 +19,7 @@ module UpGuard
19
19
 
20
20
  def change_request_by_id(id)
21
21
  obj = http_get("/api/v2/change_requests/#{id}.json")
22
- elem = ChangeRequest.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
22
+ elem = ChangeRequest.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
23
23
  elem.external_id = obj["external_id"]
24
24
  elem.id = obj["id"]
25
25
  elem.planned_end_date = obj["planned_end_date"]
@@ -33,9 +33,9 @@ module UpGuard
33
33
 
34
34
  def change_requests
35
35
  obj = http_get("/api/v2/change_requests.json")
36
- the_list = ChangeRequestList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
36
+ the_list = ChangeRequestList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
37
37
  obj.each do |x|
38
- elem = ChangeRequest.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
38
+ elem = ChangeRequest.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
39
39
  elem.external_id = x["external_id"] if x.include?("external_id")
40
40
  elem.id = x["id"] if x.include?("id")
41
41
  elem.planned_end_date = x["planned_end_date"] if x.include?("planned_end_date")
@@ -48,12 +48,16 @@ module UpGuard
48
48
  return the_list
49
49
  end
50
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
+
51
55
 
52
56
  def connection_managers
53
57
  obj = http_get("/api/v2/connection_managers.json")
54
- the_list = ConnectionManagerList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
58
+ the_list = ConnectionManagerList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
55
59
  obj.each do |x|
56
- elem = ConnectionManager.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
60
+ elem = ConnectionManager.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
57
61
  elem.channels = x["channels"] if x.include?("channels")
58
62
  elem.connection_manager_group_id = x["connection_manager_group_id"] if x.include?("connection_manager_group_id")
59
63
  elem.created_at = x["created_at"] if x.include?("created_at")
@@ -70,9 +74,9 @@ module UpGuard
70
74
 
71
75
  def connection_manager_groups
72
76
  obj = http_get("/api/v2/connection_manager_groups.json")
73
- the_list = ConnectionManagerGroupList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
77
+ the_list = ConnectionManagerGroupList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
74
78
  obj.each do |x|
75
- elem = ConnectionManagerGroup.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
79
+ elem = ConnectionManagerGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
76
80
  elem.id = x["id"] if x.include?("id")
77
81
  elem.name = x["name"] if x.include?("name")
78
82
  elem.organisation_id = x["organisation_id"] if x.include?("organisation_id")
@@ -83,13 +87,13 @@ module UpGuard
83
87
  end
84
88
 
85
89
  def new_environment
86
- return Environment.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
90
+ return Environment.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
87
91
  end
88
92
 
89
93
 
90
94
  def environment_by_id(id)
91
95
  obj = http_get("/api/v2/environments/#{id}.json")
92
- elem = Environment.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
96
+ elem = Environment.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
93
97
  elem.id = obj["id"]
94
98
  elem.name = obj["name"]
95
99
  return elem
@@ -98,9 +102,9 @@ module UpGuard
98
102
 
99
103
  def environments
100
104
  obj = http_get("/api/v2/environments.json")
101
- the_list = EnvironmentList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
105
+ the_list = EnvironmentList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
102
106
  obj.each do |x|
103
- elem = Environment.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
107
+ elem = Environment.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
104
108
  elem.description = x["description"] if x.include?("description")
105
109
  elem.id = x["id"] if x.include?("id")
106
110
  elem.name = x["name"] if x.include?("name")
@@ -116,7 +120,7 @@ module UpGuard
116
120
  obj = http_get(url)
117
121
  the_list = []
118
122
  obj.each do |x|
119
- elem = Event.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
123
+ elem = Event.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
120
124
  elem.id = x["id"]
121
125
  elem.type_id = x["type_id"]
122
126
  elem.environment_id = x["environment_id"]
@@ -131,7 +135,7 @@ module UpGuard
131
135
  obj = http_get(url)
132
136
  the_list = []
133
137
  obj.each do |x|
134
- elem = Event.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
138
+ elem = Event.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
135
139
  elem.id = x["id"]
136
140
  elem.type_id = x["type_id"]
137
141
  elem.environment_id = x["environment_id"]
@@ -144,7 +148,7 @@ module UpGuard
144
148
 
145
149
  def event_action_by_id(id)
146
150
  obj = http_get("/api/v2/event_actions/#{id}.json")
147
- elem = EventAction.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
151
+ elem = EventAction.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
148
152
  elem.id = obj["id"]
149
153
  elem.name = obj["name"]
150
154
  return elem
@@ -153,9 +157,9 @@ module UpGuard
153
157
 
154
158
  def event_types
155
159
  obj = http_get("/api/v2/events/types.json")
156
- the_list = EventTypeList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
160
+ the_list = EventTypeList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
157
161
  obj.each do |x|
158
- elem = EventType.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
162
+ elem = EventType.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
159
163
  elem.id = x["id"] if x.include?("id")
160
164
  elem.name = x["name"] if x.include?("name")
161
165
  the_list << elem
@@ -166,9 +170,9 @@ module UpGuard
166
170
 
167
171
  def event_actions
168
172
  obj = http_get("/api/v2/event_actions.json")
169
- the_list = EventActionList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
173
+ the_list = EventActionList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
170
174
  obj.each do |x|
171
- elem = EventAction.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
175
+ elem = EventAction.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
172
176
  elem.id = x["id"] if x.include?("id")
173
177
  elem.name = x["name"] if x.include?("name")
174
178
  elem.status = x["status"] if x.include?("status")
@@ -183,9 +187,9 @@ module UpGuard
183
187
 
184
188
  def incidents
185
189
  obj = http_get("/api/v2/incidents.json")
186
- the_list = IncidentList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
190
+ the_list = IncidentList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
187
191
  obj.each do |x|
188
- elem = Incident.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
192
+ elem = Incident.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
189
193
  elem.id = x["id"] if x.include?("id")
190
194
  elem.external_id = x["external_id"] if x.include?("external_id")
191
195
  elem.short_description = x["short_description"] if x.include?("short_description")
@@ -198,13 +202,25 @@ module UpGuard
198
202
  end
199
203
 
200
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
+
201
218
  def jobs
202
219
  obj = http_get("/api/v2/jobs.json")
203
- the_list = JobList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
220
+ the_list = JobList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
204
221
  obj.each do |x|
205
- elem = Job.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
222
+ elem = Job.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
206
223
  elem.id = x["id"] if x.include?("id")
207
- elem.organisation_id = x["organisation_id"] if x.include?("organisation_id")
208
224
  elem.source_id = x["source_id"] if x.include?("source_id")
209
225
  elem.source_name = x["source_name"] if x.include?("source_name")
210
226
  elem.source_type = x["source_type"] if x.include?("source_type")
@@ -214,16 +230,28 @@ module UpGuard
214
230
  return the_list
215
231
  end
216
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
243
+ end
244
+
217
245
  def new_node
218
- return Node.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
246
+ return Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
219
247
  end
220
248
 
221
249
 
222
250
  def nodes
223
251
  obj = http_get("/api/v2/nodes.json")
224
- the_list = NodeList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
252
+ the_list = NodeList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
225
253
  obj.each do |x|
226
- elem = Node.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
254
+ elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
227
255
  elem.external_id = x["external_id"] if x.include?("external_id")
228
256
  elem.environment_id = x["environment_id"] if x.include?("environment_id")
229
257
  elem.id = x["id"] if x.include?("id")
@@ -245,7 +273,7 @@ module UpGuard
245
273
  url = "/api/v2/nodes/lookup.json?external_id=#{external_id}"
246
274
  obj = http_get(url)
247
275
  id = obj["node_id"]
248
- elem = Node.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
276
+ elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
249
277
  elem.id = id
250
278
  elem.load
251
279
  return elem
@@ -255,7 +283,7 @@ module UpGuard
255
283
  url = "/api/v2/nodes/lookup.json?name=#{name}"
256
284
  obj = http_get(url)
257
285
  id = obj["node_id"]
258
- elem = Node.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
286
+ elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
259
287
  elem.id = id
260
288
  elem.load
261
289
  return elem
@@ -264,18 +292,22 @@ module UpGuard
264
292
 
265
293
  def node_by_id(id)
266
294
  obj = http_get("/api/v2/nodes/#{id}.json")
267
- elem = Node.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
295
+ elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
268
296
  elem.id = obj["id"]
269
297
  elem.name = obj["name"]
270
298
  return elem
271
299
  end
272
300
 
301
+ def new_node_group
302
+ return NodeGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
303
+ end
304
+
273
305
 
274
306
  def node_groups
275
307
  obj = http_get("/api/v2/node_groups.json")
276
- the_list = NodeGroupList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
308
+ the_list = NodeGroupList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
277
309
  obj.each do |x|
278
- elem = NodeGroup.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
310
+ elem = NodeGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
279
311
  elem.description = x["description"] if x.include?("description")
280
312
  elem.id = x["id"] if x.include?("id")
281
313
  elem.name = x["name"] if x.include?("name")
@@ -287,11 +319,38 @@ module UpGuard
287
319
  end
288
320
 
289
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
346
+ end
347
+
348
+
290
349
  def operating_system_families
291
350
  obj = http_get("/api/v2/operating_system_families.json")
292
- the_list = OperatingSystemFamilyList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
351
+ the_list = OperatingSystemFamilyList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
293
352
  obj.each do |x|
294
- elem = OperatingSystemFamily.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
353
+ elem = OperatingSystemFamily.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
295
354
  elem.id = x["id"] if x.include?("id")
296
355
  elem.name = x["name"] if x.include?("name")
297
356
  the_list << elem
@@ -302,9 +361,9 @@ module UpGuard
302
361
 
303
362
  def operating_systems
304
363
  obj = http_get("/api/v2/operating_systems.json")
305
- the_list = OperatingSystemList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
364
+ the_list = OperatingSystemList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
306
365
  obj.each do |x|
307
- elem = OperatingSystem.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
366
+ elem = OperatingSystem.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
308
367
  elem.id = x["id"] if x.include?("id")
309
368
  elem.name = x["name"] if x.include?("name")
310
369
  elem.operating_system_family_id = x["operating_system_family_id"] if x.include?("operating_system_family_id")
@@ -314,14 +373,20 @@ module UpGuard
314
373
  return the_list
315
374
  end
316
375
 
376
+ def new_policy
377
+ return Policy.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
378
+ end
379
+
317
380
 
318
381
  def policies
319
382
  obj = http_get("/api/v2/policies.json")
320
- the_list = PolicyList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
383
+ the_list = PolicyList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
321
384
  obj.each do |x|
322
- elem = Policy.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
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")
323
387
  elem.id = x["id"] if x.include?("id")
324
388
  elem.name = x["name"] if x.include?("name")
389
+ elem.short_description = x["short_description"] if x.include?("short_description")
325
390
  the_list << elem
326
391
  end
327
392
  return the_list
@@ -330,9 +395,9 @@ module UpGuard
330
395
 
331
396
  def scheduled_jobs
332
397
  obj = http_get("/api/v2/scheduled_jobs.json")
333
- the_list = ScheduledJobList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
398
+ the_list = ScheduledJobList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
334
399
  obj.each do |x|
335
- elem = ScheduledJob.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
400
+ elem = ScheduledJob.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
336
401
  elem.data = x["data"] if x.include?("data")
337
402
  elem.id = x["id"] if x.include?("id")
338
403
  elem.source_id = x["source_id"] if x.include?("source_id")
@@ -347,9 +412,9 @@ module UpGuard
347
412
 
348
413
  def system_metrics
349
414
  obj = http_get("/api/v2/system_metrics.json")
350
- the_list = SystemMetricList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
415
+ the_list = SystemMetricList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
351
416
  obj.each do |x|
352
- elem = SystemMetric.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
417
+ elem = SystemMetric.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
353
418
  elem.metric = x["metric"] if x.include?("metric")
354
419
  elem.value = x["value"] if x.include?("value")
355
420
  elem.timestamp = x["timestamp"] if x.include?("timestamp")
@@ -361,7 +426,7 @@ module UpGuard
361
426
 
362
427
  def text_file_by_id(id)
363
428
  obj = http_get("/api/v2/text_files/#{id}.json")
364
- elem = TextFile.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
429
+ elem = TextFile.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
365
430
  elem.category = obj["category"]
366
431
  elem.checksum = obj["checksum"]
367
432
  elem.created_at = obj["created_at"]
@@ -375,9 +440,9 @@ module UpGuard
375
440
 
376
441
  def users
377
442
  obj = http_get("/api/v2/users.json")
378
- the_list = UserList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
443
+ the_list = UserList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
379
444
  obj.each do |x|
380
- elem = User.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
445
+ elem = User.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
381
446
  elem.email = x["email"] if x.include?("email")
382
447
  elem.id = x["id"] if x.include?("id")
383
448
  elem.last_sign_in_at = x["last_sign_in_at"] if x.include?("last_sign_in_at")
@@ -395,6 +460,12 @@ module UpGuard
395
460
  return obj
396
461
  end
397
462
 
463
+ def remove_user(email)
464
+ url = "/api/v2/users/remove.json?email=#{email}"
465
+ obj = http_put(url, nil)
466
+ return obj
467
+ end
468
+
398
469
 
399
470
  end
400
471
  end
@@ -3,19 +3,19 @@ require 'json'
3
3
  module UpGuard
4
4
  class BaseObject
5
5
  attr_accessor :appliance_url
6
- attr_accessor :api_key
6
+ attr_accessor :appliance_api_key
7
7
  attr_accessor :sec_key
8
8
  attr_accessor :insecure
9
9
  def from_hash(h)
10
10
  self.appliance_url = h['appliance_url'] if h.include?('appliance_url')
11
- self.api_key = h['api_key'] if h.include?('api_key')
11
+ self.appliance_api_key = h['appliance_api_key'] if h.include?('appliance_api_key')
12
12
  self.sec_key = h['sec_key'] if h.include?('sec_key')
13
13
  self.insecure = h['insecure'] if h.include?('insecure')
14
14
  end
15
15
  def to_hash
16
16
  h = {}
17
17
  h['appliance_url'] = self.appliance_url
18
- h['api_key'] = self.api_key
18
+ h['appliance_api_key'] = self.appliance_api_key
19
19
  h['sec_key'] = self.sec_key
20
20
  h['insecure'] = self.insecure
21
21
  return h
@@ -24,21 +24,21 @@ module UpGuard
24
24
  h = to_hash
25
25
  return h.to_json(options)
26
26
  end
27
- def initialize(appliance_url, api_key, sec_key, insecure = false)
27
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
28
28
  if appliance_url.to_s.start_with?("http://") || appliance_url.to_s.start_with?("https://")
29
29
  # all good
30
30
  else
31
31
  appliance_url = "https://" + appliance_url
32
32
  end
33
33
  self.appliance_url = appliance_url
34
- self.api_key = api_key
34
+ self.appliance_api_key = appliance_api_key
35
35
  self.sec_key = sec_key
36
36
  self.insecure = insecure
37
37
  end
38
38
 
39
39
  def make_headers
40
40
  return {
41
- "Authorization" => "Token token=\"#{self.api_key}#{self.sec_key}\"",
41
+ "Authorization" => "Token token=\"#{self.appliance_api_key}#{self.sec_key}\"",
42
42
  "Content-Type" => "application/json"
43
43
  }
44
44
  end
@@ -62,9 +62,10 @@ module UpGuard
62
62
  :verify => (self.insecure == false),
63
63
  :body => body.to_json
64
64
  )
65
- if ["200", "201"].include?(response.code.to_s) == false
65
+ if ["200", "201", "204"].include?(response.code.to_s) == false
66
66
  raise response.body
67
67
  end
68
+ return true if response.code.to_s == "204"
68
69
  obj = JSON.parse(response.body)
69
70
  return obj
70
71
  end
@@ -37,7 +37,7 @@ module UpGuard
37
37
 
38
38
  def connection_manager_group
39
39
  obj = http_get("/api/v2/connection_manager_groups/{connection_manager_group_id}.json")
40
- elem = ConnectionManagerGroup.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
40
+ elem = ConnectionManagerGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
41
41
  elem.id = obj["id"]
42
42
  elem.name = obj["name"]
43
43
  return elem
@@ -1,20 +1,20 @@
1
1
  module UpGuard
2
2
  class ConnectionManagerGroup < BaseObject
3
+ attr_accessor :api_key
3
4
  attr_accessor :id
4
5
  attr_accessor :name
5
- attr_accessor :organisation_id
6
6
  attr_accessor :status
7
7
  def from_hash(h)
8
+ self.api_key = h['api_key'] if h.include?('api_key')
8
9
  self.id = h['id'] if h.include?('id')
9
10
  self.name = h['name'] if h.include?('name')
10
- self.organisation_id = h['organisation_id'] if h.include?('organisation_id')
11
11
  self.status = h['status'] if h.include?('status')
12
12
  end
13
13
  def to_hash
14
14
  h = {}
15
+ h['api_key'] = self.api_key
15
16
  h['id'] = self.id
16
17
  h['name'] = self.name
17
- h['organisation_id'] = self.organisation_id
18
18
  h['status'] = self.status
19
19
  return h
20
20
  end
@@ -24,10 +24,10 @@ module UpGuard
24
24
  end
25
25
 
26
26
  def connection_managers
27
- obj = http_get("todo")
28
- the_list = ConnectionManagerList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
27
+ obj = http_get("/api/v2/connection_manager_groups/#{self.id}/connection_managers.json")
28
+ the_list = ConnectionManagerList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
29
29
  obj.each do |x|
30
- elem = ConnectionManager.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
30
+ elem = ConnectionManager.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
31
31
  elem.id = x["id"] if x.include?("id")
32
32
  elem.name = x["name"] if x.include?("name")
33
33
  the_list << elem
@@ -10,11 +10,19 @@ module UpGuard
10
10
  h = to_hash
11
11
  return h.to_json(options)
12
12
  end
13
- def initialize(appliance_url, api_key, sec_key, insecure)
14
- super(appliance_url, api_key, sec_key, insecure)
13
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure)
14
+ super(appliance_url, appliance_api_key, sec_key, insecure)
15
15
  @inner_list = []
16
16
  end
17
17
 
18
+ def count
19
+ return @inner_list.count
20
+ end
21
+
22
+ def [](idx)
23
+ return @inner_list[idx]
24
+ end
25
+
18
26
 
19
27
 
20
28
  def each(&block)
@@ -10,11 +10,19 @@ module UpGuard
10
10
  h = to_hash
11
11
  return h.to_json(options)
12
12
  end
13
- def initialize(appliance_url, api_key, sec_key, insecure)
14
- super(appliance_url, api_key, sec_key, insecure)
13
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure)
14
+ super(appliance_url, appliance_api_key, sec_key, insecure)
15
15
  @inner_list = []
16
16
  end
17
17
 
18
+ def count
19
+ return @inner_list.count
20
+ end
21
+
22
+ def [](idx)
23
+ return @inner_list[idx]
24
+ end
25
+
18
26
 
19
27
 
20
28
  def each(&block)
@@ -82,9 +82,9 @@ module UpGuard
82
82
 
83
83
  def nodes
84
84
  obj = http_get("/api/v2/environments/#{self.id}/nodes.json")
85
- the_list = NodeList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
85
+ the_list = NodeList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
86
86
  obj.each do |x|
87
- elem = Node.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
87
+ elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
88
88
  elem.id = x["id"] if x.include?("id")
89
89
  elem.name = x["name"] if x.include?("name")
90
90
  the_list << elem
@@ -10,11 +10,19 @@ module UpGuard
10
10
  h = to_hash
11
11
  return h.to_json(options)
12
12
  end
13
- def initialize(appliance_url, api_key, sec_key, insecure)
14
- super(appliance_url, api_key, sec_key, insecure)
13
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure)
14
+ super(appliance_url, appliance_api_key, sec_key, insecure)
15
15
  @inner_list = []
16
16
  end
17
17
 
18
+ def count
19
+ return @inner_list.count
20
+ end
21
+
22
+ def [](idx)
23
+ return @inner_list[idx]
24
+ end
25
+
18
26
 
19
27
 
20
28
  def each(&block)
@@ -25,7 +25,7 @@ module UpGuard
25
25
 
26
26
  def environment
27
27
  obj = http_get("/api/v2/environments/#{self.environment_id}.json")
28
- elem = Environment.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
28
+ elem = Environment.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
29
29
  elem.id = obj["id"]
30
30
  elem.name = obj["name"]
31
31
  elem.organisation_id = obj["organisation_id"]
@@ -10,11 +10,19 @@ module UpGuard
10
10
  h = to_hash
11
11
  return h.to_json(options)
12
12
  end
13
- def initialize(appliance_url, api_key, sec_key, insecure)
14
- super(appliance_url, api_key, sec_key, insecure)
13
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure)
14
+ super(appliance_url, appliance_api_key, sec_key, insecure)
15
15
  @inner_list = []
16
16
  end
17
17
 
18
+ def count
19
+ return @inner_list.count
20
+ end
21
+
22
+ def [](idx)
23
+ return @inner_list[idx]
24
+ end
25
+
18
26
 
19
27
 
20
28
  def each(&block)
@@ -10,11 +10,19 @@ module UpGuard
10
10
  h = to_hash
11
11
  return h.to_json(options)
12
12
  end
13
- def initialize(appliance_url, api_key, sec_key, insecure)
14
- super(appliance_url, api_key, sec_key, insecure)
13
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure)
14
+ super(appliance_url, appliance_api_key, sec_key, insecure)
15
15
  @inner_list = []
16
16
  end
17
17
 
18
+ def count
19
+ return @inner_list.count
20
+ end
21
+
22
+ def [](idx)
23
+ return @inner_list[idx]
24
+ end
25
+
18
26
 
19
27
 
20
28
  def each(&block)
@@ -28,6 +28,33 @@ module UpGuard
28
28
  h = to_hash
29
29
  return h.to_json(options)
30
30
  end
31
+
32
+ def tasks
33
+ obj = http_get("/api/v2/jobs/{job_id}/tasks.json")
34
+ the_list = TaskList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
35
+ obj.each do |x|
36
+ elem = Task.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
37
+ elem.agent_name = x["agent_name"] if x.include?("agent_name")
38
+ elem.connection_manager_id = x["connection_manager_id"] if x.include?("connection_manager_id")
39
+ elem.created_at = x["created_at"] if x.include?("created_at")
40
+ elem.id = x["id"] if x.include?("id")
41
+ elem.job_id = x["job_id"] if x.include?("job_id")
42
+ elem.label = x["label"] if x.include?("label")
43
+ elem.log = x["log"] if x.include?("log")
44
+ elem.node_id = x["node_id"] if x.include?("node_id")
45
+ elem.node_session_id = x["node_session_id"] if x.include?("node_session_id")
46
+ elem.payload = x["payload"] if x.include?("payload")
47
+ elem.report = x["report"] if x.include?("report")
48
+ elem.sequence = x["sequence"] if x.include?("sequence")
49
+ elem.status = x["status"] if x.include?("status")
50
+ elem.step_description = x["step_description"] if x.include?("step_description")
51
+ elem.updated_at = x["updated_at"] if x.include?("updated_at")
52
+ elem.uuid = x["uuid"] if x.include?("uuid")
53
+ the_list << elem
54
+ end
55
+ return the_list
56
+ end
57
+
31
58
 
32
59
  end
33
60
  end
@@ -10,11 +10,19 @@ module UpGuard
10
10
  h = to_hash
11
11
  return h.to_json(options)
12
12
  end
13
- def initialize(appliance_url, api_key, sec_key, insecure)
14
- super(appliance_url, api_key, sec_key, insecure)
13
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure)
14
+ super(appliance_url, appliance_api_key, sec_key, insecure)
15
15
  @inner_list = []
16
16
  end
17
17
 
18
+ def count
19
+ return @inner_list.count
20
+ end
21
+
22
+ def [](idx)
23
+ return @inner_list[idx]
24
+ end
25
+
18
26
 
19
27
 
20
28
  def each(&block)
@@ -85,7 +85,7 @@ module UpGuard
85
85
 
86
86
  def connection_manager_group
87
87
  obj = http_get("/api/v2/connection_manager_groups/{connection_manager_group_id}.json")
88
- elem = ConnectionManagerGroup.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
88
+ elem = ConnectionManagerGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
89
89
  elem.id = obj["id"]
90
90
  elem.name = obj["name"]
91
91
  return elem
@@ -94,7 +94,7 @@ module UpGuard
94
94
 
95
95
  def environment
96
96
  obj = http_get("/api/v2/environments/#{self.environment_id}.json")
97
- elem = Environment.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
97
+ elem = Environment.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
98
98
  elem.id = obj["id"]
99
99
  elem.name = obj["name"]
100
100
  return elem
@@ -103,7 +103,7 @@ module UpGuard
103
103
 
104
104
  def operating_system
105
105
  obj = http_get("/api/v2/operating_systems/#{self.operating_system_id}.json")
106
- elem = OperatingSystem.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
106
+ elem = OperatingSystem.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
107
107
  elem.id = obj["id"]
108
108
  elem.name = obj["name"]
109
109
  return elem
@@ -112,7 +112,7 @@ module UpGuard
112
112
 
113
113
  def operating_system_family
114
114
  obj = http_get("/api/v2/operating_system_families/#{self.operating_system_family_id}.json")
115
- elem = OperatingSystemFamily.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
115
+ elem = OperatingSystemFamily.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
116
116
  elem.id = obj["id"]
117
117
  elem.name = obj["name"]
118
118
  return elem
@@ -124,6 +124,36 @@ module UpGuard
124
124
  return obj
125
125
  end
126
126
 
127
+
128
+ def node_groups
129
+ obj = http_get("/api/v2/nodes/#{self.id}/node_groups.json")
130
+ the_list = NodeGroupList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
131
+ obj.each do |x|
132
+ elem = NodeGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
133
+ elem.id = x["id"] if x.include?("id")
134
+ elem.name = x["name"] if x.include?("name")
135
+ elem.description = x["description"] if x.include?("description")
136
+ elem.node_rules = x["node_rules"] if x.include?("node_rules")
137
+ the_list << elem
138
+ end
139
+ return the_list
140
+ end
141
+
142
+
143
+ def raw_files
144
+ obj = http_get("/api/v2/nodes/#{self.id}/raw_files.json")
145
+ the_list = RawFileList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
146
+ obj.each do |x|
147
+ elem = RawFile.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
148
+ elem.id = x["id"] if x.include?("id")
149
+ elem.node_scan_id = x["node_scan_id"] if x.include?("node_scan_id")
150
+ elem.created_at = x["created_at"] if x.include?("created_at")
151
+ elem.updated_at = x["updated_at"] if x.include?("updated_at")
152
+ the_list << elem
153
+ end
154
+ return the_list
155
+ end
156
+
127
157
 
128
158
  end
129
159
  end
@@ -1,24 +1,48 @@
1
1
  module UpGuard
2
2
  class NodeGroup < BaseObject
3
+ attr_accessor :created_at
4
+ attr_accessor :created_by
3
5
  attr_accessor :description
6
+ attr_accessor :diff_notify
7
+ attr_accessor :external_id
4
8
  attr_accessor :id
5
9
  attr_accessor :name
6
10
  attr_accessor :node_rules
11
+ attr_accessor :scan_options
7
12
  attr_accessor :search_query
13
+ attr_accessor :status
14
+ attr_accessor :updated_at
15
+ attr_accessor :updated_by
8
16
  def from_hash(h)
17
+ self.created_at = h['created_at'] if h.include?('created_at')
18
+ self.created_by = h['created_by'] if h.include?('created_by')
9
19
  self.description = h['description'] if h.include?('description')
20
+ self.diff_notify = h['diff_notify'] if h.include?('diff_notify')
21
+ self.external_id = h['external_id'] if h.include?('external_id')
10
22
  self.id = h['id'] if h.include?('id')
11
23
  self.name = h['name'] if h.include?('name')
12
24
  self.node_rules = h['node_rules'] if h.include?('node_rules')
25
+ self.scan_options = h['scan_options'] if h.include?('scan_options')
13
26
  self.search_query = h['search_query'] if h.include?('search_query')
27
+ self.status = h['status'] if h.include?('status')
28
+ self.updated_at = h['updated_at'] if h.include?('updated_at')
29
+ self.updated_by = h['updated_by'] if h.include?('updated_by')
14
30
  end
15
31
  def to_hash
16
32
  h = {}
33
+ h['created_at'] = self.created_at
34
+ h['created_by'] = self.created_by
17
35
  h['description'] = self.description
36
+ h['diff_notify'] = self.diff_notify
37
+ h['external_id'] = self.external_id
18
38
  h['id'] = self.id
19
39
  h['name'] = self.name
20
40
  h['node_rules'] = self.node_rules
41
+ h['scan_options'] = self.scan_options
21
42
  h['search_query'] = self.search_query
43
+ h['status'] = self.status
44
+ h['updated_at'] = self.updated_at
45
+ h['updated_by'] = self.updated_by
22
46
  return h
23
47
  end
24
48
  def to_json(options = nil)
@@ -60,9 +84,9 @@ module UpGuard
60
84
 
61
85
  def nodes
62
86
  obj = http_get("/api/v2/node_groups/#{self.id}/nodes.json")
63
- the_list = NodeList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
87
+ the_list = NodeList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
64
88
  obj.each do |x|
65
- elem = Node.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
89
+ elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
66
90
  elem.id = x["id"] if x.include?("id")
67
91
  elem.name = x["name"] if x.include?("name")
68
92
  the_list << elem
@@ -70,6 +94,45 @@ module UpGuard
70
94
  return the_list
71
95
  end
72
96
 
97
+
98
+ def policy_versions
99
+ obj = http_get("/api/v2/node_groups/#{self.id}/policy_versions.json")
100
+ the_list = PolicyVersionList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
101
+ obj.each do |x|
102
+ elem = PolicyVersion.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
103
+ elem.id = x["id"] if x.include?("id")
104
+ elem.name = x["name"] if x.include?("name")
105
+ elem.version = x["version"] if x.include?("version")
106
+ the_list << elem
107
+ end
108
+ return the_list
109
+ end
110
+
111
+
112
+ def users
113
+ obj = http_get("/api/v2/node_groups/#{self.id}/users.json")
114
+ the_list = NodeGroupUserList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
115
+ obj.each do |x|
116
+ elem = NodeGroupUser.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
117
+ elem.email = x["email"] if x.include?("email")
118
+ elem.user_id = x["user_id"] if x.include?("user_id")
119
+ the_list << elem
120
+ end
121
+ return the_list
122
+ end
123
+
124
+ def add_user(user_id)
125
+ url = "/api/v2/node_groups/#{self.id}/add_users.json?user_id=#{user_id}"
126
+ obj = http_post(url, nil)
127
+ return obj
128
+ end
129
+
130
+ def remove_user(user_id)
131
+ url = "/api/v2/node_groups/#{self.id}/remove_user.json?user_id=#{user_id}"
132
+ obj = http_put(url, nil)
133
+ return obj
134
+ end
135
+
73
136
 
74
137
  end
75
138
  end
@@ -10,11 +10,19 @@ module UpGuard
10
10
  h = to_hash
11
11
  return h.to_json(options)
12
12
  end
13
- def initialize(appliance_url, api_key, sec_key, insecure)
14
- super(appliance_url, api_key, sec_key, insecure)
13
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure)
14
+ super(appliance_url, appliance_api_key, sec_key, insecure)
15
15
  @inner_list = []
16
16
  end
17
17
 
18
+ def count
19
+ return @inner_list.count
20
+ end
21
+
22
+ def [](idx)
23
+ return @inner_list[idx]
24
+ end
25
+
18
26
 
19
27
 
20
28
  def each(&block)
@@ -0,0 +1,21 @@
1
+ module UpGuard
2
+ class NodeGroupUser < BaseObject
3
+ attr_accessor :email
4
+ attr_accessor :user_id
5
+ def from_hash(h)
6
+ self.email = h['email'] if h.include?('email')
7
+ self.user_id = h['user_id'] if h.include?('user_id')
8
+ end
9
+ def to_hash
10
+ h = {}
11
+ h['email'] = self.email
12
+ h['user_id'] = self.user_id
13
+ return h
14
+ end
15
+ def to_json(options = nil)
16
+ h = to_hash
17
+ return h.to_json(options)
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,58 @@
1
+ module UpGuard
2
+ class NodeGroupUserList < BaseObject
3
+ def from_hash(h)
4
+ end
5
+ def to_hash
6
+ h = {}
7
+ return h
8
+ end
9
+ def to_json(options = nil)
10
+ h = to_hash
11
+ return h.to_json(options)
12
+ end
13
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure)
14
+ super(appliance_url, appliance_api_key, sec_key, insecure)
15
+ @inner_list = []
16
+ end
17
+
18
+ def count
19
+ return @inner_list.count
20
+ end
21
+
22
+ def [](idx)
23
+ return @inner_list[idx]
24
+ end
25
+
26
+
27
+
28
+ def each(&block)
29
+ @inner_list.each(&block)
30
+ end
31
+
32
+
33
+
34
+ def <<(obj)
35
+ @inner_list << obj
36
+ end
37
+
38
+
39
+
40
+ def to_json
41
+ return @inner_list.to_json
42
+ end
43
+
44
+
45
+
46
+ def find_by_email(email)
47
+ @inner_list.each do |x|
48
+ if x.email == email
49
+ return x
50
+ end
51
+ end
52
+ return nil
53
+ end
54
+
55
+
56
+
57
+ end
58
+ end
@@ -10,11 +10,19 @@ module UpGuard
10
10
  h = to_hash
11
11
  return h.to_json(options)
12
12
  end
13
- def initialize(appliance_url, api_key, sec_key, insecure)
14
- super(appliance_url, api_key, sec_key, insecure)
13
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure)
14
+ super(appliance_url, appliance_api_key, sec_key, insecure)
15
15
  @inner_list = []
16
16
  end
17
17
 
18
+ def count
19
+ return @inner_list.count
20
+ end
21
+
22
+ def [](idx)
23
+ return @inner_list[idx]
24
+ end
25
+
18
26
 
19
27
 
20
28
  def each(&block)
@@ -25,7 +25,7 @@ module UpGuard
25
25
 
26
26
  def operating_system_family
27
27
  obj = http_get("/api/v2/operating_system_families/#{self.operating_system_family_id}.json")
28
- elem = OperatingSystemFamily.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
28
+ elem = OperatingSystemFamily.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
29
29
  elem.id = obj["id"]
30
30
  elem.name = obj["name"]
31
31
  return elem
@@ -19,9 +19,9 @@ module UpGuard
19
19
 
20
20
  def operating_systems
21
21
  obj = http_get("/api/v2/operating_system_families/#{self.id}/operating_systems.json")
22
- the_list = OperatingSystemList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
22
+ the_list = OperatingSystemList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
23
23
  obj.each do |x|
24
- elem = OperatingSystem.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
24
+ elem = OperatingSystem.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
25
25
  elem.id = x["id"] if x.include?("id")
26
26
  elem.name = x["name"] if x.include?("name")
27
27
  the_list << elem
@@ -10,11 +10,19 @@ module UpGuard
10
10
  h = to_hash
11
11
  return h.to_json(options)
12
12
  end
13
- def initialize(appliance_url, api_key, sec_key, insecure)
14
- super(appliance_url, api_key, sec_key, insecure)
13
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure)
14
+ super(appliance_url, appliance_api_key, sec_key, insecure)
15
15
  @inner_list = []
16
16
  end
17
17
 
18
+ def count
19
+ return @inner_list.count
20
+ end
21
+
22
+ def [](idx)
23
+ return @inner_list[idx]
24
+ end
25
+
18
26
 
19
27
 
20
28
  def each(&block)
@@ -10,11 +10,19 @@ module UpGuard
10
10
  h = to_hash
11
11
  return h.to_json(options)
12
12
  end
13
- def initialize(appliance_url, api_key, sec_key, insecure)
14
- super(appliance_url, api_key, sec_key, insecure)
13
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure)
14
+ super(appliance_url, appliance_api_key, sec_key, insecure)
15
15
  @inner_list = []
16
16
  end
17
17
 
18
+ def count
19
+ return @inner_list.count
20
+ end
21
+
22
+ def [](idx)
23
+ return @inner_list[idx]
24
+ end
25
+
18
26
 
19
27
 
20
28
  def each(&block)
@@ -2,14 +2,20 @@ module UpGuard
2
2
  class Policy < BaseObject
3
3
  attr_accessor :id
4
4
  attr_accessor :name
5
+ attr_accessor :short_description
6
+ attr_accessor :description
5
7
  def from_hash(h)
6
8
  self.id = h['id'] if h.include?('id')
7
9
  self.name = h['name'] if h.include?('name')
10
+ self.short_description = h['short_description'] if h.include?('short_description')
11
+ self.description = h['description'] if h.include?('description')
8
12
  end
9
13
  def to_hash
10
14
  h = {}
11
15
  h['id'] = self.id
12
16
  h['name'] = self.name
17
+ h['short_description'] = self.short_description
18
+ h['description'] = self.description
13
19
  return h
14
20
  end
15
21
  def to_json(options = nil)
@@ -48,6 +54,26 @@ module UpGuard
48
54
  http_delete("/api/v2/policies/#{self.id}.json")
49
55
  end
50
56
 
57
+
58
+ def policy_versions
59
+ obj = http_get("/api/v2/policies/#{self.id}/versions.json")
60
+ the_list = PolicyVersionList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
61
+ obj.each do |x|
62
+ elem = PolicyVersion.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
63
+ elem.id = x["id"] if x.include?("id")
64
+ elem.version = x["version"] if x.include?("version")
65
+ elem.tag = x["tag"] if x.include?("tag")
66
+ the_list << elem
67
+ end
68
+ return the_list
69
+ end
70
+
71
+ def add_file_check(section, file_path, attr, check, expected, absent_pass=false)
72
+ url = "/api/v2/policies/#{self.id}/add_file_check.json?section=#{section}&file_path=#{file_path}&attr=#{attr}&check=#{check}&expected=#{expected}&absent_pass=#{absent_pass}"
73
+ obj = http_post(url, nil)
74
+ return obj
75
+ end
76
+
51
77
 
52
78
  end
53
79
  end
@@ -10,11 +10,19 @@ module UpGuard
10
10
  h = to_hash
11
11
  return h.to_json(options)
12
12
  end
13
- def initialize(appliance_url, api_key, sec_key, insecure)
14
- super(appliance_url, api_key, sec_key, insecure)
13
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure)
14
+ super(appliance_url, appliance_api_key, sec_key, insecure)
15
15
  @inner_list = []
16
16
  end
17
17
 
18
+ def count
19
+ return @inner_list.count
20
+ end
21
+
22
+ def [](idx)
23
+ return @inner_list[idx]
24
+ end
25
+
18
26
 
19
27
 
20
28
  def each(&block)
@@ -10,11 +10,19 @@ module UpGuard
10
10
  h = to_hash
11
11
  return h.to_json(options)
12
12
  end
13
- def initialize(appliance_url, api_key, sec_key, insecure)
14
- super(appliance_url, api_key, sec_key, insecure)
13
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure)
14
+ super(appliance_url, appliance_api_key, sec_key, insecure)
15
15
  @inner_list = []
16
16
  end
17
17
 
18
+ def count
19
+ return @inner_list.count
20
+ end
21
+
22
+ def [](idx)
23
+ return @inner_list[idx]
24
+ end
25
+
18
26
 
19
27
 
20
28
  def each(&block)
@@ -10,11 +10,19 @@ module UpGuard
10
10
  h = to_hash
11
11
  return h.to_json(options)
12
12
  end
13
- def initialize(appliance_url, api_key, sec_key, insecure)
14
- super(appliance_url, api_key, sec_key, insecure)
13
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure)
14
+ super(appliance_url, appliance_api_key, sec_key, insecure)
15
15
  @inner_list = []
16
16
  end
17
17
 
18
+ def count
19
+ return @inner_list.count
20
+ end
21
+
22
+ def [](idx)
23
+ return @inner_list[idx]
24
+ end
25
+
18
26
 
19
27
 
20
28
  def each(&block)
@@ -10,11 +10,19 @@ module UpGuard
10
10
  h = to_hash
11
11
  return h.to_json(options)
12
12
  end
13
- def initialize(appliance_url, api_key, sec_key, insecure)
14
- super(appliance_url, api_key, sec_key, insecure)
13
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure)
14
+ super(appliance_url, appliance_api_key, sec_key, insecure)
15
15
  @inner_list = []
16
16
  end
17
17
 
18
+ def count
19
+ return @inner_list.count
20
+ end
21
+
22
+ def [](idx)
23
+ return @inner_list[idx]
24
+ end
25
+
18
26
 
19
27
 
20
28
  def each(&block)
@@ -34,6 +42,17 @@ module UpGuard
34
42
  end
35
43
 
36
44
 
45
+
46
+ def find_by_email(email)
47
+ @inner_list.each do |x|
48
+ if x.email == email
49
+ return x
50
+ end
51
+ end
52
+ return nil
53
+ end
54
+
55
+
37
56
 
38
57
  end
39
58
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: upguard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - UpGuard Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-04 00:00:00.000000000 Z
11
+ date: 2020-06-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -65,6 +65,8 @@ files:
65
65
  - lib/upguard/Node.rb
66
66
  - lib/upguard/NodeGroup.rb
67
67
  - lib/upguard/NodeGroupList.rb
68
+ - lib/upguard/NodeGroupUser.rb
69
+ - lib/upguard/NodeGroupUserList.rb
68
70
  - lib/upguard/NodeList.rb
69
71
  - lib/upguard/NodeType.rb
70
72
  - lib/upguard/OperatingSystem.rb
@@ -98,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
100
  version: '0'
99
101
  requirements: []
100
102
  rubyforge_project:
101
- rubygems_version: 2.6.14
103
+ rubygems_version: 2.5.1
102
104
  signing_key:
103
105
  specification_version: 4
104
106
  summary: UpGuard Core SDK for Ruby