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
@@ -10,7 +10,17 @@ module UpGuard
10
10
  h = to_hash
11
11
  return h.to_json(options)
12
12
  end
13
+ SERVICE = "SC"
13
14
  SERVER = "SV"
15
+ DATABASE = "DB"
16
+ DESKTOP = "DT"
17
+ SWITCH = "SW"
18
+ FIREWALL = "FW"
19
+ ROUTER = "RT"
20
+ SMART_PHONE = "PH"
21
+ ROBOT = "RB"
22
+ SAN_STORAGE = "SS"
23
+ WEBSITE = "WS"
14
24
 
15
25
  end
16
26
  end
@@ -4,6 +4,14 @@ module UpGuard
4
4
  attr_accessor :id
5
5
  attr_accessor :name
6
6
  attr_accessor :operating_system_family_id
7
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
8
+ super(appliance_url, appliance_api_key, sec_key, insecure)
9
+ self.description = nil
10
+ self.id = nil
11
+ self.name = nil
12
+ self.operating_system_family_id = nil
13
+ end
14
+
7
15
  def from_hash(h)
8
16
  self.description = h['description'] if h.include?('description')
9
17
  self.id = h['id'] if h.include?('id')
@@ -25,7 +33,7 @@ module UpGuard
25
33
 
26
34
  def operating_system_family
27
35
  obj = http_get("/api/v2/operating_system_families/#{self.operating_system_family_id}.json")
28
- elem = OperatingSystemFamily.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
36
+ elem = OperatingSystemFamily.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
29
37
  elem.id = obj["id"]
30
38
  elem.name = obj["name"]
31
39
  return elem
@@ -2,6 +2,12 @@ module UpGuard
2
2
  class OperatingSystemFamily < BaseObject
3
3
  attr_accessor :id
4
4
  attr_accessor :name
5
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
6
+ super(appliance_url, appliance_api_key, sec_key, insecure)
7
+ self.id = nil
8
+ self.name = nil
9
+ end
10
+
5
11
  def from_hash(h)
6
12
  self.id = h['id'] if h.include?('id')
7
13
  self.name = h['name'] if h.include?('name')
@@ -19,9 +25,9 @@ module UpGuard
19
25
 
20
26
  def operating_systems
21
27
  obj = http_get("/api/v2/operating_system_families/#{self.id}/operating_systems.json")
22
- the_list = OperatingSystemList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
28
+ the_list = OperatingSystemList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
23
29
  obj.each do |x|
24
- elem = OperatingSystem.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
30
+ elem = OperatingSystem.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
25
31
  elem.id = x["id"] if x.include?("id")
26
32
  elem.name = x["name"] if x.include?("name")
27
33
  the_list << elem
@@ -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 ["OperatingSystemFamily", "UpGuard::OperatingSystemFamily"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'OperatingSystemFamily' to 'OperatingSystemFamilyList'"
41
+ end
28
42
  end
29
43
 
30
44
 
@@ -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 ["OperatingSystem", "UpGuard::OperatingSystem"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'OperatingSystem' to 'OperatingSystemList'"
41
+ end
28
42
  end
29
43
 
30
44
 
@@ -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
@@ -2,14 +2,28 @@ module UpGuard
2
2
  class Policy < BaseObject
3
3
  attr_accessor :id
4
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
+
5
15
  def from_hash(h)
6
16
  self.id = h['id'] if h.include?('id')
7
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')
8
20
  end
9
21
  def to_hash
10
22
  h = {}
11
23
  h['id'] = self.id
12
24
  h['name'] = self.name
25
+ h['short_description'] = self.short_description
26
+ h['description'] = self.description
13
27
  return h
14
28
  end
15
29
  def to_json(options = nil)
@@ -48,6 +62,26 @@ module UpGuard
48
62
  http_delete("/api/v2/policies/#{self.id}.json")
49
63
  end
50
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
+
51
85
 
52
86
  end
53
87
  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 ["Policy", "UpGuard::Policy"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'Policy' to 'PolicyList'"
41
+ end
28
42
  end
29
43
 
30
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.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
+
9
19
  def from_hash(h)
10
20
  self.data = h['data'] if h.include?('data')
11
21
  self.id = h['id'] if h.include?('id')
@@ -60,7 +70,7 @@ module UpGuard
60
70
  http_delete("/api/v2/scheduled_jobs/#{self.id}.json")
61
71
  end
62
72
 
63
- def cancel_jobs()
73
+ def cancel_jobs
64
74
  url = "/api/v2/scheduled_jobs/#{self.id}/cancel_jobs.json"
65
75
  obj = http_post(url, nil)
66
76
  return obj
@@ -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 ["ScheduledJob", "UpGuard::ScheduledJob"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'ScheduledJob' to 'ScheduledJobList'"
41
+ end
28
42
  end
29
43
 
30
44
 
@@ -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')