X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/ba300c9e82f9fd2f853a7bfb4e0df58685071d0c..0eb72b526bf8bbb011551ecf019f604e17a534f1:/services/api/app/controllers/arvados/v1/collections_controller.rb?ds=sidebyside diff --git a/services/api/app/controllers/arvados/v1/collections_controller.rb b/services/api/app/controllers/arvados/v1/collections_controller.rb index 2beb1e714d..87d88fe4f5 100644 --- a/services/api/app/controllers/arvados/v1/collections_controller.rb +++ b/services/api/app/controllers/arvados/v1/collections_controller.rb @@ -1,12 +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.limit_index_columns_read - ["manifest_text"] + 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 @@ -16,7 +26,7 @@ class Arvados::V1::CollectionsController < ApplicationController end def find_objects_for_index - if params[:include_trash] || ['destroy', 'trash'].include?(action_name) + if params[:include_trash] || ['destroy', 'trash', 'untrash'].include?(action_name) @objects = Collection.unscoped.readable_by(*@read_users) end super @@ -67,6 +77,21 @@ class Arvados::V1::CollectionsController < ApplicationController show end + def untrash + if @object.is_trashed + @object.trash_at = nil + + if params[:ensure_unique_name] + @object.save_with_unique_name! + else + @object.save! + end + else + raise InvalidStateTransitionError + end + show + end + def find_collections(visited, sp, &b) case sp when ArvadosModel