mms-api 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0dbc10b527566cf58f1694c0525eb267dc9ffeab
4
- data.tar.gz: cf1f710e7a902c82971a3af85c414009f1ccc1a1
3
+ metadata.gz: b9f237818d6e0c66e6511c157bbd76e0339c0a76
4
+ data.tar.gz: 8dd890ae570320a80c0bd084ca81a2c5c5af5900
5
5
  SHA512:
6
- metadata.gz: ca588615fc6636d100578f39c567ddf1952caf4f7f3abd2eeae54a306304483ac72395e65c232cdafb729f0ffcd4bcbf0791e7eccd1c9c9e5d793566d0f53ee4
7
- data.tar.gz: d4c01011132846e6fa2f62bfdbf5b4943ce21b9ca01fa743087b808f5b449860eec72083259850dec289ea85e27e2acbeca28c07927fd599c07679f5a71df66e
6
+ metadata.gz: d4de5e93a356694501f7a7a6948e16243f967f84d50485cb58a425302425526b320d640baa604312c486e9d01e6e89644153d7855d74570c71b8fc6c3cbc1847
7
+ data.tar.gz: 2ff3507c8107f1811e440479d53259bda028a9150b3a135aa8d65c960cf861b6c97e1d0f21f1b6c8314978929d29497afcb4c279b007626cd78a20b837d88135
data/README.md CHANGED
@@ -20,7 +20,7 @@ Usage:
20
20
 
21
21
  Commands:
22
22
 
23
- groups | clusters | snapshots | restorejobs | restorejobs-create
23
+ groups | hosts | clusters | snapshots | restorejobs | restorejobs-create
24
24
 
25
25
  Options:
26
26
 
@@ -41,8 +41,10 @@ agent = MMS::Agent.new('username', 'apikey')
41
41
 
42
42
  # all available resources
43
43
  group_list = agent.groups
44
+ host_list = agent.hosts
44
45
  cluster_list = agent.clusters
45
46
  snapshot_list = agent.snapshots
47
+ job_list = agent.restorejobs
46
48
 
47
49
  # get first cluster from list
48
50
  cluster = cluster_list.first
data/bin/mms-api CHANGED
@@ -7,7 +7,7 @@ require 'optparse'
7
7
  require 'terminal-table'
8
8
  require 'pp'
9
9
 
10
- actions_available = ["groups", "clusters", "snapshots", "restorejobs", "restorejobs-create"]
10
+ actions_available = ["groups", "hosts", "clusters", "snapshots", "restorejobs", "restorejobs-create"]
11
11
 
12
12
  app_name = 'mms-api'
13
13
  app_dscr = "#{app_name} is a tool for accessing MMS API"
@@ -84,9 +84,14 @@ begin
84
84
  rows = []
85
85
  case action
86
86
  when 'groups'
87
- heading = ['Name', 'Active Agents', 'Replicas count', 'Shards count', 'Last Active Agent']
87
+ heading = ['Name', 'Active Agents', 'Replicas count', 'Shards count', 'Last Active Agent', 'GroupId']
88
88
  results.each do |group|
89
- rows << [group.name, group.active_agent_count, group.replicaset_count, group.shard_count, group.last_active_agent]
89
+ rows << [group.name, group.active_agent_count, group.replicaset_count, group.shard_count, group.last_active_agent, group.id]
90
+ end
91
+ when 'hosts'
92
+ heading = ['Group', 'Type', 'Hostname', 'IP', 'Port', 'Last ping', 'Alerts enabled', 'HostId']
93
+ results.each do |host|
94
+ rows << [host.group.name, host.type_name, host.name, host.ip_address, host.port, host.last_ping, host.alerts_enabled, host.id]
90
95
  end
91
96
  when 'clusters'
92
97
  heading = ['Group', 'Cluster', 'Shard name', 'Replica name', 'Type', 'Last heartbeat']
data/lib/mms/agent.rb CHANGED
@@ -14,6 +14,14 @@ module MMS
14
14
  group_list
15
15
  end
16
16
 
17
+ def hosts
18
+ host_list = []
19
+ groups.each do |group|
20
+ host_list.concat group.hosts
21
+ end
22
+ host_list
23
+ end
24
+
17
25
  def clusters
18
26
  cluster_list = []
19
27
  groups.each do |group|
@@ -12,6 +12,14 @@ module MMS
12
12
  super id, data
13
13
  end
14
14
 
15
+ def hosts(page = 1, limit = 1000)
16
+ host_list = []
17
+ MMS::Client.instance.get('/groups/' + @id + '/hosts?pageNum=' + page.to_s + '&itemsPerPage=' + limit.to_s).each do |host|
18
+ host_list.push MMS::Resource::Host.new(host['id'], host['groupId'], host)
19
+ end
20
+ host_list
21
+ end
22
+
15
23
  def clusters(page = 1, limit = 1000)
16
24
  cluster_list = []
17
25
  MMS::Client.instance.get('/groups/' + @id + '/clusters?pageNum=' + page.to_s + '&itemsPerPage=' + limit.to_s).each do |cluster|
@@ -0,0 +1,42 @@
1
+ module MMS
2
+
3
+ class Resource::Host < Resource
4
+
5
+ attr_accessor :name
6
+ attr_accessor :group
7
+ attr_accessor :hostname
8
+ attr_accessor :port
9
+ attr_accessor :type_name
10
+ attr_accessor :last_ping
11
+ attr_accessor :ip_address
12
+ attr_accessor :version
13
+ attr_accessor :shard_name
14
+ attr_accessor :replicaset_name
15
+ attr_accessor :replica_state_name
16
+ attr_accessor :alerts_enabled
17
+
18
+ def initialize(id, group_id, data = nil)
19
+ @group = MMS::Resource::Group.new(group_id)
20
+
21
+ super id, data
22
+ end
23
+
24
+ def _load(id)
25
+ MMS::Client.instance.get '/groups/' + @group.id + '/hosts/' + id.to_s
26
+ end
27
+
28
+ def _from_hash(data)
29
+ @hostname = data['hostname']
30
+ @port = data['port']
31
+ @type_name = data['typeName']
32
+ @last_ping = data['lastPing']
33
+ @ip_address = data['ipAddress']
34
+ @version = data['version']
35
+ @shard_name = data['shardName']
36
+ @replicaset_name = data['replicaSetName']
37
+ @replica_state_name = data['replicaStateName']
38
+ @alerts_enabled = data['alertsEnabled']
39
+ @name = @hostname
40
+ end
41
+ end
42
+ end
data/lib/mms/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module MMS
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
data/lib/mms.rb CHANGED
@@ -8,6 +8,7 @@ module MMS
8
8
  require 'mms/resource'
9
9
 
10
10
  require 'mms/resource/group'
11
+ require 'mms/resource/host'
11
12
  require 'mms/resource/cluster'
12
13
  require 'mms/resource/snapshot'
13
14
  require 'mms/resource/restore_job'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mms-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cargo Media
@@ -85,6 +85,7 @@ files:
85
85
  - lib/mms/resource.rb
86
86
  - lib/mms/resource/cluster.rb
87
87
  - lib/mms/resource/group.rb
88
+ - lib/mms/resource/host.rb
88
89
  - lib/mms/resource/restore_job.rb
89
90
  - lib/mms/resource/snapshot.rb
90
91
  - lib/mms/version.rb