dor-services-client 9.1.0 → 10.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4b8ec2c059acbd588a6d64e931035f5552b16bacf9d0e6a1f0b8194fb371bb2
4
- data.tar.gz: 750be3e2a2a234299c63ee1aeb6b40c4a0a87116785cf085bc359d80676465da
3
+ metadata.gz: 7d5e8a1919cb3cf3e1ad0ae59f1d29a0a30d181d330146ddb0cc8a580f5e37a8
4
+ data.tar.gz: abc969bfa3b1aae80c666d5ab244ca8ca3ebf2bbfe73fde20dabeffa8dfdefea
5
5
  SHA512:
6
- metadata.gz: d0ffa417486e6136c276b2aa289d4f17e01a798ea288e727ce5b2955b722934ce7b992318ff3c88e3060a57a7cfd2a203b29d0302c6862d79cce80e6f4bab1d9
7
- data.tar.gz: f707910e959af48ab45e29a4328217517b42c50f49314ff14e142afed33688d842b2ecfc9df8ea740e59914c31cbbd4d5b5dbff67cbb7b6e1b64e197a7aa1618
6
+ metadata.gz: 969b9fde995a8598ef1fa33c6aefb18e0fae6aa42fb38ff30ed1c8e6e939622e45921d5c26dbcf19668eb52930a81fd18e44e005345ee51a98da80dcde5f2fe9
7
+ data.tar.gz: edfe4f38b84cde8a1da06b527d16d1b8a46ccba945db6944809bc1d9748f56d328e449d3921668018e1bc966812a123a70a3508858331e9ac6892992e02f0391
data/.rubocop.yml CHANGED
@@ -13,7 +13,7 @@ Metrics/BlockLength:
13
13
  - 'spec/**/*'
14
14
 
15
15
  RSpec/MultipleMemoizedHelpers:
16
- Max: 10
16
+ Enabled: false
17
17
 
18
18
  RSpec/ExampleLength:
19
19
  Max: 10
data/README.md CHANGED
@@ -123,9 +123,11 @@ object_client.notify_goobi
123
123
  # Manage versions
124
124
  object_client.version.inventory
125
125
  object_client.version.current
126
- object_client.version.openable?(**params)
127
- object_client.version.open(**params)
128
- object_client.version.close(description: 'Changed title', significance: 'minor')
126
+ object_client.version.openable?
127
+ # see dor-services-app openapi.yml for optional params
128
+ object_client.version.open(description: 'Changed title', significance: 'minor')
129
+ # see dor-services-app openapi.yml for optional params
130
+ object_client.version.close
129
131
 
130
132
  # Get the Dublin Core XML representation
131
133
  object_client.metadata.dublin_core
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.required_ruby_version = '>= 2.7', '< 4' # dor-services-app needs 2.7 due to fedora3
26
26
 
27
27
  spec.add_dependency 'activesupport', '>= 4.2', '< 8'
28
- spec.add_dependency 'cocina-models', '~> 0.75.0' # leave pinned to patch level until cocina-models hits 1.0
28
+ spec.add_dependency 'cocina-models', '~> 0.76.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', '~> 2.0'
31
31
  spec.add_dependency 'faraday-retry'
@@ -15,10 +15,10 @@ module Dor
15
15
 
16
16
  # Start accession on an object (start specified workflow, assemblyWF by default, and version if needed)
17
17
  # @param params [Hash<Symbol,String>] optional parameter hash
18
- # @option params [String] :significance set significance (major/minor/patch) of version change
19
- # @option params [String] :description set description of version change
20
- # @option params [String] :opening_user_name add opening username to the events datastream
21
- # @option params [String] :workflow the workflow to start (defaults to 'assemblyWF')
18
+ # @option params [String] :significance set significance (major/minor/patch) of version change - required
19
+ # @option params [String] :description set description of version change - required
20
+ # @option params [String] :opening_user_name add opening username to the events datastream - optional
21
+ # @option params [String] :workflow the workflow to start - defaults to 'assemblyWF'
22
22
  # @return [Boolean] true on success
23
23
  # @raise [NotFoundResponse] when the response is a 404 (object not found)
24
24
  # @raise [UnexpectedResponse] when the response is not successful.
@@ -33,7 +33,10 @@ module Dor
33
33
  # @raise [BadRequestError] when ETag not provided.
34
34
  # @return [Cocina::Models::DROWithMetadata,Cocina::Models::CollectionWithMetadata,Cocina::Models::AdminPolicyWithMetadata] the returned model
35
35
  # rubocop:disable Metrics/AbcSize
36
+ # rubocop:disable Metrics/MethodLength
36
37
  def update(params:, skip_lock: false)
38
+ raise ArgumentError, 'Cocina object not provided.' unless params.respond_to?(:externalIdentifier)
39
+
37
40
  # Raised if Cocina::Models::*WithMetadata not provided.
38
41
  raise ArgumentError, 'ETag not provided.' unless skip_lock || params.respond_to?(:lock)
39
42
 
@@ -42,7 +45,7 @@ module Dor
42
45
  req.headers['Content-Type'] = 'application/json'
43
46
  # asking the service to return JSON (else it'll be plain text)
44
47
  req.headers['Accept'] = 'application/json'
45
- req.headers['If-Match'] = params[:lock] unless skip_lock
48
+ req.headers['If-Match'] = params.lock unless skip_lock
46
49
  req.body = build_json_from_cocina(params)
47
50
  end
48
51
 
@@ -51,6 +54,7 @@ module Dor
51
54
  build_cocina_from_response(resp)
52
55
  end
53
56
  # rubocop:enable Metrics/AbcSize
57
+ # rubocop:enable Metrics/MethodLength
54
58
 
55
59
  # Pull in metadata from Symphony and updates descriptive metadata
56
60
  # @raise [NotFoundResponse] when the response is a 404 (object not found)
@@ -27,15 +27,13 @@ module Dor
27
27
  end
28
28
 
29
29
  # Determines if a new version can be opened for a DOR object.
30
- # @param params [Hash] optional params (see dor-services-app)
31
30
  # @raise [NotFoundResponse] when the response is a 404 (object not found)
32
31
  # @raise [UnexpectedResponse] when the response is not successful.
33
32
  # @return [Boolean] true if a new version can be opened
34
33
  # rubocop:disable Metrics/MethodLength
35
- def openable?(**params)
34
+ def openable?
36
35
  resp = connection.get do |req|
37
36
  req.url "#{base_path}/openable"
38
- req.params = params
39
37
  end
40
38
 
41
39
  raise_exception_based_on_response!(resp) unless resp.success?
@@ -52,20 +50,30 @@ module Dor
52
50
  # rubocop:enable Metrics/MethodLength
53
51
 
54
52
  # Open new version for an object
55
- # @param params [Hash] optional params (see dor-services-app)
56
- # @raise [MalformedResponse] when the response is not parseable.
53
+ # @param description [String] a description of the object version being opened - required
54
+ # @param significance [String] 'major' 'minor' or 'admin' - required
55
+ # @param opening_user_name [String] sunetid - defaults to nil
56
+ # @param assume_accessioned [Boolean] if true, does not check whether object has been accessioned; defaults to false
57
57
  # @raise [NotFoundResponse] when the response is a 404 (object not found)
58
58
  # @raise [UnexpectedResponse] when the response is not successful.
59
- # @return [String] the current version
59
+ # @return [Cocina::Models::DROWithMetadata|CollectionWithMetadata|AdminPolicyWithMetadata] cocina model with updated version
60
60
  def open(**params)
61
- version = open_new_version_response(**params)
62
- raise MalformedResponse, "Version of #{object_identifier} is empty" if version.empty?
61
+ resp = connection.post do |req|
62
+ req.url open_new_version_path
63
+ req.headers['Content-Type'] = 'application/json'
64
+ req.body = params.to_json if params.any?
65
+ end
63
66
 
64
- version
67
+ raise_exception_based_on_response!(resp) unless resp.success?
68
+
69
+ build_cocina_from_response(resp)
65
70
  end
66
71
 
67
72
  # Close current version for an object
68
- # @param params [Hash] optional params (see dor-services-app)
73
+ # @param description [String] (optional) - a description of the object version being opened
74
+ # @param significance [String] (optional) - 'major' 'minor' or 'admin'
75
+ # @param user_name [String] (optional) - sunetid
76
+ # @param start_accession [Boolean] (optional) - whether to start accessioning workflow; defaults to true
69
77
  # @raise [NotFoundResponse] when the response is a 404 (object not found)
70
78
  # @raise [UnexpectedResponse] when the response is not successful.
71
79
  # @return [String] a message confirming successful closing
@@ -99,22 +107,6 @@ module Dor
99
107
  "#{api_version}/objects/#{object_identifier}"
100
108
  end
101
109
 
102
- # Make request to server to open a new version
103
- # @param params [Hash] optional params (see dor-services-app)
104
- # @raise [NotFoundResponse] when the response is a 404 (object not found)
105
- # @raise [UnexpectedResponse] on an unsuccessful response from the server
106
- # @return [String] the plain text from the server
107
- def open_new_version_response(**params)
108
- resp = connection.post do |req|
109
- req.url open_new_version_path
110
- req.headers['Content-Type'] = 'application/json'
111
- req.body = params.to_json if params.any?
112
- end
113
- return resp.body if resp.success?
114
-
115
- raise_exception_based_on_response!(resp)
116
- end
117
-
118
110
  def base_path
119
111
  "#{object_path}/versions"
120
112
  end
@@ -8,9 +8,9 @@ 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 params [Cocina::Models::RequestDRO,Cocina::Models::RequestCollection,Cocina::Models::RequestAPO]
11
+ # @param params [Cocina::Models::RequestDRO,Cocina::Models::RequestCollection,Cocina::Models::RequestAdminPolicy]
12
12
  # @param assign_doi [Boolean]
13
- # @return [Cocina::Models::RequestDRO,Cocina::Models::RequestCollection,Cocina::Models::RequestAPO] the returned model
13
+ # @return [Cocina::Models::DROWithMetadata,Cocina::Models::CollectionWithMetadata,Cocina::Models::AdminPolicyWithMetadata] the returned model
14
14
  def register(params:, assign_doi: false)
15
15
  resp = connection.post do |req|
16
16
  req.url "#{api_version}/objects"
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '9.1.0'
6
+ VERSION = '10.1.0'
7
7
  end
8
8
  end
9
9
  end
@@ -13,6 +13,8 @@ module Dor
13
13
  412 => PreconditionFailedResponse
14
14
  }.freeze
15
15
 
16
+ JSON_API_MIME_TYPE = 'application/vnd.api+json'
17
+
16
18
  def initialize(connection:, version:)
17
19
  @connection = connection
18
20
  @api_version = version
@@ -28,7 +30,7 @@ module Dor
28
30
  attr_reader :connection, :api_version
29
31
 
30
32
  def raise_exception_based_on_response!(response, object_identifier = nil)
31
- data = if response.headers['content-type'] == 'application/json'
33
+ data = if response.headers.fetch('content-type', '').start_with?(JSON_API_MIME_TYPE)
32
34
  JSON.parse(response.body)
33
35
  else
34
36
  {}
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: 9.1.0
4
+ version: 10.1.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: 2022-04-20 00:00:00.000000000 Z
12
+ date: 2022-04-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.75.0
40
+ version: 0.76.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.75.0
47
+ version: 0.76.0
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: deprecation
50
50
  requirement: !ruby/object:Gem::Requirement
@@ -213,7 +213,7 @@ dependencies:
213
213
  - - ">="
214
214
  - !ruby/object:Gem::Version
215
215
  version: '0'
216
- description:
216
+ description:
217
217
  email:
218
218
  - jcoyne@justincoyne.com
219
219
  - leftwing@alumni.rutgers.edu
@@ -262,7 +262,7 @@ homepage: https://github.com/sul-dlss/dor-services-client
262
262
  licenses: []
263
263
  metadata:
264
264
  rubygems_mfa_required: 'true'
265
- post_install_message:
265
+ post_install_message:
266
266
  rdoc_options: []
267
267
  require_paths:
268
268
  - lib
@@ -280,8 +280,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
280
280
  - !ruby/object:Gem::Version
281
281
  version: '0'
282
282
  requirements: []
283
- rubygems_version: 3.3.7
284
- signing_key:
283
+ rubygems_version: 3.1.4
284
+ signing_key:
285
285
  specification_version: 4
286
286
  summary: A client for dor-services-app
287
287
  test_files: []