dor-services-client 10.2.0 → 12.1.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: 06256135ae4d1e556af51bd67aa764f3bdf4095503b5e7c41daf9fa32093be49
4
- data.tar.gz: 9007c044ff70251c24b9216b447b4190c4162b4f97b8ce2d8c488223d75d0d92
3
+ metadata.gz: 60325a5c1cf8adb36234b64f76d44b3a0bfd35f432bc015c709a093127cb5280
4
+ data.tar.gz: 54a8ca1543a6c04c2e5d706f1ccff2a36d3b2e58b578da6416a88361caedc199
5
5
  SHA512:
6
- metadata.gz: 5ec452bfeb53407eed48aa5342a339e4137c95542547fcf098c7b9d91ba9cb0930e1afb3d42a2ce5c6e6bc0a779e6bd4555250cdb4fb37d566eb1d034b450f4f
7
- data.tar.gz: eda0ad02dec02532b6430a46d997d9df4d5aeb963274efd9f08fedbb645d41721b81791d6a7641b7bd0e9834e9a02bafc8ae9e1ce4ece19e747a61b253351837
6
+ metadata.gz: 69b8b22b5fcef3eb6da7979bdf1134297ee1ec241aa2f547c919526be53d45e390cc1237524f47e4c728555f23c9a59a7ab58d21bd9af9121482110985dd1254
7
+ data.tar.gz: ebe5b8069b3649324115218bd35249cbb16030ee9d6e3096f8e46bfd468ea8aa4ac3293a519478ce3c36edaba292dbf536bb0e0a6a1ff48a05a26a2ff92ac606
data/README.md CHANGED
@@ -138,14 +138,6 @@ object_client.metadata.descriptive
138
138
  # Get the public XML representation
139
139
  object_client.metadata.public_xml
140
140
 
141
- # Update legacy XML representation
142
- object_client.metadata.legacy_update(
143
- descriptive: {
144
- updated: Time.now,
145
- content: '<descMetadata/>'
146
- }
147
- )
148
-
149
141
  # Return the Cocina metadata
150
142
  object_client.find
151
143
 
@@ -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.77.0' # leave pinned to patch level until cocina-models hits 1.0
28
+ spec.add_dependency 'cocina-models', '~> 0.80.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'
@@ -17,7 +17,7 @@ module Dor
17
17
  # @param params [Hash<Symbol,String>] optional parameter hash
18
18
  # @option params [String] :significance set significance (major/minor/patch) of version change - required
19
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
20
+ # @option params [String] :opening_user_name add opening username to the event - optional
21
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)
@@ -13,32 +13,6 @@ module Dor
13
13
  @object_identifier = object_identifier
14
14
  end
15
15
 
16
- # Updates using the legacy SDR/Fedora3 metadata
17
- # @param [Hash<Symbol,Hash>] opts the options for legacy update
18
- # @option opts [Hash] :administrative Data for administrative metadata
19
- # @option opts [Hash] :content Data for structural metadata
20
- # @option opts [Hash] :descriptive Data for descriptive metadata
21
- # @option opts [Hash] :geo Data for geographic metadata
22
- # @option opts [Hash] :identity Data for identity metadata
23
- # @option opts [Hash] :provenance Data for provenance metadata
24
- # @option opts [Hash] :relationships Data for RELS-EXT metadata
25
- # @option opts [Hash] :rights Data for access rights metadata
26
- # @option opts [Hash] :technical Data for technical metadata
27
- # @option opts [Hash] :version Data for version metadata
28
- # @example:
29
- # legacy_update(descriptive: { updated: '2001-12-20', content: '<descMetadata />' })
30
- def legacy_update(opts)
31
- opts = opts.slice(:administrative, :content, :descriptive, :geo, :identity, :provenance, :relationships, :rights, :technical, :version)
32
- resp = connection.patch do |req|
33
- req.url "#{base_path}/legacy"
34
- req.headers['Content-Type'] = 'application/json'
35
- req.body = opts.to_json
36
- end
37
- return if resp.success?
38
-
39
- raise_exception_based_on_response!(resp, object_identifier)
40
- end
41
-
42
16
  # @return [String, NilClass] The Dublin Core XML representation of the object or nil if response is 404
43
17
  # @raise [UnexpectedResponse] on an unsuccessful response from the server
44
18
  def dublin_core
@@ -87,47 +61,6 @@ module Dor
87
61
  raise_exception_based_on_response!(resp, object_identifier)
88
62
  end
89
63
 
90
- # Update the MODS XML metadata
91
- # @raise [NotFoundResponse] when the response is a 404 (object not found)
92
- # @return [boolean] true on success
93
- def update_mods(mods_xml)
94
- resp = connection.put do |req|
95
- req.url "#{base_path}/mods"
96
- req.headers['Content-Type'] = 'application/xml'
97
- req.body = mods_xml
98
- end
99
- return if resp.success?
100
-
101
- raise_exception_based_on_response!(resp, object_identifier)
102
- end
103
-
104
- # rubocop:disable Lint/StructNewOverride
105
- Datastream = Struct.new(:label, :dsid, :pid, :size, :mimeType, :versionId, keyword_init: true)
106
- # rubocop:enable Lint/StructNewOverride
107
-
108
- # @return [Array] the list of datastreams for the item
109
- # @raise [UnexpectedResponse] on an unsuccessful response from the server
110
- def datastreams
111
- resp = connection.get do |req|
112
- req.url "#{base_path}/datastreams"
113
- end
114
- raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
115
-
116
- JSON.parse(resp.body).map { |params| Datastream.new(**params.symbolize_keys!) }
117
- end
118
-
119
- # @param [String] dsid the identifier for the datastream
120
- # @return [String] the contents of the specified datastream
121
- # @raise [UnexpectedResponse] on an unsuccessful response from the server
122
- def datastream(dsid)
123
- resp = connection.get do |req|
124
- req.url "#{base_path}/datastreams/#{dsid}"
125
- end
126
- raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
127
-
128
- resp.body
129
- end
130
-
131
64
  private
132
65
 
133
66
  attr_reader :object_identifier
@@ -28,13 +28,14 @@ module Dor
28
28
  # Updates the object
29
29
  # @param [Cocina::Models::DROWithMetadata|CollectionWithMetadata|AdminPolicyWithMetadata|DRO|Collection|AdminPolicy] params model object
30
30
  # @param [boolean] skip_lock do not provide ETag
31
+ # @param [boolean] validate validate the response object
31
32
  # @raise [NotFoundResponse] when the response is a 404 (object not found)
32
33
  # @raise [UnexpectedResponse] when the response is not successful.
33
34
  # @raise [BadRequestError] when ETag not provided.
34
35
  # @return [Cocina::Models::DROWithMetadata,Cocina::Models::CollectionWithMetadata,Cocina::Models::AdminPolicyWithMetadata] the returned model
35
36
  # rubocop:disable Metrics/AbcSize
36
37
  # rubocop:disable Metrics/MethodLength
37
- def update(params:, skip_lock: false)
38
+ def update(params:, skip_lock: false, validate: false)
38
39
  raise ArgumentError, 'Cocina object not provided.' unless params.respond_to?(:externalIdentifier)
39
40
 
40
41
  # Raised if Cocina::Models::*WithMetadata not provided.
@@ -51,7 +52,7 @@ module Dor
51
52
 
52
53
  raise_exception_based_on_response!(resp) unless resp.success?
53
54
 
54
- build_cocina_from_response(resp)
55
+ build_cocina_from_response(resp, validate: validate)
55
56
  end
56
57
  # rubocop:enable Metrics/AbcSize
57
58
  # rubocop:enable Metrics/MethodLength
@@ -43,16 +43,17 @@ module Dor
43
43
  end
44
44
 
45
45
  # Retrieves the Cocina model
46
+ # @param [boolean] validate validate the response object
46
47
  # @raise [NotFoundResponse] when the response is a 404 (object not found)
47
48
  # @raise [UnexpectedResponse] when the response is not successful.
48
49
  # @return [Cocina::Models::DROWithMetadata,Cocina::Models::CollectionWithMetadata,Cocina::Models::AdminPolicyWithMetadata] the returned model
49
- def find
50
+ def find(validate: false)
50
51
  resp = connection.get do |req|
51
52
  req.url object_path
52
53
  end
53
54
  raise_exception_based_on_response!(resp) unless resp.success?
54
55
 
55
- build_cocina_from_response(resp)
56
+ build_cocina_from_response(resp, validate: validate)
56
57
  end
57
58
 
58
59
  # Get a list of the collections. (Similar to Valkyrie's find_inverse_references_by)
@@ -10,8 +10,9 @@ module Dor
10
10
  # Creates a new object in DOR
11
11
  # @param params [Cocina::Models::RequestDRO,Cocina::Models::RequestCollection,Cocina::Models::RequestAdminPolicy]
12
12
  # @param assign_doi [Boolean]
13
+ # @param [boolean] validate validate the response object
13
14
  # @return [Cocina::Models::DROWithMetadata,Cocina::Models::CollectionWithMetadata,Cocina::Models::AdminPolicyWithMetadata] the returned model
14
- def register(params:, assign_doi: false)
15
+ def register(params:, assign_doi: false, validate: false)
15
16
  resp = connection.post do |req|
16
17
  req.url "#{api_version}/objects"
17
18
  req.headers['Content-Type'] = 'application/json'
@@ -23,7 +24,7 @@ module Dor
23
24
 
24
25
  raise_exception_based_on_response!(resp) unless resp.success?
25
26
 
26
- build_cocina_from_response(resp)
27
+ build_cocina_from_response(resp, validate: validate)
27
28
  end
28
29
  end
29
30
  end
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '10.2.0'
6
+ VERSION = '12.1.0'
7
7
  end
8
8
  end
9
9
  end
@@ -41,8 +41,8 @@ module Dor
41
41
  errors: data.fetch('errors', []))
42
42
  end
43
43
 
44
- def build_cocina_from_response(response)
45
- cocina_object = Cocina::Models.build(JSON.parse(response.body))
44
+ def build_cocina_from_response(response, validate: false)
45
+ cocina_object = Cocina::Models.build(JSON.parse(response.body), validate: validate)
46
46
  Cocina::Models.with_metadata(cocina_object, response.headers['ETag'], created: date_from_header(response, 'X-Created-At'),
47
47
  modified: date_from_header(response, 'Last-Modified'))
48
48
  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: 10.2.0
4
+ version: 12.1.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: 2022-05-02 00:00:00.000000000 Z
12
+ date: 2022-05-13 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.77.0
40
+ version: 0.80.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.77.0
47
+ version: 0.80.0
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: deprecation
50
50
  requirement: !ruby/object:Gem::Requirement
@@ -279,7 +279,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
279
279
  - !ruby/object:Gem::Version
280
280
  version: '0'
281
281
  requirements: []
282
- rubygems_version: 3.2.32
282
+ rubygems_version: 3.3.4
283
283
  signing_key:
284
284
  specification_version: 4
285
285
  summary: A client for dor-services-app