Class: Dor::Services::Client::Workspace

Inherits:
VersionedService show all
Defined in:
lib/dor/services/client/workspace.rb

Overview

API calls that are about the DOR workspace

Instance Method Summary collapse

Constructor Details

#initialize(connection:, version:, object_identifier:) ⇒ Workspace

Returns a new instance of Workspace.

Parameters:

  • object_identifier (String)

    the pid for the object



9
10
11
12
# File 'lib/dor/services/client/workspace.rb', line 9

def initialize(connection:, version:, object_identifier:)
  super(connection: connection, version: version)
  @object_identifier = object_identifier
end

Instance Method Details

#create(source:) ⇒ Object

Initializes a new workspace

Parameters:

  • source (String)

    the path to the object

Returns:

  • nil

Raises:



18
19
20
21
22
23
24
# File 'lib/dor/services/client/workspace.rb', line 18

def create(source:)
  resp = connection.post do |req|
    req.url "#{api_version}/objects/#{object_identifier}/initialize_workspace"
    req.params['source'] = source
  end
  raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body})" unless resp.success?
end