Module: SdrClient::Find

Defined in:
lib/sdr_client/find.rb

Overview

The namespace for the “get” command

Constant Summary collapse

DRO_PATH =
'/v1/resources/%<id>s'

Class Method Summary collapse

Class Method Details

.run(druid, url:, logger: Logger.new($stdout)) ⇒ String

Returns JSON for the given Cocina object or an error.

Returns:

  • (String)

    JSON for the given Cocina object or an error

Raises:

  • (Failed)

    if the find operation fails



10
11
12
13
14
15
16
17
18
19
# File 'lib/sdr_client/find.rb', line 10

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