dor-services-client 14.12.0 → 14.14.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: c0c0ec136ed9ea12e5a6c0efc2c2663a5657f49bc2b956ff057586da83c360a5
4
- data.tar.gz: bb9c3b96fc62eb5456f85cea0e08de070e3831df74230fff530575d4df2b791e
3
+ metadata.gz: b17e776b7a8c068dd71595ca1d2e508c96b69700c87f8516f7247f4a0208f28a
4
+ data.tar.gz: 70b426fa3ac52729feb726c8c63e5907ede88b255f8095c91acfbbb9d5a8a724
5
5
  SHA512:
6
- metadata.gz: 9f1094a15841a375b9f3542064a4f64b30b1d701e91a2db1b923e056383bdc0ecf35ec1067f9eefcb426e7f3cc7e2acd90d64854e6b59c7458e8f20158c35c7e
7
- data.tar.gz: 908f23a64f6c4028f2a6eddb1956ccb0b9823195a6b4a667029ce2dabe6103604fc3f489cdf68e4aa8d4eb982eb1c9c2319330803716ec56385326f504a0acd2
6
+ metadata.gz: de501280c3a367a9557f146ad44fe1c8a76dd408904ba6f866c3472722868b64ab650670fb9cffc6da6b06847ac723323d8436a72f77e0b27e17b4f8754ce8e8
7
+ data.tar.gz: 3783ee7eead4fc35d9305e9b88482b10708c153cf64b5ad2a695567086be641ec7e0ed9592c55dfd0369a0fadfe6f034e88fa02e29d080a0cb898b4578444a6b
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dor-services-client (14.11.0)
4
+ dor-services-client (14.14.0)
5
5
  activesupport (>= 4.2, < 8)
6
- cocina-models (~> 0.97.0)
6
+ cocina-models (~> 0.98.0)
7
7
  deprecation
8
8
  faraday (~> 2.0)
9
9
  faraday-retry
@@ -12,7 +12,7 @@ PATH
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
- activesupport (7.1.3.3)
15
+ activesupport (7.1.3.4)
16
16
  base64
17
17
  bigdecimal
18
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
@@ -22,14 +22,14 @@ GEM
22
22
  minitest (>= 5.1)
23
23
  mutex_m
24
24
  tzinfo (~> 2.0)
25
- addressable (2.8.6)
26
- public_suffix (>= 2.0.2, < 6.0)
25
+ addressable (2.8.7)
26
+ public_suffix (>= 2.0.2, < 7.0)
27
27
  ast (2.4.2)
28
28
  attr_extras (7.1.0)
29
29
  base64 (0.2.0)
30
30
  bigdecimal (3.1.8)
31
31
  byebug (11.1.3)
32
- cocina-models (0.97.0)
32
+ cocina-models (0.98.0)
33
33
  activesupport
34
34
  deprecation
35
35
  dry-struct (~> 1.0)
@@ -44,10 +44,10 @@ GEM
44
44
  super_diff
45
45
  thor
46
46
  zeitwerk (~> 2.1)
47
- commonmarker (1.1.3-arm64-darwin)
48
- commonmarker (1.1.3-x86_64-darwin)
49
- commonmarker (1.1.3-x86_64-linux)
50
- concurrent-ruby (1.3.1)
47
+ commonmarker (1.1.4-arm64-darwin)
48
+ commonmarker (1.1.4-x86_64-darwin)
49
+ commonmarker (1.1.4-x86_64-linux)
50
+ concurrent-ruby (1.3.3)
51
51
  connection_pool (2.4.1)
52
52
  crack (1.0.0)
53
53
  bigdecimal
@@ -81,7 +81,7 @@ GEM
81
81
  activesupport (>= 3.0, < 8.0)
82
82
  equivalent-xml (0.6.0)
83
83
  nokogiri (>= 1.4.3)
84
- faraday (2.9.0)
84
+ faraday (2.9.2)
85
85
  faraday-net_http (>= 2.0, < 3.2)
86
86
  faraday-net_http (3.1.0)
87
87
  net-http
@@ -95,41 +95,41 @@ GEM
95
95
  jsonpath (1.1.5)
96
96
  multi_json
97
97
  language_server-protocol (3.17.0.3)
98
- minitest (5.23.1)
98
+ minitest (5.24.0)
99
99
  multi_json (1.15.0)
100
100
  mutex_m (0.2.0)
101
101
  net-http (0.4.1)
102
102
  uri
103
- nokogiri (1.16.5-arm64-darwin)
103
+ nokogiri (1.16.6-arm64-darwin)
104
104
  racc (~> 1.4)
105
- nokogiri (1.16.5-x86_64-darwin)
105
+ nokogiri (1.16.6-x86_64-darwin)
106
106
  racc (~> 1.4)
107
- nokogiri (1.16.5-x86_64-linux)
107
+ nokogiri (1.16.6-x86_64-linux)
108
108
  racc (~> 1.4)
109
109
  openapi3_parser (0.10.0)
110
110
  commonmarker (>= 1.0)
111
111
  openapi_parser (1.0.0)
112
112
  optimist (3.1.0)
113
- parallel (1.24.0)
114
- parser (3.3.2.0)
113
+ parallel (1.25.1)
114
+ parser (3.3.3.0)
115
115
  ast (~> 2.4.1)
116
116
  racc
117
117
  patience_diff (1.2.0)
118
118
  optimist (~> 3.0)
119
- public_suffix (5.0.5)
119
+ public_suffix (6.0.0)
120
120
  racc (1.8.0)
121
121
  rainbow (3.1.1)
122
122
  rake (13.2.1)
123
123
  regexp_parser (2.9.2)
124
- rexml (3.2.8)
125
- strscan (>= 3.0.9)
124
+ rexml (3.3.0)
125
+ strscan
126
126
  rspec (3.13.0)
127
127
  rspec-core (~> 3.13.0)
128
128
  rspec-expectations (~> 3.13.0)
129
129
  rspec-mocks (~> 3.13.0)
130
130
  rspec-core (3.13.0)
131
131
  rspec-support (~> 3.13.0)
132
- rspec-expectations (3.13.0)
132
+ rspec-expectations (3.13.1)
133
133
  diff-lcs (>= 1.2.0, < 2.0)
134
134
  rspec-support (~> 3.13.0)
135
135
  rspec-mocks (3.13.1)
@@ -149,17 +149,17 @@ GEM
149
149
  unicode-display_width (>= 2.4.0, < 3.0)
150
150
  rubocop-ast (1.31.3)
151
151
  parser (>= 3.3.1.0)
152
- rubocop-capybara (2.20.0)
152
+ rubocop-capybara (2.21.0)
153
153
  rubocop (~> 1.41)
154
- rubocop-factory_bot (2.25.1)
155
- rubocop (~> 1.41)
156
- rubocop-rspec (2.30.0)
154
+ rubocop-factory_bot (2.26.1)
155
+ rubocop (~> 1.61)
156
+ rubocop-rspec (2.31.0)
157
157
  rubocop (~> 1.40)
158
158
  rubocop-capybara (~> 2.17)
159
159
  rubocop-factory_bot (~> 2.22)
160
160
  rubocop-rspec_rails (~> 2.28)
161
- rubocop-rspec_rails (2.28.3)
162
- rubocop (~> 1.40)
161
+ rubocop-rspec_rails (2.29.1)
162
+ rubocop (~> 1.61)
163
163
  ruby-progressbar (1.13.0)
164
164
  simplecov (0.22.0)
165
165
  docile (~> 1.1)
@@ -181,7 +181,7 @@ GEM
181
181
  addressable (>= 2.8.0)
182
182
  crack (>= 0.3.2)
183
183
  hashdiff (>= 0.4.0, < 2.0.0)
184
- zeitwerk (2.6.15)
184
+ zeitwerk (2.6.16)
185
185
 
186
186
  PLATFORMS
187
187
  arm64-darwin-23
data/README.md CHANGED
@@ -129,6 +129,12 @@ object_client.version.open(description: 'Changed title')
129
129
  # see dor-services-app openapi.yml for optional params
130
130
  object_client.version.close
131
131
 
132
+ # Manage user versions
133
+ object_client.user_version.inventory
134
+ object_client.user_version.find(2)
135
+ object_client.user_version.create(object_version: 3)
136
+ object_client.user_version.update(user_version: Dor::Services::Client::UserVersion::Version.new(version: 3, userVersion: 3, withdrawn: true))
137
+
132
138
  # Return the Cocina metadata
133
139
  object_client.find
134
140
 
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.required_ruby_version = '>= 3.0', '< 4'
26
26
 
27
27
  spec.add_dependency 'activesupport', '>= 4.2', '< 8'
28
- spec.add_dependency 'cocina-models', '~> 0.97.0'
28
+ spec.add_dependency 'cocina-models', '~> 0.98.0'
29
29
  spec.add_dependency 'deprecation', '>= 0'
30
30
  spec.add_dependency 'faraday', '~> 2.0'
31
31
  spec.add_dependency 'faraday-retry'
@@ -5,7 +5,7 @@ module Dor
5
5
  class Client
6
6
  # API calls that are about user versions
7
7
  class UserVersion < VersionedService
8
- Version = Struct.new(:version, :userVersion, keyword_init: true)
8
+ Version = Struct.new(:version, :userVersion, :withdrawn, keyword_init: true)
9
9
 
10
10
  # @param object_identifier [String] the pid for the object
11
11
  def initialize(connection:, version:, object_identifier:)
@@ -24,6 +24,53 @@ module Dor
24
24
  JSON.parse(resp.body).fetch('user_versions').map { |params| Version.new(**params.symbolize_keys!) }
25
25
  end
26
26
 
27
+ # @return [Cocina::Models::DROWithMetadata] the object metadata
28
+ # @raise [UnexpectedResponse] on an unsuccessful response from the server
29
+ def find(version)
30
+ resp = connection.get do |req|
31
+ req.url "#{base_path}/#{version}"
32
+ end
33
+ raise_exception_based_on_response!(resp) unless resp.success?
34
+
35
+ build_cocina_from_response(resp, validate: false)
36
+ end
37
+
38
+ # Create a user version for an object
39
+ #
40
+ # @param [String] object_version the version of the object to create a user version for
41
+ # @return [Version]
42
+ # @raise [NotFoundResponse] when the response is a 404 (object not found)
43
+ # @raise [UnexpectedResponse] if the request is unsuccessful.
44
+ def create(object_version:)
45
+ resp = connection.post do |req|
46
+ req.url "#{api_version}/objects/#{object_identifier}/user_versions"
47
+ req.headers['Content-Type'] = 'application/json'
48
+ req.body = { version: object_version }.to_json
49
+ end
50
+ raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
51
+
52
+ Version.new(**JSON.parse(resp.body).symbolize_keys!)
53
+ end
54
+
55
+ # Updates a user version
56
+ #
57
+ # @param [Version] user_version the updated user version
58
+ # @return [Version]
59
+ # @raise [NotFoundResponse] when the response is a 404 (object not found)
60
+ # @raise [UnexpectedResponse] if the request is unsuccessful.
61
+ # rubocop:disable Metrics/AbcSize
62
+ def update(user_version:)
63
+ resp = connection.patch do |req|
64
+ req.url "#{api_version}/objects/#{object_identifier}/user_versions/#{user_version.userVersion}"
65
+ req.headers['Content-Type'] = 'application/json'
66
+ req.body = user_version.to_h.except(:userVersion).compact.to_json
67
+ end
68
+ raise_exception_based_on_response!(resp, object_identifier) unless resp.success?
69
+
70
+ Version.new(**JSON.parse(resp.body).symbolize_keys!)
71
+ end
72
+ # rubocop:enable Metrics/AbcSize
73
+
27
74
  private
28
75
 
29
76
  attr_reader :object_identifier
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '14.12.0'
6
+ VERSION = '14.14.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: 14.12.0
4
+ version: 14.14.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: 2024-06-05 00:00:00.000000000 Z
12
+ date: 2024-06-27 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.97.0
40
+ version: 0.98.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.97.0
47
+ version: 0.98.0
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: deprecation
50
50
  requirement: !ruby/object:Gem::Requirement
@@ -280,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
280
280
  - !ruby/object:Gem::Version
281
281
  version: '0'
282
282
  requirements: []
283
- rubygems_version: 3.5.9
283
+ rubygems_version: 3.4.19
284
284
  signing_key:
285
285
  specification_version: 4
286
286
  summary: A client for dor-services-app