Merge branch 'master' of git.curoverse.com:arvados into 11876-r-sdk
[arvados.git] / apps / workbench / app / models / arvados_resource_list.rb
index 27069706fb36e1f5f56b2853ff0b93216e9637ae..9ba61eaba08ef1d9e008233cf4f06e6c9f8ac97f 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 class ArvadosResourceList
   include ArvadosApiClientHelper
   include Enumerable
@@ -21,6 +25,16 @@ class ArvadosResourceList
     self
   end
 
+  def include_trash(option=nil)
+    @include_trash = option
+    self
+  end
+
+  def recursive(option=nil)
+    @recursive = option
+    self
+  end
+
   def limit(max_results)
     if not max_results.nil? and not max_results.is_a? Integer
       raise ArgumentError("argument to limit() must be an Integer or nil")
@@ -84,6 +98,13 @@ class ArvadosResourceList
     self
   end
 
+  # with_count sets the 'count' parameter to 'exact' or 'none' -- see
+  # https://doc.arvados.org/api/methods.html#index
+  def with_count(count_param='exact')
+    @count = count_param
+    self
+  end
+
   def fetch_multiple_pages(f)
     @fetch_multiple_pages = f
     self
@@ -178,12 +199,14 @@ class ArvadosResourceList
     api_params = {
       _method: 'GET'
     }
+    api_params[:count] = @count if @count
     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
     api_params[:distinct] = @distinct if @distinct
+    api_params[:include_trash] = @include_trash if @include_trash
     if @fetch_multiple_pages
       # Default limit to (effectively) api server's MAX_LIMIT
       api_params[:limit] = 2**(0.size*8 - 1) - 1