class Dag::ClusterCollection

Public Class Methods

new(api) click to toggle source
Calls superclass method Dag::Model::new
# File lib/dag/client/model/cluster_collection.rb, line 6
def initialize(api)
  super(api)
end

Public Instance Methods

each() { |cluster| ... } click to toggle source
# File lib/dag/client/model/cluster_collection.rb, line 34
def each
  marker = nil
  truncated = false
  begin
    cluster_info_list = @api.cluster_info_list(make_options(marker))
    cluster_info_list['clusters'].each do |cluster_info|
      yield Dag::Cluster.new(@api, cluster_info)
    end
    truncated = cluster_info_list['isTruncated']
    marker = cluster_info_list['nextMarker']
  end while truncated
end
order(o) click to toggle source
# File lib/dag/client/model/cluster_collection.rb, line 23
def order(o)
  result = o.downcase.to_s
  unless ['asc', 'desc'].include?(result)
    raise Dag::Client::ParameterInvalid.new("Invalid order condition: #{o}")
  end

  @order = result

  self
end
where(params) click to toggle source

Parameters ==

status - 'init', 'stopped', restarting, 'norm', 'failed', 'ptfailed', 'error', 'released'

# File lib/dag/client/model/cluster_collection.rb, line 13
def where(params)
  validate_cluster_param_keys(params)

  @status = params[:status] if params[:status]
  @type = params[:type] if params[:type]
  @cluster_name = params[:cluster_name] if params[:cluster_name].present?

  self
end

Private Instance Methods

make_options(marker = nil) click to toggle source
# File lib/dag/client/model/cluster_collection.rb, line 49
def make_options(marker = nil)
  options = { max: 100 }
  if marker
    options = options.merge(marker: marker)
  end

  if @order
    options = options.merge(order: @order)
  end

  if @status
    status = @status.respond_to?(:join) ? @status.join(",") : @status
    options = options.merge(status: status)
  end

  if @type
    options = options.merge(type: @type)
  end

  if @cluster_name
    options = options.merge(cluster_name: @cluster_name)
  end

  options
end