Sha256: e47b79a4e7fec04886ce4c7f34973503472a2390afac24d02d2c1e3b524f9ed0

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module PurlFetcher
  class Client
    # Delete an item from the purl-fetcher cache
    class Unpublish
      # @param [String] druid the identifier of the item
      # @param [String] version the version of the item
      # @raise [Purl::Fetcher::Client::AlreadyDeletedResponseError] if the item is already deleted
      def self.unpublish(druid:, version:)
        new(druid:, version:).unpublish
      end

      # @param [String] druid the identifier of the item
      # @param [String] version the version of the item
      def initialize(druid:, version:)
        @druid = druid
        @version = version
      end

      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

      private

      attr_reader :druid, :version

      def logger
        Client.config.logger
      end

      def client
        Client.instance
      end

      def path
        "/v1/purls/#{druid}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
purl_fetcher-client-2.1.2 lib/purl_fetcher/client/unpublish.rb
purl_fetcher-client-2.1.1 lib/purl_fetcher/client/unpublish.rb
purl_fetcher-client-2.1.0 lib/purl_fetcher/client/unpublish.rb