Sha256: 977fae4583ea59f0cf6847eef959d0430208c6322c6a7dad3e8317fb079a5c42
Contents?: true
Size: 1.87 KB
Versions: 23
Compression:
Stored size: 1.87 KB
Contents
# frozen_string_literal: true module Dor module Services class Client # API calls that are about the DOR workspace class Workspace < VersionedService # @param object_identifier [String] the pid for the object def initialize(connection:, version:, object_identifier:) super(connection: connection, version: version) @object_identifier = object_identifier end # Initializes a new workspace # @param source [String] the path to the object # @raise [UnexpectedResponse] if the request is unsuccessful. # @return nil def create(source:) resp = connection.post do |req| req.url workspace_path req.params['source'] = source end raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp) unless resp.success? end # Cleans up a workspace # @raise [UnexpectedResponse] if the request is unsuccessful. # @return nil def cleanup resp = connection.delete do |req| req.url workspace_path end raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp) unless resp.success? end # After an object has been copied to preservation the workspace can be # reset. This is called by the reset-workspace step of the accessionWF # @raise [UnexpectedResponse] if the request is unsuccessful. # @return nil def reset resp = connection.post do |req| req.url "#{workspace_path}/reset" end raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp) unless resp.success? end private def workspace_path "#{api_version}/objects/#{object_identifier}/workspace" end attr_reader :object_identifier end end end end
Version data entries
23 entries across 23 versions & 1 rubygems