Class: AtlasRb::Admin::Resource

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

Overview

Destructive lifecycle operations that need no type, against Atlas's generic /resources/{id} surface.

The typed Work, Collection and Community delegate here. See AtlasRb::Admin for why the namespace exists and what confirm: :i_understand is for — both apply unchanged, which is why purge did not move onto Resource beside the other generic writes.

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.

"/resources/"

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, read_body, read_raw, system_connection, with_file_part

Class Method Details

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

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

Removes the resource's metadata, cascades into its members, and removes the OCFL objects holding the preserved bytes: every retained revision, not only the current one. Nothing survives but the audit row, which records the NOIDs it removed.

Unrecoverable — prefer Resource.tombstone for the user-visible withdrawal path, which keeps everything and can be reversed. Admin-only.

Examples:

AtlasRb::Admin::Resource.destroy("xsj3xmz", confirm: :i_understand)

Parameters:

  • id (String)

    the resource's NOID.

  • confirm (Symbol)

    must be :i_understand.

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

    optional acting user's NUID.

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

    optional NUID for the On-Behalf-Of header.

Returns:

  • (Faraday::Response)

    the raw delete response.

Raises:

  • (ArgumentError)

    if confirm: is missing or not the sentinel value. Raised before any request goes out.



42
43
44
45
46
47
48
# File 'lib/atlas_rb/admin/resource.rb', line 42

def self.destroy(id, confirm:, nuid: nil, on_behalf_of: nil)
  unless confirm == :i_understand
    raise ArgumentError,
          "AtlasRb::Admin::Resource.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 resource.

Reverses a withdrawal: search and show pages stop returning a withdrawn stub. No confirm: marker — restoring is itself reversible, by tombstoning again.

Examples:

AtlasRb::Admin::Resource.restore("xsj3xmz")

Parameters:

  • id (String)

    the resource's NOID.

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

    optional acting user's NUID.

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

    optional NUID for the On-Behalf-Of header.

Returns:

  • (Faraday::Response)

    the raw response.



64
65
66
# File 'lib/atlas_rb/admin/resource.rb', line 64

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