Class: Dor::Services::Client::Transfer
- Inherits:
-
VersionedService
- Object
- VersionedService
- Dor::Services::Client::Transfer
- Defined in:
- lib/dor/services/client/transfer.rb
Overview
API calls that move data around.
Constant Summary
Constants inherited from VersionedService
VersionedService::EXCEPTION_CLASS, VersionedService::JSON_API_MIME_TYPE
Instance Method Summary collapse
-
#initialize(connection:, version:, object_identifier:) ⇒ Transfer
constructor
A new instance of Transfer.
-
#preserve(lane_id: nil) ⇒ String
Preserve an object (send to SDR).
-
#publish(workflow: nil, lane_id: nil) ⇒ String
Publish an object (send to PURL).
-
#shelve(lane_id: nil) ⇒ boolean
Shelve an object (send to Stacks).
-
#unpublish ⇒ String
Unpublish an object (yank from to PURL).
Methods inherited from VersionedService
#async_result, #with_querystring
Constructor Details
#initialize(connection:, version:, object_identifier:) ⇒ Transfer
Returns a new instance of Transfer.
9 10 11 12 |
# File 'lib/dor/services/client/transfer.rb', line 9 def initialize(connection:, version:, object_identifier:) super(connection: connection, version: version) @object_identifier = object_identifier end |
Instance Method Details
#preserve(lane_id: nil) ⇒ String
Preserve an object (send to SDR)
53 54 55 56 57 58 59 60 61 |
# File 'lib/dor/services/client/transfer.rb', line 53 def preserve(lane_id: nil) query_string = lane_id ? "?lane-id=#{lane_id}" : '' resp = connection.post do |req| req.url "#{object_path}/preserve#{query_string}" end return resp.headers['Location'] if resp.success? raise_exception_based_on_response!(resp) end |
#publish(workflow: nil, lane_id: nil) ⇒ String
Publish an object (send to PURL)
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/dor/services/client/transfer.rb', line 20 def publish(workflow: nil, lane_id: nil) query_params = [].tap do |params| params << "workflow=#{workflow}" if workflow params << "lane-id=#{lane_id}" if lane_id end query_string = query_params.any? ? "?#{query_params.join('&')}" : '' publish_path = "#{object_path}/publish#{query_string}" resp = connection.post do |req| req.url publish_path end return resp.headers['Location'] if resp.success? raise_exception_based_on_response!(resp) end |
#shelve(lane_id: nil) ⇒ boolean
Shelve an object (send to Stacks)
68 69 70 71 72 73 74 75 76 |
# File 'lib/dor/services/client/transfer.rb', line 68 def shelve(lane_id: nil) query_string = lane_id ? "?lane-id=#{lane_id}" : '' resp = connection.post do |req| req.url "#{object_path}/shelve#{query_string}" end return resp.headers['Location'] if resp.success? raise_exception_based_on_response!(resp) end |
#unpublish ⇒ String
Unpublish an object (yank from to PURL)
39 40 41 42 43 44 45 46 |
# File 'lib/dor/services/client/transfer.rb', line 39 def unpublish resp = connection.post do |req| req.url "#{object_path}/unpublish" end return resp.headers['Location'] if resp.success? raise_exception_based_on_response!(resp) end |