dor-services-client 2.4.0 → 2.5.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_todo.yml +3 -3
- data/.travis.yml +3 -0
- data/README.md +16 -1
- data/dor-services-client.gemspec +2 -0
- data/lib/dor/services/client.rb +1 -0
- data/lib/dor/services/client/collections.rb +47 -0
- data/lib/dor/services/client/embargo.rb +47 -0
- data/lib/dor/services/client/object.rb +36 -7
- data/lib/dor/services/client/version.rb +1 -1
- metadata +33 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f1b9bc16853637725f55982999f804c6733175541a56e7902135e4f34e47180
|
4
|
+
data.tar.gz: 595126a2daaf676dd90f05bd990c12c52deca3d3f6ff93fd0ab9270adbd9fb85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ce268a47a767ec0008e3f54430d259049cd5527d769ec7b821e8b5cac4e8e87f381dc89091272776bd4d80c7607ec5824b0dc8440414ae567f336e53944281e
|
7
|
+
data.tar.gz: e707b6b477457b37b08542fe7cd570222dcf088eefdabb35546a95c2d4061cb8b03602e6149b62f520a8611df3788eded6b8dc29fc36b8908be183798e624312
|
data/.rubocop_todo.yml
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2019-09-03 08:11:02 -0500 using RuboCop version 0.61.1.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
9
|
+
# Offense count: 2
|
10
10
|
Style/Documentation:
|
11
11
|
Exclude:
|
12
12
|
- 'spec/**/*'
|
13
13
|
- 'test/**/*'
|
14
14
|
- 'lib/dor/services/client.rb'
|
15
15
|
|
16
|
-
# Offense count:
|
16
|
+
# Offense count: 151
|
17
17
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
18
18
|
# URISchemes: http, https
|
19
19
|
Metrics/LineLength:
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -49,7 +49,7 @@ Note that the client may **not** be used without first having been configured, a
|
|
49
49
|
|
50
50
|
## API Coverage
|
51
51
|
|
52
|
-
Dor::Services:Client provides a number of methods to simplify connecting to the RESTful HTTP API of dor-services-app. In this section we list all of the available methods, reflecting how much of the API the client covers
|
52
|
+
Dor::Services:Client provides a number of methods to simplify connecting to the RESTful HTTP API of dor-services-app. In this section we list all of the available methods, reflecting how much of the API the client covers. For details see the [API docs](https://www.rubydoc.info/github/sul-dlss/dor-services-client/master/Dor/Services/Client)
|
53
53
|
|
54
54
|
```ruby
|
55
55
|
# For registering a non-existent object
|
@@ -58,8 +58,13 @@ objects_client.register(params: {})
|
|
58
58
|
|
59
59
|
# For performing operations on a known, registered object
|
60
60
|
object_client = Dor::Services::Client.object(object_identifier)
|
61
|
+
|
62
|
+
# Publish an object
|
61
63
|
object_client.publish
|
62
64
|
|
65
|
+
# Update the MARC record
|
66
|
+
object_client.update_marc_record
|
67
|
+
|
63
68
|
# Copy metadata from Symphony into descMetadata
|
64
69
|
object_client.refresh_metadata
|
65
70
|
|
@@ -80,6 +85,13 @@ object_client.metadata.dublin_core
|
|
80
85
|
|
81
86
|
# Get the public descriptive XML representation
|
82
87
|
object_client.metadata.descriptive
|
88
|
+
|
89
|
+
# Return the Cocina metadata
|
90
|
+
object_client.find
|
91
|
+
|
92
|
+
# Query for an objects collections
|
93
|
+
object_client.collections
|
94
|
+
|
83
95
|
object_client.files.retrieve(filename: filename_string)
|
84
96
|
object_client.files.preserved_content(filename: filename_string, version: version_string)
|
85
97
|
object_client.files.list
|
@@ -92,6 +104,9 @@ object_client.sdr.signature_catalog
|
|
92
104
|
# Create and remove workspaces
|
93
105
|
object_client.workspace.create(source: object_path_string)
|
94
106
|
object_client.workspace.cleanup
|
107
|
+
|
108
|
+
# Update embargo
|
109
|
+
object_client.embargo.update(embargo_date: date_string, requesting_user: username_string)
|
95
110
|
```
|
96
111
|
|
97
112
|
## Development
|
data/dor-services-client.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
25
|
spec.add_dependency 'activesupport', '>= 4.2', '< 7'
|
26
|
+
spec.add_dependency 'cocina-models', '~> 0.1.0'
|
26
27
|
spec.add_dependency 'faraday', '~> 0.15'
|
27
28
|
spec.add_dependency 'moab-versioning', '~> 4.0'
|
28
29
|
spec.add_dependency 'nokogiri', '~> 1.8'
|
@@ -32,5 +33,6 @@ Gem::Specification.new do |spec|
|
|
32
33
|
spec.add_development_dependency 'rake', '~> 10.0'
|
33
34
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
34
35
|
spec.add_development_dependency 'rubocop', '~> 0.61.0'
|
36
|
+
spec.add_development_dependency 'simplecov'
|
35
37
|
spec.add_development_dependency 'webmock'
|
36
38
|
end
|
data/lib/dor/services/client.rb
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Dor
|
4
|
+
module Services
|
5
|
+
class Client
|
6
|
+
# API calls that are queries about a particular object.
|
7
|
+
# This attempts to parallel the Valkyrie QueryService interface
|
8
|
+
# (e.g. https://github.com/samvera/valkyrie/blob/master/lib/valkyrie/persistence/memory/query_service.rb)
|
9
|
+
class Collections < VersionedService
|
10
|
+
# @param object_identifier [String] the pid for the object
|
11
|
+
def initialize(connection:, version:, object_identifier:)
|
12
|
+
super(connection: connection, version: version)
|
13
|
+
@object_identifier = object_identifier
|
14
|
+
end
|
15
|
+
|
16
|
+
# Get a list of the collections. (Similar to Valkyrie's find_inverse_references_by)
|
17
|
+
# @raise [UnexpectedResponse] if the request is unsuccessful.
|
18
|
+
# @return [Array<Cocina::Models::DRO>]
|
19
|
+
def collections
|
20
|
+
resp = connection.get do |req|
|
21
|
+
req.url "#{query_path}/collections"
|
22
|
+
end
|
23
|
+
|
24
|
+
return response_to_models(resp) if resp.success?
|
25
|
+
|
26
|
+
raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def response_to_models(resp)
|
32
|
+
JSON.parse(resp.body)['collections'].map { |data| Cocina::Models::DRO.new(data.symbolize_keys) }
|
33
|
+
end
|
34
|
+
|
35
|
+
def object_path
|
36
|
+
"#{api_version}/objects/#{object_identifier}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def query_path
|
40
|
+
"#{object_path}/queries"
|
41
|
+
end
|
42
|
+
|
43
|
+
attr_reader :object_identifier
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: tru
|
2
|
+
|
3
|
+
module Dor
|
4
|
+
module Services
|
5
|
+
class Client
|
6
|
+
# API calls that are about managing embargo on a repository object
|
7
|
+
class Embargo < VersionedService
|
8
|
+
# @param object_identifier [String] the pid for the object
|
9
|
+
def initialize(connection:, version:, object_identifier:)
|
10
|
+
super(connection: connection, version: version)
|
11
|
+
@object_identifier = object_identifier
|
12
|
+
end
|
13
|
+
|
14
|
+
# @param [String] embargo_date The date to update the embargo to (ISO 8601)
|
15
|
+
# @param [String] requesting_user Who is making this change.
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
# client.update(embargo_date: '2099-10-20', requesting_user: 'jane')
|
19
|
+
#
|
20
|
+
# @raise [UnexpectedResponse] on an unsuccessful response from the server
|
21
|
+
#
|
22
|
+
# @return [NilClass] when the update is successful
|
23
|
+
def update(embargo_date:, requesting_user:)
|
24
|
+
resp = connection.patch do |req|
|
25
|
+
req.url path
|
26
|
+
req.headers['Content-Type'] = 'application/json'
|
27
|
+
req.body = {
|
28
|
+
embargo_date: embargo_date,
|
29
|
+
requesting_user: requesting_user
|
30
|
+
}.to_json
|
31
|
+
end
|
32
|
+
return if resp.success?
|
33
|
+
|
34
|
+
raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp, object_identifier: object_identifier)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
attr_reader :object_identifier
|
40
|
+
|
41
|
+
def path
|
42
|
+
"#{api_version}/objects/#{object_identifier}/embargo"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -16,27 +16,52 @@ module Dor
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def sdr
|
19
|
-
@sdr ||= SDR.new(
|
19
|
+
@sdr ||= SDR.new(parent_params)
|
20
20
|
end
|
21
21
|
|
22
22
|
def metadata
|
23
|
-
@metadata ||= Metadata.new(
|
23
|
+
@metadata ||= Metadata.new(parent_params)
|
24
24
|
end
|
25
25
|
|
26
26
|
def files
|
27
|
-
@files ||= Files.new(
|
27
|
+
@files ||= Files.new(parent_params)
|
28
28
|
end
|
29
29
|
|
30
30
|
def workspace
|
31
|
-
@workspace ||= Workspace.new(
|
31
|
+
@workspace ||= Workspace.new(parent_params)
|
32
32
|
end
|
33
33
|
|
34
34
|
def release_tags
|
35
|
-
@release_tags ||= ReleaseTags.new(
|
35
|
+
@release_tags ||= ReleaseTags.new(parent_params)
|
36
36
|
end
|
37
37
|
|
38
38
|
def version
|
39
|
-
@version ||= ObjectVersion.new(
|
39
|
+
@version ||= ObjectVersion.new(parent_params)
|
40
|
+
end
|
41
|
+
|
42
|
+
def embargo
|
43
|
+
@embargo ||= Embargo.new(parent_params)
|
44
|
+
end
|
45
|
+
|
46
|
+
# Retrieves the Cocina model
|
47
|
+
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
48
|
+
# @raise [UnexpectedResponse] when the response is not successful.
|
49
|
+
# @return [Cocina::Models::DRO] the returned model
|
50
|
+
def find
|
51
|
+
resp = connection.get do |req|
|
52
|
+
req.url object_path
|
53
|
+
end
|
54
|
+
|
55
|
+
return Cocina::Models::DRO.from_json(resp.body) if resp.success?
|
56
|
+
|
57
|
+
raise_exception_based_on_response!(resp)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Get a list of the collections. (Similar to Valkyrie's find_inverse_references_by)
|
61
|
+
# @raise [UnexpectedResponse] if the request is unsuccessful.
|
62
|
+
# @return [Array<Cocina::Models::DRO>]
|
63
|
+
def collections
|
64
|
+
Collections.new(parent_params).collections
|
40
65
|
end
|
41
66
|
|
42
67
|
# Publish a new object
|
@@ -52,7 +77,7 @@ module Dor
|
|
52
77
|
raise_exception_based_on_response!(resp)
|
53
78
|
end
|
54
79
|
|
55
|
-
# Update the marc record for the
|
80
|
+
# Update the marc record for the given object
|
56
81
|
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
57
82
|
# @raise [UnexpectedResponse] when the response is not successful.
|
58
83
|
# @return [boolean] true on success
|
@@ -105,6 +130,10 @@ module Dor
|
|
105
130
|
|
106
131
|
private
|
107
132
|
|
133
|
+
def parent_params
|
134
|
+
{ connection: connection, version: api_version, object_identifier: object_identifier }
|
135
|
+
end
|
136
|
+
|
108
137
|
def object_path
|
109
138
|
"#{api_version}/objects/#{object_identifier}"
|
110
139
|
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: 2.
|
4
|
+
version: 2.5.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: 2019-
|
12
|
+
date: 2019-09-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -31,6 +31,20 @@ dependencies:
|
|
31
31
|
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '7'
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: cocina-models
|
36
|
+
requirement: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.0
|
41
|
+
type: :runtime
|
42
|
+
prerelease: false
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.1.0
|
34
48
|
- !ruby/object:Gem::Dependency
|
35
49
|
name: faraday
|
36
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,6 +157,20 @@ dependencies:
|
|
143
157
|
- - "~>"
|
144
158
|
- !ruby/object:Gem::Version
|
145
159
|
version: 0.61.0
|
160
|
+
- !ruby/object:Gem::Dependency
|
161
|
+
name: simplecov
|
162
|
+
requirement: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
type: :development
|
168
|
+
prerelease: false
|
169
|
+
version_requirements: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
146
174
|
- !ruby/object:Gem::Dependency
|
147
175
|
name: webmock
|
148
176
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +206,8 @@ files:
|
|
178
206
|
- bin/setup
|
179
207
|
- dor-services-client.gemspec
|
180
208
|
- lib/dor/services/client.rb
|
209
|
+
- lib/dor/services/client/collections.rb
|
210
|
+
- lib/dor/services/client/embargo.rb
|
181
211
|
- lib/dor/services/client/error_faraday_middleware.rb
|
182
212
|
- lib/dor/services/client/files.rb
|
183
213
|
- lib/dor/services/client/metadata.rb
|
@@ -209,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
239
|
version: '0'
|
210
240
|
requirements: []
|
211
241
|
rubyforge_project:
|
212
|
-
rubygems_version: 2.7.
|
242
|
+
rubygems_version: 2.7.6
|
213
243
|
signing_key:
|
214
244
|
specification_version: 4
|
215
245
|
summary: A client for dor-services-app
|