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
@@ -1,26 +1,58 @@
1
1
  module UpGuard
2
2
  class Environment < BaseObject
3
+ attr_accessor :description
3
4
  attr_accessor :id
4
5
  attr_accessor :name
5
- attr_accessor :organisation_id
6
+ attr_accessor :node_rules
6
7
  attr_accessor :short_description
8
+ attr_accessor :updated_by
9
+ attr_accessor :created_by
10
+ attr_accessor :updated_at
11
+ attr_accessor :created_at
12
+ attr_accessor :weight
13
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
14
+ super(appliance_url, appliance_api_key, sec_key, insecure)
15
+ self.description = nil
16
+ self.id = nil
17
+ self.name = nil
18
+ self.node_rules = nil
19
+ self.short_description = nil
20
+ self.updated_by = nil
21
+ self.created_by = nil
22
+ self.updated_at = nil
23
+ self.created_at = nil
24
+ self.weight = nil
25
+ end
26
+
7
27
  def from_hash(h)
28
+ self.description = h['description'] if h.include?('description')
8
29
  self.id = h['id'] if h.include?('id')
9
30
  self.name = h['name'] if h.include?('name')
10
- self.organisation_id = h['organisation_id'] if h.include?('organisation_id')
31
+ self.node_rules = h['node_rules'] if h.include?('node_rules')
11
32
  self.short_description = h['short_description'] if h.include?('short_description')
33
+ self.updated_by = h['updated_by'] if h.include?('updated_by')
34
+ self.created_by = h['created_by'] if h.include?('created_by')
35
+ self.updated_at = h['updated_at'] if h.include?('updated_at')
36
+ self.created_at = h['created_at'] if h.include?('created_at')
37
+ self.weight = h['weight'] if h.include?('weight')
12
38
  end
13
39
  def to_hash
14
40
  h = {}
41
+ h['description'] = self.description
15
42
  h['id'] = self.id
16
43
  h['name'] = self.name
17
- h['organisation_id'] = self.organisation_id
44
+ h['node_rules'] = self.node_rules
18
45
  h['short_description'] = self.short_description
46
+ h['updated_by'] = self.updated_by
47
+ h['created_by'] = self.created_by
48
+ h['updated_at'] = self.updated_at
49
+ h['created_at'] = self.created_at
50
+ h['weight'] = self.weight
19
51
  return h
20
52
  end
21
- def to_json
53
+ def to_json(options = nil)
22
54
  h = to_hash
23
- return h.to_json
55
+ return h.to_json(options)
24
56
  end
25
57
 
26
58
  def load
@@ -49,6 +81,11 @@ module UpGuard
49
81
  h = to_hash
50
82
  h.delete("id")
51
83
  h.delete("organisation_id")
84
+ h.delete("updated_by")
85
+ h.delete("created_by")
86
+ h.delete("updated_at")
87
+ h.delete("created_at")
88
+ h.delete("weight")
52
89
  http_put("/api/v2/environments/#{self.id}.json", h)
53
90
  end
54
91
 
@@ -59,14 +96,14 @@ module UpGuard
59
96
 
60
97
  def nodes
61
98
  obj = http_get("/api/v2/environments/#{self.id}/nodes.json")
62
- list = []
99
+ the_list = NodeList.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
63
100
  obj.each do |x|
64
- elem = Node.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
65
- elem.id = x["id"]
66
- elem.name = x["name"]
67
- list << elem
101
+ elem = Node.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
102
+ elem.id = x["id"] if x.include?("id")
103
+ elem.name = x["name"] if x.include?("name")
104
+ the_list << elem
68
105
  end
69
- return list
106
+ return the_list
70
107
  end
71
108
 
72
109
 
@@ -0,0 +1,53 @@
1
+ module UpGuard
2
+ class EnvironmentList < 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 ["Environment", "UpGuard::Environment"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'Environment' to 'EnvironmentList'"
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
@@ -4,11 +4,22 @@ module UpGuard
4
4
  attr_accessor :type_id
5
5
  attr_accessor :environment_id
6
6
  attr_accessor :created_at
7
+ attr_accessor :variables
8
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
9
+ super(appliance_url, appliance_api_key, sec_key, insecure)
10
+ self.id = nil
11
+ self.type_id = nil
12
+ self.environment_id = nil
13
+ self.created_at = nil
14
+ self.variables = EventVariables.new(appliance_url, appliance_api_key, sec_key, insecure)
15
+ end
16
+
7
17
  def from_hash(h)
8
18
  self.id = h['id'] if h.include?('id')
9
19
  self.type_id = h['type_id'] if h.include?('type_id')
10
20
  self.environment_id = h['environment_id'] if h.include?('environment_id')
11
21
  self.created_at = h['created_at'] if h.include?('created_at')
22
+ self.variables = h['variables'] if h.include?('variables')
12
23
  end
13
24
  def to_hash
14
25
  h = {}
@@ -16,16 +27,17 @@ module UpGuard
16
27
  h['type_id'] = self.type_id
17
28
  h['environment_id'] = self.environment_id
18
29
  h['created_at'] = self.created_at
30
+ h['variables'] = self.variables
19
31
  return h
20
32
  end
21
- def to_json
33
+ def to_json(options = nil)
22
34
  h = to_hash
23
- return h.to_json
35
+ return h.to_json(options)
24
36
  end
25
37
 
26
38
  def environment
27
39
  obj = http_get("/api/v2/environments/#{self.environment_id}.json")
28
- elem = Environment.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
40
+ elem = Environment.new(self.appliance_url, self.appliance_api_key, self.sec_key, self.insecure)
29
41
  elem.id = obj["id"]
30
42
  elem.name = obj["name"]
31
43
  elem.organisation_id = obj["organisation_id"]
@@ -4,11 +4,25 @@ 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
9
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
10
+ super(appliance_url, appliance_api_key, sec_key, insecure)
11
+ self.id = nil
12
+ self.name = nil
13
+ self.status = nil
14
+ self.type = nil
15
+ self.variables = nil
16
+ self.view = nil
17
+ end
18
+
7
19
  def from_hash(h)
8
20
  self.id = h['id'] if h.include?('id')
9
21
  self.name = h['name'] if h.include?('name')
10
22
  self.status = h['status'] if h.include?('status')
11
23
  self.type = h['type'] if h.include?('type')
24
+ self.variables = h['variables'] if h.include?('variables')
25
+ self.view = h['view'] if h.include?('view')
12
26
  end
13
27
  def to_hash
14
28
  h = {}
@@ -16,11 +30,13 @@ module UpGuard
16
30
  h['name'] = self.name
17
31
  h['status'] = self.status
18
32
  h['type'] = self.type
33
+ h['variables'] = self.variables
34
+ h['view'] = self.view
19
35
  return h
20
36
  end
21
- def to_json
37
+ def to_json(options = nil)
22
38
  h = to_hash
23
- return h.to_json
39
+ return h.to_json(options)
24
40
  end
25
41
 
26
42
  end
@@ -0,0 +1,53 @@
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
+
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 ["EventAction", "UpGuard::EventAction"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'EventAction' to 'EventActionList'"
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 EventList < 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 ["Event", "UpGuard::Event"].include?(obj.class.name)
38
+ @inner_list << obj
39
+ else
40
+ raise "Can only append 'Event' to 'EventList'"
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,43 @@
1
+ module UpGuard
2
+ class EventVariables < 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
+ end
43
+ end
@@ -0,0 +1,36 @@
1
+ module UpGuard
2
+ class ExternalEvent < BaseObject
3
+ attr_accessor :type
4
+ attr_accessor :variables
5
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
6
+ super(appliance_url, appliance_api_key, sec_key, insecure)
7
+ self.type = nil
8
+ self.variables = EventVariables.new(appliance_url, appliance_api_key, sec_key, insecure)
9
+ end
10
+
11
+ def from_hash(h)
12
+ self.type = h['type'] if h.include?('type')
13
+ self.variables = h['variables'] if h.include?('variables')
14
+ end
15
+ def to_hash
16
+ h = {}
17
+ h['type'] = self.type
18
+ h['variables'] = self.variables
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 create
27
+ h = {}
28
+ h["variables"] = self.variables.to_hash
29
+ h["variables"]["type"] = self.type
30
+ http_post("/api/v2/events.json", h)
31
+ end
32
+
33
+
34
+
35
+ end
36
+ end
@@ -6,6 +6,16 @@ module UpGuard
6
6
  attr_accessor :short_description
7
7
  attr_accessor :started_at
8
8
  attr_accessor :url
9
+ def initialize(appliance_url, appliance_api_key, sec_key, insecure = false)
10
+ super(appliance_url, appliance_api_key, sec_key, insecure)
11
+ self.ended_at = nil
12
+ self.external_id = nil
13
+ self.id = nil
14
+ self.short_description = nil
15
+ self.started_at = nil
16
+ self.url = nil
17
+ end
18
+
9
19
  def from_hash(h)
10
20
  self.ended_at = h['ended_at'] if h.include?('ended_at')
11
21
  self.external_id = h['external_id'] if h.include?('external_id')
@@ -24,9 +34,9 @@ module UpGuard
24
34
  h['url'] = self.url
25
35
  return h
26
36
  end
27
- def to_json
37
+ def to_json(options = nil)
28
38
  h = to_hash
29
- return h.to_json
39
+ return h.to_json(options)
30
40
  end
31
41
 
32
42
  end