dor-services-client 10.1.0 → 12.0.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 +4 -4
- data/.rubocop.yml +19 -0
- data/Gemfile +1 -1
- data/README.md +0 -8
- data/dor-services-client.gemspec +1 -1
- data/lib/dor/services/client/accession.rb +1 -1
- data/lib/dor/services/client/metadata.rb +0 -67
- data/lib/dor/services/client/mutate.rb +3 -2
- data/lib/dor/services/client/object.rb +3 -23
- data/lib/dor/services/client/objects.rb +3 -2
- data/lib/dor/services/client/version.rb +1 -1
- data/lib/dor/services/client/versioned_service.rb +2 -2
- metadata +5 -6
- data/lib/dor/services/client/object_metadata.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d123cfe73a0981439bec1c66e49f10bb6dd5d0d43bebf72eebaede03f4ae6ae
|
4
|
+
data.tar.gz: 0f2f18cc38f22bca07062506662f0feaa1613e7179f4ab86379d3d60dca74394
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45638215f8d33a565923e1c75368d649faa675bcd9491914b6d9fd73f5bb72ac9c2d3b9c32a2754ac6307545ed9ad88e85e05c298a3c141bafbe44defeae5ded
|
7
|
+
data.tar.gz: fddfd25949ecda8603982e4008321dce816dd2633d51db01c97de3b589c5341092c7fe90f3df164446ce85162c4ed8bb6a80dbbf33472ae4831b376ede539b29
|
data/.rubocop.yml
CHANGED
@@ -134,3 +134,22 @@ RSpec/FactoryBot/SyntaxMethods: # new in 2.7
|
|
134
134
|
Enabled: true
|
135
135
|
RSpec/Rails/AvoidSetupHook: # new in 2.4
|
136
136
|
Enabled: true
|
137
|
+
|
138
|
+
Lint/RefinementImportMethods: # new in 1.27
|
139
|
+
Enabled: true
|
140
|
+
Security/CompoundHash: # new in 1.28
|
141
|
+
Enabled: true
|
142
|
+
Style/FetchEnvVar: # new in 1.28
|
143
|
+
Enabled: true
|
144
|
+
Style/NestedFileDirname: # new in 1.26
|
145
|
+
Enabled: true
|
146
|
+
Style/ObjectThen: # new in 1.28
|
147
|
+
Enabled: true
|
148
|
+
Style/RedundantInitialize: # new in 1.27
|
149
|
+
Enabled: true
|
150
|
+
RSpec/BeEq: # new in 2.9.0
|
151
|
+
Enabled: true
|
152
|
+
RSpec/BeNil: # new in 2.9.0
|
153
|
+
Enabled: true
|
154
|
+
RSpec/VerifiedDoubleReference: # new in 2.10.0
|
155
|
+
Enabled: true
|
data/Gemfile
CHANGED
@@ -4,7 +4,7 @@ source 'https://rubygems.org'
|
|
4
4
|
|
5
5
|
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
6
6
|
|
7
|
-
gem 'activesupport', ENV
|
7
|
+
gem 'activesupport', ENV.fetch('RAILS_VERSION', nil) if ENV['RAILS_VERSION']
|
8
8
|
|
9
9
|
# Specify your gem's dependencies in dor-services-client.gemspec
|
10
10
|
gemspec
|
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
|
|
data/dor-services-client.gemspec
CHANGED
@@ -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.
|
28
|
+
spec.add_dependency 'cocina-models', '~> 0.79.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
|
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,39 +43,19 @@ 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
|
-
# Retrieves the Cocina model and response metadata
|
59
|
-
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
60
|
-
# @raise [UnexpectedResponse] when the response is not successful.
|
61
|
-
# @return [Array<Cocina::Models::DRO,Cocina::Models::Collection,Cocina::Models::AdminPolicy,ObjectMetadata>] a tuple where
|
62
|
-
# the first is the model and the second is a ObjectMetadata object
|
63
|
-
def find_with_metadata
|
64
|
-
resp = connection.get do |req|
|
65
|
-
req.url object_path
|
66
|
-
end
|
67
|
-
raise_exception_based_on_response!(resp) unless resp.success?
|
68
|
-
|
69
|
-
model = Cocina::Models.build(JSON.parse(resp.body))
|
70
|
-
|
71
|
-
# Don't use #slice here as Faraday will downcase the keys.
|
72
|
-
metadata = ObjectMetadata.new(updated_at: resp.headers['Last-Modified'],
|
73
|
-
created_at: resp.headers['X-Created-At'],
|
74
|
-
etag: resp.headers['ETag'])
|
75
|
-
[model, metadata]
|
76
|
-
end
|
77
|
-
deprecation_deprecate find_with_metadata: 'Use find instead with provides models with metadata.'
|
78
|
-
|
79
59
|
# Get a list of the collections. (Similar to Valkyrie's find_inverse_references_by)
|
80
60
|
# @raise [UnexpectedResponse] if the request is unsuccessful.
|
81
61
|
# @return [Array<Cocina::Models::DRO>]
|
@@ -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
|
@@ -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:
|
4
|
+
version: 12.0.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-
|
12
|
+
date: 2022-05-09 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.
|
40
|
+
version: 0.79.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.
|
47
|
+
version: 0.79.0
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: deprecation
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -249,7 +249,6 @@ files:
|
|
249
249
|
- lib/dor/services/client/metadata.rb
|
250
250
|
- lib/dor/services/client/mutate.rb
|
251
251
|
- lib/dor/services/client/object.rb
|
252
|
-
- lib/dor/services/client/object_metadata.rb
|
253
252
|
- lib/dor/services/client/object_version.rb
|
254
253
|
- lib/dor/services/client/objects.rb
|
255
254
|
- lib/dor/services/client/response_error_formatter.rb
|
@@ -280,7 +279,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
280
279
|
- !ruby/object:Gem::Version
|
281
280
|
version: '0'
|
282
281
|
requirements: []
|
283
|
-
rubygems_version: 3.
|
282
|
+
rubygems_version: 3.3.4
|
284
283
|
signing_key:
|
285
284
|
specification_version: 4
|
286
285
|
summary: A client for dor-services-app
|
@@ -1,34 +0,0 @@
|
|
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, :etag
|
13
|
-
|
14
|
-
def initialize(created_at:, updated_at:, etag: nil)
|
15
|
-
@created_at = created_at
|
16
|
-
@updated_at = updated_at
|
17
|
-
@etag = etag
|
18
|
-
end
|
19
|
-
|
20
|
-
def [](key)
|
21
|
-
case key
|
22
|
-
when 'Last-Modified'
|
23
|
-
updated_at
|
24
|
-
when 'X-Created-At'
|
25
|
-
created_at
|
26
|
-
else
|
27
|
-
raise KeyError, 'Unknown key'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
deprecation_deprecate(:[] => 'Hash accessor is no longer used, use object accessor instead')
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|