upguard 0.0.3 → 0.0.14
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 +5 -5
- data/lib/upguard.rb +25 -0
- data/lib/upguard/Account.rb +374 -129
- data/lib/upguard/BaseObject.rb +23 -22
- data/lib/upguard/ChangeRequest.rb +42 -0
- data/lib/upguard/ChangeRequestList.rb +52 -0
- data/lib/upguard/ConnectionManager.rb +18 -3
- data/lib/upguard/ConnectionManagerGroup.rb +31 -9
- data/lib/upguard/ConnectionManagerGroupList.rb +52 -0
- data/lib/upguard/ConnectionManagerList.rb +52 -0
- data/lib/upguard/Environment.rb +34 -11
- data/lib/upguard/EnvironmentList.rb +52 -0
- data/lib/upguard/Event.rb +6 -3
- data/lib/upguard/EventAction.rb +8 -2
- data/lib/upguard/EventActionList.rb +52 -0
- data/lib/upguard/EventList.rb +52 -0
- data/lib/upguard/EventVariables.rb +43 -0
- data/lib/upguard/ExternalEvent.rb +30 -0
- data/lib/upguard/Incident.rb +2 -2
- data/lib/upguard/IncidentList.rb +52 -0
- data/lib/upguard/Job.rb +60 -0
- data/lib/upguard/JobList.rb +52 -0
- data/lib/upguard/MediumType.rb +5 -2
- data/lib/upguard/Node.rb +63 -9
- data/lib/upguard/NodeGroup.rb +80 -8
- data/lib/upguard/NodeGroupList.rb +63 -0
- data/lib/upguard/NodeGroupUser.rb +21 -0
- data/lib/upguard/NodeGroupUserList.rb +63 -0
- data/lib/upguard/NodeList.rb +52 -0
- data/lib/upguard/NodeMediumInfo.rb +49 -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 +52 -0
- data/lib/upguard/OperatingSystemList.rb +52 -0
- data/lib/upguard/Policy.rb +79 -0
- data/lib/upguard/PolicyList.rb +52 -0
- data/lib/upguard/ScheduledJob.rb +6 -3
- data/lib/upguard/ScheduledJobList.rb +52 -0
- data/lib/upguard/SystemMetric.rb +2 -2
- data/lib/upguard/SystemMetricList.rb +52 -0
- data/lib/upguard/User.rb +26 -2
- data/lib/upguard/UserList.rb +74 -0
- data/lib/upguard/Version.rb +21 -0
- metadata +35 -10
data/lib/upguard/MediumType.rb
CHANGED
data/lib/upguard/Node.rb
CHANGED
@@ -3,45 +3,69 @@ module UpGuard
|
|
3
3
|
attr_accessor :connection_manager_group_id
|
4
4
|
attr_accessor :environment_id
|
5
5
|
attr_accessor :external_id
|
6
|
-
attr_accessor :hostname
|
7
6
|
attr_accessor :id
|
7
|
+
attr_accessor :ip_address
|
8
|
+
attr_accessor :last_scan_status
|
9
|
+
attr_accessor :last_scan_status_string
|
10
|
+
attr_accessor :mac_address
|
8
11
|
attr_accessor :medium_hostname
|
12
|
+
attr_accessor :medium_info
|
13
|
+
attr_accessor :medium_port
|
9
14
|
attr_accessor :medium_type
|
15
|
+
attr_accessor :medium_username
|
10
16
|
attr_accessor :name
|
11
17
|
attr_accessor :node_type
|
18
|
+
attr_accessor :online
|
12
19
|
attr_accessor :operating_system_family_id
|
13
20
|
attr_accessor :operating_system_id
|
21
|
+
attr_accessor :short_description
|
14
22
|
def from_hash(h)
|
15
23
|
self.connection_manager_group_id = h['connection_manager_group_id'] if h.include?('connection_manager_group_id')
|
16
24
|
self.environment_id = h['environment_id'] if h.include?('environment_id')
|
17
25
|
self.external_id = h['external_id'] if h.include?('external_id')
|
18
|
-
self.hostname = h['hostname'] if h.include?('hostname')
|
19
26
|
self.id = h['id'] if h.include?('id')
|
27
|
+
self.ip_address = h['ip_address'] if h.include?('ip_address')
|
28
|
+
self.last_scan_status = h['last_scan_status'] if h.include?('last_scan_status')
|
29
|
+
self.last_scan_status_string = h['last_scan_status_string'] if h.include?('last_scan_status_string')
|
30
|
+
self.mac_address = h['mac_address'] if h.include?('mac_address')
|
20
31
|
self.medium_hostname = h['medium_hostname'] if h.include?('medium_hostname')
|
32
|
+
self.medium_info = h['medium_info'] if h.include?('medium_info')
|
33
|
+
self.medium_port = h['medium_port'] if h.include?('medium_port')
|
21
34
|
self.medium_type = h['medium_type'] if h.include?('medium_type')
|
35
|
+
self.medium_username = h['medium_username'] if h.include?('medium_username')
|
22
36
|
self.name = h['name'] if h.include?('name')
|
23
37
|
self.node_type = h['node_type'] if h.include?('node_type')
|
38
|
+
self.online = h['online'] if h.include?('online')
|
24
39
|
self.operating_system_family_id = h['operating_system_family_id'] if h.include?('operating_system_family_id')
|
25
40
|
self.operating_system_id = h['operating_system_id'] if h.include?('operating_system_id')
|
41
|
+
self.short_description = h['short_description'] if h.include?('short_description')
|
26
42
|
end
|
27
43
|
def to_hash
|
28
44
|
h = {}
|
29
45
|
h['connection_manager_group_id'] = self.connection_manager_group_id
|
30
46
|
h['environment_id'] = self.environment_id
|
31
47
|
h['external_id'] = self.external_id
|
32
|
-
h['hostname'] = self.hostname
|
33
48
|
h['id'] = self.id
|
49
|
+
h['ip_address'] = self.ip_address
|
50
|
+
h['last_scan_status'] = self.last_scan_status
|
51
|
+
h['last_scan_status_string'] = self.last_scan_status_string
|
52
|
+
h['mac_address'] = self.mac_address
|
34
53
|
h['medium_hostname'] = self.medium_hostname
|
54
|
+
h['medium_info'] = self.medium_info
|
55
|
+
h['medium_port'] = self.medium_port
|
35
56
|
h['medium_type'] = self.medium_type
|
57
|
+
h['medium_username'] = self.medium_username
|
36
58
|
h['name'] = self.name
|
37
59
|
h['node_type'] = self.node_type
|
60
|
+
h['online'] = self.online
|
38
61
|
h['operating_system_family_id'] = self.operating_system_family_id
|
39
62
|
h['operating_system_id'] = self.operating_system_id
|
63
|
+
h['short_description'] = self.short_description
|
40
64
|
return h
|
41
65
|
end
|
42
|
-
def to_json
|
66
|
+
def to_json(options = nil)
|
43
67
|
h = to_hash
|
44
|
-
return h.to_json
|
68
|
+
return h.to_json(options)
|
45
69
|
end
|
46
70
|
|
47
71
|
def load
|
@@ -79,7 +103,7 @@ module UpGuard
|
|
79
103
|
|
80
104
|
def connection_manager_group
|
81
105
|
obj = http_get("/api/v2/connection_manager_groups/{connection_manager_group_id}.json")
|
82
|
-
elem = ConnectionManagerGroup.new(self.
|
106
|
+
elem = ConnectionManagerGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
83
107
|
elem.id = obj["id"]
|
84
108
|
elem.name = obj["name"]
|
85
109
|
return elem
|
@@ -88,7 +112,7 @@ module UpGuard
|
|
88
112
|
|
89
113
|
def environment
|
90
114
|
obj = http_get("/api/v2/environments/#{self.environment_id}.json")
|
91
|
-
elem = Environment.new(self.
|
115
|
+
elem = Environment.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
92
116
|
elem.id = obj["id"]
|
93
117
|
elem.name = obj["name"]
|
94
118
|
return elem
|
@@ -97,7 +121,7 @@ module UpGuard
|
|
97
121
|
|
98
122
|
def operating_system
|
99
123
|
obj = http_get("/api/v2/operating_systems/#{self.operating_system_id}.json")
|
100
|
-
elem = OperatingSystem.new(self.
|
124
|
+
elem = OperatingSystem.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
101
125
|
elem.id = obj["id"]
|
102
126
|
elem.name = obj["name"]
|
103
127
|
return elem
|
@@ -106,7 +130,7 @@ module UpGuard
|
|
106
130
|
|
107
131
|
def operating_system_family
|
108
132
|
obj = http_get("/api/v2/operating_system_families/#{self.operating_system_family_id}.json")
|
109
|
-
elem = OperatingSystemFamily.new(self.
|
133
|
+
elem = OperatingSystemFamily.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
110
134
|
elem.id = obj["id"]
|
111
135
|
elem.name = obj["name"]
|
112
136
|
return elem
|
@@ -118,6 +142,36 @@ module UpGuard
|
|
118
142
|
return obj
|
119
143
|
end
|
120
144
|
|
145
|
+
|
146
|
+
def node_groups
|
147
|
+
obj = http_get("/api/v2/nodes/#{self.id}/node_groups.json")
|
148
|
+
the_list = NodeGroupList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
149
|
+
obj.each do |x|
|
150
|
+
elem = NodeGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
151
|
+
elem.id = x["id"] if x.include?("id")
|
152
|
+
elem.name = x["name"] if x.include?("name")
|
153
|
+
elem.description = x["description"] if x.include?("description")
|
154
|
+
elem.node_rules = x["node_rules"] if x.include?("node_rules")
|
155
|
+
the_list << elem
|
156
|
+
end
|
157
|
+
return the_list
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
def raw_files
|
162
|
+
obj = http_get("/api/v2/nodes/#{self.id}/raw_files.json")
|
163
|
+
the_list = RawFileList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
164
|
+
obj.each do |x|
|
165
|
+
elem = RawFile.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
166
|
+
elem.id = x["id"] if x.include?("id")
|
167
|
+
elem.node_scan_id = x["node_scan_id"] if x.include?("node_scan_id")
|
168
|
+
elem.created_at = x["created_at"] if x.include?("created_at")
|
169
|
+
elem.updated_at = x["updated_at"] if x.include?("updated_at")
|
170
|
+
the_list << elem
|
171
|
+
end
|
172
|
+
return the_list
|
173
|
+
end
|
174
|
+
|
121
175
|
|
122
176
|
end
|
123
177
|
end
|
data/lib/upguard/NodeGroup.rb
CHANGED
@@ -1,20 +1,53 @@
|
|
1
1
|
module UpGuard
|
2
2
|
class NodeGroup < BaseObject
|
3
|
+
attr_accessor :created_at
|
4
|
+
attr_accessor :created_by
|
5
|
+
attr_accessor :description
|
6
|
+
attr_accessor :diff_notify
|
7
|
+
attr_accessor :external_id
|
3
8
|
attr_accessor :id
|
4
9
|
attr_accessor :name
|
10
|
+
attr_accessor :node_rules
|
11
|
+
attr_accessor :scan_options
|
12
|
+
attr_accessor :search_query
|
13
|
+
attr_accessor :status
|
14
|
+
attr_accessor :updated_at
|
15
|
+
attr_accessor :updated_by
|
5
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')
|
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')
|
6
22
|
self.id = h['id'] if h.include?('id')
|
7
23
|
self.name = h['name'] if h.include?('name')
|
24
|
+
self.node_rules = h['node_rules'] if h.include?('node_rules')
|
25
|
+
self.scan_options = h['scan_options'] if h.include?('scan_options')
|
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')
|
8
30
|
end
|
9
31
|
def to_hash
|
10
32
|
h = {}
|
33
|
+
h['created_at'] = self.created_at
|
34
|
+
h['created_by'] = self.created_by
|
35
|
+
h['description'] = self.description
|
36
|
+
h['diff_notify'] = self.diff_notify
|
37
|
+
h['external_id'] = self.external_id
|
11
38
|
h['id'] = self.id
|
12
39
|
h['name'] = self.name
|
40
|
+
h['node_rules'] = self.node_rules
|
41
|
+
h['scan_options'] = self.scan_options
|
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
|
13
46
|
return h
|
14
47
|
end
|
15
|
-
def to_json
|
48
|
+
def to_json(options = nil)
|
16
49
|
h = to_hash
|
17
|
-
return h.to_json
|
50
|
+
return h.to_json(options)
|
18
51
|
end
|
19
52
|
|
20
53
|
def load
|
@@ -51,14 +84,53 @@ module UpGuard
|
|
51
84
|
|
52
85
|
def nodes
|
53
86
|
obj = http_get("/api/v2/node_groups/#{self.id}/nodes.json")
|
54
|
-
|
87
|
+
the_list = NodeList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
55
88
|
obj.each do |x|
|
56
|
-
elem = Node.new(self.
|
57
|
-
elem.id = x["id"]
|
58
|
-
elem.name = x["name"]
|
59
|
-
|
89
|
+
elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
90
|
+
elem.id = x["id"] if x.include?("id")
|
91
|
+
elem.name = x["name"] if x.include?("name")
|
92
|
+
the_list << elem
|
60
93
|
end
|
61
|
-
return
|
94
|
+
return the_list
|
95
|
+
end
|
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
|
62
134
|
end
|
63
135
|
|
64
136
|
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module UpGuard
|
2
|
+
class NodeGroupList < 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 obj.class.name != "NodeGroup"
|
38
|
+
raise "Can only append 'NodeGroup' to 'NodeGroupList'
|
39
|
+
end
|
40
|
+
@inner_list << obj
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
def to_json
|
46
|
+
return @inner_list.to_json
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
def find_by_id(id)
|
52
|
+
@inner_list.each do |x|
|
53
|
+
if x.id.to_s == id.to_s
|
54
|
+
return x
|
55
|
+
end
|
56
|
+
end
|
57
|
+
return nil
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -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,63 @@
|
|
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 obj.class.name != "NodeGroupUser"
|
38
|
+
raise "Can only append 'NodeGroupUser' to 'NodeGroupUserList'
|
39
|
+
end
|
40
|
+
@inner_list << obj
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
def to_json
|
46
|
+
return @inner_list.to_json
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
def find_by_email(email)
|
52
|
+
@inner_list.each do |x|
|
53
|
+
if x.email == email
|
54
|
+
return x
|
55
|
+
end
|
56
|
+
end
|
57
|
+
return nil
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module UpGuard
|
2
|
+
class NodeList < 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 obj.class.name != "Node"
|
38
|
+
raise "Can only append 'Node' to 'NodeList'
|
39
|
+
end
|
40
|
+
@inner_list << obj
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
def to_json
|
46
|
+
return @inner_list.to_json
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|