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.
Files changed (47) hide show
  1. checksums.yaml +5 -5
  2. data/lib/upguard.rb +27 -0
  3. data/lib/upguard/Account.rb +404 -129
  4. data/lib/upguard/BaseObject.rb +23 -22
  5. data/lib/upguard/ChangeRequest.rb +55 -0
  6. data/lib/upguard/ChangeRequestList.rb +53 -0
  7. data/lib/upguard/ConnectionManager.rb +42 -3
  8. data/lib/upguard/ConnectionManagerGroup.rb +41 -9
  9. data/lib/upguard/ConnectionManagerGroupList.rb +53 -0
  10. data/lib/upguard/ConnectionManagerList.rb +53 -0
  11. data/lib/upguard/Environment.rb +48 -11
  12. data/lib/upguard/EnvironmentList.rb +53 -0
  13. data/lib/upguard/Event.rb +15 -3
  14. data/lib/upguard/EventAction.rb +18 -2
  15. data/lib/upguard/EventActionList.rb +53 -0
  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 +12 -2
  20. data/lib/upguard/IncidentList.rb +53 -0
  21. data/lib/upguard/Job.rb +70 -0
  22. data/lib/upguard/JobList.rb +53 -0
  23. data/lib/upguard/MediumType.rb +5 -2
  24. data/lib/upguard/Node.rb +86 -9
  25. data/lib/upguard/NodeGroup.rb +97 -8
  26. data/lib/upguard/NodeGroupList.rb +64 -0
  27. data/lib/upguard/NodeGroupUser.rb +27 -0
  28. data/lib/upguard/NodeGroupUserList.rb +64 -0
  29. data/lib/upguard/NodeList.rb +53 -0
  30. data/lib/upguard/NodeMediumInfo.rb +49 -0
  31. data/lib/upguard/NodeType.rb +12 -2
  32. data/lib/upguard/OperatingSystem.rb +11 -3
  33. data/lib/upguard/OperatingSystemFamily.rb +14 -8
  34. data/lib/upguard/OperatingSystemFamilyList.rb +53 -0
  35. data/lib/upguard/OperatingSystemList.rb +53 -0
  36. data/lib/upguard/Pluggable.rb +81 -0
  37. data/lib/upguard/PluggableList.rb +53 -0
  38. data/lib/upguard/Policy.rb +87 -0
  39. data/lib/upguard/PolicyList.rb +53 -0
  40. data/lib/upguard/ScheduledJob.rb +16 -3
  41. data/lib/upguard/ScheduledJobList.rb +53 -0
  42. data/lib/upguard/SystemMetric.rb +9 -2
  43. data/lib/upguard/SystemMetricList.rb +53 -0
  44. data/lib/upguard/User.rb +39 -2
  45. data/lib/upguard/UserList.rb +75 -0
  46. data/lib/upguard/Version.rb +21 -0
  47. metadata +37 -10
@@ -0,0 +1,64 @@
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 ["NodeGroup", "UpGuard::NodeGroup"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'NodeGroup' to 'NodeGroupList'"
41
+ end
42
+ end
43
+
44
+
45
+
46
+ def to_json
47
+ return @inner_list.to_json
48
+ end
49
+
50
+
51
+
52
+ def find_by_id(id)
53
+ @inner_list.each do |x|
54
+ if x.id.to_s == id.to_s
55
+ return x
56
+ end
57
+ end
58
+ return nil
59
+ end
60
+
61
+
62
+
63
+ end
64
+ end
@@ -0,0 +1,27 @@
1
+ module UpGuard
2
+ class NodeGroupUser < BaseObject
3
+ attr_accessor :email
4
+ attr_accessor :user_id
5
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
6
+ super(appliance_url, appliance_api_key, sec_key, insecure)
7
+ self.email = nil
8
+ self.user_id = nil
9
+ end
10
+
11
+ def from_hash(h)
12
+ self.email = h['email'] if h.include?('email')
13
+ self.user_id = h['user_id'] if h.include?('user_id')
14
+ end
15
+ def to_hash
16
+ h = {}
17
+ h['email'] = self.email
18
+ h['user_id'] = self.user_id
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
+ end
27
+ end
@@ -0,0 +1,64 @@
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 ["NodeGroupUser", "UpGuard::NodeGroupUser"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'NodeGroupUser' to 'NodeGroupUserList'"
41
+ end
42
+ end
43
+
44
+
45
+
46
+ def to_json
47
+ return @inner_list.to_json
48
+ end
49
+
50
+
51
+
52
+ def find_by_email(email)
53
+ @inner_list.each do |x|
54
+ if x.email == email
55
+ return x
56
+ end
57
+ end
58
+ return nil
59
+ end
60
+
61
+
62
+
63
+ end
64
+ end
@@ -0,0 +1,53 @@
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 ["Node", "UpGuard::Node"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'Node' to 'NodeList'"
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,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(options = nil)
31
+ return @inner_map.to_json(options)
32
+ end
33
+
34
+
35
+
36
+ def to_hash
37
+ return @inner_map
38
+ end
39
+
40
+
41
+
42
+ def from_hash(h)
43
+ @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
@@ -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')
@@ -18,14 +26,14 @@ module UpGuard
18
26
  h['operating_system_family_id'] = self.operating_system_family_id
19
27
  return h
20
28
  end
21
- def to_json
29
+ def to_json(options = nil)
22
30
  h = to_hash
23
- return h.to_json
31
+ return h.to_json(options)
24
32
  end
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_hostname, 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')
@@ -12,21 +18,21 @@ module UpGuard
12
18
  h['name'] = self.name
13
19
  return h
14
20
  end
15
- def to_json
21
+ def to_json(options = nil)
16
22
  h = to_hash
17
- return h.to_json
23
+ return h.to_json(options)
18
24
  end
19
25
 
20
26
  def operating_systems
21
27
  obj = http_get("/api/v2/operating_system_families/#{self.id}/operating_systems.json")
22
- list = []
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_hostname, self.api_key, self.sec_key, self.insecure)
25
- elem.id = x["id"]
26
- elem.name = x["name"]
27
- list << elem
30
+ elem = OperatingSystem.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
31
+ elem.id = x["id"] if x.include?("id")
32
+ elem.name = x["name"] if x.include?("name")
33
+ the_list << elem
28
34
  end
29
- return list
35
+ return the_list
30
36
  end
31
37
 
32
38
 
@@ -0,0 +1,53 @@
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 ["OperatingSystemFamily", "UpGuard::OperatingSystemFamily"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'OperatingSystemFamily' to 'OperatingSystemFamilyList'"
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,53 @@
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 ["OperatingSystem", "UpGuard::OperatingSystem"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'OperatingSystem' to 'OperatingSystemList'"
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