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/"

Class Method Summary collapse

Methods included from FaradayHelper

connection, multipart, system_connection

Class Method Details

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

Hard-delete a Collection.

Unrecoverable — prefer Collection.tombstone for user-visible withdrawal. Operator-only.

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.



32
33
34
35
36
37
38
# File 'lib/atlas_rb/admin/collection.rb', line 32

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.



49
50
51
# File 'lib/atlas_rb/admin/collection.rb', line 49

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