dor-services-client 7.7.1 → 7.11.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: 8d879cd3b73b2dba4e04252bc66d32552a2ddbcb8935a4f59136d08a9741fa54
4
- data.tar.gz: 6b6f48eb757a52ad7aa4f8b60abc8d8798131a31281018373725d14ce57cc0dd
3
+ metadata.gz: 5daa536eed5f0cf1c7ddaeed7c159d8b7b8f55f9e82321cc9aac567f1133caf6
4
+ data.tar.gz: dda62da3d92bf55455fc568c458c48c63f4081ba4a12b7d25020f459cfa150ad
5
5
  SHA512:
6
- metadata.gz: d050e0e58cd9b00aef611e2ceef7766d6c607536c94c03fbc5bb30123e084e72338ae22e073c2686b31ac3dd9ac7dae55a24557e6c472656575264f1c9ca5045
7
- data.tar.gz: 2b9aef700ce2328cf8267685d82507cecc4dd5200b11dd4d76107bcb30e97b2ee045f35ba543e4a43d422baec6dd4d44be2b5bb5091447a3b085b1823b5d9055
6
+ metadata.gz: 62d5bd30f16a862494570bb511da48a6bbf4f4c9d4cace4485f69e6c0dab71e91c5d404fb21c5e8622eb549392d17c568992b43180189103c42f9c95bc9b5caa
7
+ data.tar.gz: 3aaef88355a8a3e04d0a7fe37276b69f534ae1772bb6be365706d25eb440385a415c1367c1eb0e248ea3353c966a1788c96c0efb08e45f03a597ba813e37b2d1
data/README.md CHANGED
@@ -112,7 +112,7 @@ object_client.preserve(lane_id: 'low')
112
112
  object_client.update_marc_record
113
113
 
114
114
  # Copy metadata from Symphony into descMetadata
115
- object_client.refresh_metadata
115
+ object_client.refresh_descriptive_metadata_from_ils
116
116
 
117
117
  # Apply defaults from the item's AdminPolicy to the item itself
118
118
  object_client.apply_admin_policy_defaults
@@ -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.63.1' # leave pinned to patch level until cocina-models hits 1.0
28
+ spec.add_dependency 'cocina-models', '~> 0.65.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 'zeitwerk', '~> 2.1'
@@ -87,6 +87,20 @@ module Dor
87
87
  raise_exception_based_on_response!(resp, object_identifier)
88
88
  end
89
89
 
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
+
90
104
  # rubocop:disable Lint/StructNewOverride
91
105
  Datastream = Struct.new(:label, :dsid, :pid, :size, :mimeType, :versionId, keyword_init: true)
92
106
  # rubocop:enable Lint/StructNewOverride
@@ -26,7 +26,7 @@ module Dor
26
26
  end
27
27
 
28
28
  # Updates the object
29
- # @param [Cocina::Models::RequestDRO,Cocina::Models::RequestCollection,Cocina::Models::RequestAPO] params model object
29
+ # @param [Cocina::Models::DRO,Cocina::Models::Collection,Cocina::Models::AdminPolicy] params model object
30
30
  # @raise [NotFoundResponse] when the response is a 404 (object not found)
31
31
  # @raise [UnexpectedResponse] when the response is not successful.
32
32
  # @return [Cocina::Models::DRO,Cocina::Models::Collection,Cocina::Models::AdminPolicy] the returned model
@@ -48,7 +48,7 @@ module Dor
48
48
  # @raise [NotFoundResponse] when the response is a 404 (object not found)
49
49
  # @raise [UnexpectedResponse] when the response is not successful.
50
50
  # @return [boolean] true on success
51
- def refresh_metadata
51
+ def refresh_descriptive_metadata_from_ils
52
52
  resp = connection.post do |req|
53
53
  req.url "#{object_path}/refresh_metadata"
54
54
  end
@@ -1,10 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'deprecation'
4
+
3
5
  module Dor
4
6
  module Services
5
7
  class Client
6
8
  # API calls that are about a repository object
7
9
  class Object < VersionedService
10
+ extend Deprecation
8
11
  attr_reader :object_identifier
9
12
 
10
13
  # @param object_identifier [String] the pid for the object
@@ -50,8 +53,8 @@ module Dor
50
53
  # Retrieves the Cocina model and response metadata
51
54
  # @raise [NotFoundResponse] when the response is a 404 (object not found)
52
55
  # @raise [UnexpectedResponse] when the response is not successful.
53
- # @return [Array<Cocina::Models::DRO,Cocina::Models::Collection,Cocina::Models::AdminPolicy,Hash>] a tuple where
54
- # the first is the model and the second is a hash of metadata
56
+ # @return [Array<Cocina::Models::DRO,Cocina::Models::Collection,Cocina::Models::AdminPolicy,ObjectMetadata>] a tuple where
57
+ # the first is the model and the second is a ObjectMetadata object
55
58
  def find_with_metadata
56
59
  resp = connection.get do |req|
57
60
  req.url object_path
@@ -61,7 +64,7 @@ module Dor
61
64
  model = Cocina::Models.build(JSON.parse(resp.body))
62
65
 
63
66
  # Don't use #slice here as Faraday will downcase the keys.
64
- metadata = { 'Last-Modified' => resp.headers['Last-Modified'] }
67
+ metadata = ObjectMetadata.new(updated_at: resp.headers['Last-Modified'], created_at: resp.headers['X-Created-At'])
65
68
  [model, metadata]
66
69
  end
67
70
 
@@ -89,7 +92,10 @@ module Dor
89
92
  Mutate.new(**parent_params)
90
93
  end
91
94
 
92
- delegate :refresh_metadata, :update, :destroy, :apply_admin_policy_defaults, to: :mutate
95
+ delegate :refresh_descriptive_metadata_from_ils, :update, :destroy, :apply_admin_policy_defaults, to: :mutate
96
+
97
+ alias refresh_metadata refresh_descriptive_metadata_from_ils
98
+ deprecation_deprecate refresh_metadata: 'Use refresh_descriptive_metadata_from_ils instead'
93
99
 
94
100
  # Update the marc record for the given object
95
101
  # @raise [NotFoundResponse] when the response is a 404 (object not found)
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'deprecation'
4
+
5
+ module Dor
6
+ module Services
7
+ class Client
8
+ # An object representing metadata about the cocina object returned by the object show method
9
+ class ObjectMetadata
10
+ extend Deprecation
11
+
12
+ attr_reader :created_at, :updated_at
13
+
14
+ def initialize(created_at:, updated_at:)
15
+ @created_at = created_at
16
+ @updated_at = updated_at
17
+ end
18
+
19
+ def [](key)
20
+ case key
21
+ when 'Last-Modified'
22
+ updated_at
23
+ when 'X-Created-At'
24
+ created_at
25
+ else
26
+ raise KeyError, 'Unknown key'
27
+ end
28
+ end
29
+ deprecation_deprecate(:[] => 'Hash accessor is no longer used, use object accessor instead')
30
+ end
31
+ end
32
+ end
33
+ end
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '7.7.1'
6
+ VERSION = '7.11.0'
7
7
  end
8
8
  end
9
9
  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: 7.7.1
4
+ version: 7.11.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-01-20 00:00:00.000000000 Z
12
+ date: 2022-02-08 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.63.1
40
+ version: 0.65.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.63.1
47
+ version: 0.65.0
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: deprecation
50
50
  requirement: !ruby/object:Gem::Requirement
@@ -241,6 +241,7 @@ files:
241
241
  - lib/dor/services/client/metadata.rb
242
242
  - lib/dor/services/client/mutate.rb
243
243
  - lib/dor/services/client/object.rb
244
+ - lib/dor/services/client/object_metadata.rb
244
245
  - lib/dor/services/client/object_version.rb
245
246
  - lib/dor/services/client/objects.rb
246
247
  - lib/dor/services/client/response_error_formatter.rb
@@ -271,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
271
272
  - !ruby/object:Gem::Version
272
273
  version: '0'
273
274
  requirements: []
274
- rubygems_version: 3.1.4
275
+ rubygems_version: 3.2.32
275
276
  signing_key:
276
277
  specification_version: 4
277
278
  summary: A client for dor-services-app