dor-services-client 6.31.0 → 6.36.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c85fd522359334f94d23ad939efb45cc660e4e0dc31e0578dc5ce0609fbe59fe
4
- data.tar.gz: 60e2758cf72fe578a1cd5a8fdf4af895b222761461ea8e26d31de13285d2baba
3
+ metadata.gz: 9a432159ad7c4d7f287ec97a252c2783e3e3a7c2d67cea054577727b97acfa52
4
+ data.tar.gz: 710bca4a6fd453a73842b534616f5a8eae79040544ab563f1141e5151f903fde
5
5
  SHA512:
6
- metadata.gz: b0cf506dbafdafdeb7970cfe60bd4107358c2fb65813c20406c42964dba3266e2098632682aec91f434a6e4a61add553054a3fb50bc37cd40f99e2de572f787d
7
- data.tar.gz: 7b7c62fa90a5518de1a1db9b3c38c96f1ad393c89e658b6c1e4b94edff48b1cecc3babe683dd53e1c38ebc3e6d872d303256f7df1692b154232ef49e102846f9
6
+ metadata.gz: '0486fff69b07ebd63f409b9b8f587622fa6595d279a8cfc657dfbd230016d433fe2b01fd9b6ecef9742067bb9467e79d91d4fea28aecb38dd2601f5d7b114431'
7
+ data.tar.gz: 99a486c70acb3b5926977555be3515d16dc8ff062661427037b585014024ba929515b8a71d3e2911a7118d9309222a89e10cfbd39a41d0c6c10f5d58c62436a9
data/.rubocop.yml CHANGED
@@ -8,3 +8,72 @@ Metrics/BlockLength:
8
8
  Exclude:
9
9
  - 'dor-services-client.gemspec'
10
10
  - 'spec/**/*'
11
+
12
+ Gemspec/DateAssignment: # (new in 1.10)
13
+ Enabled: true
14
+ Layout/SpaceBeforeBrackets: # (new in 1.7)
15
+ Enabled: true
16
+ Lint/AmbiguousAssignment: # (new in 1.7)
17
+ Enabled: true
18
+ Lint/DeprecatedConstants: # (new in 1.8)
19
+ Enabled: true
20
+ Lint/DuplicateBranch: # (new in 1.3)
21
+ Enabled: true
22
+ Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
23
+ Enabled: true
24
+ Lint/EmptyBlock: # (new in 1.1)
25
+ Enabled: true
26
+ Lint/EmptyClass: # (new in 1.3)
27
+ Enabled: true
28
+ Lint/EmptyInPattern: # (new in 1.16)
29
+ Enabled: true
30
+ Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
31
+ Enabled: true
32
+ Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
33
+ Enabled: true
34
+ Lint/NumberedParameterAssignment: # (new in 1.9)
35
+ Enabled: true
36
+ Lint/OrAssignmentToConstant: # (new in 1.9)
37
+ Enabled: true
38
+ Lint/RedundantDirGlobSort: # (new in 1.8)
39
+ Enabled: true
40
+ Lint/SymbolConversion: # (new in 1.9)
41
+ Enabled: true
42
+ Lint/ToEnumArguments: # (new in 1.1)
43
+ Enabled: true
44
+ Lint/TripleQuotes: # (new in 1.9)
45
+ Enabled: true
46
+ Lint/UnexpectedBlockArity: # (new in 1.5)
47
+ Enabled: true
48
+ Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
49
+ Enabled: true
50
+ Style/ArgumentsForwarding: # (new in 1.1)
51
+ Enabled: true
52
+ Style/CollectionCompact: # (new in 1.2)
53
+ Enabled: true
54
+ Style/DocumentDynamicEvalDefinition: # (new in 1.1)
55
+ Enabled: true
56
+ Style/EndlessMethod: # (new in 1.8)
57
+ Enabled: true
58
+ Style/HashConversion: # (new in 1.10)
59
+ Enabled: true
60
+ Style/HashExcept: # (new in 1.7)
61
+ Enabled: true
62
+ Style/IfWithBooleanLiteralBranches: # (new in 1.9)
63
+ Enabled: true
64
+ Style/InPatternThen: # (new in 1.16)
65
+ Enabled: true
66
+ Style/MultilineInPatternThen: # (new in 1.16)
67
+ Enabled: true
68
+ Style/NegatedIfElseCondition: # (new in 1.2)
69
+ Enabled: true
70
+ Style/NilLambda: # (new in 1.3)
71
+ Enabled: true
72
+ Style/QuotedSymbols: # (new in 1.16)
73
+ Enabled: true
74
+ Style/RedundantArgument: # (new in 1.4)
75
+ Enabled: true
76
+ Style/StringChars: # (new in 1.12)
77
+ Enabled: true
78
+ Style/SwapValues: # (new in 1.1)
79
+ Enabled: true
data/README.md CHANGED
@@ -129,6 +129,9 @@ object_client.metadata.dublin_core
129
129
  # Get the public descriptive XML representation
130
130
  object_client.metadata.descriptive
131
131
 
132
+ # Get the public XML representation
133
+ object_client.metadata.public_xml
134
+
132
135
  # Update legacy XML representation
133
136
  object_client.metadata.legacy_update(
134
137
  descriptive: {
@@ -166,10 +169,6 @@ object_client.workspace.create(source: object_path_string)
166
169
  object_client.workspace.cleanup
167
170
  object_client.workspace.reset
168
171
 
169
-
170
- # Update embargo
171
- object_client.embargo.update(embargo_date: date_string, requesting_user: username_string)
172
-
173
172
  # Search for administrative tags:
174
173
  Dor::Services::Client.administrative_tags.search(q: 'Project')
175
174
  ```
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.required_ruby_version = '~> 2.6'
26
26
 
27
27
  spec.add_dependency 'activesupport', '>= 4.2', '< 7'
28
- spec.add_dependency 'cocina-models', '~> 0.57.0' # leave pinned to patch level until cocina-models hits 1.0
28
+ spec.add_dependency 'cocina-models', '~> 0.60.0' # leave pinned to patch level until cocina-models hits 1.0
29
29
  spec.add_dependency 'deprecation', '>= 0'
30
30
  spec.add_dependency 'faraday', '>= 0.15', '< 2'
31
31
  spec.add_dependency 'moab-versioning', '~> 4.0'
@@ -26,11 +26,17 @@ module Dor
26
26
  # Base class for Dor::Services::Client exceptions
27
27
  class Error < StandardError; end
28
28
 
29
- # Error that is raised when the remote server returns a 404 Not Found
29
+ # Error that is raised when the ultimate remote server returns a 404 Not Found for the id in our request (e.g. for druid, barcode, catkey)
30
30
  class NotFoundResponse < Error; end
31
31
 
32
+ # Error that is raised when the remote server returns some unparsable response
33
+ class MalformedResponse < Error; end
34
+
35
+ # Error that wraps Faraday connection exceptions
36
+ class ConnectionFailed < Error; end
37
+
32
38
  # Error that is raised when the remote server returns some unexpected response
33
- # this could be any 4xx or 5xx status
39
+ # this could be any 4xx or 5xx status (except the ones that are direct children of the Error class above)
34
40
  class UnexpectedResponse < Error; end
35
41
 
36
42
  # Error that is raised when the remote server returns a 401 Unauthorized
@@ -39,11 +45,8 @@ module Dor
39
45
  # Error that is raised when the remote server returns a 409 Conflict
40
46
  class ConflictResponse < UnexpectedResponse; end
41
47
 
42
- # Error that is raised when the remote server returns some unparsable response
43
- class MalformedResponse < Error; end
44
-
45
- # Error that wraps Faraday connection exceptions
46
- class ConnectionFailed < Error; end
48
+ # Error that is raised when the remote server returns a 400 Bad Request; apps should not retry the request
49
+ class BadRequestError < UnexpectedResponse; end
47
50
 
48
51
  # @param object_identifier [String] the pid for the object
49
52
  # @raise [ArgumentError] when `object_identifier` is `nil`
@@ -21,6 +21,7 @@ module Dor
21
21
  return resp.body if resp.success? && resp.body.present?
22
22
 
23
23
  # This method needs its own exception handling logic due to how the endpoint service (SearchWorks) operates
24
+ # raise a NotFoundResponse because the resource being requested was not found in the ILS (via dor-services-app)
24
25
  raise NotFoundResponse, ResponseErrorFormatter.format(response: resp) if resp.success? && resp.body.blank?
25
26
 
26
27
  raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp)
@@ -42,10 +43,12 @@ module Dor
42
43
  end
43
44
 
44
45
  # This method needs its own exception handling logic due to how the endpoint service (Symphony) operates
45
- #
46
+
46
47
  # DOR Services App does not respond with a 404 when no match in Symphony.
47
48
  # Rather, it responds with a 500 containing "Record not found in Symphony" in the body.
49
+ # raise a NotFoundResponse because the resource being requested was not found in the ILS (via dor-services-app)
48
50
  raise NotFoundResponse, ResponseErrorFormatter.format(response: resp) if !resp.success? && resp.body.match?(/Record not found in Symphony/)
51
+
49
52
  raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp) unless resp.success?
50
53
 
51
54
  resp.body
@@ -63,6 +63,18 @@ module Dor
63
63
  raise_exception_based_on_response!(resp, object_identifier)
64
64
  end
65
65
 
66
+ # @return [String, NilClass] The public XML representation of the object or nil if response is 404
67
+ # @raise [UnexpectedResponse] on an unsuccessful response from the server
68
+ def public_xml
69
+ resp = connection.get do |req|
70
+ req.url "#{base_path}/public_xml"
71
+ end
72
+ return resp.body if resp.success?
73
+ return if resp.status == 404
74
+
75
+ raise_exception_based_on_response!(resp, object_identifier)
76
+ end
77
+
66
78
  # @return [String, NilClass] the dor object's source MODS XML or nil if response is 404
67
79
  # @raise [UnexpectedResponse] on an unsuccessful response from the server
68
80
  def mods
@@ -39,10 +39,6 @@ module Dor
39
39
  @version ||= ObjectVersion.new(**parent_params)
40
40
  end
41
41
 
42
- def embargo
43
- @embargo ||= Embargo.new(**parent_params)
44
- end
45
-
46
42
  def accession(params = {})
47
43
  @accession ||= Accession.new(**parent_params.merge(params))
48
44
  end
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '6.31.0'
6
+ VERSION = '6.36.0'
7
7
  end
8
8
  end
9
9
  end
@@ -22,10 +22,12 @@ module Dor
22
22
  # rubocop:disable Metrics/MethodLength
23
23
  def raise_exception_based_on_response!(response, object_identifier = nil)
24
24
  exception_class = case response.status
25
- when 404
26
- NotFoundResponse
25
+ when 400
26
+ BadRequestError
27
27
  when 401
28
28
  UnauthorizedResponse
29
+ when 404
30
+ NotFoundResponse
29
31
  when 409
30
32
  ConflictResponse
31
33
  else
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dor-services-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.31.0
4
+ version: 6.36.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  - Michael Giarlo
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-03-30 00:00:00.000000000 Z
12
+ date: 2021-06-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -37,14 +37,14 @@ dependencies:
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.57.0
40
+ version: 0.60.0
41
41
  type: :runtime
42
42
  prerelease: false
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.57.0
47
+ version: 0.60.0
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: deprecation
50
50
  requirement: !ruby/object:Gem::Requirement
@@ -205,7 +205,7 @@ dependencies:
205
205
  - - ">="
206
206
  - !ruby/object:Gem::Version
207
207
  version: '0'
208
- description:
208
+ description:
209
209
  email:
210
210
  - jcoyne@justincoyne.com
211
211
  - leftwing@alumni.rutgers.edu
@@ -234,7 +234,6 @@ files:
234
234
  - lib/dor/services/client/background_job_results.rb
235
235
  - lib/dor/services/client/collections.rb
236
236
  - lib/dor/services/client/connection_wrapper.rb
237
- - lib/dor/services/client/embargo.rb
238
237
  - lib/dor/services/client/error_faraday_middleware.rb
239
238
  - lib/dor/services/client/events.rb
240
239
  - lib/dor/services/client/marcxml.rb
@@ -254,7 +253,7 @@ files:
254
253
  homepage: https://github.com/sul-dlss/dor-services-client
255
254
  licenses: []
256
255
  metadata: {}
257
- post_install_message:
256
+ post_install_message:
258
257
  rdoc_options: []
259
258
  require_paths:
260
259
  - lib
@@ -269,8 +268,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
269
268
  - !ruby/object:Gem::Version
270
269
  version: '0'
271
270
  requirements: []
272
- rubygems_version: 3.0.6
273
- signing_key:
271
+ rubygems_version: 3.1.4
272
+ signing_key:
274
273
  specification_version: 4
275
274
  summary: A client for dor-services-app
276
275
  test_files: []
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Dor
4
- module Services
5
- class Client
6
- # API calls that are about managing embargo on a repository object
7
- class Embargo < 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
- # @param [String] embargo_date The date to update the embargo to (ISO 8601)
15
- # @param [String] requesting_user Who is making this change.
16
- #
17
- # @example
18
- # client.update(embargo_date: '2099-10-20', requesting_user: 'jane')
19
- #
20
- # @raise [UnexpectedResponse] on an unsuccessful response from the server
21
- #
22
- # @return [NilClass] when the update is successful
23
- def update(embargo_date:, requesting_user:)
24
- resp = connection.patch do |req|
25
- req.url path
26
- req.headers['Content-Type'] = 'application/json'
27
- req.body = {
28
- embargo_date: embargo_date,
29
- requesting_user: requesting_user
30
- }.to_json
31
- end
32
- return if resp.success?
33
-
34
- raise_exception_based_on_response!(resp, object_identifier)
35
- end
36
-
37
- private
38
-
39
- attr_reader :object_identifier
40
-
41
- def path
42
- "#{api_version}/objects/#{object_identifier}/embargo"
43
- end
44
- end
45
- end
46
- end
47
- end