Module: Dag::Client::API::ListParams

Included in:
Cluster, Database, Job
Defined in:
lib/dag/client/api/list_params.rb

Instance Method Summary collapse

Instance Method Details

#list_params(options) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dag/client/api/list_params.rb', line 4

def list_params(options)
  params = {}

  max = options[:max]

  if max.present?
    unless max.kind_of?(Integer)
      raise Dag::Client::ParameterInvalid.new("max should be integer")
    end

    if max < 1
      raise Dag::Client::ParameterInvalid.new("max should be greater than 0:#{max}")
    end

    if max > 100
      raise Dag::Client::ParameterInvalid.new("max should be less than 100 or equal to 100:#{max}")
    end

    params.merge!('max' => max)
  end

  marker = options[:marker]


  if marker.present?
    params.merge!('marker' => marker)
  end

  params
end