Class: PurlFetcher::Client::Unpublish

Inherits:
Object
  • Object
show all
Defined in:
lib/purl_fetcher/client/unpublish.rb

Overview

Delete an item from the purl-fetcher cache

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(druid:, version:) ⇒ Unpublish

Returns a new instance of Unpublish.

Parameters:

  • druid (String)

    the identifier of the item

  • version (String)

    the version of the item



16
17
18
19
# File 'lib/purl_fetcher/client/unpublish.rb', line 16

def initialize(druid:, version:)
  @druid = druid
  @version = version
end

Class Method Details

.unpublish(druid:, version:) ⇒ Object

Parameters:

  • druid (String)

    the identifier of the item

  • version (String)

    the version of the item

Raises:

  • (Purl::Fetcher::Client::AlreadyDeletedResponseError)

    if the item is already deleted



10
11
12
# File 'lib/purl_fetcher/client/unpublish.rb', line 10

def self.unpublish(druid:, version:)
  new(druid:, version:).unpublish
end

Instance Method Details

#unpublishObject



21
22
23
24
25
26
# File 'lib/purl_fetcher/client/unpublish.rb', line 21

def unpublish
  logger.debug("Starting a unpublish request for: #{druid} (#{version})")
  response = client.delete(path:, params: { version: version })
  logger.debug("Unpublish request complete")
  response
end