- # Return links provided with API response that point to the
- # specified object, and have the specified link_class. If link_class
- # is false or omitted, return all links pointing to the specified
- # object.
- def links_for item_or_uuid, link_class=false
- return [] if !result_links
- unless @links_for_uuid
- @links_for_uuid = {}
- result_links.each do |link|
- if link.respond_to? :head_uuid
- @links_for_uuid[link.head_uuid] ||= []
- @links_for_uuid[link.head_uuid] << link
- end
+ protected
+
+ def each_page
+ api_params = {
+ _method: 'GET'
+ }
+ api_params[:where] = @cond if @cond
+ api_params[:eager] = '1' if @eager
+ api_params[:select] = @select if @select
+ api_params[:order] = @orderby_spec if @orderby_spec
+ api_params[:filters] = @filters if @filters
+
+
+ item_count = 0
+ offset = @offset || 0
+ @result_limit = nil
+ @result_offset = nil
+
+ begin
+ api_params[:offset] = offset
+ api_params[:limit] = (@limit - item_count) if @limit
+
+ res = arvados_api_client.api(@resource_class, '', api_params,
+ arvados_api_token: @arvados_api_token,
+ reader_tokens: @reader_tokens)
+ items = arvados_api_client.unpack_api_response res
+
+ @items_available = items.items_available if items.respond_to?(:items_available)
+ @result_limit = items.limit if (@fetch_multiple_pages == false) and items.respond_to?(:limit)
+ @result_offset = items.offset if (@fetch_multiple_pages == false) and items.respond_to?(:offset)
+
+ break if items.nil? or not items.any?
+
+ item_count += items.size
+ if items.respond_to?(:offset)
+ offset = items.offset + items.size
+ else
+ offset = item_count