dor-services-client 6.35.0 → 7.2.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: 0f284625ef5de76b844cbfa7569c83e1dc7deae5d19c94b4bb845f1cf69bab2e
4
- data.tar.gz: 37cce8c5f6f95008bec16638f4ed2d30dd19ad01e7eb6da5e4b58ac2b330f7b4
3
+ metadata.gz: 26ea6df47f6abced00a0cc0aa06683f0ffffc3b7e09c04df374245ca0e510fa0
4
+ data.tar.gz: a19dfa02264725f02f51713077bc3a391a15c6f26e96dd2074be4546d6dfdc9d
5
5
  SHA512:
6
- metadata.gz: 5b3f568bce673ef4d722d8140a7db715d35234e1312718205d9b352850899b10b59daaac34771ad27efe9a8715b6be5b4ba1c396d6fdc068c17b83e32abb4fcf
7
- data.tar.gz: 5307d1ff1cd2a067168e452996761bb8bfde4b4c62ddf63cc070cb35478fe1dbe6b13fa1f6a3accf9dfc7bc6758dc496acea4cfe111bea4737f47231c4c1835b
6
+ metadata.gz: a53f6fb8e64122cfb94267fad031ed6594fb7df1d9dcb94828e7ad377f31842790faa7d5cabbdc6bba9425013075639f0b7b06c1f72a08c9d0466d0ea6572568
7
+ data.tar.gz: f78536e5a84e2579eabcf662b445090889748576ff9fa9a8d0a2445052712929f49f46695f0cd068f9afc8b4968ee566fbca98c40f3668511278b6b14f108548
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
@@ -61,6 +61,7 @@ objects_client = Dor::Services::Client.objects
61
61
 
62
62
  # Register a non-existent object
63
63
  objects_client.register(params: {})
64
+ objects_client.register(params: {}, assign_doi: true)
64
65
 
65
66
  # Interact with virtual objects
66
67
  virtual_objects_client = Dor::Services::Client.virtual_objects
@@ -156,10 +157,6 @@ object_client.administrative_tags.update(current: 'Current : Tag', new: 'Replace
156
157
  object_client.administrative_tags.destroy(tag: 'Delete : Me')
157
158
  object_client.administrative_tags.list
158
159
 
159
- # Create and list release tags for an object
160
- object_client.release_tags.create(release: release, what: what, to: to, who: who)
161
- object_client.release_tags.list
162
-
163
160
  # Create and list events for an object
164
161
  object_client.events.create(type: type, data: data)
165
162
  object_client.events.list
@@ -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.60.0' # leave pinned to patch level until cocina-models hits 1.0
28
+ spec.add_dependency 'cocina-models', '~> 0.61.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
@@ -27,10 +27,6 @@ module Dor
27
27
  @workspace ||= Workspace.new(**parent_params)
28
28
  end
29
29
 
30
- def release_tags
31
- @release_tags ||= ReleaseTags.new(**parent_params)
32
- end
33
-
34
30
  def administrative_tags
35
31
  @administrative_tags ||= AdministrativeTags.new(**parent_params)
36
32
  end
@@ -108,6 +104,18 @@ module Dor
108
104
  raise_exception_based_on_response!(resp)
109
105
  end
110
106
 
107
+ # Update the DOI metadata at DataCite
108
+ # @raise [NotFoundResponse] when the response is a 404 (object not found)
109
+ # @return [boolean] true on success
110
+ def update_doi_metadata
111
+ resp = connection.post do |req|
112
+ req.url "#{object_path}/update_doi_metadata"
113
+ end
114
+ return true if resp.success?
115
+
116
+ raise_exception_based_on_response!(resp)
117
+ end
118
+
111
119
  # Notify the external Goobi system for a new object that was registered in DOR
112
120
  # @raise [NotFoundResponse] when the response is a 404 (object not found)
113
121
  # @raise [UnexpectedResponse] when the response is not successful.
@@ -8,10 +8,11 @@ module Dor
8
8
  # API calls that are about a repository objects
9
9
  class Objects < VersionedService
10
10
  # Creates a new object in DOR
11
- # @param [Cocina::Models::RequestDRO,Cocina::Models::RequestCollection,Cocina::Models::RequestAPO]
11
+ # @param params [Cocina::Models::RequestDRO,Cocina::Models::RequestCollection,Cocina::Models::RequestAPO]
12
+ # @param assign_doi [Boolean]
12
13
  # @return [Cocina::Models::RequestDRO,Cocina::Models::RequestCollection,Cocina::Models::RequestAPO] the returned model
13
- def register(params:)
14
- json_str = register_response(params: params)
14
+ def register(params:, assign_doi: false)
15
+ json_str = register_response(params: params, assign_doi: assign_doi)
15
16
  json = JSON.parse(json_str)
16
17
 
17
18
  Cocina::Models.build(json)
@@ -21,14 +22,16 @@ module Dor
21
22
 
22
23
  # make the registration request to the server
23
24
  # @param params [Hash] optional params (see dor-services-app)
25
+ # @param assign_doi [Boolean]
24
26
  # @raise [UnexpectedResponse] on an unsuccessful response from the server
25
27
  # @return [String] the raw JSON from the server
26
- def register_response(params:)
28
+ def register_response(params:, assign_doi:)
27
29
  resp = connection.post do |req|
28
30
  req.url "#{api_version}/objects"
29
31
  req.headers['Content-Type'] = 'application/json'
30
32
  # asking the service to return JSON (else it'll be plain text)
31
33
  req.headers['Accept'] = 'application/json'
34
+ req.params[:assign_doi] = true if assign_doi
32
35
  req.body = params.to_json
33
36
  end
34
37
  return resp.body if resp.success?
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '6.35.0'
6
+ VERSION = '7.2.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,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.35.0
4
+ version: 7.2.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-06-07 00:00:00.000000000 Z
12
+ date: 2021-07-15 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.60.0
40
+ version: 0.61.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.60.0
47
+ version: 0.61.0
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: deprecation
50
50
  requirement: !ruby/object:Gem::Requirement
@@ -243,7 +243,6 @@ files:
243
243
  - lib/dor/services/client/object.rb
244
244
  - lib/dor/services/client/object_version.rb
245
245
  - lib/dor/services/client/objects.rb
246
- - lib/dor/services/client/release_tags.rb
247
246
  - lib/dor/services/client/response_error_formatter.rb
248
247
  - lib/dor/services/client/transfer.rb
249
248
  - lib/dor/services/client/version.rb
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Dor
4
- module Services
5
- class Client
6
- # API calls that are about a repository object
7
- class ReleaseTags < 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
- # Creates a new release tag for the object
15
- # @param release [Boolean]
16
- # @param what [String]
17
- # @param to [String]
18
- # @param who [String]
19
- # @return [Boolean] true if successful
20
- # @raise [NotFoundResponse] when the response is a 404 (object not found)
21
- # @raise [UnexpectedResponse] if the request is unsuccessful.
22
- # rubocop:disable Metrics/MethodLength
23
- def create(release:, what:, to:, who:)
24
- params = {
25
- to: to,
26
- who: who,
27
- what: what,
28
- release: release
29
- }
30
- resp = connection.post do |req|
31
- req.url "#{api_version}/objects/#{object_identifier}/release_tags"
32
- req.headers['Content-Type'] = 'application/json'
33
- req.body = params.to_json
34
- end
35
- raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
36
-
37
- true
38
- end
39
- # rubocop:enable Metrics/MethodLength
40
-
41
- # List new release tags for the object
42
- # @raise [NotFoundResponse] when the response is a 404 (object not found)
43
- # @raise [UnexpectedResponse] if the request is unsuccessful.
44
- # @return [Hash] (see Dor::ReleaseTags::IdentityMetadata.released_for)
45
- def list
46
- resp = connection.get do |req|
47
- req.url "#{api_version}/objects/#{object_identifier}/release_tags"
48
- end
49
-
50
- raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
51
-
52
- JSON.parse(resp.body)
53
- end
54
-
55
- private
56
-
57
- attr_reader :object_identifier
58
- end
59
- end
60
- end
61
- end