Class: AtlasRb::Admin::Work

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

Overview

Destructive lifecycle operations on a Work.

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.

"/works/"

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 Work.

Removes the Work, its FileSets, and their Blobs from Atlas storage. Unrecoverable — prefer Work.tombstone for the user-visible withdrawal path. This is operator-only.

Examples:

AtlasRb::Admin::Work.destroy("w-789", confirm: :i_understand)

Parameters:

  • id (String)

    the Work ID.

  • confirm (Symbol)

    must be :i_understand. Any other value (including the kwarg being omitted) raises ArgumentError.

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

    optional acting user's NUID. Falls through to AtlasRb.config.default_nuid when omitted.

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

    optional NUID for the On-Behalf-Of header. Falls through to AtlasRb.config.default_on_behalf_of when omitted.

Returns:

  • (Faraday::Response)

    the raw delete response.

Raises:

  • (ArgumentError)

    if confirm: is missing or not the sentinel value.



36
37
38
39
40
41
42
# File 'lib/atlas_rb/admin/work.rb', line 36

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

Reverses a withdrawal: search and show pages stop returning a withdrawn stub. Operator-only; typically driven from a Rails console or a future admin panel after the library has decided a withdrawn Work should come back.

Examples:

AtlasRb::Admin::Work.restore("w-789")

Parameters:

  • id (String)

    the Work ID.

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

    optional acting user's NUID. Falls through to AtlasRb.config.default_nuid when omitted.

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

    optional NUID for the On-Behalf-Of header. Falls through to AtlasRb.config.default_on_behalf_of when omitted.

Returns:

  • (Faraday::Response)

    the raw response.



61
62
63
# File 'lib/atlas_rb/admin/work.rb', line 61

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