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