Class: MMS::Resource::Cluster

Inherits:
MMS::Resource show all
Defined in:
lib/mms/resource/cluster.rb

Instance Attribute Summary collapse

Attributes inherited from MMS::Resource

#data, #id

Instance Method Summary collapse

Methods inherited from MMS::Resource

#from_hash, #load, #save

Constructor Details

#initialize(id, group_id, data = nil) ⇒ Cluster

Returns a new instance of Cluster.



12
13
14
15
16
# File 'lib/mms/resource/cluster.rb', line 12

def initialize(id, group_id, data = nil)
  @group = MMS::Resource::Group.new(group_id)

  super id, data
end

Instance Attribute Details

#group ⇒ Object

Returns the value of attribute group.



6
7
8
# File 'lib/mms/resource/cluster.rb', line 6

def group
  @group
end

#last_heartbeat ⇒ Object

Returns the value of attribute last_heartbeat.



10
11
12
# File 'lib/mms/resource/cluster.rb', line 10

def last_heartbeat
  @last_heartbeat
end

#name ⇒ Object

Returns the value of attribute name.



5
6
7
# File 'lib/mms/resource/cluster.rb', line 5

def name
  @name
end

#replicaset_name ⇒ Object

Returns the value of attribute replicaset_name.



8
9
10
# File 'lib/mms/resource/cluster.rb', line 8

def replicaset_name
  @replicaset_name
end

#shard_name ⇒ Object

Returns the value of attribute shard_name.



7
8
9
# File 'lib/mms/resource/cluster.rb', line 7

def shard_name
  @shard_name
end

#type_name ⇒ Object

Returns the value of attribute type_name.



9
10
11
# File 'lib/mms/resource/cluster.rb', line 9

def type_name
  @type_name
end

Instance Method Details

#_from_hash(data) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/mms/resource/cluster.rb', line 42

def _from_hash(data)
  @name = data['clusterName']
  @shard_name = data['shardName']
  @replicaset_name = data['replicaSetName']
  @type_name = data['typeName']
  @last_heartbeat = data['lastHeartbeat']
end

#_load(id) ⇒ Object



38
39
40
# File 'lib/mms/resource/cluster.rb', line 38

def _load(id)
  MMS::Client.instance.get '/groups/' + @group.id + '/clusters/' + id.to_s
end

#restorejobs(page = 1, limit = 1000) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/mms/resource/cluster.rb', line 30

def restorejobs(page = 1, limit = 1000)
  job_list = []
  MMS::Client.instance.get('/groups/' + @group.id + '/clusters/' + @id + '/restoreJobs?pageNum=' + page.to_s + '&itemsPerPage=' + limit.to_s).each do |job|
    job_list.push MMS::Resource::RestoreJob.new(job['id'], job['clusterId'], job['groupId'], job)
  end
  job_list
end

#snapshot(id) ⇒ Object



18
19
20
# File 'lib/mms/resource/cluster.rb', line 18

def snapshot(id)
  MMS::Resource::Snapshot.new id, self.id, self.group.id
end

#snapshots(page = 1, limit = 1000) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/mms/resource/cluster.rb', line 22

def snapshots(page = 1, limit = 1000)
  snapshot_list = []
  MMS::Client.instance.get('/groups/' + @group.id + '/clusters/' + @id + '/snapshots?pageNum=' + page.to_s + '&itemsPerPage=' + limit.to_s).each do |snapshot|
    snapshot_list.push MMS::Resource::Snapshot.new(snapshot['id'], snapshot['clusterId'], snapshot['groupId'], snapshot)
  end
  snapshot_list
end