dor-services-client 6.27.0 → 6.28.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -1
- data/.rubocop_todo.yml +6 -11
- data/README.md +3 -0
- data/dor-services-client.gemspec +3 -1
- data/lib/dor/services/client/administrative_tag_search.rb +1 -3
- data/lib/dor/services/client/mutate.rb +84 -0
- data/lib/dor/services/client/object.rb +7 -91
- data/lib/dor/services/client/object_version.rb +3 -2
- data/lib/dor/services/client/transfer.rb +75 -0
- data/lib/dor/services/client/version.rb +1 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7deb2e9cf11e029ea63aa7bad9b918c09ccb0e8e556eff7e4fda128f8c6ad02e
|
4
|
+
data.tar.gz: 71e3ddd60c340352e76e1a2f97cca49238a900deaa15216507761abab2d3b51a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 130bb091aac14a28ed07bfcae47cf610ae301195252b15a8a69b26e073eb6258e29f25ea1971000a5189dfa10a4c313b786566c9b934c1dc87bd85b0bf3555bf
|
7
|
+
data.tar.gz: c9c729fdbb5b8191e676467703a225f70678fc884d8e79abb01a940a7d3b55ff6f6850b7478af4c59d16e649e9a75ac751ca27272309994764e3a278138f1dbe
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,23 +1,18 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2021-03-17 17:24:07 UTC using RuboCop version 1.11.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
9
|
# Offense count: 2
|
10
|
-
# Configuration parameters: IgnoredMethods.
|
10
|
+
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
|
11
11
|
Metrics/AbcSize:
|
12
|
-
Max:
|
12
|
+
Max: 22
|
13
13
|
|
14
14
|
# Offense count: 1
|
15
|
-
# Configuration parameters: CountComments.
|
16
|
-
Metrics/ClassLength:
|
17
|
-
Max: 115
|
18
|
-
|
19
|
-
# Offense count: 1
|
20
|
-
# Configuration parameters: CountComments, ExcludedMethods.
|
15
|
+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
21
16
|
Metrics/MethodLength:
|
22
17
|
Max: 11
|
23
18
|
|
@@ -28,9 +23,9 @@ Style/Documentation:
|
|
28
23
|
- 'test/**/*'
|
29
24
|
- 'lib/dor/services/client.rb'
|
30
25
|
|
31
|
-
# Offense count:
|
26
|
+
# Offense count: 77
|
32
27
|
# Cop supports --auto-correct.
|
33
28
|
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
34
29
|
# URISchemes: http, https
|
35
|
-
|
30
|
+
Layout/LineLength:
|
36
31
|
Max: 164
|
data/README.md
CHANGED
@@ -110,6 +110,9 @@ object_client.update_marc_record
|
|
110
110
|
# Copy metadata from Symphony into descMetadata
|
111
111
|
object_client.refresh_metadata
|
112
112
|
|
113
|
+
# Apply defaults from the item's AdminPolicy to the item itself
|
114
|
+
object_client.apply_admin_policy_defaults
|
115
|
+
|
113
116
|
# Send a notification to goobi
|
114
117
|
object_client.notify_goobi
|
115
118
|
|
data/dor-services-client.gemspec
CHANGED
@@ -22,6 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
+
spec.required_ruby_version = '~> 2.6'
|
26
|
+
|
25
27
|
spec.add_dependency 'activesupport', '>= 4.2', '< 7'
|
26
28
|
spec.add_dependency 'cocina-models', '~> 0.55.0' # leave pinned to patch level until cocina-models hits 1.0
|
27
29
|
spec.add_dependency 'deprecation', '>= 0'
|
@@ -33,7 +35,7 @@ Gem::Specification.new do |spec|
|
|
33
35
|
spec.add_development_dependency 'byebug'
|
34
36
|
spec.add_development_dependency 'rake', '>= 12.3.3'
|
35
37
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
36
|
-
spec.add_development_dependency 'rubocop', '~>
|
38
|
+
spec.add_development_dependency 'rubocop', '~> 1.0'
|
37
39
|
spec.add_development_dependency 'simplecov', '~> 0.17.0' # CodeClimate cannot use SimpleCov >= 0.18.0 for generating test coverage
|
38
40
|
spec.add_development_dependency 'webmock'
|
39
41
|
end
|
@@ -7,8 +7,7 @@ module Dor
|
|
7
7
|
class Client
|
8
8
|
# API calls that are about searching AdministrativeTags
|
9
9
|
class AdministrativeTagSearch < VersionedService
|
10
|
-
# rubocop:disable Naming/
|
11
|
-
def search(q:)
|
10
|
+
def search(q:) # rubocop:disable Naming/MethodParameterName
|
12
11
|
resp = connection.get do |req|
|
13
12
|
req.url "#{api_version}/administrative_tags/search?q=#{q}"
|
14
13
|
end
|
@@ -18,7 +17,6 @@ module Dor
|
|
18
17
|
|
19
18
|
raise_exception_based_on_response!(resp)
|
20
19
|
end
|
21
|
-
# rubocop:enable Naming/UncommunicativeMethodParamName
|
22
20
|
end
|
23
21
|
end
|
24
22
|
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dor
|
4
|
+
module Services
|
5
|
+
class Client
|
6
|
+
# API calls that update the data.
|
7
|
+
class Mutate < 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
|
+
# Copies the values from the admin policy to the item
|
15
|
+
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
16
|
+
# @raise [UnexpectedResponse] when the response is not successful.
|
17
|
+
# @return [boolean] true on success
|
18
|
+
def apply_admin_policy_defaults
|
19
|
+
resp = connection.post do |req|
|
20
|
+
req.url "#{object_path}/apply_admin_policy_defaults"
|
21
|
+
end
|
22
|
+
|
23
|
+
raise_exception_based_on_response!(resp) unless resp.success?
|
24
|
+
|
25
|
+
true
|
26
|
+
end
|
27
|
+
|
28
|
+
# Updates the object
|
29
|
+
# @param [Cocina::Models::RequestDRO,Cocina::Models::RequestCollection,Cocina::Models::RequestAPO] params model object
|
30
|
+
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
31
|
+
# @raise [UnexpectedResponse] when the response is not successful.
|
32
|
+
# @return [Cocina::Models::DRO,Cocina::Models::Collection,Cocina::Models::AdminPolicy] the returned model
|
33
|
+
def update(params:)
|
34
|
+
resp = connection.patch do |req|
|
35
|
+
req.url object_path
|
36
|
+
req.headers['Content-Type'] = 'application/json'
|
37
|
+
# asking the service to return JSON (else it'll be plain text)
|
38
|
+
req.headers['Accept'] = 'application/json'
|
39
|
+
req.body = params.to_json
|
40
|
+
end
|
41
|
+
|
42
|
+
raise_exception_based_on_response!(resp) unless resp.success?
|
43
|
+
|
44
|
+
Cocina::Models.build(JSON.parse(resp.body))
|
45
|
+
end
|
46
|
+
|
47
|
+
# Pull in metadata from Symphony and updates descriptive metadata
|
48
|
+
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
49
|
+
# @raise [UnexpectedResponse] when the response is not successful.
|
50
|
+
# @return [boolean] true on success
|
51
|
+
def refresh_metadata
|
52
|
+
resp = connection.post do |req|
|
53
|
+
req.url "#{object_path}/refresh_metadata"
|
54
|
+
end
|
55
|
+
|
56
|
+
raise_exception_based_on_response!(resp) unless resp.success?
|
57
|
+
|
58
|
+
true
|
59
|
+
end
|
60
|
+
|
61
|
+
# Destroys an object
|
62
|
+
# @return [Boolean] true if successful
|
63
|
+
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
64
|
+
# @raise [UnexpectedResponse] if the request is unsuccessful.
|
65
|
+
def destroy
|
66
|
+
resp = connection.delete do |req|
|
67
|
+
req.url object_path
|
68
|
+
end
|
69
|
+
raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
|
70
|
+
|
71
|
+
true
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def object_path
|
77
|
+
"#{api_version}/objects/#{object_identifier}"
|
78
|
+
end
|
79
|
+
|
80
|
+
attr_reader :object_identifier
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -4,7 +4,7 @@ module Dor
|
|
4
4
|
module Services
|
5
5
|
class Client
|
6
6
|
# API calls that are about a repository object
|
7
|
-
class Object < VersionedService
|
7
|
+
class Object < VersionedService
|
8
8
|
attr_reader :object_identifier
|
9
9
|
|
10
10
|
# @param object_identifier [String] the pid for the object
|
@@ -73,25 +73,6 @@ module Dor
|
|
73
73
|
[model, metadata]
|
74
74
|
end
|
75
75
|
|
76
|
-
# Updates the object
|
77
|
-
# @param [Cocina::Models::RequestDRO,Cocina::Models::RequestCollection,Cocina::Models::RequestAPO] params model object
|
78
|
-
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
79
|
-
# @raise [UnexpectedResponse] when the response is not successful.
|
80
|
-
# @return [Cocina::Models::DRO,Cocina::Models::Collection,Cocina::Models::AdminPolicy] the returned model
|
81
|
-
def update(params:)
|
82
|
-
resp = connection.patch do |req|
|
83
|
-
req.url object_path
|
84
|
-
req.headers['Content-Type'] = 'application/json'
|
85
|
-
# asking the service to return JSON (else it'll be plain text)
|
86
|
-
req.headers['Accept'] = 'application/json'
|
87
|
-
req.body = params.to_json
|
88
|
-
end
|
89
|
-
|
90
|
-
return Cocina::Models.build(JSON.parse(resp.body)) if resp.success?
|
91
|
-
|
92
|
-
raise_exception_based_on_response!(resp)
|
93
|
-
end
|
94
|
-
|
95
76
|
# Get a list of the collections. (Similar to Valkyrie's find_inverse_references_by)
|
96
77
|
# @raise [UnexpectedResponse] if the request is unsuccessful.
|
97
78
|
# @return [Array<Cocina::Models::DRO>]
|
@@ -106,56 +87,17 @@ module Dor
|
|
106
87
|
Members.new(**parent_params).members
|
107
88
|
end
|
108
89
|
|
109
|
-
|
110
|
-
|
111
|
-
# @raise [UnexpectedResponse] when the response is not successful.
|
112
|
-
# @param [String] workflow ('accessionWF') which workflow to callback to.
|
113
|
-
# @param [String] lane_id for prioritization (default or low)
|
114
|
-
# @return [boolean] true on success
|
115
|
-
def publish(workflow: nil, lane_id: nil)
|
116
|
-
query_params = [].tap do |params|
|
117
|
-
params << "workflow=#{workflow}" if workflow
|
118
|
-
params << "lane-id=#{lane_id}" if lane_id
|
119
|
-
end
|
120
|
-
query_string = query_params.any? ? "?#{query_params.join('&')}" : ''
|
121
|
-
publish_path = "#{object_path}/publish#{query_string}"
|
122
|
-
resp = connection.post do |req|
|
123
|
-
req.url publish_path
|
124
|
-
end
|
125
|
-
return resp.headers['Location'] if resp.success?
|
126
|
-
|
127
|
-
raise_exception_based_on_response!(resp)
|
90
|
+
def transfer
|
91
|
+
Transfer.new(**parent_params)
|
128
92
|
end
|
129
93
|
|
130
|
-
|
131
|
-
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
132
|
-
# @raise [UnexpectedResponse] when the response is not successful.
|
133
|
-
# @param [String] lane_id for prioritization (default or low)
|
134
|
-
# @return [String] URL from Location response header if no errors
|
135
|
-
def preserve(lane_id: nil)
|
136
|
-
query_string = lane_id ? "?lane-id=#{lane_id}" : ''
|
137
|
-
resp = connection.post do |req|
|
138
|
-
req.url "#{object_path}/preserve#{query_string}"
|
139
|
-
end
|
140
|
-
return resp.headers['Location'] if resp.success?
|
94
|
+
delegate :publish, :preserve, :shelve, to: :transfer
|
141
95
|
|
142
|
-
|
96
|
+
def mutate
|
97
|
+
Mutate.new(**parent_params)
|
143
98
|
end
|
144
99
|
|
145
|
-
|
146
|
-
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
147
|
-
# @raise [UnexpectedResponse] when the response is not successful.
|
148
|
-
# @param [String] lane_id for prioritization (default or low)
|
149
|
-
# @return [boolean] true on success
|
150
|
-
def shelve(lane_id: nil)
|
151
|
-
query_string = lane_id ? "?lane-id=#{lane_id}" : ''
|
152
|
-
resp = connection.post do |req|
|
153
|
-
req.url "#{object_path}/shelve#{query_string}"
|
154
|
-
end
|
155
|
-
return resp.headers['Location'] if resp.success?
|
156
|
-
|
157
|
-
raise_exception_based_on_response!(resp)
|
158
|
-
end
|
100
|
+
delegate :refresh_metadata, :update, :destroy, :apply_admin_policy_defaults, to: :mutate
|
159
101
|
|
160
102
|
# Update the marc record for the given object
|
161
103
|
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
@@ -170,32 +112,6 @@ module Dor
|
|
170
112
|
raise_exception_based_on_response!(resp)
|
171
113
|
end
|
172
114
|
|
173
|
-
# Pull in metadata from Symphony and update descMetadata
|
174
|
-
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
175
|
-
# @raise [UnexpectedResponse] when the response is not successful.
|
176
|
-
# @return [boolean] true on success
|
177
|
-
def refresh_metadata
|
178
|
-
resp = connection.post do |req|
|
179
|
-
req.url "#{object_path}/refresh_metadata"
|
180
|
-
end
|
181
|
-
return true if resp.success?
|
182
|
-
|
183
|
-
raise_exception_based_on_response!(resp)
|
184
|
-
end
|
185
|
-
|
186
|
-
# Destroys an object
|
187
|
-
# @return [Boolean] true if successful
|
188
|
-
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
189
|
-
# @raise [UnexpectedResponse] if the request is unsuccessful.
|
190
|
-
def destroy
|
191
|
-
resp = connection.delete do |req|
|
192
|
-
req.url object_path
|
193
|
-
end
|
194
|
-
raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
|
195
|
-
|
196
|
-
true
|
197
|
-
end
|
198
|
-
|
199
115
|
# Notify the external Goobi system for a new object that was registered in DOR
|
200
116
|
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
201
117
|
# @raise [UnexpectedResponse] when the response is not successful.
|
@@ -38,9 +38,10 @@ module Dor
|
|
38
38
|
|
39
39
|
raise_exception_based_on_response!(resp) unless resp.success?
|
40
40
|
|
41
|
-
|
41
|
+
case resp.body
|
42
|
+
when 'true'
|
42
43
|
true
|
43
|
-
|
44
|
+
when 'false'
|
44
45
|
false
|
45
46
|
else
|
46
47
|
raise MalformedResponse, "Expected true or false, not #{resp.body}"
|
@@ -0,0 +1,75 @@
|
|
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 ('accessionWF') which workflow to callback to.
|
18
|
+
# @param [String] lane_id for prioritization (default or low)
|
19
|
+
# @return [boolean] true on success
|
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
|
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: 6.
|
4
|
+
version: 6.28.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: 2021-03-
|
12
|
+
date: 2021-03-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -169,14 +169,14 @@ dependencies:
|
|
169
169
|
requirements:
|
170
170
|
- - "~>"
|
171
171
|
- !ruby/object:Gem::Version
|
172
|
-
version:
|
172
|
+
version: '1.0'
|
173
173
|
type: :development
|
174
174
|
prerelease: false
|
175
175
|
version_requirements: !ruby/object:Gem::Requirement
|
176
176
|
requirements:
|
177
177
|
- - "~>"
|
178
178
|
- !ruby/object:Gem::Version
|
179
|
-
version:
|
179
|
+
version: '1.0'
|
180
180
|
- !ruby/object:Gem::Dependency
|
181
181
|
name: simplecov
|
182
182
|
requirement: !ruby/object:Gem::Requirement
|
@@ -240,11 +240,13 @@ files:
|
|
240
240
|
- lib/dor/services/client/marcxml.rb
|
241
241
|
- lib/dor/services/client/members.rb
|
242
242
|
- lib/dor/services/client/metadata.rb
|
243
|
+
- lib/dor/services/client/mutate.rb
|
243
244
|
- lib/dor/services/client/object.rb
|
244
245
|
- lib/dor/services/client/object_version.rb
|
245
246
|
- lib/dor/services/client/objects.rb
|
246
247
|
- lib/dor/services/client/release_tags.rb
|
247
248
|
- lib/dor/services/client/response_error_formatter.rb
|
249
|
+
- lib/dor/services/client/transfer.rb
|
248
250
|
- lib/dor/services/client/version.rb
|
249
251
|
- lib/dor/services/client/versioned_service.rb
|
250
252
|
- lib/dor/services/client/virtual_objects.rb
|
@@ -258,9 +260,9 @@ require_paths:
|
|
258
260
|
- lib
|
259
261
|
required_ruby_version: !ruby/object:Gem::Requirement
|
260
262
|
requirements:
|
261
|
-
- - "
|
263
|
+
- - "~>"
|
262
264
|
- !ruby/object:Gem::Version
|
263
|
-
version: '
|
265
|
+
version: '2.6'
|
264
266
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
265
267
|
requirements:
|
266
268
|
- - ">="
|