upguard 0.0.2 → 0.0.10
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 +2 -5
- data/lib/upguard.rb +19 -0
- data/lib/upguard/Account.rb +333 -129
- data/lib/upguard/BaseObject.rb +23 -22
- data/lib/upguard/ConnectionManager.rb +18 -3
- data/lib/upguard/ConnectionManagerGroup.rb +31 -9
- data/lib/upguard/ConnectionManagerGroupList.rb +47 -0
- data/lib/upguard/ConnectionManagerList.rb +47 -0
- data/lib/upguard/Environment.rb +34 -11
- data/lib/upguard/EnvironmentList.rb +47 -0
- data/lib/upguard/Event.rb +3 -3
- data/lib/upguard/EventAction.rb +8 -2
- data/lib/upguard/EventActionList.rb +47 -0
- data/lib/upguard/Incident.rb +2 -2
- data/lib/upguard/IncidentList.rb +47 -0
- data/lib/upguard/Job.rb +60 -0
- data/lib/upguard/JobList.rb +47 -0
- data/lib/upguard/MediumType.rb +2 -2
- data/lib/upguard/Node.rb +54 -18
- data/lib/upguard/NodeGroup.rb +80 -8
- data/lib/upguard/NodeGroupList.rb +58 -0
- data/lib/upguard/NodeGroupUser.rb +21 -0
- data/lib/upguard/NodeGroupUserList.rb +58 -0
- data/lib/upguard/NodeList.rb +47 -0
- data/lib/upguard/NodeType.rb +12 -2
- data/lib/upguard/OperatingSystem.rb +3 -3
- data/lib/upguard/OperatingSystemFamily.rb +8 -8
- data/lib/upguard/OperatingSystemFamilyList.rb +47 -0
- data/lib/upguard/OperatingSystemList.rb +47 -0
- data/lib/upguard/Policy.rb +79 -0
- data/lib/upguard/PolicyList.rb +47 -0
- data/lib/upguard/ScheduledJob.rb +6 -3
- data/lib/upguard/ScheduledJobList.rb +47 -0
- data/lib/upguard/SystemMetric.rb +2 -2
- data/lib/upguard/SystemMetricList.rb +47 -0
- data/lib/upguard/User.rb +17 -2
- data/lib/upguard/UserList.rb +69 -0
- data/lib/upguard/Version.rb +21 -0
- metadata +24 -5
checksums.yaml
CHANGED
@@ -1,7 +1,4 @@
|
|
1
1
|
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: b683026e4527311504fdc094069f88cf2316bd9a
|
4
|
-
data.tar.gz: dc37e5246f08faf9bb48276d82a55f97080d36bf
|
5
2
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73a3f8cdabc58e33984017a37b30cf51a019be1fa5c97ce1697a083c464dc5ec990f1daf59d4db8c1930a07153baafbd9ffb3251206fe85b432c1b71b11e7e12
|
4
|
+
data.tar.gz: f23fe2899775985d9d55041ba81ae53c38fe07df39718a3e56f5a7d2e2bc354585bc0cba59291f4793a815bb1a88f9b378c0a5c26dda51cc971043a484a4dec5
|
data/lib/upguard.rb
CHANGED
@@ -1,17 +1,36 @@
|
|
1
1
|
require_relative 'upguard/BaseObject'
|
2
|
+
require_relative 'upguard/Version'
|
2
3
|
require_relative 'upguard/Account'
|
3
4
|
require_relative 'upguard/ConnectionManager'
|
5
|
+
require_relative 'upguard/ConnectionManagerList'
|
4
6
|
require_relative 'upguard/ConnectionManagerGroup'
|
7
|
+
require_relative 'upguard/ConnectionManagerGroupList'
|
5
8
|
require_relative 'upguard/Environment'
|
9
|
+
require_relative 'upguard/EnvironmentList'
|
6
10
|
require_relative 'upguard/Event'
|
7
11
|
require_relative 'upguard/EventAction'
|
12
|
+
require_relative 'upguard/EventActionList'
|
8
13
|
require_relative 'upguard/Incident'
|
14
|
+
require_relative 'upguard/IncidentList'
|
15
|
+
require_relative 'upguard/Job'
|
16
|
+
require_relative 'upguard/JobList'
|
9
17
|
require_relative 'upguard/MediumType'
|
10
18
|
require_relative 'upguard/Node'
|
19
|
+
require_relative 'upguard/NodeList'
|
11
20
|
require_relative 'upguard/NodeGroup'
|
21
|
+
require_relative 'upguard/NodeGroupList'
|
22
|
+
require_relative 'upguard/NodeGroupUser'
|
23
|
+
require_relative 'upguard/NodeGroupUserList'
|
12
24
|
require_relative 'upguard/NodeType'
|
13
25
|
require_relative 'upguard/OperatingSystem'
|
26
|
+
require_relative 'upguard/OperatingSystemList'
|
14
27
|
require_relative 'upguard/OperatingSystemFamily'
|
28
|
+
require_relative 'upguard/OperatingSystemFamilyList'
|
29
|
+
require_relative 'upguard/Policy'
|
30
|
+
require_relative 'upguard/PolicyList'
|
15
31
|
require_relative 'upguard/ScheduledJob'
|
32
|
+
require_relative 'upguard/ScheduledJobList'
|
16
33
|
require_relative 'upguard/SystemMetric'
|
34
|
+
require_relative 'upguard/SystemMetricList'
|
17
35
|
require_relative 'upguard/User'
|
36
|
+
require_relative 'upguard/UserList'
|
data/lib/upguard/Account.rb
CHANGED
@@ -12,221 +12,447 @@ 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
|
-
|
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.
|
25
|
-
elem.
|
26
|
-
elem.
|
27
|
-
elem.
|
28
|
-
|
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
|
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
|
-
|
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.
|
39
|
-
elem.id = x["id"]
|
40
|
-
elem.name = x["name"]
|
41
|
-
|
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
|
86
|
+
return the_list
|
44
87
|
end
|
45
88
|
|
46
89
|
def new_environment
|
47
|
-
return Environment.new(self.
|
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
|
-
|
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.
|
56
|
-
elem.
|
57
|
-
elem.
|
58
|
-
|
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
|
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
|
-
|
121
|
+
the_list = EventList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure
|
67
122
|
obj.each do |x|
|
68
|
-
elem = Event.new(self.
|
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
|
-
|
128
|
+
the_list << elem
|
74
129
|
end
|
75
|
-
return
|
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
|
-
|
136
|
+
the_list = EventList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure
|
82
137
|
obj.each do |x|
|
83
|
-
elem = Event.new(self.
|
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
|
-
|
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
|
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
|
-
|
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.
|
99
|
-
elem.id = x["id"]
|
100
|
-
elem.name = x["name"]
|
101
|
-
elem.status = x["status"]
|
102
|
-
elem.type = x["type"]
|
103
|
-
|
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
|
184
|
+
return the_list
|
106
185
|
end
|
107
186
|
|
108
187
|
|
109
188
|
def incidents
|
110
189
|
obj = http_get("/api/v2/incidents.json")
|
111
|
-
|
190
|
+
the_list = IncidentList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
112
191
|
obj.each do |x|
|
113
|
-
elem = Incident.new(self.
|
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
|
-
|
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
|
121
200
|
end
|
122
|
-
return
|
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
|
123
215
|
end
|
124
216
|
|
125
217
|
|
126
218
|
def jobs
|
127
219
|
obj = http_get("/api/v2/jobs.json")
|
128
|
-
|
220
|
+
the_list = JobList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
129
221
|
obj.each do |x|
|
130
|
-
elem = Job.new(self.
|
131
|
-
elem.id = x["id"]
|
132
|
-
elem.
|
133
|
-
elem.
|
134
|
-
elem.source_type = x["source_type"]
|
135
|
-
elem.status = x["status"]
|
136
|
-
|
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
|
137
229
|
end
|
138
|
-
return
|
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
|
139
243
|
end
|
140
244
|
|
141
245
|
def new_node
|
142
|
-
return Node.new(self.
|
246
|
+
return Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
143
247
|
end
|
144
248
|
|
145
249
|
|
146
250
|
def nodes
|
147
251
|
obj = http_get("/api/v2/nodes.json")
|
148
|
-
|
252
|
+
the_list = NodeList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
149
253
|
obj.each do |x|
|
150
|
-
elem = Node.new(self.
|
151
|
-
elem.
|
152
|
-
elem.
|
153
|
-
elem.
|
154
|
-
elem.
|
155
|
-
elem.
|
156
|
-
elem.
|
157
|
-
|
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
|
158
268
|
end
|
159
|
-
return
|
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)
|
160
303
|
end
|
161
304
|
|
162
305
|
|
163
306
|
def node_groups
|
164
307
|
obj = http_get("/api/v2/node_groups.json")
|
165
|
-
|
308
|
+
the_list = NodeGroupList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
166
309
|
obj.each do |x|
|
167
|
-
elem =
|
168
|
-
elem.
|
169
|
-
elem.
|
170
|
-
|
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
|
171
317
|
end
|
172
|
-
return
|
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
|
173
346
|
end
|
174
347
|
|
175
348
|
|
176
349
|
def operating_system_families
|
177
350
|
obj = http_get("/api/v2/operating_system_families.json")
|
178
|
-
|
351
|
+
the_list = OperatingSystemFamilyList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
179
352
|
obj.each do |x|
|
180
|
-
elem = OperatingSystemFamily.new(self.
|
181
|
-
elem.id = x["id"]
|
182
|
-
elem.name = x["name"]
|
183
|
-
|
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
|
184
357
|
end
|
185
|
-
return
|
358
|
+
return the_list
|
186
359
|
end
|
187
360
|
|
188
361
|
|
189
362
|
def operating_systems
|
190
363
|
obj = http_get("/api/v2/operating_systems.json")
|
191
|
-
|
364
|
+
the_list = OperatingSystemList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
192
365
|
obj.each do |x|
|
193
|
-
elem = OperatingSystem.new(self.
|
194
|
-
elem.id = x["id"]
|
195
|
-
elem.name = x["name"]
|
196
|
-
elem.operating_system_family_id = x["operating_system_family_id"]
|
197
|
-
|
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
|
198
408
|
end
|
199
|
-
return
|
409
|
+
return the_list
|
200
410
|
end
|
201
411
|
|
202
412
|
|
203
413
|
def system_metrics
|
204
414
|
obj = http_get("/api/v2/system_metrics.json")
|
205
|
-
|
415
|
+
the_list = SystemMetricList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
206
416
|
obj.each do |x|
|
207
|
-
elem = SystemMetric.new(self.
|
208
|
-
elem.metric = x["metric"]
|
209
|
-
elem.value = x["value"]
|
210
|
-
elem.timestamp = x["timestamp"]
|
211
|
-
|
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
|
212
422
|
end
|
213
|
-
return
|
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
|
214
438
|
end
|
215
439
|
|
216
440
|
|
217
441
|
def users
|
218
442
|
obj = http_get("/api/v2/users.json")
|
219
|
-
|
443
|
+
the_list = UserList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
220
444
|
obj.each do |x|
|
221
|
-
elem = User.new(self.
|
222
|
-
elem.
|
223
|
-
elem.
|
224
|
-
elem.
|
225
|
-
elem.
|
226
|
-
elem.role = x["role"]
|
227
|
-
|
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
|
+
elem.external_id = x["external_id"] if x.include?("external_id")
|
453
|
+
the_list << elem
|
228
454
|
end
|
229
|
-
return
|
455
|
+
return the_list
|
230
456
|
end
|
231
457
|
|
232
458
|
def invite_user(email, role)
|
@@ -235,32 +461,10 @@ module UpGuard
|
|
235
461
|
return obj
|
236
462
|
end
|
237
463
|
|
238
|
-
def
|
239
|
-
url = "/api/v2/
|
240
|
-
obj =
|
241
|
-
|
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
|
464
|
+
def remove_user(email)
|
465
|
+
url = "/api/v2/users/remove.json?email=#{email}"
|
466
|
+
obj = http_put(url, nil)
|
467
|
+
return obj
|
264
468
|
end
|
265
469
|
|
266
470
|
|