upguard 0.0.9 → 0.0.18

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 (48) hide show
  1. checksums.yaml +5 -2
  2. data/lib/upguard.rb +11 -0
  3. data/lib/upguard/Account.rb +87 -5
  4. data/lib/upguard/ChangeRequest.rb +55 -0
  5. data/lib/upguard/ChangeRequestList.rb +53 -0
  6. data/lib/upguard/ConnectionManager.rb +24 -0
  7. data/lib/upguard/ConnectionManagerGroup.rb +10 -0
  8. data/lib/upguard/ConnectionManagerGroupList.rb +11 -5
  9. data/lib/upguard/ConnectionManagerList.rb +11 -5
  10. data/lib/upguard/Environment.rb +14 -0
  11. data/lib/upguard/EnvironmentList.rb +11 -5
  12. data/lib/upguard/Event.rb +12 -0
  13. data/lib/upguard/EventAction.rb +10 -0
  14. data/lib/upguard/EventActionList.rb +11 -5
  15. data/lib/upguard/EventList.rb +53 -0
  16. data/lib/upguard/EventVariables.rb +43 -0
  17. data/lib/upguard/ExternalEvent.rb +36 -0
  18. data/lib/upguard/Incident.rb +10 -0
  19. data/lib/upguard/IncidentList.rb +11 -5
  20. data/lib/upguard/Job.rb +10 -0
  21. data/lib/upguard/JobList.rb +11 -5
  22. data/lib/upguard/MediumType.rb +3 -0
  23. data/lib/upguard/Node.rb +59 -1
  24. data/lib/upguard/NodeGroup.rb +17 -0
  25. data/lib/upguard/NodeGroupList.rb +22 -5
  26. data/lib/upguard/NodeGroupUser.rb +6 -0
  27. data/lib/upguard/NodeGroupUserList.rb +11 -5
  28. data/lib/upguard/NodeList.rb +11 -5
  29. data/lib/upguard/NodeMediumInfo.rb +49 -0
  30. data/lib/upguard/NodeScan.rb +78 -0
  31. data/lib/upguard/NodeScanList.rb +53 -0
  32. data/lib/upguard/NodeType.rb +10 -0
  33. data/lib/upguard/OperatingSystem.rb +8 -0
  34. data/lib/upguard/OperatingSystemFamily.rb +6 -0
  35. data/lib/upguard/OperatingSystemFamilyList.rb +11 -5
  36. data/lib/upguard/OperatingSystemList.rb +11 -5
  37. data/lib/upguard/Pluggable.rb +81 -0
  38. data/lib/upguard/PluggableList.rb +53 -0
  39. data/lib/upguard/Policy.rb +8 -0
  40. data/lib/upguard/PolicyList.rb +11 -5
  41. data/lib/upguard/ScheduledJob.rb +11 -1
  42. data/lib/upguard/ScheduledJobList.rb +11 -5
  43. data/lib/upguard/SystemMetric.rb +7 -0
  44. data/lib/upguard/SystemMetricList.rb +11 -5
  45. data/lib/upguard/User.rb +37 -0
  46. data/lib/upguard/UserList.rb +22 -5
  47. data/lib/upguard/Version.rb +21 -0
  48. metadata +19 -8
@@ -10,6 +10,20 @@ module UpGuard
10
10
  attr_accessor :updated_at
11
11
  attr_accessor :created_at
12
12
  attr_accessor :weight
13
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
14
+ super(appliance_url, appliance_api_key, sec_key, insecure)
15
+ self.description = nil
16
+ self.id = nil
17
+ self.name = nil
18
+ self.node_rules = nil
19
+ self.short_description = nil
20
+ self.updated_by = nil
21
+ self.created_by = nil
22
+ self.updated_at = nil
23
+ self.created_at = nil
24
+ self.weight = nil
25
+ end
26
+
13
27
  def from_hash(h)
14
28
  self.description = h['description'] if h.include?('description')
15
29
  self.id = h['id'] if h.include?('id')
@@ -15,15 +15,17 @@ module UpGuard
15
15
  @inner_list = []
16
16
  end
17
17
 
18
- def count
19
- return @inner_list.count
20
- end
21
-
18
+
22
19
  def [](idx)
23
20
  return @inner_list[idx]
24
21
  end
25
22
 
26
23
 
24
+ def count
25
+ return @inner_list.count
26
+ end
27
+
28
+
27
29
 
28
30
  def each(&block)
29
31
  @inner_list.each(&block)
@@ -32,7 +34,11 @@ module UpGuard
32
34
 
33
35
 
34
36
  def <<(obj)
35
- @inner_list << obj
37
+ if ["Environment", "UpGuard::Environment"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'Environment' to 'EnvironmentList'"
41
+ end
36
42
  end
37
43
 
38
44
 
@@ -4,11 +4,22 @@ module UpGuard
4
4
  attr_accessor :type_id
5
5
  attr_accessor :environment_id
6
6
  attr_accessor :created_at
7
+ attr_accessor :variables
8
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
9
+ super(appliance_url, appliance_api_key, sec_key, insecure)
10
+ self.id = nil
11
+ self.type_id = nil
12
+ self.environment_id = nil
13
+ self.created_at = nil
14
+ self.variables = EventVariables.new(appliance_url, appliance_api_key, sec_key, insecure)
15
+ end
16
+
7
17
  def from_hash(h)
8
18
  self.id = h['id'] if h.include?('id')
9
19
  self.type_id = h['type_id'] if h.include?('type_id')
10
20
  self.environment_id = h['environment_id'] if h.include?('environment_id')
11
21
  self.created_at = h['created_at'] if h.include?('created_at')
22
+ self.variables = h['variables'] if h.include?('variables')
12
23
  end
13
24
  def to_hash
14
25
  h = {}
@@ -16,6 +27,7 @@ module UpGuard
16
27
  h['type_id'] = self.type_id
17
28
  h['environment_id'] = self.environment_id
18
29
  h['created_at'] = self.created_at
30
+ h['variables'] = self.variables
19
31
  return h
20
32
  end
21
33
  def to_json(options = nil)
@@ -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')
@@ -15,15 +15,17 @@ module UpGuard
15
15
  @inner_list = []
16
16
  end
17
17
 
18
- def count
19
- return @inner_list.count
20
- end
21
-
18
+
22
19
  def [](idx)
23
20
  return @inner_list[idx]
24
21
  end
25
22
 
26
23
 
24
+ def count
25
+ return @inner_list.count
26
+ end
27
+
28
+
27
29
 
28
30
  def each(&block)
29
31
  @inner_list.each(&block)
@@ -32,7 +34,11 @@ module UpGuard
32
34
 
33
35
 
34
36
  def <<(obj)
35
- @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
36
42
  end
37
43
 
38
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')
@@ -15,15 +15,17 @@ module UpGuard
15
15
  @inner_list = []
16
16
  end
17
17
 
18
- def count
19
- return @inner_list.count
20
- end
21
-
18
+
22
19
  def [](idx)
23
20
  return @inner_list[idx]
24
21
  end
25
22
 
26
23
 
24
+ def count
25
+ return @inner_list.count
26
+ end
27
+
28
+
27
29
 
28
30
  def each(&block)
29
31
  @inner_list.each(&block)
@@ -32,7 +34,11 @@ module UpGuard
32
34
 
33
35
 
34
36
  def <<(obj)
35
- @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
36
42
  end
37
43
 
38
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')
@@ -15,15 +15,17 @@ module UpGuard
15
15
  @inner_list = []
16
16
  end
17
17
 
18
- def count
19
- return @inner_list.count
20
- end
21
-
18
+
22
19
  def [](idx)
23
20
  return @inner_list[idx]
24
21
  end
25
22
 
26
23
 
24
+ def count
25
+ return @inner_list.count
26
+ end
27
+
28
+
27
29
 
28
30
  def each(&block)
29
31
  @inner_list.each(&block)
@@ -32,7 +34,11 @@ module UpGuard
32
34
 
33
35
 
34
36
  def <<(obj)
35
- @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
36
42
  end
37
43
 
38
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
@@ -118,12 +159,29 @@ module UpGuard
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
+
127
185
 
128
186
  def node_groups
129
187
  obj = http_get("/api/v2/nodes/#{self.id}/node_groups.json")