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(workflow: nil, lane_id: nil) ⇒ String

Cleans up a workspace

Parameters:

  • workflow (String) (defaults to: nil)

    (nil) which workflow to callback to.

  • lane_id (String) (defaults to: nil)

    for prioritization (default or low)

Returns:

  • (String)

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

Raises:



32
33
34
35
36
37
38
39
# File 'lib/dor/services/client/workspace.rb', line 32

def cleanup(workflow: nil, lane_id: nil)
  resp = connection.delete do |req|
    req.url with_query_params(workspace_path, workflow, lane_id)
  end
  return resp.headers['Location'] if resp.success?

  raise_exception_based_on_response!(resp, object_identifier)
end

#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 workspace_path
    req.params['source'] = source
  end
  raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
end

#reset(workflow: nil, lane_id: nil) ⇒ Object

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:

  • workflow (String) (defaults to: nil)

    (nil) which workflow to callback to.

  • lane_id (String) (defaults to: nil)

    for prioritization (default or low)

Returns:

  • nil

Raises:



47
48
49
50
51
52
# File 'lib/dor/services/client/workspace.rb', line 47

def reset(workflow: nil, lane_id: nil)
  resp = connection.post do |req|
    req.url with_query_params("#{workspace_path}/reset", workflow, lane_id)
  end
  raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
end