Sha256: ba7b577b0134b6177cffb87e712c2b1fe5a5104a8e58cdf8b4e1515e7e5c4007

Contents?: true

Size: 723 Bytes

Versions: 16

Compression:

Stored size: 723 Bytes

Contents

# frozen_string_literal: true

require 'logger'

module SdrClient
  # The namespace for the "get" command
  module Find
    DRO_PATH = '/v1/resources/%<id>s'

    # @raise [Failed] if the find operation fails
    # @return [String] JSON for the given Cocina object or an error
    def self.run(druid, url:, logger: Logger.new($stdout))
      connection = Connection.new(url: url)
      path = format(DRO_PATH, id: druid)
      logger.info("Retrieving metadata from: #{path}")
      response = connection.get(path)
      return response.body if response.success?

      logger.error("There was an HTTP #{response.status} error making the request: #{response.body}")
      UnexpectedResponse.call(response)
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
sdr-client-2.11.0 lib/sdr_client/find.rb
sdr-client-2.10.1 lib/sdr_client/find.rb
sdr-client-2.10.0 lib/sdr_client/find.rb
sdr-client-2.9.0 lib/sdr_client/find.rb
sdr-client-2.8.0 lib/sdr_client/find.rb
sdr-client-2.7.1 lib/sdr_client/find.rb
sdr-client-2.7.0 lib/sdr_client/find.rb
sdr-client-2.6.0 lib/sdr_client/find.rb
sdr-client-2.5.0 lib/sdr_client/find.rb
sdr-client-2.4.0 lib/sdr_client/find.rb
sdr-client-2.3.1 lib/sdr_client/find.rb
sdr-client-2.3.0 lib/sdr_client/find.rb
sdr-client-2.2.0 lib/sdr_client/find.rb
sdr-client-2.1.0 lib/sdr_client/find.rb
sdr-client-2.0.1 lib/sdr_client/find.rb
sdr-client-2.0.0 lib/sdr_client/find.rb