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

Constant Summary

Constants inherited from VersionedService

VersionedService::EXCEPTION_CLASS, VersionedService::JSON_API_MIME_TYPE

Instance Method Summary collapse

Methods inherited from VersionedService

#async_result, #with_querystring

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

#cleanup(lane_id: nil) ⇒ String

Cleans up and resets the workspace After an object has been copied to preservation the workspace can be reset. This is called by the reset-workspace step of the accessionWF

Parameters:

  • lane_id (String) (defaults to: nil)

    for prioritization (default or low)

Returns:

  • (String)

    the URL of the background job on dor-service-app

Raises:



41
42
43
44
45
46
47
48
49
50
# File 'lib/dor/services/client/workspace.rb', line 41

def cleanup(lane_id: nil)
  cleanup_workspace_path = workspace_path
  cleanup_workspace_path += "?lane-id=#{lane_id}" if lane_id
  resp = connection.delete do |req|
    req.url cleanup_workspace_path
  end
  return resp.headers['Location'] if resp.success?

  raise_exception_based_on_response!(resp, object_identifier)
end

#create(source: nil, content: false, metadata: false) ⇒ String

Initializes a new workspace rubocop:disable Metrics/AbcSize

Parameters:

  • source (String) (defaults to: nil)

    the path to the object (optional)

  • content (Boolean) (defaults to: false)

    determines if the content directory should be created (defaults to false)

  • metadata (Boolean) (defaults to: false)

    determines if the metadata directory should be created (defaults to false)

Returns:

  • (String)

    the path to the directory created

Raises:



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dor/services/client/workspace.rb', line 21

def create(source: nil, content: false, metadata: false)
  resp = connection.post do |req|
    req.url workspace_path
    req.params['source'] = source if source
    req.params['content'] = content
    req.params['metadata'] = 
  end
  return JSON.parse(resp.body)['path'] if resp.success?

  raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
end