Sha256: 97774a6e21b14981bfff5c221b559f61c6768b302522af19eb4ad062902e9288

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

# frozen_string_literal: true

module PurlFetcher
  class Client
    # Transfer release tags to purl-fetcher
    class ReleaseTags
      # @param [String] druid the identifier of the object
      # @param [Array<String>] index ([]) list of properties to index to
      # @param [Array<String>] delete ([]) list of properties to delete from
      def self.release(druid:, index: [], delete: [])
        new(druid:, index:, delete:).release
      end

      # @param [String] druid the identifier of the object
      # @param [Array<String>] index ([]) list of properties to index to
      # @param [Array<String>] delete ([]) list of properties to delete from
      def initialize(druid:, index: [], delete: [])
        @druid = druid
        @index = index
        @delete = delete
      end

      def release
        logger.debug("Starting an release request for: #{druid}")
        response = client.put(path:, body:)
        logger.debug("Release request complete")
      end

      private

      attr_reader :druid, :index, :delete

      def body
        { actions: { index:, delete: } }.to_json
      end

      def logger
        Client.config.logger
      end

      def client
        Client.instance
      end

      def path
        "/v1/purls/#{druid}/release_tags"
      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/release_tags.rb
purl_fetcher-client-2.1.1 lib/purl_fetcher/client/release_tags.rb
purl_fetcher-client-2.1.0 lib/purl_fetcher/client/release_tags.rb