11789: Merge branch 'master' into 11789-arvput-exclude-flag
[arvados.git] / services / api / app / controllers / arvados / v1 / collections_controller.rb
index e3c10b78eee427ec093db7483d9e64a47c8212b8..87d88fe4f584092e06315ad9eb9f93f0593b850c 100644 (file)
@@ -1,8 +1,22 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 require "arvados/keep"
 
 class Arvados::V1::CollectionsController < ApplicationController
   include DbCurrentTime
 
+  def self._index_requires_parameters
+    (super rescue {}).
+      merge({
+        include_trash: {
+          type: 'boolean', required: false, description: "Include collections whose is_trashed attribute is true."
+        },
+      })
+  end
+
+
   def create
     if resource_attrs[:uuid] and (loc = Keep::Locator.parse(resource_attrs[:uuid]))
       resource_attrs[:portable_data_hash] = loc.to_s
@@ -65,7 +79,13 @@ class Arvados::V1::CollectionsController < ApplicationController
 
   def untrash
     if @object.is_trashed
-      @object.update_attributes!(trash_at: nil)
+      @object.trash_at = nil
+
+      if params[:ensure_unique_name]
+        @object.save_with_unique_name!
+      else
+        @object.save!
+      end
     else
       raise InvalidStateTransitionError
     end