dor-services-client 15.2.0 → 15.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/Gemfile.lock +49 -40
- data/README.md +6 -20
- data/dor-services-client.gemspec +1 -1
- data/lib/dor/services/client/object.rb +17 -46
- data/lib/dor/services/client/objects.rb +16 -0
- data/lib/dor/services/client/version.rb +1 -1
- data/lib/dor/services/client/workspace.rb +0 -18
- metadata +4 -11
- data/lib/dor/services/client/transfer.rb +0 -75
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e74ca0ad7c415b3106f4877959eb84fd330a1d6165fde35061b9b8cf329ed2f
|
4
|
+
data.tar.gz: 467ca654ab6c53959a8cfa59f8379357129de3f531a236091712c798ec6d24eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbbd6072449d6d5204e446c314ea3e5b334ab7678ad3e99e6c04332a1020f97c8c2d6db5621f68958d19aa899f0790b47d78ca0bda2bf43107c6f54113cb7724
|
7
|
+
data.tar.gz: 57c5d87ca0045680736832ba487417add78b9a0a85a7f78192a470dd311d189d27f0f13f6e4219cedc24c962b8abe2f19ff93a2c772111289d8aa32d8ab58728
|
data/.circleci/config.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dor-services-client (15.
|
5
|
-
activesupport (>=
|
4
|
+
dor-services-client (15.3.0)
|
5
|
+
activesupport (>= 7.0.0)
|
6
6
|
cocina-models (~> 0.99.0)
|
7
7
|
deprecation
|
8
8
|
faraday (~> 2.0)
|
@@ -12,8 +12,9 @@ PATH
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
activesupport (
|
15
|
+
activesupport (8.0.1)
|
16
16
|
base64
|
17
|
+
benchmark (>= 0.3)
|
17
18
|
bigdecimal
|
18
19
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
19
20
|
connection_pool (>= 2.2.5)
|
@@ -23,15 +24,18 @@ GEM
|
|
23
24
|
minitest (>= 5.1)
|
24
25
|
securerandom (>= 0.3)
|
25
26
|
tzinfo (~> 2.0, >= 2.0.5)
|
27
|
+
uri (>= 0.13.1)
|
26
28
|
addressable (2.8.7)
|
27
29
|
public_suffix (>= 2.0.2, < 7.0)
|
28
30
|
ast (2.4.2)
|
29
31
|
attr_extras (7.1.0)
|
30
32
|
base64 (0.2.0)
|
31
|
-
|
33
|
+
benchmark (0.4.0)
|
34
|
+
bigdecimal (3.1.9)
|
32
35
|
byebug (11.1.3)
|
33
|
-
cocina-models (0.99.
|
36
|
+
cocina-models (0.99.2)
|
34
37
|
activesupport
|
38
|
+
commonmarker (= 2.0.1)
|
35
39
|
deprecation
|
36
40
|
dry-struct (~> 1.0)
|
37
41
|
dry-types (~> 1.1)
|
@@ -45,9 +49,9 @@ GEM
|
|
45
49
|
super_diff
|
46
50
|
thor
|
47
51
|
zeitwerk (~> 2.1)
|
48
|
-
commonmarker (
|
49
|
-
commonmarker (
|
50
|
-
commonmarker (
|
52
|
+
commonmarker (2.0.1-arm64-darwin)
|
53
|
+
commonmarker (2.0.1-x86_64-darwin)
|
54
|
+
commonmarker (2.0.1-x86_64-linux)
|
51
55
|
concurrent-ruby (1.3.4)
|
52
56
|
connection_pool (2.4.1)
|
53
57
|
crack (1.0.0)
|
@@ -58,13 +62,15 @@ GEM
|
|
58
62
|
diff-lcs (1.5.1)
|
59
63
|
docile (1.4.1)
|
60
64
|
drb (2.2.1)
|
61
|
-
dry-core (1.0
|
65
|
+
dry-core (1.1.0)
|
62
66
|
concurrent-ruby (~> 1.0)
|
67
|
+
logger
|
63
68
|
zeitwerk (~> 2.6)
|
64
|
-
dry-inflector (1.
|
65
|
-
dry-logic (1.
|
69
|
+
dry-inflector (1.2.0)
|
70
|
+
dry-logic (1.6.0)
|
71
|
+
bigdecimal
|
66
72
|
concurrent-ruby (~> 1.0)
|
67
|
-
dry-core (~> 1.
|
73
|
+
dry-core (~> 1.1)
|
68
74
|
zeitwerk (~> 2.6)
|
69
75
|
dry-struct (1.6.0)
|
70
76
|
dry-core (~> 1.0, < 2)
|
@@ -78,43 +84,43 @@ GEM
|
|
78
84
|
dry-inflector (~> 1.0)
|
79
85
|
dry-logic (~> 1.4)
|
80
86
|
zeitwerk (~> 2.6)
|
81
|
-
edtf (3.
|
82
|
-
activesupport (>= 3.0, <
|
87
|
+
edtf (3.2.0)
|
88
|
+
activesupport (>= 3.0, < 9.0)
|
83
89
|
equivalent-xml (0.6.0)
|
84
90
|
nokogiri (>= 1.4.3)
|
85
|
-
faraday (2.12.
|
86
|
-
faraday-net_http (>= 2.0, < 3.
|
91
|
+
faraday (2.12.2)
|
92
|
+
faraday-net_http (>= 2.0, < 3.5)
|
87
93
|
json
|
88
94
|
logger
|
89
|
-
faraday-net_http (3.
|
90
|
-
net-http
|
95
|
+
faraday-net_http (3.4.0)
|
96
|
+
net-http (>= 0.5.0)
|
91
97
|
faraday-retry (2.2.1)
|
92
98
|
faraday (~> 2.0)
|
93
|
-
hashdiff (1.1.
|
99
|
+
hashdiff (1.1.2)
|
94
100
|
i18n (1.14.6)
|
95
101
|
concurrent-ruby (~> 1.0)
|
96
102
|
ice_nine (0.11.2)
|
97
|
-
json (2.
|
103
|
+
json (2.9.1)
|
98
104
|
jsonpath (1.1.5)
|
99
105
|
multi_json
|
100
106
|
language_server-protocol (3.17.0.3)
|
101
|
-
logger (1.6.
|
102
|
-
minitest (5.25.
|
107
|
+
logger (1.6.4)
|
108
|
+
minitest (5.25.4)
|
103
109
|
multi_json (1.15.0)
|
104
|
-
net-http (0.
|
110
|
+
net-http (0.6.0)
|
105
111
|
uri
|
106
|
-
nokogiri (1.
|
112
|
+
nokogiri (1.18.1-arm64-darwin)
|
107
113
|
racc (~> 1.4)
|
108
|
-
nokogiri (1.
|
114
|
+
nokogiri (1.18.1-x86_64-darwin)
|
109
115
|
racc (~> 1.4)
|
110
|
-
nokogiri (1.
|
116
|
+
nokogiri (1.18.1-x86_64-linux-gnu)
|
111
117
|
racc (~> 1.4)
|
112
118
|
openapi3_parser (0.10.0)
|
113
119
|
commonmarker (>= 1.0)
|
114
120
|
openapi_parser (1.0.0)
|
115
|
-
optimist (3.
|
121
|
+
optimist (3.2.0)
|
116
122
|
parallel (1.26.3)
|
117
|
-
parser (3.3.
|
123
|
+
parser (3.3.6.0)
|
118
124
|
ast (~> 2.4.1)
|
119
125
|
racc
|
120
126
|
patience_diff (1.2.0)
|
@@ -123,8 +129,8 @@ GEM
|
|
123
129
|
racc (1.8.1)
|
124
130
|
rainbow (3.1.1)
|
125
131
|
rake (13.2.1)
|
126
|
-
regexp_parser (2.
|
127
|
-
rexml (3.
|
132
|
+
regexp_parser (2.10.0)
|
133
|
+
rexml (3.4.0)
|
128
134
|
rspec (3.13.0)
|
129
135
|
rspec-core (~> 3.13.0)
|
130
136
|
rspec-expectations (~> 3.13.0)
|
@@ -137,18 +143,18 @@ GEM
|
|
137
143
|
rspec-mocks (3.13.2)
|
138
144
|
diff-lcs (>= 1.2.0, < 2.0)
|
139
145
|
rspec-support (~> 3.13.0)
|
140
|
-
rspec-support (3.13.
|
141
|
-
rubocop (1.
|
146
|
+
rspec-support (3.13.2)
|
147
|
+
rubocop (1.69.2)
|
142
148
|
json (~> 2.3)
|
143
149
|
language_server-protocol (>= 3.17.0)
|
144
150
|
parallel (~> 1.10)
|
145
151
|
parser (>= 3.3.0.2)
|
146
152
|
rainbow (>= 2.2.2, < 4.0)
|
147
|
-
regexp_parser (>= 2.
|
148
|
-
rubocop-ast (>= 1.
|
153
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
154
|
+
rubocop-ast (>= 1.36.2, < 2.0)
|
149
155
|
ruby-progressbar (~> 1.7)
|
150
|
-
unicode-display_width (>= 2.4.0, <
|
151
|
-
rubocop-ast (1.
|
156
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
157
|
+
rubocop-ast (1.37.0)
|
152
158
|
parser (>= 3.3.1.0)
|
153
159
|
rubocop-capybara (2.21.0)
|
154
160
|
rubocop (~> 1.41)
|
@@ -162,22 +168,24 @@ GEM
|
|
162
168
|
rubocop-rspec_rails (2.29.1)
|
163
169
|
rubocop (~> 1.61)
|
164
170
|
ruby-progressbar (1.13.0)
|
165
|
-
securerandom (0.
|
171
|
+
securerandom (0.4.1)
|
166
172
|
simplecov (0.22.0)
|
167
173
|
docile (~> 1.1)
|
168
174
|
simplecov-html (~> 0.11)
|
169
175
|
simplecov_json_formatter (~> 0.1)
|
170
176
|
simplecov-html (0.13.1)
|
171
177
|
simplecov_json_formatter (0.1.4)
|
172
|
-
super_diff (0.
|
178
|
+
super_diff (0.14.0)
|
173
179
|
attr_extras (>= 6.2.4)
|
174
180
|
diff-lcs
|
175
181
|
patience_diff
|
176
182
|
thor (1.3.2)
|
177
183
|
tzinfo (2.0.6)
|
178
184
|
concurrent-ruby (~> 1.0)
|
179
|
-
unicode-display_width (
|
180
|
-
|
185
|
+
unicode-display_width (3.1.3)
|
186
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
187
|
+
unicode-emoji (4.0.4)
|
188
|
+
uri (1.0.2)
|
181
189
|
webmock (3.24.0)
|
182
190
|
addressable (>= 2.8.0)
|
183
191
|
crack (>= 0.3.2)
|
@@ -186,6 +194,7 @@ GEM
|
|
186
194
|
|
187
195
|
PLATFORMS
|
188
196
|
arm64-darwin-23
|
197
|
+
arm64-darwin-24
|
189
198
|
x86_64-darwin-19
|
190
199
|
x86_64-darwin-20
|
191
200
|
x86_64-darwin-21
|
data/README.md
CHANGED
@@ -66,6 +66,9 @@ objects_client.register(params: {}, assign_doi: true)
|
|
66
66
|
# Find object by source ID
|
67
67
|
objects_client.find(source_id: 'sul:abc123')
|
68
68
|
|
69
|
+
# Get status for a batch of objects
|
70
|
+
objects_client.statuses(object_ids: ['druid:bc123df4567', 'druid:bc987gh6543'])
|
71
|
+
|
69
72
|
# Interact with virtual objects
|
70
73
|
virtual_objects_client = Dor::Services::Client.virtual_objects
|
71
74
|
|
@@ -87,39 +90,23 @@ object_client.update(params: dro)
|
|
87
90
|
# Publish an object (push to PURL)
|
88
91
|
object_client.publish(workflow: 'releaseWF', lane_id: 'low')
|
89
92
|
|
90
|
-
# Shelve an object (push to Stacks)
|
91
|
-
object_client.shelve(lane_id: 'low')
|
92
|
-
|
93
93
|
# Start accessioning an object (initialize assemblyWF or specified workflow, and version object if needed)
|
94
94
|
object_client.accession.start(**versioning_params)
|
95
95
|
|
96
|
-
# Preserve an object (push to SDR)
|
97
|
-
object_client.preserve(lane_id: 'low')
|
98
|
-
|
99
|
-
# Update the MARC record (used in the releaseWF)
|
100
|
-
object_client.update_marc_record
|
101
|
-
|
102
|
-
# Update the DOI metadata (used by robot)
|
103
|
-
object_client.update_doi_metadata
|
104
|
-
|
105
|
-
# Update the Orcid work (used by robot)
|
106
|
-
object_client.update_orcid_work
|
107
|
-
|
108
96
|
# Copy metadata from Symphony into descMetadata
|
109
97
|
object_client.refresh_descriptive_metadata_from_ils
|
110
98
|
|
111
99
|
# Apply defaults from the item's AdminPolicy to the item itself
|
112
100
|
object_client.apply_admin_policy_defaults
|
113
101
|
|
114
|
-
# Send a notification to goobi
|
115
|
-
object_client.notify_goobi
|
116
|
-
|
117
102
|
# Manage versions
|
118
103
|
object_client.version.inventory
|
119
104
|
object_client.version.current
|
120
105
|
# Returns a struct containing the status.
|
121
106
|
# Status includes whether the object is open, assembling, accessioning, or closeable.
|
107
|
+
# See also objects_client.statuses for getting statuses in batch.
|
122
108
|
object_client.version.status
|
109
|
+
|
123
110
|
# see dor-services-app openapi.yml for optional params
|
124
111
|
object_client.version.open(description: 'Changed title')
|
125
112
|
# see dor-services-app openapi.yml for optional params
|
@@ -160,9 +147,8 @@ object_client.release_tags.list(public: true) # only public release tags (i.e. l
|
|
160
147
|
object_client.events.create(type: type, data: data)
|
161
148
|
object_client.events.list
|
162
149
|
|
163
|
-
# Create
|
150
|
+
# Create workspaces
|
164
151
|
object_client.workspace.create(source: object_path_string)
|
165
|
-
object_client.workspace.cleanup
|
166
152
|
|
167
153
|
# Reindex
|
168
154
|
object_client.reindex
|
data/dor-services-client.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
|
25
25
|
spec.required_ruby_version = '>= 3.0', '< 4'
|
26
26
|
|
27
|
-
spec.add_dependency 'activesupport', '>=
|
27
|
+
spec.add_dependency 'activesupport', '>= 7.0.0'
|
28
28
|
spec.add_dependency 'cocina-models', '~> 0.99.0'
|
29
29
|
spec.add_dependency 'deprecation', '>= 0'
|
30
30
|
spec.add_dependency 'faraday', '~> 2.0'
|
@@ -107,8 +107,6 @@ module Dor
|
|
107
107
|
Transfer.new(**parent_params)
|
108
108
|
end
|
109
109
|
|
110
|
-
delegate :publish, :preserve, :shelve, to: :transfer
|
111
|
-
|
112
110
|
def mutate
|
113
111
|
Mutate.new(**parent_params)
|
114
112
|
end
|
@@ -118,68 +116,41 @@ module Dor
|
|
118
116
|
alias refresh_metadata refresh_descriptive_metadata_from_ils
|
119
117
|
deprecation_deprecate refresh_metadata: 'Use refresh_descriptive_metadata_from_ils instead'
|
120
118
|
|
121
|
-
#
|
119
|
+
# Reindex the object in Solr.
|
122
120
|
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
123
121
|
# @raise [UnexpectedResponse] when the response is not successful.
|
124
122
|
# @return [boolean] true on success
|
125
|
-
def
|
126
|
-
resp = connection.post do |req|
|
127
|
-
req.url "#{object_path}/update_marc_record"
|
128
|
-
end
|
129
|
-
return true if resp.success?
|
130
|
-
|
131
|
-
raise_exception_based_on_response!(resp)
|
132
|
-
end
|
133
|
-
|
134
|
-
# Update the DOI metadata at DataCite
|
135
|
-
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
136
|
-
# @return [boolean] true on success
|
137
|
-
def update_doi_metadata
|
138
|
-
resp = connection.post do |req|
|
139
|
-
req.url "#{object_path}/update_doi_metadata"
|
140
|
-
end
|
141
|
-
return true if resp.success?
|
142
|
-
|
143
|
-
raise_exception_based_on_response!(resp)
|
144
|
-
end
|
145
|
-
|
146
|
-
# Update the ORCID Work
|
147
|
-
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
148
|
-
# @return [Boolean] true on success
|
149
|
-
def update_orcid_work
|
123
|
+
def reindex
|
150
124
|
resp = connection.post do |req|
|
151
|
-
req.url "#{object_path}/
|
125
|
+
req.url "#{object_path}/reindex"
|
152
126
|
end
|
153
127
|
return true if resp.success?
|
154
128
|
|
155
129
|
raise_exception_based_on_response!(resp)
|
156
130
|
end
|
157
131
|
|
158
|
-
#
|
132
|
+
# Publish an object (send to PURL)
|
159
133
|
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
160
134
|
# @raise [UnexpectedResponse] when the response is not successful.
|
161
|
-
# @
|
162
|
-
|
163
|
-
|
164
|
-
|
135
|
+
# @param [String] workflow (nil) which workflow to callback to.
|
136
|
+
# @param [String] lane_id for prioritization (default or low)
|
137
|
+
# @return [String] the URL of the background job on dor-service-app
|
138
|
+
# rubocop:disable Metrics/MethodLength
|
139
|
+
def publish(workflow: nil, lane_id: nil)
|
140
|
+
query_params = [].tap do |params|
|
141
|
+
params << "workflow=#{workflow}" if workflow
|
142
|
+
params << "lane-id=#{lane_id}" if lane_id
|
165
143
|
end
|
166
|
-
|
167
|
-
|
168
|
-
raise_exception_based_on_response!(resp)
|
169
|
-
end
|
170
|
-
|
171
|
-
# Reindex the object in Solr.
|
172
|
-
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
173
|
-
# @raise [UnexpectedResponse] when the response is not successful.
|
174
|
-
# @return [boolean] true on success
|
175
|
-
def reindex
|
144
|
+
query_string = query_params.any? ? "?#{query_params.join('&')}" : ''
|
145
|
+
publish_path = "#{object_path}/publish#{query_string}"
|
176
146
|
resp = connection.post do |req|
|
177
|
-
req.url
|
147
|
+
req.url publish_path
|
178
148
|
end
|
179
|
-
return
|
149
|
+
return resp.headers['Location'] if resp.success?
|
180
150
|
|
181
151
|
raise_exception_based_on_response!(resp)
|
182
152
|
end
|
153
|
+
# rubocop:enable Metrics/MethodLength
|
183
154
|
|
184
155
|
private
|
185
156
|
|
@@ -41,6 +41,22 @@ module Dor
|
|
41
41
|
build_cocina_from_response(resp, validate: validate)
|
42
42
|
end
|
43
43
|
|
44
|
+
# Retrieves the version statuses for a batch of objects
|
45
|
+
# @param [Array<String>] object_ids the druids to get statuses for
|
46
|
+
# @return [Hash<String,VersionStatus>] Map of druids to statuses
|
47
|
+
# @raise [UnexpectedResponse] on an unsuccessful response from the server
|
48
|
+
def statuses(object_ids:)
|
49
|
+
resp = connection.post do |req|
|
50
|
+
req.url "#{objects_path}/versions/status"
|
51
|
+
req.headers['Content-Type'] = 'application/json'
|
52
|
+
req.body = { externalIdentifiers: object_ids }.to_json
|
53
|
+
end
|
54
|
+
|
55
|
+
raise_exception_based_on_response!(resp) unless resp.success?
|
56
|
+
|
57
|
+
JSON.parse(resp.body).transform_values { |status| ObjectVersion::VersionStatus.new(status.symbolize_keys!) }
|
58
|
+
end
|
59
|
+
|
44
60
|
private
|
45
61
|
|
46
62
|
def objects_path
|
@@ -31,24 +31,6 @@ module Dor
|
|
31
31
|
end
|
32
32
|
# rubocop:enable Metrics/AbcSize
|
33
33
|
|
34
|
-
# Cleans up and resets the workspace
|
35
|
-
# After an object has been copied to preservation the workspace can be
|
36
|
-
# reset. This is called by the reset-workspace step of the accessionWF
|
37
|
-
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
38
|
-
# @raise [UnexpectedResponse] when the response is not successful.
|
39
|
-
# @param [String] lane_id for prioritization (default or low)
|
40
|
-
# @return [String] the URL of the background job on dor-service-app
|
41
|
-
def cleanup(lane_id: nil)
|
42
|
-
cleanup_workspace_path = workspace_path
|
43
|
-
cleanup_workspace_path += "?lane-id=#{lane_id}" if lane_id
|
44
|
-
resp = connection.delete do |req|
|
45
|
-
req.url cleanup_workspace_path
|
46
|
-
end
|
47
|
-
return resp.headers['Location'] if resp.success?
|
48
|
-
|
49
|
-
raise_exception_based_on_response!(resp, object_identifier)
|
50
|
-
end
|
51
|
-
|
52
34
|
private
|
53
35
|
|
54
36
|
def workspace_path
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dor-services-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 15.
|
4
|
+
version: 15.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2025-01-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -17,20 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
21
|
-
- - "<"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: '8'
|
20
|
+
version: 7.0.0
|
24
21
|
type: :runtime
|
25
22
|
prerelease: false
|
26
23
|
version_requirements: !ruby/object:Gem::Requirement
|
27
24
|
requirements:
|
28
25
|
- - ">="
|
29
26
|
- !ruby/object:Gem::Version
|
30
|
-
version:
|
31
|
-
- - "<"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '8'
|
27
|
+
version: 7.0.0
|
34
28
|
- !ruby/object:Gem::Dependency
|
35
29
|
name: cocina-models
|
36
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -252,7 +246,6 @@ files:
|
|
252
246
|
- lib/dor/services/client/release_tag.rb
|
253
247
|
- lib/dor/services/client/release_tags.rb
|
254
248
|
- lib/dor/services/client/response_error_formatter.rb
|
255
|
-
- lib/dor/services/client/transfer.rb
|
256
249
|
- lib/dor/services/client/user_version.rb
|
257
250
|
- lib/dor/services/client/version.rb
|
258
251
|
- lib/dor/services/client/versioned_service.rb
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Dor
|
4
|
-
module Services
|
5
|
-
class Client
|
6
|
-
# API calls that move data around.
|
7
|
-
class Transfer < VersionedService
|
8
|
-
# @param object_identifier [String] the pid for the object
|
9
|
-
def initialize(connection:, version:, object_identifier:)
|
10
|
-
super(connection: connection, version: version)
|
11
|
-
@object_identifier = object_identifier
|
12
|
-
end
|
13
|
-
|
14
|
-
# Publish an object (send to PURL)
|
15
|
-
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
16
|
-
# @raise [UnexpectedResponse] when the response is not successful.
|
17
|
-
# @param [String] workflow (nil) which workflow to callback to.
|
18
|
-
# @param [String] lane_id for prioritization (default or low)
|
19
|
-
# @return [String] the URL of the background job on dor-service-app
|
20
|
-
def publish(workflow: nil, lane_id: nil)
|
21
|
-
query_params = [].tap do |params|
|
22
|
-
params << "workflow=#{workflow}" if workflow
|
23
|
-
params << "lane-id=#{lane_id}" if lane_id
|
24
|
-
end
|
25
|
-
query_string = query_params.any? ? "?#{query_params.join('&')}" : ''
|
26
|
-
publish_path = "#{object_path}/publish#{query_string}"
|
27
|
-
resp = connection.post do |req|
|
28
|
-
req.url publish_path
|
29
|
-
end
|
30
|
-
return resp.headers['Location'] if resp.success?
|
31
|
-
|
32
|
-
raise_exception_based_on_response!(resp)
|
33
|
-
end
|
34
|
-
|
35
|
-
# Preserve an object (send to SDR)
|
36
|
-
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
37
|
-
# @raise [UnexpectedResponse] when the response is not successful.
|
38
|
-
# @param [String] lane_id for prioritization (default or low)
|
39
|
-
# @return [String] URL from Location response header if no errors
|
40
|
-
def preserve(lane_id: nil)
|
41
|
-
query_string = lane_id ? "?lane-id=#{lane_id}" : ''
|
42
|
-
resp = connection.post do |req|
|
43
|
-
req.url "#{object_path}/preserve#{query_string}"
|
44
|
-
end
|
45
|
-
return resp.headers['Location'] if resp.success?
|
46
|
-
|
47
|
-
raise_exception_based_on_response!(resp)
|
48
|
-
end
|
49
|
-
|
50
|
-
# Shelve an object (send to Stacks)
|
51
|
-
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
52
|
-
# @raise [UnexpectedResponse] when the response is not successful.
|
53
|
-
# @param [String] lane_id for prioritization (default or low)
|
54
|
-
# @return [boolean] true on success
|
55
|
-
def shelve(lane_id: nil)
|
56
|
-
query_string = lane_id ? "?lane-id=#{lane_id}" : ''
|
57
|
-
resp = connection.post do |req|
|
58
|
-
req.url "#{object_path}/shelve#{query_string}"
|
59
|
-
end
|
60
|
-
return resp.headers['Location'] if resp.success?
|
61
|
-
|
62
|
-
raise_exception_based_on_response!(resp)
|
63
|
-
end
|
64
|
-
|
65
|
-
private
|
66
|
-
|
67
|
-
def object_path
|
68
|
-
"#{api_version}/objects/#{object_identifier}"
|
69
|
-
end
|
70
|
-
|
71
|
-
attr_reader :object_identifier
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|