upguard 0.0.4 → 0.0.6

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.
@@ -1,28 +1,43 @@
1
1
  module UpGuard
2
2
  class ConnectionManager < BaseObject
3
+ attr_accessor :channels
4
+ attr_accessor :connection_manager_group_id
5
+ attr_accessor :created_at
3
6
  attr_accessor :id
4
7
  attr_accessor :hostname
5
8
  attr_accessor :last_contact
9
+ attr_accessor :stats
10
+ attr_accessor :updated_at
6
11
  def from_hash(h)
12
+ self.channels = h['channels'] if h.include?('channels')
13
+ self.connection_manager_group_id = h['connection_manager_group_id'] if h.include?('connection_manager_group_id')
14
+ self.created_at = h['created_at'] if h.include?('created_at')
7
15
  self.id = h['id'] if h.include?('id')
8
16
  self.hostname = h['hostname'] if h.include?('hostname')
9
17
  self.last_contact = h['last_contact'] if h.include?('last_contact')
18
+ self.stats = h['stats'] if h.include?('stats')
19
+ self.updated_at = h['updated_at'] if h.include?('updated_at')
10
20
  end
11
21
  def to_hash
12
22
  h = {}
23
+ h['channels'] = self.channels
24
+ h['connection_manager_group_id'] = self.connection_manager_group_id
25
+ h['created_at'] = self.created_at
13
26
  h['id'] = self.id
14
27
  h['hostname'] = self.hostname
15
28
  h['last_contact'] = self.last_contact
29
+ h['stats'] = self.stats
30
+ h['updated_at'] = self.updated_at
16
31
  return h
17
32
  end
18
- def to_json
33
+ def to_json(options = nil)
19
34
  h = to_hash
20
- return h.to_json
35
+ return h.to_json(options)
21
36
  end
22
37
 
23
38
  def connection_manager_group
24
39
  obj = http_get("/api/v2/connection_manager_groups/{connection_manager_group_id}.json")
25
- elem = ConnectionManagerGroup.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
40
+ elem = ConnectionManagerGroup.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
26
41
  elem.id = obj["id"]
27
42
  elem.name = obj["name"]
28
43
  return elem
@@ -2,31 +2,53 @@ module UpGuard
2
2
  class ConnectionManagerGroup < BaseObject
3
3
  attr_accessor :id
4
4
  attr_accessor :name
5
+ attr_accessor :organisation_id
6
+ attr_accessor :status
5
7
  def from_hash(h)
6
8
  self.id = h['id'] if h.include?('id')
7
9
  self.name = h['name'] if h.include?('name')
10
+ self.organisation_id = h['organisation_id'] if h.include?('organisation_id')
11
+ self.status = h['status'] if h.include?('status')
8
12
  end
9
13
  def to_hash
10
14
  h = {}
11
15
  h['id'] = self.id
12
16
  h['name'] = self.name
17
+ h['organisation_id'] = self.organisation_id
18
+ h['status'] = self.status
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 connection_managers
21
27
  obj = http_get("todo")
22
- list = []
28
+ the_list = ConnectionManagerList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
23
29
  obj.each do |x|
24
- elem = ConnectionManager.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 = ConnectionManager.new(self.appliance_url, self.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
36
+ end
37
+
38
+
39
+ def save
40
+ if self.id.to_i == 0
41
+ return create
42
+ else
43
+ raise "Cannot update a ConnectionManagerGroup"
44
+ end
45
+ end
46
+
47
+
48
+ def create
49
+ h = to_hash
50
+ out = http_post("/api/v2/connection_manager_groups.json", h)
51
+ from_hash(out)
30
52
  end
31
53
 
32
54
 
@@ -0,0 +1,39 @@
1
+ module UpGuard
2
+ class ConnectionManagerGroupList < 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, api_key, sec_key, insecure)
14
+ super(appliance_url, api_key, sec_key, insecure)
15
+ @inner_list = []
16
+ end
17
+
18
+
19
+
20
+ def each(&block)
21
+ @inner_list.each(&block)
22
+ end
23
+
24
+
25
+
26
+ def <<(obj)
27
+ @inner_list << obj
28
+ end
29
+
30
+
31
+
32
+ def to_json
33
+ return @inner_list.to_json
34
+ end
35
+
36
+
37
+
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ module UpGuard
2
+ class ConnectionManagerList < 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, api_key, sec_key, insecure)
14
+ super(appliance_url, api_key, sec_key, insecure)
15
+ @inner_list = []
16
+ end
17
+
18
+
19
+
20
+ def each(&block)
21
+ @inner_list.each(&block)
22
+ end
23
+
24
+
25
+
26
+ def <<(obj)
27
+ @inner_list << obj
28
+ end
29
+
30
+
31
+
32
+ def to_json
33
+ return @inner_list.to_json
34
+ end
35
+
36
+
37
+
38
+ end
39
+ end
@@ -1,26 +1,44 @@
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
7
13
  def from_hash(h)
14
+ self.description = h['description'] if h.include?('description')
8
15
  self.id = h['id'] if h.include?('id')
9
16
  self.name = h['name'] if h.include?('name')
10
- self.organisation_id = h['organisation_id'] if h.include?('organisation_id')
17
+ self.node_rules = h['node_rules'] if h.include?('node_rules')
11
18
  self.short_description = h['short_description'] if h.include?('short_description')
19
+ self.updated_by = h['updated_by'] if h.include?('updated_by')
20
+ self.created_by = h['created_by'] if h.include?('created_by')
21
+ self.updated_at = h['updated_at'] if h.include?('updated_at')
22
+ self.created_at = h['created_at'] if h.include?('created_at')
23
+ self.weight = h['weight'] if h.include?('weight')
12
24
  end
13
25
  def to_hash
14
26
  h = {}
27
+ h['description'] = self.description
15
28
  h['id'] = self.id
16
29
  h['name'] = self.name
17
- h['organisation_id'] = self.organisation_id
30
+ h['node_rules'] = self.node_rules
18
31
  h['short_description'] = self.short_description
32
+ h['updated_by'] = self.updated_by
33
+ h['created_by'] = self.created_by
34
+ h['updated_at'] = self.updated_at
35
+ h['created_at'] = self.created_at
36
+ h['weight'] = self.weight
19
37
  return h
20
38
  end
21
- def to_json
39
+ def to_json(options = nil)
22
40
  h = to_hash
23
- return h.to_json
41
+ return h.to_json(options)
24
42
  end
25
43
 
26
44
  def load
@@ -49,6 +67,11 @@ module UpGuard
49
67
  h = to_hash
50
68
  h.delete("id")
51
69
  h.delete("organisation_id")
70
+ h.delete("updated_by")
71
+ h.delete("created_by")
72
+ h.delete("updated_at")
73
+ h.delete("created_at")
74
+ h.delete("weight")
52
75
  http_put("/api/v2/environments/#{self.id}.json", h)
53
76
  end
54
77
 
@@ -59,14 +82,14 @@ module UpGuard
59
82
 
60
83
  def nodes
61
84
  obj = http_get("/api/v2/environments/#{self.id}/nodes.json")
62
- list = []
85
+ the_list = NodeList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
63
86
  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
87
+ elem = Node.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
88
+ elem.id = x["id"] if x.include?("id")
89
+ elem.name = x["name"] if x.include?("name")
90
+ the_list << elem
68
91
  end
69
- return list
92
+ return the_list
70
93
  end
71
94
 
72
95
 
@@ -0,0 +1,39 @@
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, api_key, sec_key, insecure)
14
+ super(appliance_url, api_key, sec_key, insecure)
15
+ @inner_list = []
16
+ end
17
+
18
+
19
+
20
+ def each(&block)
21
+ @inner_list.each(&block)
22
+ end
23
+
24
+
25
+
26
+ def <<(obj)
27
+ @inner_list << obj
28
+ end
29
+
30
+
31
+
32
+ def to_json
33
+ return @inner_list.to_json
34
+ end
35
+
36
+
37
+
38
+ end
39
+ end
data/lib/upguard/Event.rb CHANGED
@@ -18,14 +18,14 @@ module UpGuard
18
18
  h['created_at'] = self.created_at
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 environment
27
27
  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)
28
+ elem = Environment.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
29
29
  elem.id = obj["id"]
30
30
  elem.name = obj["name"]
31
31
  elem.organisation_id = obj["organisation_id"]
@@ -4,11 +4,15 @@ 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
7
9
  def from_hash(h)
8
10
  self.id = h['id'] if h.include?('id')
9
11
  self.name = h['name'] if h.include?('name')
10
12
  self.status = h['status'] if h.include?('status')
11
13
  self.type = h['type'] if h.include?('type')
14
+ self.variables = h['variables'] if h.include?('variables')
15
+ self.view = h['view'] if h.include?('view')
12
16
  end
13
17
  def to_hash
14
18
  h = {}
@@ -16,11 +20,13 @@ module UpGuard
16
20
  h['name'] = self.name
17
21
  h['status'] = self.status
18
22
  h['type'] = self.type
23
+ h['variables'] = self.variables
24
+ h['view'] = self.view
19
25
  return h
20
26
  end
21
- def to_json
27
+ def to_json(options = nil)
22
28
  h = to_hash
23
- return h.to_json
29
+ return h.to_json(options)
24
30
  end
25
31
 
26
32
  end
@@ -0,0 +1,39 @@
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, api_key, sec_key, insecure)
14
+ super(appliance_url, api_key, sec_key, insecure)
15
+ @inner_list = []
16
+ end
17
+
18
+
19
+
20
+ def each(&block)
21
+ @inner_list.each(&block)
22
+ end
23
+
24
+
25
+
26
+ def <<(obj)
27
+ @inner_list << obj
28
+ end
29
+
30
+
31
+
32
+ def to_json
33
+ return @inner_list.to_json
34
+ end
35
+
36
+
37
+
38
+ end
39
+ end
@@ -24,9 +24,9 @@ module UpGuard
24
24
  h['url'] = self.url
25
25
  return h
26
26
  end
27
- def to_json
27
+ def to_json(options = nil)
28
28
  h = to_hash
29
- return h.to_json
29
+ return h.to_json(options)
30
30
  end
31
31
 
32
32
  end
@@ -0,0 +1,39 @@
1
+ module UpGuard
2
+ class IncidentList < 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, api_key, sec_key, insecure)
14
+ super(appliance_url, api_key, sec_key, insecure)
15
+ @inner_list = []
16
+ end
17
+
18
+
19
+
20
+ def each(&block)
21
+ @inner_list.each(&block)
22
+ end
23
+
24
+
25
+
26
+ def <<(obj)
27
+ @inner_list << obj
28
+ end
29
+
30
+
31
+
32
+ def to_json
33
+ return @inner_list.to_json
34
+ end
35
+
36
+
37
+
38
+ end
39
+ end
@@ -0,0 +1,33 @@
1
+ module UpGuard
2
+ class Job < BaseObject
3
+ attr_accessor :id
4
+ attr_accessor :organisation_id
5
+ attr_accessor :source_id
6
+ attr_accessor :source_name
7
+ attr_accessor :source_type
8
+ attr_accessor :status
9
+ def from_hash(h)
10
+ self.id = h['id'] if h.include?('id')
11
+ self.organisation_id = h['organisation_id'] if h.include?('organisation_id')
12
+ self.source_id = h['source_id'] if h.include?('source_id')
13
+ self.source_name = h['source_name'] if h.include?('source_name')
14
+ self.source_type = h['source_type'] if h.include?('source_type')
15
+ self.status = h['status'] if h.include?('status')
16
+ end
17
+ def to_hash
18
+ h = {}
19
+ h['id'] = self.id
20
+ h['organisation_id'] = self.organisation_id
21
+ h['source_id'] = self.source_id
22
+ h['source_name'] = self.source_name
23
+ h['source_type'] = self.source_type
24
+ h['status'] = self.status
25
+ return h
26
+ end
27
+ def to_json(options = nil)
28
+ h = to_hash
29
+ return h.to_json(options)
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,39 @@
1
+ module UpGuard
2
+ class JobList < 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, api_key, sec_key, insecure)
14
+ super(appliance_url, api_key, sec_key, insecure)
15
+ @inner_list = []
16
+ end
17
+
18
+
19
+
20
+ def each(&block)
21
+ @inner_list.each(&block)
22
+ end
23
+
24
+
25
+
26
+ def <<(obj)
27
+ @inner_list << obj
28
+ end
29
+
30
+
31
+
32
+ def to_json
33
+ return @inner_list.to_json
34
+ end
35
+
36
+
37
+
38
+ end
39
+ end
@@ -6,9 +6,9 @@ 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
13
  SSH = 3
14
14
 
data/lib/upguard/Node.rb CHANGED
@@ -1,47 +1,53 @@
1
1
  module UpGuard
2
2
  class Node < BaseObject
3
- attr_accessor :connection_manager_group_id
4
3
  attr_accessor :environment_id
5
4
  attr_accessor :external_id
6
- attr_accessor :hostname
7
5
  attr_accessor :id
8
- attr_accessor :medium_hostname
9
- attr_accessor :medium_type
6
+ attr_accessor :ip_address
7
+ attr_accessor :last_scan_status
8
+ attr_accessor :last_scan_status_string
9
+ attr_accessor :mac_address
10
10
  attr_accessor :name
11
11
  attr_accessor :node_type
12
+ attr_accessor :online
12
13
  attr_accessor :operating_system_family_id
13
14
  attr_accessor :operating_system_id
15
+ attr_accessor :short_description
14
16
  def from_hash(h)
15
- self.connection_manager_group_id = h['connection_manager_group_id'] if h.include?('connection_manager_group_id')
16
17
  self.environment_id = h['environment_id'] if h.include?('environment_id')
17
18
  self.external_id = h['external_id'] if h.include?('external_id')
18
- self.hostname = h['hostname'] if h.include?('hostname')
19
19
  self.id = h['id'] if h.include?('id')
20
- self.medium_hostname = h['medium_hostname'] if h.include?('medium_hostname')
21
- self.medium_type = h['medium_type'] if h.include?('medium_type')
20
+ self.ip_address = h['ip_address'] if h.include?('ip_address')
21
+ self.last_scan_status = h['last_scan_status'] if h.include?('last_scan_status')
22
+ self.last_scan_status_string = h['last_scan_status_string'] if h.include?('last_scan_status_string')
23
+ self.mac_address = h['mac_address'] if h.include?('mac_address')
22
24
  self.name = h['name'] if h.include?('name')
23
25
  self.node_type = h['node_type'] if h.include?('node_type')
26
+ self.online = h['online'] if h.include?('online')
24
27
  self.operating_system_family_id = h['operating_system_family_id'] if h.include?('operating_system_family_id')
25
28
  self.operating_system_id = h['operating_system_id'] if h.include?('operating_system_id')
29
+ self.short_description = h['short_description'] if h.include?('short_description')
26
30
  end
27
31
  def to_hash
28
32
  h = {}
29
- h['connection_manager_group_id'] = self.connection_manager_group_id
30
33
  h['environment_id'] = self.environment_id
31
34
  h['external_id'] = self.external_id
32
- h['hostname'] = self.hostname
33
35
  h['id'] = self.id
34
- h['medium_hostname'] = self.medium_hostname
35
- h['medium_type'] = self.medium_type
36
+ h['ip_address'] = self.ip_address
37
+ h['last_scan_status'] = self.last_scan_status
38
+ h['last_scan_status_string'] = self.last_scan_status_string
39
+ h['mac_address'] = self.mac_address
36
40
  h['name'] = self.name
37
41
  h['node_type'] = self.node_type
42
+ h['online'] = self.online
38
43
  h['operating_system_family_id'] = self.operating_system_family_id
39
44
  h['operating_system_id'] = self.operating_system_id
45
+ h['short_description'] = self.short_description
40
46
  return h
41
47
  end
42
- def to_json
48
+ def to_json(options = nil)
43
49
  h = to_hash
44
- return h.to_json
50
+ return h.to_json(options)
45
51
  end
46
52
 
47
53
  def load
@@ -79,7 +85,7 @@ module UpGuard
79
85
 
80
86
  def connection_manager_group
81
87
  obj = http_get("/api/v2/connection_manager_groups/{connection_manager_group_id}.json")
82
- elem = ConnectionManagerGroup.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
88
+ elem = ConnectionManagerGroup.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
83
89
  elem.id = obj["id"]
84
90
  elem.name = obj["name"]
85
91
  return elem
@@ -88,7 +94,7 @@ module UpGuard
88
94
 
89
95
  def environment
90
96
  obj = http_get("/api/v2/environments/#{self.environment_id}.json")
91
- elem = Environment.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
97
+ elem = Environment.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
92
98
  elem.id = obj["id"]
93
99
  elem.name = obj["name"]
94
100
  return elem
@@ -97,7 +103,7 @@ module UpGuard
97
103
 
98
104
  def operating_system
99
105
  obj = http_get("/api/v2/operating_systems/#{self.operating_system_id}.json")
100
- elem = OperatingSystem.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
106
+ elem = OperatingSystem.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
101
107
  elem.id = obj["id"]
102
108
  elem.name = obj["name"]
103
109
  return elem
@@ -106,7 +112,7 @@ module UpGuard
106
112
 
107
113
  def operating_system_family
108
114
  obj = http_get("/api/v2/operating_system_families/#{self.operating_system_family_id}.json")
109
- elem = OperatingSystemFamily.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
115
+ elem = OperatingSystemFamily.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
110
116
  elem.id = obj["id"]
111
117
  elem.name = obj["name"]
112
118
  return elem