class Dag::JobCollection
Public Class Methods
new(api)
click to toggle source
Calls superclass method
Dag::Model::new
# File lib/dag/client/model/job_collection.rb, line 6 def initialize(api) super(api) end
Public Instance Methods
each() { |job| ... }
click to toggle source
# File lib/dag/client/model/job_collection.rb, line 48 def each if @limit count, i = 0, 0 total = @max ? @max.inject(:+) : @limit end marker = nil truncated = false begin @limit = @max[i] if @max job_info_list = @api.query_info_list(make_options(marker)) job_info_list['queries'].each do |job_info| yield Dag::Job.new(@api, job_info) end truncated = job_info_list['isTruncated'] marker = job_info_list['nextMarker'] if @limit i += 1 count += @limit break if total <= count end end while truncated end
limit(number = 100)
click to toggle source
# File lib/dag/client/model/job_collection.rb, line 33 def limit(number = 100) @limit = number.to_i max = 100 if number > max @max = [] (number / max).times { @max << max } if rem = (number % max) @max << rem if rem != 0 end end self end
order(o)
click to toggle source
# File lib/dag/client/model/job_collection.rb, line 22 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
# File lib/dag/client/model/job_collection.rb, line 10 def where(params = {}) validate_job_param_keys(params) @status = params[:status] if params[:status].present? @type = params[:type] if params[:type].present? @cluster_name = params[:cluster_name] if params[:cluster_name].present? @label = params[:label] if params[:label].present? @cluster_rebooted = params[:cluster_rebooted] self end
Private Instance Methods
make_options(marker = nil)
click to toggle source
# File lib/dag/client/model/job_collection.rb, line 75 def make_options(marker = nil) options = { max: 100 } if marker options = options.merge(marker: marker) end if @limit options = options.merge(max: @limit) 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 if @label options = options.merge(label_prefix: @label) end unless @cluster_rebooted.nil? options = options.merge(cluster_rebooted: @cluster_rebooted) end options end