upguard 0.0.4 → 0.0.16
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 +27 -0
- data/lib/upguard/Account.rb +404 -129
- data/lib/upguard/BaseObject.rb +23 -22
- data/lib/upguard/ChangeRequest.rb +55 -0
- data/lib/upguard/ChangeRequestList.rb +53 -0
- data/lib/upguard/ConnectionManager.rb +42 -3
- data/lib/upguard/ConnectionManagerGroup.rb +41 -9
- data/lib/upguard/ConnectionManagerGroupList.rb +53 -0
- data/lib/upguard/ConnectionManagerList.rb +53 -0
- data/lib/upguard/Environment.rb +48 -11
- data/lib/upguard/EnvironmentList.rb +53 -0
- data/lib/upguard/Event.rb +15 -3
- data/lib/upguard/EventAction.rb +18 -2
- data/lib/upguard/EventActionList.rb +53 -0
- data/lib/upguard/EventList.rb +53 -0
- data/lib/upguard/EventVariables.rb +43 -0
- data/lib/upguard/ExternalEvent.rb +36 -0
- data/lib/upguard/Incident.rb +12 -2
- data/lib/upguard/IncidentList.rb +53 -0
- data/lib/upguard/Job.rb +70 -0
- data/lib/upguard/JobList.rb +53 -0
- data/lib/upguard/MediumType.rb +5 -2
- data/lib/upguard/Node.rb +86 -9
- data/lib/upguard/NodeGroup.rb +97 -8
- data/lib/upguard/NodeGroupList.rb +64 -0
- data/lib/upguard/NodeGroupUser.rb +27 -0
- data/lib/upguard/NodeGroupUserList.rb +64 -0
- data/lib/upguard/NodeList.rb +53 -0
- data/lib/upguard/NodeMediumInfo.rb +49 -0
- data/lib/upguard/NodeType.rb +12 -2
- data/lib/upguard/OperatingSystem.rb +11 -3
- data/lib/upguard/OperatingSystemFamily.rb +14 -8
- data/lib/upguard/OperatingSystemFamilyList.rb +53 -0
- data/lib/upguard/OperatingSystemList.rb +53 -0
- data/lib/upguard/Pluggable.rb +81 -0
- data/lib/upguard/PluggableList.rb +53 -0
- data/lib/upguard/Policy.rb +87 -0
- data/lib/upguard/PolicyList.rb +53 -0
- data/lib/upguard/ScheduledJob.rb +16 -3
- data/lib/upguard/ScheduledJobList.rb +53 -0
- data/lib/upguard/SystemMetric.rb +9 -2
- data/lib/upguard/SystemMetricList.rb +53 -0
- data/lib/upguard/User.rb +39 -2
- data/lib/upguard/UserList.rb +75 -0
- data/lib/upguard/Version.rb +21 -0
- metadata +37 -10
@@ -0,0 +1,81 @@
|
|
1
|
+
module UpGuard
|
2
|
+
class Pluggable < BaseObject
|
3
|
+
attr_accessor :description
|
4
|
+
attr_accessor :id
|
5
|
+
attr_accessor :name
|
6
|
+
attr_accessor :operating_system_family
|
7
|
+
attr_accessor :operating_system_family_id
|
8
|
+
attr_accessor :operating_system_id
|
9
|
+
attr_accessor :script
|
10
|
+
def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
|
11
|
+
super(appliance_url, appliance_api_key, sec_key, insecure)
|
12
|
+
self.description = nil
|
13
|
+
self.id = nil
|
14
|
+
self.name = nil
|
15
|
+
self.operating_system_family = nil
|
16
|
+
self.operating_system_family_id = nil
|
17
|
+
self.operating_system_id = nil
|
18
|
+
self.script = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def from_hash(h)
|
22
|
+
self.description = h['description'] if h.include?('description')
|
23
|
+
self.id = h['id'] if h.include?('id')
|
24
|
+
self.name = h['name'] if h.include?('name')
|
25
|
+
self.operating_system_family = h['operating_system_family'] if h.include?('operating_system_family')
|
26
|
+
self.operating_system_family_id = h['operating_system_family_id'] if h.include?('operating_system_family_id')
|
27
|
+
self.operating_system_id = h['operating_system_id'] if h.include?('operating_system_id')
|
28
|
+
self.script = h['script'] if h.include?('script')
|
29
|
+
end
|
30
|
+
def to_hash
|
31
|
+
h = {}
|
32
|
+
h['description'] = self.description
|
33
|
+
h['id'] = self.id
|
34
|
+
h['name'] = self.name
|
35
|
+
h['operating_system_family'] = self.operating_system_family
|
36
|
+
h['operating_system_family_id'] = self.operating_system_family_id
|
37
|
+
h['operating_system_id'] = self.operating_system_id
|
38
|
+
h['script'] = self.script
|
39
|
+
return h
|
40
|
+
end
|
41
|
+
def to_json(options = nil)
|
42
|
+
h = to_hash
|
43
|
+
return h.to_json(options)
|
44
|
+
end
|
45
|
+
|
46
|
+
def load
|
47
|
+
obj = http_get("/api/v2/pluggables/#{self.operating_system_id}.json")
|
48
|
+
from_hash(obj)
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
def save
|
53
|
+
if self.id.to_i == 0
|
54
|
+
return create
|
55
|
+
else
|
56
|
+
return update
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
def create
|
62
|
+
h = to_hash
|
63
|
+
out = http_post("/api/v2/pluggables.json", h)
|
64
|
+
from_hash(out)
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def update
|
69
|
+
h = to_hash
|
70
|
+
h.delete("operating_system_family_id")
|
71
|
+
h.delete("operating_system_id")
|
72
|
+
http_put("/api/v2/pluggables/#{self.operating_system_id}.json", h)
|
73
|
+
end
|
74
|
+
|
75
|
+
def delete
|
76
|
+
http_delete("/api/v2/pluggables/#{self.operating_system_id}.json")
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module UpGuard
|
2
|
+
class PluggableList < 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 ["Pluggable", "UpGuard::Pluggable"].include?(obj.class.name)
|
38
|
+
@inner_list << obj
|
39
|
+
else
|
40
|
+
raise "Can only append 'Pluggable' to 'PluggableList'"
|
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,87 @@
|
|
1
|
+
module UpGuard
|
2
|
+
class Policy < BaseObject
|
3
|
+
attr_accessor :id
|
4
|
+
attr_accessor :name
|
5
|
+
attr_accessor :short_description
|
6
|
+
attr_accessor :description
|
7
|
+
def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
|
8
|
+
super(appliance_url, appliance_api_key, sec_key, insecure)
|
9
|
+
self.id = nil
|
10
|
+
self.name = nil
|
11
|
+
self.short_description = nil
|
12
|
+
self.description = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def from_hash(h)
|
16
|
+
self.id = h['id'] if h.include?('id')
|
17
|
+
self.name = h['name'] if h.include?('name')
|
18
|
+
self.short_description = h['short_description'] if h.include?('short_description')
|
19
|
+
self.description = h['description'] if h.include?('description')
|
20
|
+
end
|
21
|
+
def to_hash
|
22
|
+
h = {}
|
23
|
+
h['id'] = self.id
|
24
|
+
h['name'] = self.name
|
25
|
+
h['short_description'] = self.short_description
|
26
|
+
h['description'] = self.description
|
27
|
+
return h
|
28
|
+
end
|
29
|
+
def to_json(options = nil)
|
30
|
+
h = to_hash
|
31
|
+
return h.to_json(options)
|
32
|
+
end
|
33
|
+
|
34
|
+
def load
|
35
|
+
obj = http_get("/api/v2/policies/#{self.id}.json")
|
36
|
+
from_hash(obj)
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def save
|
41
|
+
if self.id.to_i == 0
|
42
|
+
return create
|
43
|
+
else
|
44
|
+
return update
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
def create
|
50
|
+
h = to_hash
|
51
|
+
out = http_post("/api/v2/policies.json", h)
|
52
|
+
from_hash(out)
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def update
|
57
|
+
h = to_hash
|
58
|
+
http_put("/api/v2/policies/#{self.id}.json", h)
|
59
|
+
end
|
60
|
+
|
61
|
+
def delete
|
62
|
+
http_delete("/api/v2/policies/#{self.id}.json")
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
def policy_versions
|
67
|
+
obj = http_get("/api/v2/policies/#{self.id}/versions.json")
|
68
|
+
the_list = PolicyVersionList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
69
|
+
obj.each do |x|
|
70
|
+
elem = PolicyVersion.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
|
71
|
+
elem.id = x["id"] if x.include?("id")
|
72
|
+
elem.version = x["version"] if x.include?("version")
|
73
|
+
elem.tag = x["tag"] if x.include?("tag")
|
74
|
+
the_list << elem
|
75
|
+
end
|
76
|
+
return the_list
|
77
|
+
end
|
78
|
+
|
79
|
+
def add_file_check(section, file_path, attr, check, expected, absent_pass=false)
|
80
|
+
url = "/api/v2/policies/#{self.id}/add_file_check.json?section=#{section}&file_path=#{file_path}&attr=#{attr}&check=#{check}&expected=#{expected}&absent_pass=#{absent_pass}"
|
81
|
+
obj = http_post(url, nil)
|
82
|
+
return obj
|
83
|
+
end
|
84
|
+
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module UpGuard
|
2
|
+
class PolicyList < 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 ["Policy", "UpGuard::Policy"].include?(obj.class.name)
|
38
|
+
@inner_list << obj
|
39
|
+
else
|
40
|
+
raise "Can only append 'Policy' to 'PolicyList'"
|
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
|
data/lib/upguard/ScheduledJob.rb
CHANGED
@@ -1,11 +1,23 @@
|
|
1
1
|
module UpGuard
|
2
2
|
class ScheduledJob < BaseObject
|
3
|
+
attr_accessor :data
|
3
4
|
attr_accessor :id
|
4
5
|
attr_accessor :source_id
|
5
6
|
attr_accessor :source_name
|
6
7
|
attr_accessor :source_type
|
7
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.data = nil
|
12
|
+
self.id = nil
|
13
|
+
self.source_id = nil
|
14
|
+
self.source_name = nil
|
15
|
+
self.source_type = nil
|
16
|
+
self.status = nil
|
17
|
+
end
|
18
|
+
|
8
19
|
def from_hash(h)
|
20
|
+
self.data = h['data'] if h.include?('data')
|
9
21
|
self.id = h['id'] if h.include?('id')
|
10
22
|
self.source_id = h['source_id'] if h.include?('source_id')
|
11
23
|
self.source_name = h['source_name'] if h.include?('source_name')
|
@@ -14,6 +26,7 @@ module UpGuard
|
|
14
26
|
end
|
15
27
|
def to_hash
|
16
28
|
h = {}
|
29
|
+
h['data'] = self.data
|
17
30
|
h['id'] = self.id
|
18
31
|
h['source_id'] = self.source_id
|
19
32
|
h['source_name'] = self.source_name
|
@@ -21,13 +34,13 @@ module UpGuard
|
|
21
34
|
h['status'] = self.status
|
22
35
|
return h
|
23
36
|
end
|
24
|
-
def to_json
|
37
|
+
def to_json(options = nil)
|
25
38
|
h = to_hash
|
26
|
-
return h.to_json
|
39
|
+
return h.to_json(options)
|
27
40
|
end
|
28
41
|
|
29
42
|
def load
|
30
|
-
obj = http_get("/api/v2/
|
43
|
+
obj = http_get("/api/v2/scheduled_jobs/#{self.id}.json")
|
31
44
|
from_hash(obj)
|
32
45
|
end
|
33
46
|
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module UpGuard
|
2
|
+
class ScheduledJobList < 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 ["ScheduledJob", "UpGuard::ScheduledJob"].include?(obj.class.name)
|
38
|
+
@inner_list << obj
|
39
|
+
else
|
40
|
+
raise "Can only append 'ScheduledJob' to 'ScheduledJobList'"
|
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
|
data/lib/upguard/SystemMetric.rb
CHANGED
@@ -3,6 +3,13 @@ module UpGuard
|
|
3
3
|
attr_accessor :metric
|
4
4
|
attr_accessor :value
|
5
5
|
attr_accessor :timestamp
|
6
|
+
def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
|
7
|
+
super(appliance_url, appliance_api_key, sec_key, insecure)
|
8
|
+
self.metric = nil
|
9
|
+
self.value = nil
|
10
|
+
self.timestamp = nil
|
11
|
+
end
|
12
|
+
|
6
13
|
def from_hash(h)
|
7
14
|
self.metric = h['metric'] if h.include?('metric')
|
8
15
|
self.value = h['value'] if h.include?('value')
|
@@ -15,9 +22,9 @@ module UpGuard
|
|
15
22
|
h['timestamp'] = self.timestamp
|
16
23
|
return h
|
17
24
|
end
|
18
|
-
def to_json
|
25
|
+
def to_json(options = nil)
|
19
26
|
h = to_hash
|
20
|
-
return h.to_json
|
27
|
+
return h.to_json(options)
|
21
28
|
end
|
22
29
|
|
23
30
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module UpGuard
|
2
|
+
class SystemMetricList < 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 ["SystemMetric", "UpGuard::SystemMetric"].include?(obj.class.name)
|
38
|
+
@inner_list << obj
|
39
|
+
else
|
40
|
+
raise "Can only append 'SystemMetric' to 'SystemMetricList'"
|
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
|