upguard 0.0.6 → 0.0.17

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 (49) hide show
  1. checksums.yaml +5 -5
  2. data/lib/upguard.rb +13 -0
  3. data/lib/upguard/Account.rb +192 -49
  4. data/lib/upguard/BaseObject.rb +8 -7
  5. data/lib/upguard/ChangeRequest.rb +55 -0
  6. data/lib/upguard/ChangeRequestList.rb +53 -0
  7. data/lib/upguard/ConnectionManager.rb +25 -1
  8. data/lib/upguard/ConnectionManagerGroup.rb +16 -6
  9. data/lib/upguard/ConnectionManagerGroupList.rb +17 -3
  10. data/lib/upguard/ConnectionManagerList.rb +17 -3
  11. data/lib/upguard/Environment.rb +16 -2
  12. data/lib/upguard/EnvironmentList.rb +17 -3
  13. data/lib/upguard/Event.rb +13 -1
  14. data/lib/upguard/EventAction.rb +10 -0
  15. data/lib/upguard/EventActionList.rb +17 -3
  16. data/lib/upguard/EventList.rb +53 -0
  17. data/lib/upguard/EventVariables.rb +43 -0
  18. data/lib/upguard/ExternalEvent.rb +36 -0
  19. data/lib/upguard/Incident.rb +10 -0
  20. data/lib/upguard/IncidentList.rb +17 -3
  21. data/lib/upguard/Job.rb +37 -0
  22. data/lib/upguard/JobList.rb +17 -3
  23. data/lib/upguard/MediumType.rb +3 -0
  24. data/lib/upguard/Node.rb +93 -5
  25. data/lib/upguard/NodeGroup.rb +82 -2
  26. data/lib/upguard/NodeGroupList.rb +28 -3
  27. data/lib/upguard/NodeGroupUser.rb +27 -0
  28. data/lib/upguard/NodeGroupUserList.rb +64 -0
  29. data/lib/upguard/NodeList.rb +17 -3
  30. data/lib/upguard/NodeMediumInfo.rb +49 -0
  31. data/lib/upguard/NodeScan.rb +78 -0
  32. data/lib/upguard/NodeScanList.rb +53 -0
  33. data/lib/upguard/NodeType.rb +10 -0
  34. data/lib/upguard/OperatingSystem.rb +9 -1
  35. data/lib/upguard/OperatingSystemFamily.rb +8 -2
  36. data/lib/upguard/OperatingSystemFamilyList.rb +17 -3
  37. data/lib/upguard/OperatingSystemList.rb +17 -3
  38. data/lib/upguard/Pluggable.rb +81 -0
  39. data/lib/upguard/PluggableList.rb +53 -0
  40. data/lib/upguard/Policy.rb +34 -0
  41. data/lib/upguard/PolicyList.rb +17 -3
  42. data/lib/upguard/ScheduledJob.rb +11 -1
  43. data/lib/upguard/ScheduledJobList.rb +17 -3
  44. data/lib/upguard/SystemMetric.rb +7 -0
  45. data/lib/upguard/SystemMetricList.rb +17 -3
  46. data/lib/upguard/User.rb +37 -0
  47. data/lib/upguard/UserList.rb +39 -3
  48. data/lib/upguard/Version.rb +21 -0
  49. metadata +21 -8
@@ -6,6 +6,16 @@ module UpGuard
6
6
  attr_accessor :type
7
7
  attr_accessor :variables
8
8
  attr_accessor :view
9
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
10
+ super(appliance_url, appliance_api_key, sec_key, insecure)
11
+ self.id = nil
12
+ self.name = nil
13
+ self.status = nil
14
+ self.type = nil
15
+ self.variables = nil
16
+ self.view = nil
17
+ end
18
+
9
19
  def from_hash(h)
10
20
  self.id = h['id'] if h.include?('id')
11
21
  self.name = h['name'] if h.include?('name')
@@ -10,12 +10,22 @@ 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
18
 
19
+ def [](idx)
20
+ return @inner_list[idx]
21
+ end
22
+
23
+
24
+ def count
25
+ return @inner_list.count
26
+ end
27
+
28
+
19
29
 
20
30
  def each(&block)
21
31
  @inner_list.each(&block)
@@ -24,7 +34,11 @@ module UpGuard
24
34
 
25
35
 
26
36
  def <<(obj)
27
- @inner_list << obj
37
+ if ["EventAction", "UpGuard::EventAction"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'EventAction' to 'EventActionList'"
41
+ end
28
42
  end
29
43
 
30
44
 
@@ -0,0 +1,53 @@
1
+ module UpGuard
2
+ class EventList < 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
+
19
+ def [](idx)
20
+ return @inner_list[idx]
21
+ end
22
+
23
+
24
+ def count
25
+ return @inner_list.count
26
+ end
27
+
28
+
29
+
30
+ def each(&block)
31
+ @inner_list.each(&block)
32
+ end
33
+
34
+
35
+
36
+ def <<(obj)
37
+ if ["Event", "UpGuard::Event"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'Event' to 'EventList'"
41
+ end
42
+ end
43
+
44
+
45
+
46
+ def to_json
47
+ return @inner_list.to_json
48
+ end
49
+
50
+
51
+
52
+ end
53
+ end
@@ -0,0 +1,43 @@
1
+ module UpGuard
2
+ class EventVariables < 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_map = {}
16
+ end
17
+
18
+
19
+ def [](key)
20
+ return @inner_map[key]
21
+ end
22
+
23
+
24
+ def []=(key, value)
25
+ @inner_map[key] = value
26
+ end
27
+
28
+
29
+
30
+ def to_json(options = nil)
31
+ return @inner_map.to_json(options)
32
+ end
33
+
34
+
35
+
36
+ def to_hash
37
+ return @inner_map
38
+ end
39
+
40
+
41
+
42
+ end
43
+ end
@@ -0,0 +1,36 @@
1
+ module UpGuard
2
+ class ExternalEvent < BaseObject
3
+ attr_accessor :type
4
+ attr_accessor :variables
5
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
6
+ super(appliance_url, appliance_api_key, sec_key, insecure)
7
+ self.type = nil
8
+ self.variables = EventVariables.new(appliance_url, appliance_api_key, sec_key, insecure)
9
+ end
10
+
11
+ def from_hash(h)
12
+ self.type = h['type'] if h.include?('type')
13
+ self.variables = h['variables'] if h.include?('variables')
14
+ end
15
+ def to_hash
16
+ h = {}
17
+ h['type'] = self.type
18
+ h['variables'] = self.variables
19
+ return h
20
+ end
21
+ def to_json(options = nil)
22
+ h = to_hash
23
+ return h.to_json(options)
24
+ end
25
+
26
+ def create
27
+ h = {}
28
+ h["variables"] = self.variables.to_hash
29
+ h["variables"]["type"] = self.type
30
+ http_post("/api/v2/events.json", h)
31
+ end
32
+
33
+
34
+
35
+ end
36
+ end
@@ -6,6 +6,16 @@ module UpGuard
6
6
  attr_accessor :short_description
7
7
  attr_accessor :started_at
8
8
  attr_accessor :url
9
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
10
+ super(appliance_url, appliance_api_key, sec_key, insecure)
11
+ self.ended_at = nil
12
+ self.external_id = nil
13
+ self.id = nil
14
+ self.short_description = nil
15
+ self.started_at = nil
16
+ self.url = nil
17
+ end
18
+
9
19
  def from_hash(h)
10
20
  self.ended_at = h['ended_at'] if h.include?('ended_at')
11
21
  self.external_id = h['external_id'] if h.include?('external_id')
@@ -10,12 +10,22 @@ 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
18
 
19
+ def [](idx)
20
+ return @inner_list[idx]
21
+ end
22
+
23
+
24
+ def count
25
+ return @inner_list.count
26
+ end
27
+
28
+
19
29
 
20
30
  def each(&block)
21
31
  @inner_list.each(&block)
@@ -24,7 +34,11 @@ module UpGuard
24
34
 
25
35
 
26
36
  def <<(obj)
27
- @inner_list << obj
37
+ if ["Incident", "UpGuard::Incident"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'Incident' to 'IncidentList'"
41
+ end
28
42
  end
29
43
 
30
44
 
@@ -6,6 +6,16 @@ module UpGuard
6
6
  attr_accessor :source_name
7
7
  attr_accessor :source_type
8
8
  attr_accessor :status
9
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
10
+ super(appliance_url, appliance_api_key, sec_key, insecure)
11
+ self.id = nil
12
+ self.organisation_id = nil
13
+ self.source_id = nil
14
+ self.source_name = nil
15
+ self.source_type = nil
16
+ self.status = nil
17
+ end
18
+
9
19
  def from_hash(h)
10
20
  self.id = h['id'] if h.include?('id')
11
21
  self.organisation_id = h['organisation_id'] if h.include?('organisation_id')
@@ -28,6 +38,33 @@ module UpGuard
28
38
  h = to_hash
29
39
  return h.to_json(options)
30
40
  end
41
+
42
+ def tasks
43
+ obj = http_get("/api/v2/jobs/{job_id}/tasks.json")
44
+ the_list = TaskList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
45
+ obj.each do |x|
46
+ elem = Task.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
47
+ elem.agent_name = x["agent_name"] if x.include?("agent_name")
48
+ elem.connection_manager_id = x["connection_manager_id"] if x.include?("connection_manager_id")
49
+ elem.created_at = x["created_at"] if x.include?("created_at")
50
+ elem.id = x["id"] if x.include?("id")
51
+ elem.job_id = x["job_id"] if x.include?("job_id")
52
+ elem.label = x["label"] if x.include?("label")
53
+ elem.log = x["log"] if x.include?("log")
54
+ elem.node_id = x["node_id"] if x.include?("node_id")
55
+ elem.node_session_id = x["node_session_id"] if x.include?("node_session_id")
56
+ elem.payload = x["payload"] if x.include?("payload")
57
+ elem.report = x["report"] if x.include?("report")
58
+ elem.sequence = x["sequence"] if x.include?("sequence")
59
+ elem.status = x["status"] if x.include?("status")
60
+ elem.step_description = x["step_description"] if x.include?("step_description")
61
+ elem.updated_at = x["updated_at"] if x.include?("updated_at")
62
+ elem.uuid = x["uuid"] if x.include?("uuid")
63
+ the_list << elem
64
+ end
65
+ return the_list
66
+ end
67
+
31
68
 
32
69
  end
33
70
  end
@@ -10,12 +10,22 @@ 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
18
 
19
+ def [](idx)
20
+ return @inner_list[idx]
21
+ end
22
+
23
+
24
+ def count
25
+ return @inner_list.count
26
+ end
27
+
28
+
19
29
 
20
30
  def each(&block)
21
31
  @inner_list.each(&block)
@@ -24,7 +34,11 @@ module UpGuard
24
34
 
25
35
 
26
36
  def <<(obj)
27
- @inner_list << obj
37
+ if ["Job", "UpGuard::Job"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'Job' to 'JobList'"
41
+ end
28
42
  end
29
43
 
30
44
 
@@ -10,7 +10,10 @@ module UpGuard
10
10
  h = to_hash
11
11
  return h.to_json(options)
12
12
  end
13
+ AGENT = 1
13
14
  SSH = 3
15
+ WINRM = 7
16
+ DATABASE = 11
14
17
 
15
18
  end
16
19
  end
@@ -1,5 +1,6 @@
1
1
  module UpGuard
2
2
  class Node < BaseObject
3
+ attr_accessor :connection_manager_group_id
3
4
  attr_accessor :environment_id
4
5
  attr_accessor :external_id
5
6
  attr_accessor :id
@@ -7,13 +8,42 @@ module UpGuard
7
8
  attr_accessor :last_scan_status
8
9
  attr_accessor :last_scan_status_string
9
10
  attr_accessor :mac_address
11
+ attr_accessor :medium_hostname
12
+ attr_accessor :medium_info
13
+ attr_accessor :medium_port
14
+ attr_accessor :medium_type
15
+ attr_accessor :medium_username
10
16
  attr_accessor :name
11
17
  attr_accessor :node_type
12
18
  attr_accessor :online
13
19
  attr_accessor :operating_system_family_id
14
20
  attr_accessor :operating_system_id
15
21
  attr_accessor :short_description
22
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
23
+ super(appliance_url, appliance_api_key, sec_key, insecure)
24
+ self.connection_manager_group_id = nil
25
+ self.environment_id = nil
26
+ self.external_id = nil
27
+ self.id = nil
28
+ self.ip_address = nil
29
+ self.last_scan_status = nil
30
+ self.last_scan_status_string = nil
31
+ self.mac_address = nil
32
+ self.medium_hostname = nil
33
+ self.medium_info = NodeMediumInfo.new(appliance_url, appliance_api_key, sec_key, insecure)
34
+ self.medium_port = nil
35
+ self.medium_type = nil
36
+ self.medium_username = nil
37
+ self.name = nil
38
+ self.node_type = nil
39
+ self.online = nil
40
+ self.operating_system_family_id = nil
41
+ self.operating_system_id = nil
42
+ self.short_description = nil
43
+ end
44
+
16
45
  def from_hash(h)
46
+ self.connection_manager_group_id = h['connection_manager_group_id'] if h.include?('connection_manager_group_id')
17
47
  self.environment_id = h['environment_id'] if h.include?('environment_id')
18
48
  self.external_id = h['external_id'] if h.include?('external_id')
19
49
  self.id = h['id'] if h.include?('id')
@@ -21,6 +51,11 @@ module UpGuard
21
51
  self.last_scan_status = h['last_scan_status'] if h.include?('last_scan_status')
22
52
  self.last_scan_status_string = h['last_scan_status_string'] if h.include?('last_scan_status_string')
23
53
  self.mac_address = h['mac_address'] if h.include?('mac_address')
54
+ self.medium_hostname = h['medium_hostname'] if h.include?('medium_hostname')
55
+ self.medium_info = h['medium_info'] if h.include?('medium_info')
56
+ self.medium_port = h['medium_port'] if h.include?('medium_port')
57
+ self.medium_type = h['medium_type'] if h.include?('medium_type')
58
+ self.medium_username = h['medium_username'] if h.include?('medium_username')
24
59
  self.name = h['name'] if h.include?('name')
25
60
  self.node_type = h['node_type'] if h.include?('node_type')
26
61
  self.online = h['online'] if h.include?('online')
@@ -30,6 +65,7 @@ module UpGuard
30
65
  end
31
66
  def to_hash
32
67
  h = {}
68
+ h['connection_manager_group_id'] = self.connection_manager_group_id
33
69
  h['environment_id'] = self.environment_id
34
70
  h['external_id'] = self.external_id
35
71
  h['id'] = self.id
@@ -37,6 +73,11 @@ module UpGuard
37
73
  h['last_scan_status'] = self.last_scan_status
38
74
  h['last_scan_status_string'] = self.last_scan_status_string
39
75
  h['mac_address'] = self.mac_address
76
+ h['medium_hostname'] = self.medium_hostname
77
+ h['medium_info'] = self.medium_info
78
+ h['medium_port'] = self.medium_port
79
+ h['medium_type'] = self.medium_type
80
+ h['medium_username'] = self.medium_username
40
81
  h['name'] = self.name
41
82
  h['node_type'] = self.node_type
42
83
  h['online'] = self.online
@@ -85,7 +126,7 @@ module UpGuard
85
126
 
86
127
  def connection_manager_group
87
128
  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)
129
+ elem = ConnectionManagerGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
89
130
  elem.id = obj["id"]
90
131
  elem.name = obj["name"]
91
132
  return elem
@@ -94,7 +135,7 @@ module UpGuard
94
135
 
95
136
  def environment
96
137
  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)
138
+ elem = Environment.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
98
139
  elem.id = obj["id"]
99
140
  elem.name = obj["name"]
100
141
  return elem
@@ -103,7 +144,7 @@ module UpGuard
103
144
 
104
145
  def operating_system
105
146
  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)
147
+ elem = OperatingSystem.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
107
148
  elem.id = obj["id"]
108
149
  elem.name = obj["name"]
109
150
  return elem
@@ -112,18 +153,65 @@ module UpGuard
112
153
 
113
154
  def operating_system_family
114
155
  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)
156
+ elem = OperatingSystemFamily.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
116
157
  elem.id = obj["id"]
117
158
  elem.name = obj["name"]
118
159
  return elem
119
160
  end
120
161
 
121
- def start_scan()
162
+ def start_scan
122
163
  url = "/api/v2/nodes/#{self.id}/start_scan.json"
123
164
  obj = http_post(url, nil)
124
165
  return obj
125
166
  end
126
167
 
168
+ def node_scans
169
+ url = "/api/v2/node_scans.json?node_id=#{self.id}&per_page=5000"
170
+ obj = http_get(url)
171
+ the_list = NodeScanList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
172
+ obj.each do |x|
173
+ elem = NodeScan.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
174
+ elem.id = x["id"]
175
+ elem.node_id = x["node_id"]
176
+ elem.created_at = x["created_at"]
177
+ elem.updated_at = x["updated_at"]
178
+ elem.scan_options = x["scan_options"]
179
+ the_list << elem
180
+ end
181
+ return the_list
182
+ end
183
+
184
+
185
+
186
+ def node_groups
187
+ obj = http_get("/api/v2/nodes/#{self.id}/node_groups.json")
188
+ the_list = NodeGroupList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
189
+ obj.each do |x|
190
+ elem = NodeGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
191
+ elem.id = x["id"] if x.include?("id")
192
+ elem.name = x["name"] if x.include?("name")
193
+ elem.description = x["description"] if x.include?("description")
194
+ elem.node_rules = x["node_rules"] if x.include?("node_rules")
195
+ the_list << elem
196
+ end
197
+ return the_list
198
+ end
199
+
200
+
201
+ def raw_files
202
+ obj = http_get("/api/v2/nodes/#{self.id}/raw_files.json")
203
+ the_list = RawFileList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
204
+ obj.each do |x|
205
+ elem = RawFile.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
206
+ elem.id = x["id"] if x.include?("id")
207
+ elem.node_scan_id = x["node_scan_id"] if x.include?("node_scan_id")
208
+ elem.created_at = x["created_at"] if x.include?("created_at")
209
+ elem.updated_at = x["updated_at"] if x.include?("updated_at")
210
+ the_list << elem
211
+ end
212
+ return the_list
213
+ end
214
+
127
215
 
128
216
  end
129
217
  end