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,20 +1,29 @@
1
1
  module UpGuard
2
2
  class NodeGroup < BaseObject
3
+ attr_accessor :description
3
4
  attr_accessor :id
4
5
  attr_accessor :name
6
+ attr_accessor :node_rules
7
+ attr_accessor :search_query
5
8
  def from_hash(h)
9
+ self.description = h['description'] if h.include?('description')
6
10
  self.id = h['id'] if h.include?('id')
7
11
  self.name = h['name'] if h.include?('name')
12
+ self.node_rules = h['node_rules'] if h.include?('node_rules')
13
+ self.search_query = h['search_query'] if h.include?('search_query')
8
14
  end
9
15
  def to_hash
10
16
  h = {}
17
+ h['description'] = self.description
11
18
  h['id'] = self.id
12
19
  h['name'] = self.name
20
+ h['node_rules'] = self.node_rules
21
+ h['search_query'] = self.search_query
13
22
  return h
14
23
  end
15
- def to_json
24
+ def to_json(options = nil)
16
25
  h = to_hash
17
- return h.to_json
26
+ return h.to_json(options)
18
27
  end
19
28
 
20
29
  def load
@@ -51,14 +60,14 @@ module UpGuard
51
60
 
52
61
  def nodes
53
62
  obj = http_get("/api/v2/node_groups/#{self.id}/nodes.json")
54
- list = []
63
+ the_list = NodeList.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
55
64
  obj.each do |x|
56
- elem = Node.new(self.appliance_hostname, self.api_key, self.sec_key, self.insecure)
57
- elem.id = x["id"]
58
- elem.name = x["name"]
59
- list << elem
65
+ elem = Node.new(self.appliance_url, self.api_key, self.sec_key, self.insecure)
66
+ elem.id = x["id"] if x.include?("id")
67
+ elem.name = x["name"] if x.include?("name")
68
+ the_list << elem
60
69
  end
61
- return list
70
+ return the_list
62
71
  end
63
72
 
64
73
 
@@ -0,0 +1,39 @@
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, 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 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, 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
  SERVER = "SV"
14
14
 
@@ -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.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.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.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,39 @@
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, 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 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, 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,53 @@
1
+ module UpGuard
2
+ class Policy < BaseObject
3
+ attr_accessor :id
4
+ attr_accessor :name
5
+ def from_hash(h)
6
+ self.id = h['id'] if h.include?('id')
7
+ self.name = h['name'] if h.include?('name')
8
+ end
9
+ def to_hash
10
+ h = {}
11
+ h['id'] = self.id
12
+ h['name'] = self.name
13
+ return h
14
+ end
15
+ def to_json(options = nil)
16
+ h = to_hash
17
+ return h.to_json(options)
18
+ end
19
+
20
+ def load
21
+ obj = http_get("/api/v2/policies/#{self.id}.json")
22
+ from_hash(obj)
23
+ end
24
+
25
+
26
+ def save
27
+ if self.id.to_i == 0
28
+ return create
29
+ else
30
+ return update
31
+ end
32
+ end
33
+
34
+
35
+ def create
36
+ h = to_hash
37
+ out = http_post("/api/v2/policies.json", h)
38
+ from_hash(out)
39
+ end
40
+
41
+
42
+ def update
43
+ h = to_hash
44
+ http_put("/api/v2/policies/#{self.id}.json", h)
45
+ end
46
+
47
+ def delete
48
+ http_delete("/api/v2/policies/#{self.id}.json")
49
+ end
50
+
51
+
52
+ end
53
+ end
@@ -0,0 +1,39 @@
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, 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,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,39 @@
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, 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
@@ -15,9 +15,9 @@ module UpGuard
15
15
  h['timestamp'] = self.timestamp
16
16
  return h
17
17
  end
18
- def to_json
18
+ def to_json(options = nil)
19
19
  h = to_hash
20
- return h.to_json
20
+ return h.to_json(options)
21
21
  end
22
22
 
23
23
  end
@@ -0,0 +1,39 @@
1
+ module UpGuard
2
+ class SystemMetricList < 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/User.rb CHANGED
@@ -30,9 +30,9 @@ module UpGuard
30
30
  h['expiry'] = self.expiry
31
31
  return h
32
32
  end
33
- def to_json
33
+ def to_json(options = nil)
34
34
  h = to_hash
35
- return h.to_json
35
+ return h.to_json(options)
36
36
  end
37
37
  def update_role(role)
38
38
  url = "/api/v2/users/update_role.json?role=#{role}"
@@ -0,0 +1,39 @@
1
+ module UpGuard
2
+ class UserList < 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.rb CHANGED
@@ -1,17 +1,33 @@
1
1
  require_relative 'upguard/BaseObject'
2
2
  require_relative 'upguard/Account'
3
3
  require_relative 'upguard/ConnectionManager'
4
+ require_relative 'upguard/ConnectionManagerList'
4
5
  require_relative 'upguard/ConnectionManagerGroup'
6
+ require_relative 'upguard/ConnectionManagerGroupList'
5
7
  require_relative 'upguard/Environment'
8
+ require_relative 'upguard/EnvironmentList'
6
9
  require_relative 'upguard/Event'
7
10
  require_relative 'upguard/EventAction'
11
+ require_relative 'upguard/EventActionList'
8
12
  require_relative 'upguard/Incident'
13
+ require_relative 'upguard/IncidentList'
14
+ require_relative 'upguard/Job'
15
+ require_relative 'upguard/JobList'
9
16
  require_relative 'upguard/MediumType'
10
17
  require_relative 'upguard/Node'
18
+ require_relative 'upguard/NodeList'
11
19
  require_relative 'upguard/NodeGroup'
20
+ require_relative 'upguard/NodeGroupList'
12
21
  require_relative 'upguard/NodeType'
13
22
  require_relative 'upguard/OperatingSystem'
23
+ require_relative 'upguard/OperatingSystemList'
14
24
  require_relative 'upguard/OperatingSystemFamily'
25
+ require_relative 'upguard/OperatingSystemFamilyList'
26
+ require_relative 'upguard/Policy'
27
+ require_relative 'upguard/PolicyList'
15
28
  require_relative 'upguard/ScheduledJob'
29
+ require_relative 'upguard/ScheduledJobList'
16
30
  require_relative 'upguard/SystemMetric'
31
+ require_relative 'upguard/SystemMetricList'
17
32
  require_relative 'upguard/User'
33
+ require_relative 'upguard/UserList'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: upguard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - UpGuard Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-21 00:00:00.000000000 Z
11
+ date: 2019-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -50,20 +50,36 @@ files:
50
50
  - lib/upguard/BaseObject.rb
51
51
  - lib/upguard/ConnectionManager.rb
52
52
  - lib/upguard/ConnectionManagerGroup.rb
53
+ - lib/upguard/ConnectionManagerGroupList.rb
54
+ - lib/upguard/ConnectionManagerList.rb
53
55
  - lib/upguard/Environment.rb
56
+ - lib/upguard/EnvironmentList.rb
54
57
  - lib/upguard/Event.rb
55
58
  - lib/upguard/EventAction.rb
59
+ - lib/upguard/EventActionList.rb
56
60
  - lib/upguard/Incident.rb
61
+ - lib/upguard/IncidentList.rb
62
+ - lib/upguard/Job.rb
63
+ - lib/upguard/JobList.rb
57
64
  - lib/upguard/MediumType.rb
58
65
  - lib/upguard/Node.rb
59
66
  - lib/upguard/NodeGroup.rb
67
+ - lib/upguard/NodeGroupList.rb
68
+ - lib/upguard/NodeList.rb
60
69
  - lib/upguard/NodeType.rb
61
70
  - lib/upguard/OperatingSystem.rb
62
71
  - lib/upguard/OperatingSystemFamily.rb
72
+ - lib/upguard/OperatingSystemFamilyList.rb
73
+ - lib/upguard/OperatingSystemList.rb
74
+ - lib/upguard/Policy.rb
75
+ - lib/upguard/PolicyList.rb
63
76
  - lib/upguard/ScheduledJob.rb
77
+ - lib/upguard/ScheduledJobList.rb
64
78
  - lib/upguard/SystemMetric.rb
79
+ - lib/upguard/SystemMetricList.rb
65
80
  - lib/upguard/User.rb
66
- homepage:
81
+ - lib/upguard/UserList.rb
82
+ homepage: https://www.upguard.com
67
83
  licenses: []
68
84
  metadata: {}
69
85
  post_install_message:
@@ -85,5 +101,5 @@ rubyforge_project:
85
101
  rubygems_version: 2.6.14
86
102
  signing_key:
87
103
  specification_version: 4
88
- summary: UpGuard SDK for Ruby
104
+ summary: UpGuard Core SDK for Ruby
89
105
  test_files: []