upguard 0.0.1 → 0.0.9
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 +346 -102
- 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 +33 -0
- 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 +47 -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 +2 -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 +2 -2
- data/lib/upguard/UserList.rb +58 -0
- metadata +23 -4
data/lib/upguard/Event.rb
CHANGED
@@ -18,14 +18,14 @@ module UpGuard
|
|
18
18
|
h['created_at'] = self.created_at
|
19
19
|
return h
|
20
20
|
end
|
21
|
-
def to_json
|
21
|
+
def to_json(options = nil)
|
22
22
|
h = to_hash
|
23
|
-
return h.to_json
|
23
|
+
return h.to_json(options)
|
24
24
|
end
|
25
25
|
|
26
26
|
def environment
|
27
27
|
obj = http_get("/api/v2/environments/#{self.environment_id}.json")
|
28
|
-
elem = Environment.new(self.
|
28
|
+
elem = Environment.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
29
29
|
elem.id = obj["id"]
|
30
30
|
elem.name = obj["name"]
|
31
31
|
elem.organisation_id = obj["organisation_id"]
|
data/lib/upguard/EventAction.rb
CHANGED
@@ -4,11 +4,15 @@ module UpGuard
|
|
4
4
|
attr_accessor :name
|
5
5
|
attr_accessor :status
|
6
6
|
attr_accessor :type
|
7
|
+
attr_accessor :variables
|
8
|
+
attr_accessor :view
|
7
9
|
def from_hash(h)
|
8
10
|
self.id = h['id'] if h.include?('id')
|
9
11
|
self.name = h['name'] if h.include?('name')
|
10
12
|
self.status = h['status'] if h.include?('status')
|
11
13
|
self.type = h['type'] if h.include?('type')
|
14
|
+
self.variables = h['variables'] if h.include?('variables')
|
15
|
+
self.view = h['view'] if h.include?('view')
|
12
16
|
end
|
13
17
|
def to_hash
|
14
18
|
h = {}
|
@@ -16,11 +20,13 @@ module UpGuard
|
|
16
20
|
h['name'] = self.name
|
17
21
|
h['status'] = self.status
|
18
22
|
h['type'] = self.type
|
23
|
+
h['variables'] = self.variables
|
24
|
+
h['view'] = self.view
|
19
25
|
return h
|
20
26
|
end
|
21
|
-
def to_json
|
27
|
+
def to_json(options = nil)
|
22
28
|
h = to_hash
|
23
|
-
return h.to_json
|
29
|
+
return h.to_json(options)
|
24
30
|
end
|
25
31
|
|
26
32
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module UpGuard
|
2
|
+
class EventActionList < 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
|
+
def count
|
19
|
+
return @inner_list.count
|
20
|
+
end
|
21
|
+
|
22
|
+
def [](idx)
|
23
|
+
return @inner_list[idx]
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
def each(&block)
|
29
|
+
@inner_list.each(&block)
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
def <<(obj)
|
35
|
+
@inner_list << obj
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
def to_json
|
41
|
+
return @inner_list.to_json
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module UpGuard
|
2
|
+
class Incident < BaseObject
|
3
|
+
attr_accessor :ended_at
|
4
|
+
attr_accessor :external_id
|
5
|
+
attr_accessor :id
|
6
|
+
attr_accessor :short_description
|
7
|
+
attr_accessor :started_at
|
8
|
+
attr_accessor :url
|
9
|
+
def from_hash(h)
|
10
|
+
self.ended_at = h['ended_at'] if h.include?('ended_at')
|
11
|
+
self.external_id = h['external_id'] if h.include?('external_id')
|
12
|
+
self.id = h['id'] if h.include?('id')
|
13
|
+
self.short_description = h['short_description'] if h.include?('short_description')
|
14
|
+
self.started_at = h['started_at'] if h.include?('started_at')
|
15
|
+
self.url = h['url'] if h.include?('url')
|
16
|
+
end
|
17
|
+
def to_hash
|
18
|
+
h = {}
|
19
|
+
h['ended_at'] = self.ended_at
|
20
|
+
h['external_id'] = self.external_id
|
21
|
+
h['id'] = self.id
|
22
|
+
h['short_description'] = self.short_description
|
23
|
+
h['started_at'] = self.started_at
|
24
|
+
h['url'] = self.url
|
25
|
+
return h
|
26
|
+
end
|
27
|
+
def to_json(options = nil)
|
28
|
+
h = to_hash
|
29
|
+
return h.to_json(options)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module UpGuard
|
2
|
+
class IncidentList < 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
|
+
def count
|
19
|
+
return @inner_list.count
|
20
|
+
end
|
21
|
+
|
22
|
+
def [](idx)
|
23
|
+
return @inner_list[idx]
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
def each(&block)
|
29
|
+
@inner_list.each(&block)
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
def <<(obj)
|
35
|
+
@inner_list << obj
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
def to_json
|
41
|
+
return @inner_list.to_json
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
data/lib/upguard/Job.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
module UpGuard
|
2
|
+
class Job < BaseObject
|
3
|
+
attr_accessor :id
|
4
|
+
attr_accessor :organisation_id
|
5
|
+
attr_accessor :source_id
|
6
|
+
attr_accessor :source_name
|
7
|
+
attr_accessor :source_type
|
8
|
+
attr_accessor :status
|
9
|
+
def from_hash(h)
|
10
|
+
self.id = h['id'] if h.include?('id')
|
11
|
+
self.organisation_id = h['organisation_id'] if h.include?('organisation_id')
|
12
|
+
self.source_id = h['source_id'] if h.include?('source_id')
|
13
|
+
self.source_name = h['source_name'] if h.include?('source_name')
|
14
|
+
self.source_type = h['source_type'] if h.include?('source_type')
|
15
|
+
self.status = h['status'] if h.include?('status')
|
16
|
+
end
|
17
|
+
def to_hash
|
18
|
+
h = {}
|
19
|
+
h['id'] = self.id
|
20
|
+
h['organisation_id'] = self.organisation_id
|
21
|
+
h['source_id'] = self.source_id
|
22
|
+
h['source_name'] = self.source_name
|
23
|
+
h['source_type'] = self.source_type
|
24
|
+
h['status'] = self.status
|
25
|
+
return h
|
26
|
+
end
|
27
|
+
def to_json(options = nil)
|
28
|
+
h = to_hash
|
29
|
+
return h.to_json(options)
|
30
|
+
end
|
31
|
+
|
32
|
+
def tasks
|
33
|
+
obj = http_get("/api/v2/jobs/{job_id}/tasks.json")
|
34
|
+
the_list = TaskList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
35
|
+
obj.each do |x|
|
36
|
+
elem = Task.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
37
|
+
elem.agent_name = x["agent_name"] if x.include?("agent_name")
|
38
|
+
elem.connection_manager_id = x["connection_manager_id"] if x.include?("connection_manager_id")
|
39
|
+
elem.created_at = x["created_at"] if x.include?("created_at")
|
40
|
+
elem.id = x["id"] if x.include?("id")
|
41
|
+
elem.job_id = x["job_id"] if x.include?("job_id")
|
42
|
+
elem.label = x["label"] if x.include?("label")
|
43
|
+
elem.log = x["log"] if x.include?("log")
|
44
|
+
elem.node_id = x["node_id"] if x.include?("node_id")
|
45
|
+
elem.node_session_id = x["node_session_id"] if x.include?("node_session_id")
|
46
|
+
elem.payload = x["payload"] if x.include?("payload")
|
47
|
+
elem.report = x["report"] if x.include?("report")
|
48
|
+
elem.sequence = x["sequence"] if x.include?("sequence")
|
49
|
+
elem.status = x["status"] if x.include?("status")
|
50
|
+
elem.step_description = x["step_description"] if x.include?("step_description")
|
51
|
+
elem.updated_at = x["updated_at"] if x.include?("updated_at")
|
52
|
+
elem.uuid = x["uuid"] if x.include?("uuid")
|
53
|
+
the_list << elem
|
54
|
+
end
|
55
|
+
return the_list
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module UpGuard
|
2
|
+
class JobList < 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
|
+
def count
|
19
|
+
return @inner_list.count
|
20
|
+
end
|
21
|
+
|
22
|
+
def [](idx)
|
23
|
+
return @inner_list[idx]
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
def each(&block)
|
29
|
+
@inner_list.each(&block)
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
def <<(obj)
|
35
|
+
@inner_list << obj
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
def to_json
|
41
|
+
return @inner_list.to_json
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
data/lib/upguard/MediumType.rb
CHANGED
data/lib/upguard/Node.rb
CHANGED
@@ -1,47 +1,53 @@
|
|
1
1
|
module UpGuard
|
2
2
|
class Node < BaseObject
|
3
|
-
attr_accessor :connection_manager_group_id
|
4
3
|
attr_accessor :environment_id
|
5
4
|
attr_accessor :external_id
|
6
|
-
attr_accessor :hostname
|
7
5
|
attr_accessor :id
|
8
|
-
attr_accessor :
|
9
|
-
attr_accessor :
|
6
|
+
attr_accessor :ip_address
|
7
|
+
attr_accessor :last_scan_status
|
8
|
+
attr_accessor :last_scan_status_string
|
9
|
+
attr_accessor :mac_address
|
10
10
|
attr_accessor :name
|
11
11
|
attr_accessor :node_type
|
12
|
+
attr_accessor :online
|
12
13
|
attr_accessor :operating_system_family_id
|
13
14
|
attr_accessor :operating_system_id
|
15
|
+
attr_accessor :short_description
|
14
16
|
def from_hash(h)
|
15
|
-
self.connection_manager_group_id = h['connection_manager_group_id'] if h.include?('connection_manager_group_id')
|
16
17
|
self.environment_id = h['environment_id'] if h.include?('environment_id')
|
17
18
|
self.external_id = h['external_id'] if h.include?('external_id')
|
18
|
-
self.hostname = h['hostname'] if h.include?('hostname')
|
19
19
|
self.id = h['id'] if h.include?('id')
|
20
|
-
self.
|
21
|
-
self.
|
20
|
+
self.ip_address = h['ip_address'] if h.include?('ip_address')
|
21
|
+
self.last_scan_status = h['last_scan_status'] if h.include?('last_scan_status')
|
22
|
+
self.last_scan_status_string = h['last_scan_status_string'] if h.include?('last_scan_status_string')
|
23
|
+
self.mac_address = h['mac_address'] if h.include?('mac_address')
|
22
24
|
self.name = h['name'] if h.include?('name')
|
23
25
|
self.node_type = h['node_type'] if h.include?('node_type')
|
26
|
+
self.online = h['online'] if h.include?('online')
|
24
27
|
self.operating_system_family_id = h['operating_system_family_id'] if h.include?('operating_system_family_id')
|
25
28
|
self.operating_system_id = h['operating_system_id'] if h.include?('operating_system_id')
|
29
|
+
self.short_description = h['short_description'] if h.include?('short_description')
|
26
30
|
end
|
27
31
|
def to_hash
|
28
32
|
h = {}
|
29
|
-
h['connection_manager_group_id'] = self.connection_manager_group_id
|
30
33
|
h['environment_id'] = self.environment_id
|
31
34
|
h['external_id'] = self.external_id
|
32
|
-
h['hostname'] = self.hostname
|
33
35
|
h['id'] = self.id
|
34
|
-
h['
|
35
|
-
h['
|
36
|
+
h['ip_address'] = self.ip_address
|
37
|
+
h['last_scan_status'] = self.last_scan_status
|
38
|
+
h['last_scan_status_string'] = self.last_scan_status_string
|
39
|
+
h['mac_address'] = self.mac_address
|
36
40
|
h['name'] = self.name
|
37
41
|
h['node_type'] = self.node_type
|
42
|
+
h['online'] = self.online
|
38
43
|
h['operating_system_family_id'] = self.operating_system_family_id
|
39
44
|
h['operating_system_id'] = self.operating_system_id
|
45
|
+
h['short_description'] = self.short_description
|
40
46
|
return h
|
41
47
|
end
|
42
|
-
def to_json
|
48
|
+
def to_json(options = nil)
|
43
49
|
h = to_hash
|
44
|
-
return h.to_json
|
50
|
+
return h.to_json(options)
|
45
51
|
end
|
46
52
|
|
47
53
|
def load
|
@@ -79,7 +85,7 @@ module UpGuard
|
|
79
85
|
|
80
86
|
def connection_manager_group
|
81
87
|
obj = http_get("/api/v2/connection_manager_groups/{connection_manager_group_id}.json")
|
82
|
-
elem = ConnectionManagerGroup.new(self.
|
88
|
+
elem = ConnectionManagerGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
83
89
|
elem.id = obj["id"]
|
84
90
|
elem.name = obj["name"]
|
85
91
|
return elem
|
@@ -88,7 +94,7 @@ module UpGuard
|
|
88
94
|
|
89
95
|
def environment
|
90
96
|
obj = http_get("/api/v2/environments/#{self.environment_id}.json")
|
91
|
-
elem = Environment.new(self.
|
97
|
+
elem = Environment.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
92
98
|
elem.id = obj["id"]
|
93
99
|
elem.name = obj["name"]
|
94
100
|
return elem
|
@@ -97,7 +103,7 @@ module UpGuard
|
|
97
103
|
|
98
104
|
def operating_system
|
99
105
|
obj = http_get("/api/v2/operating_systems/#{self.operating_system_id}.json")
|
100
|
-
elem = OperatingSystem.new(self.
|
106
|
+
elem = OperatingSystem.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
101
107
|
elem.id = obj["id"]
|
102
108
|
elem.name = obj["name"]
|
103
109
|
return elem
|
@@ -106,7 +112,7 @@ module UpGuard
|
|
106
112
|
|
107
113
|
def operating_system_family
|
108
114
|
obj = http_get("/api/v2/operating_system_families/#{self.operating_system_family_id}.json")
|
109
|
-
elem = OperatingSystemFamily.new(self.
|
115
|
+
elem = OperatingSystemFamily.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
110
116
|
elem.id = obj["id"]
|
111
117
|
elem.name = obj["name"]
|
112
118
|
return elem
|
@@ -118,6 +124,36 @@ module UpGuard
|
|
118
124
|
return obj
|
119
125
|
end
|
120
126
|
|
127
|
+
|
128
|
+
def node_groups
|
129
|
+
obj = http_get("/api/v2/nodes/#{self.id}/node_groups.json")
|
130
|
+
the_list = NodeGroupList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
131
|
+
obj.each do |x|
|
132
|
+
elem = NodeGroup.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
133
|
+
elem.id = x["id"] if x.include?("id")
|
134
|
+
elem.name = x["name"] if x.include?("name")
|
135
|
+
elem.description = x["description"] if x.include?("description")
|
136
|
+
elem.node_rules = x["node_rules"] if x.include?("node_rules")
|
137
|
+
the_list << elem
|
138
|
+
end
|
139
|
+
return the_list
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
def raw_files
|
144
|
+
obj = http_get("/api/v2/nodes/#{self.id}/raw_files.json")
|
145
|
+
the_list = RawFileList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
146
|
+
obj.each do |x|
|
147
|
+
elem = RawFile.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
148
|
+
elem.id = x["id"] if x.include?("id")
|
149
|
+
elem.node_scan_id = x["node_scan_id"] if x.include?("node_scan_id")
|
150
|
+
elem.created_at = x["created_at"] if x.include?("created_at")
|
151
|
+
elem.updated_at = x["updated_at"] if x.include?("updated_at")
|
152
|
+
the_list << elem
|
153
|
+
end
|
154
|
+
return the_list
|
155
|
+
end
|
156
|
+
|
121
157
|
|
122
158
|
end
|
123
159
|
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
|
|