Sha256: 668f32fea823e325a6131ac39eebb19555a4b01c69a27f5c461ff66c30df34e8

Contents?: true

Size: 1.83 KB

Versions: 101

Compression:

Stored size: 1.83 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_exception_based_on_response!(resp, object_identifier) 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_exception_based_on_response!(resp, object_identifier) 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_exception_based_on_response!(resp, object_identifier) 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

101 entries across 101 versions & 1 rubygems

Version Path
dor-services-client-12.9.1 lib/dor/services/client/workspace.rb
dor-services-client-12.9.0 lib/dor/services/client/workspace.rb
dor-services-client-12.8.0 lib/dor/services/client/workspace.rb
dor-services-client-12.7.0 lib/dor/services/client/workspace.rb
dor-services-client-12.6.0 lib/dor/services/client/workspace.rb
dor-services-client-12.5.0 lib/dor/services/client/workspace.rb
dor-services-client-12.4.0 lib/dor/services/client/workspace.rb
dor-services-client-12.3.0 lib/dor/services/client/workspace.rb
dor-services-client-12.2.0 lib/dor/services/client/workspace.rb
dor-services-client-12.1.0 lib/dor/services/client/workspace.rb
dor-services-client-12.0.0 lib/dor/services/client/workspace.rb
dor-services-client-11.0.0 lib/dor/services/client/workspace.rb
dor-services-client-10.2.0 lib/dor/services/client/workspace.rb
dor-services-client-10.1.0 lib/dor/services/client/workspace.rb
dor-services-client-10.0.0 lib/dor/services/client/workspace.rb
dor-services-client-9.1.1 lib/dor/services/client/workspace.rb
dor-services-client-9.1.0 lib/dor/services/client/workspace.rb
dor-services-client-9.0.0 lib/dor/services/client/workspace.rb
dor-services-client-8.9.0 lib/dor/services/client/workspace.rb
dor-services-client-8.8.0 lib/dor/services/client/workspace.rb