Class: AtlasRb::Admin::Collection

Inherits:
Object
  • Object
show all
Extended by:
FaradayHelper
Defined in:
lib/atlas_rb/admin/collection.rb

Overview

Destructive lifecycle operations on a Collection.

See AtlasRb::Admin for the rationale behind the namespace and the confirm: :i_understand friction marker.

Constant Summary collapse

ROUTE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Atlas REST endpoint prefix.

"/collections/"

Constants included from FaradayHelper

FaradayHelper::ASSERTION_AUDIENCE, FaradayHelper::ASSERTION_ISSUER, FaradayHelper::ASSERTION_TTL, FaradayHelper::INSTRUMENTATION_EVENT

Class Method Summary collapse

Methods included from FaradayHelper

connection, multipart, system_connection, with_file_part

Class Method Details

.destroy(id, confirm:, nuid: nil, on_behalf_of: nil) ⇒ Faraday::Response

Hard-delete a Collection — a purge, not a withdrawal.

Removes the Collection's metadata, its descriptive-metadata FileSet, and the OCFL objects holding the preserved bytes. Unrecoverable — prefer Collection.tombstone for user-visible withdrawal. Admin-only.

Atlas refuses with a 422 (has_children) while the Collection still holds a Work or a sub-container, including tombstoned ones. That is stricter than tombstone, which counts only live members: a member left behind by a purge is orphaned for good. Empty the tree leaf-first.

Examples:

AtlasRb::Admin::Collection.destroy("col-456", confirm: :i_understand)

Parameters:

  • id (String)

    the Collection ID.

  • confirm (Symbol)

    must be :i_understand. Any other value raises ArgumentError.

  • nuid (String, nil) (defaults to: nil)

    optional acting user's NUID.

  • on_behalf_of (String, nil) (defaults to: nil)

    optional On-Behalf-Of NUID.

Returns:

  • (Faraday::Response)

    the raw delete response.

Raises:

  • (ArgumentError)

    if confirm: is missing or not the sentinel value.



40
41
42
43
44
45
46
# File 'lib/atlas_rb/admin/collection.rb', line 40

def self.destroy(id, confirm:, nuid: nil, on_behalf_of: nil)
  unless confirm == :i_understand
    raise ArgumentError,
          "AtlasRb::Admin::Collection.destroy requires confirm: :i_understand"
  end
  connection({}, nuid, on_behalf_of: on_behalf_of).delete(ROUTE + id)
end

.restore(id, nuid: nil, on_behalf_of: nil) ⇒ Faraday::Response

Restore a previously-tombstoned Collection.

Examples:

AtlasRb::Admin::Collection.restore("col-456")

Parameters:

  • id (String)

    the Collection ID.

  • nuid (String, nil) (defaults to: nil)

    optional acting user's NUID.

  • on_behalf_of (String, nil) (defaults to: nil)

    optional On-Behalf-Of NUID.

Returns:

  • (Faraday::Response)

    the raw response.



57
58
59
# File 'lib/atlas_rb/admin/collection.rb', line 57

def self.restore(id, nuid: nil, on_behalf_of: nil)
  connection({}, nuid, on_behalf_of: on_behalf_of).post(ROUTE + id + '/restore')
end