class MMS::Resource::Group

Attributes

active_agent_count[R]
clusters[RW]
last_active_agent[R]
name[R]
replicaset_count[R]
shard_count[R]

Public Class Methods

_find(client, id) click to toggle source
# File lib/mms/resource/group.rb, line 125
def self._find(client, id)
  client.get('/groups/' + id)
end
new() click to toggle source
# File lib/mms/resource/group.rb, line 11
def initialize
  @clusters = []
  @backup_configs = []
end
table_header() click to toggle source
# File lib/mms/resource/group.rb, line 121
def self.table_header
  ['Name', 'Active Agents', 'Replicas count', 'Shards count', 'Last Active Agent', 'GroupId']
end

Public Instance Methods

alert(id) click to toggle source

@param [String] id @return [MMS::Resource::Alert]

# File lib/mms/resource/group.rb, line 49
def alert(id)
  MMS::Resource::Alert.find(@client, @id, id)
end
alerts(page = 1, limit = 100, status = 'OPEN') click to toggle source

@param [Integer] page @param [Integer] limit @param [String] status @return [Array<MMS::Resource::Alert>]

# File lib/mms/resource/group.rb, line 35
def alerts(page = 1, limit = 100, status = 'OPEN')
  alert_list = []
  @client.get('/groups/' + @id + '/alerts?status=' + status + '&pageNum=' + page.to_s + '&itemsPerPage=' + limit.to_s).each do |alert|
    a = MMS::Resource::Alert.new
    a.client(@client)
    a.data(alert)

    alert_list.push a
  end
  alert_list
end
backup_configs() click to toggle source
# File lib/mms/resource/group.rb, line 75
def backup_configs
  if @backup_configs.empty?
    @client.get('/groups/' + @id + '/backupConfigs').each do |backup_config|
      bc = MMS::Resource::BackupConfig.new
      bc.client(@client)
      bc.data(backup_config)

      @backup_configs.push bc
    end
  end
  @backup_configs
end
cluster(id) click to toggle source

@param [String] id @return [MMS::Resource::Cluster]

# File lib/mms/resource/group.rb, line 71
def cluster(id)
  MMS::Resource::Cluster.find(@client, @id, id)
end
find_snapshot(id) click to toggle source

@param [String] id @return [MMS::Resource::Snapshot, NilClass]

# File lib/mms/resource/group.rb, line 90
def find_snapshot(id)
  snapshot = nil
  clusters.each do |cluster|
    begin
      snapshot = cluster.snapshot(id)
      break unless snapshot.nil?
    rescue MMS::ApiError => _e
      # Snapshot is not available on this cluster. Skip it!
    end
  end
  if snapshot.nil?
    hosts.each do |host|
      begin
        snapshot = host.snapshot(id)
        break unless snapshot.nil?
      rescue MMS::ApiError => _e
        # Snapshot is not available on this host. Skip it!
      end
    end
  end
  snapshot
end
hosts(page = 1, limit = 100) click to toggle source

@param [Integer] page @param [Integer] limit @return [Array<MMS::Resource::Host>]

# File lib/mms/resource/group.rb, line 19
def hosts(page = 1, limit = 100)
  host_list = []
  @client.get('/groups/' + @id + '/hosts?pageNum=' + page.to_s + '&itemsPerPage=' + limit.to_s).each do |host|
    h = MMS::Resource::Host.new
    h.client(@client)
    h.data(host)

    host_list.push h
  end
  host_list
end
table_row() click to toggle source
# File lib/mms/resource/group.rb, line 113
def table_row
  [@name, @active_agent_count, @replicaset_count, @shard_count, @last_active_agent, @id]
end
table_section() click to toggle source
# File lib/mms/resource/group.rb, line 117
def table_section
  [table_row]
end

Private Instance Methods

_from_hash(data) click to toggle source
# File lib/mms/resource/group.rb, line 131
def _from_hash(data)
  @name = data['name']
  @active_agent_count = data['activeAgentCount']
  @replicaset_count = data['replicaSetCount']
  @shard_count = data['shardCount']
  @last_active_agent = data['lastActiveAgent']
end
_to_hash() click to toggle source
# File lib/mms/resource/group.rb, line 139
def _to_hash
  @data
end