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
@@ -1,24 +1,65 @@
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
16
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
17
+ super(appliance_url, appliance_api_key, sec_key, insecure)
18
+ self.created_at = nil
19
+ self.created_by = nil
20
+ self.description = nil
21
+ self.diff_notify = nil
22
+ self.external_id = nil
23
+ self.id = nil
24
+ self.name = nil
25
+ self.node_rules = nil
26
+ self.scan_options = nil
27
+ self.search_query = nil
28
+ self.status = nil
29
+ self.updated_at = nil
30
+ self.updated_by = nil
31
+ end
32
+
8
33
  def from_hash(h)
34
+ self.created_at = h['created_at'] if h.include?('created_at')
35
+ self.created_by = h['created_by'] if h.include?('created_by')
9
36
  self.description = h['description'] if h.include?('description')
37
+ self.diff_notify = h['diff_notify'] if h.include?('diff_notify')
38
+ self.external_id = h['external_id'] if h.include?('external_id')
10
39
  self.id = h['id'] if h.include?('id')
11
40
  self.name = h['name'] if h.include?('name')
12
41
  self.node_rules = h['node_rules'] if h.include?('node_rules')
42
+ self.scan_options = h['scan_options'] if h.include?('scan_options')
13
43
  self.search_query = h['search_query'] if h.include?('search_query')
44
+ self.status = h['status'] if h.include?('status')
45
+ self.updated_at = h['updated_at'] if h.include?('updated_at')
46
+ self.updated_by = h['updated_by'] if h.include?('updated_by')
14
47
  end
15
48
  def to_hash
16
49
  h = {}
50
+ h['created_at'] = self.created_at
51
+ h['created_by'] = self.created_by
17
52
  h['description'] = self.description
53
+ h['diff_notify'] = self.diff_notify
54
+ h['external_id'] = self.external_id
18
55
  h['id'] = self.id
19
56
  h['name'] = self.name
20
57
  h['node_rules'] = self.node_rules
58
+ h['scan_options'] = self.scan_options
21
59
  h['search_query'] = self.search_query
60
+ h['status'] = self.status
61
+ h['updated_at'] = self.updated_at
62
+ h['updated_by'] = self.updated_by
22
63
  return h
23
64
  end
24
65
  def to_json(options = nil)
@@ -60,16 +101,55 @@ module UpGuard
60
101
 
61
102
  def nodes
62
103
  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)
104
+ the_list = NodeList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
105
+ obj.each do |x|
106
+ elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
107
+ elem.id = x["id"] if x.include?("id")
108
+ elem.name = x["name"] if x.include?("name")
109
+ the_list << elem
110
+ end
111
+ return the_list
112
+ end
113
+
114
+
115
+ def policy_versions
116
+ obj = http_get("/api/v2/node_groups/#{self.id}/policy_versions.json")
117
+ the_list = PolicyVersionList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
64
118
  obj.each do |x|
65
- elem = Node.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
119
+ elem = PolicyVersion.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
66
120
  elem.id = x["id"] if x.include?("id")
67
121
  elem.name = x["name"] if x.include?("name")
122
+ elem.version = x["version"] if x.include?("version")
68
123
  the_list << elem
69
124
  end
70
125
  return the_list
71
126
  end
72
127
 
128
+
129
+ def users
130
+ obj = http_get("/api/v2/node_groups/#{self.id}/users.json")
131
+ the_list = NodeGroupUserList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
132
+ obj.each do |x|
133
+ elem = NodeGroupUser.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
134
+ elem.email = x["email"] if x.include?("email")
135
+ elem.user_id = x["user_id"] if x.include?("user_id")
136
+ the_list << elem
137
+ end
138
+ return the_list
139
+ end
140
+
141
+ def add_user(user_id)
142
+ url = "/api/v2/node_groups/#{self.id}/add_users.json?user_id=#{user_id}"
143
+ obj = http_post(url, nil)
144
+ return obj
145
+ end
146
+
147
+ def remove_user(user_id)
148
+ url = "/api/v2/node_groups/#{self.id}/remove_user.json?user_id=#{user_id}"
149
+ obj = http_put(url, nil)
150
+ return obj
151
+ end
152
+
73
153
 
74
154
  end
75
155
  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 ["NodeGroup", "UpGuard::NodeGroup"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'NodeGroup' to 'NodeGroupList'"
41
+ end
28
42
  end
29
43
 
30
44
 
@@ -34,6 +48,17 @@ module UpGuard
34
48
  end
35
49
 
36
50
 
51
+
52
+ def find_by_id(id)
53
+ @inner_list.each do |x|
54
+ if x.id.to_s == id.to_s
55
+ return x
56
+ end
57
+ end
58
+ return nil
59
+ end
60
+
61
+
37
62
 
38
63
  end
39
64
  end
@@ -0,0 +1,27 @@
1
+ module UpGuard
2
+ class NodeGroupUser < BaseObject
3
+ attr_accessor :email
4
+ attr_accessor :user_id
5
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
6
+ super(appliance_url, appliance_api_key, sec_key, insecure)
7
+ self.email = nil
8
+ self.user_id = nil
9
+ end
10
+
11
+ def from_hash(h)
12
+ self.email = h['email'] if h.include?('email')
13
+ self.user_id = h['user_id'] if h.include?('user_id')
14
+ end
15
+ def to_hash
16
+ h = {}
17
+ h['email'] = self.email
18
+ h['user_id'] = self.user_id
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
+ end
27
+ end
@@ -0,0 +1,64 @@
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
+
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 ["NodeGroupUser", "UpGuard::NodeGroupUser"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'NodeGroupUser' to 'NodeGroupUserList'"
41
+ end
42
+ end
43
+
44
+
45
+
46
+ def to_json
47
+ return @inner_list.to_json
48
+ end
49
+
50
+
51
+
52
+ def find_by_email(email)
53
+ @inner_list.each do |x|
54
+ if x.email == email
55
+ return x
56
+ end
57
+ end
58
+ return nil
59
+ end
60
+
61
+
62
+
63
+ end
64
+ 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 ["Node", "UpGuard::Node"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'Node' to 'NodeList'"
41
+ end
28
42
  end
29
43
 
30
44
 
@@ -0,0 +1,49 @@
1
+ module UpGuard
2
+ class NodeMediumInfo < 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
+ def from_hash(h)
43
+ @inner_map = h
44
+ end
45
+
46
+
47
+
48
+ end
49
+ end
@@ -0,0 +1,78 @@
1
+ module UpGuard
2
+ class NodeScan < BaseObject
3
+ attr_accessor :associated_id
4
+ attr_accessor :category
5
+ attr_accessor :created_at
6
+ attr_accessor :data
7
+ attr_accessor :id
8
+ attr_accessor :label
9
+ attr_accessor :node_id
10
+ attr_accessor :scan_options
11
+ attr_accessor :task_id
12
+ attr_accessor :tsv
13
+ attr_accessor :updated_at
14
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
15
+ super(appliance_url, appliance_api_key, sec_key, insecure)
16
+ self.associated_id = nil
17
+ self.category = nil
18
+ self.created_at = nil
19
+ self.data = nil
20
+ self.id = nil
21
+ self.label = nil
22
+ self.node_id = nil
23
+ self.scan_options = nil
24
+ self.task_id = nil
25
+ self.tsv = nil
26
+ self.updated_at = nil
27
+ end
28
+
29
+ def from_hash(h)
30
+ self.associated_id = h['associated_id'] if h.include?('associated_id')
31
+ self.category = h['category'] if h.include?('category')
32
+ self.created_at = h['created_at'] if h.include?('created_at')
33
+ self.data = h['data'] if h.include?('data')
34
+ self.id = h['id'] if h.include?('id')
35
+ self.label = h['label'] if h.include?('label')
36
+ self.node_id = h['node_id'] if h.include?('node_id')
37
+ self.scan_options = h['scan_options'] if h.include?('scan_options')
38
+ self.task_id = h['task_id'] if h.include?('task_id')
39
+ self.tsv = h['tsv'] if h.include?('tsv')
40
+ self.updated_at = h['updated_at'] if h.include?('updated_at')
41
+ end
42
+ def to_hash
43
+ h = {}
44
+ h['associated_id'] = self.associated_id
45
+ h['category'] = self.category
46
+ h['created_at'] = self.created_at
47
+ h['data'] = self.data
48
+ h['id'] = self.id
49
+ h['label'] = self.label
50
+ h['node_id'] = self.node_id
51
+ h['scan_options'] = self.scan_options
52
+ h['task_id'] = self.task_id
53
+ h['tsv'] = self.tsv
54
+ h['updated_at'] = self.updated_at
55
+ return h
56
+ end
57
+ def to_json(options = nil)
58
+ h = to_hash
59
+ return h.to_json(options)
60
+ end
61
+
62
+ def load
63
+ obj = http_get("/api/v2/node_scans/#{self.id}.json")
64
+ from_hash(obj)
65
+ end
66
+
67
+
68
+ def node
69
+ obj = http_get("/api/v2/nodes/{node_id}.json")
70
+ elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
71
+ elem.id = obj["id"]
72
+ elem.name = obj["name"]
73
+ return elem
74
+ end
75
+
76
+
77
+ end
78
+ end
@@ -0,0 +1,53 @@
1
+ module UpGuard
2
+ class NodeScanList < 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 ["NodeScan", "UpGuard::NodeScan"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'NodeScan' to 'NodeScanList'"
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