1 class ArvadosResourceList
4 def initialize(resource_class)
5 @resource_class = resource_class
13 def limit(max_results)
23 def order(orderby_spec)
24 @orderby_spec = orderby_spec
30 cond.keys.each do |uuid_key|
31 if cond[uuid_key] and (cond[uuid_key].is_a? Array or
32 cond[uuid_key].is_a? ArvadosBase)
33 # Coerce cond[uuid_key] to an array of uuid strings. This
34 # allows caller the convenience of passing an array of real
35 # objects and uuids in cond[uuid_key].
36 if !cond[uuid_key].is_a? Array
37 cond[uuid_key] = [cond[uuid_key]]
39 cond[uuid_key] = cond[uuid_key].collect do |item|
40 if item.is_a? ArvadosBase
48 cond.keys.select { |x| x.match /_kind$/ }.each do |kind_key|
49 if cond[kind_key].is_a? Class
50 cond = cond.merge({ kind_key => 'arvados#' + $arvados_api_client.class_kind(cond[kind_key]) })
57 api_params[:eager] = '1' if @eager
58 api_params[:limit] = @limit if @limit
59 api_params[:offset] = @offset if @offset
60 api_params[:order] = @orderby_spec if @orderby_spec
61 res = $arvados_api_client.api @resource_class, '', api_params
62 @results = $arvados_api_client.unpack_api_response res
67 self.where({}) if !@results
91 results.send('[]', *x)
107 Hash[results.collect { |x| [x.uuid, x] }]
115 results.items_available if results.respond_to? :items_available
119 results.limit if results.respond_to? :limit
123 results.offset if results.respond_to? :offset