dor-services-client 2.4.0 → 2.5.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: 98ce334358d0f3233121f562d96610339aa762e7758d3805a78fce94af96ae15
4
- data.tar.gz: 72ca530a50cb19d8f37c9923942bcc222b4a19367ce760c638e1c9635adafbfa
3
+ metadata.gz: 6f1b9bc16853637725f55982999f804c6733175541a56e7902135e4f34e47180
4
+ data.tar.gz: 595126a2daaf676dd90f05bd990c12c52deca3d3f6ff93fd0ab9270adbd9fb85
5
5
  SHA512:
6
- metadata.gz: 689c2c25b4409e7a84cd9dfe5ac956027e1c41acfd95abc6643da2f97256b714a89d48699a0a85f683eb01811c5b8f9a3f65e1a6dd9c75417213f77362562397
7
- data.tar.gz: d40443664b067ce06f4050695746fc9e6f8099d756b3c9c664699b1474e61253169a31701bd54565c95aa5ead3c4463f8ee10b57ac816dcb913b06696eaf3c5f
6
+ metadata.gz: 8ce268a47a767ec0008e3f54430d259049cd5527d769ec7b821e8b5cac4e8e87f381dc89091272776bd4d80c7607ec5824b0dc8440414ae567f336e53944281e
7
+ data.tar.gz: e707b6b477457b37b08542fe7cd570222dcf088eefdabb35546a95c2d4061cb8b03602e6149b62f520a8611df3788eded6b8dc29fc36b8908be183798e624312
@@ -1,19 +1,19 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2018-12-18 09:21:53 -0800 using RuboCop version 0.60.0.
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: 1
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: 17
16
+ # Offense count: 151
17
17
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
18
18
  # URISchemes: http, https
19
19
  Metrics/LineLength:
@@ -16,3 +16,6 @@ before_script:
16
16
  - ./cc-test-reporter before-build
17
17
  after_script:
18
18
  - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
19
+
20
+ notifications:
21
+ email: false
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
@@ -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
@@ -6,6 +6,7 @@ require 'active_support/core_ext/object/blank'
6
6
  require 'faraday'
7
7
  require 'singleton'
8
8
  require 'zeitwerk'
9
+ require 'cocina/models'
9
10
 
10
11
  class DorServicesClientInflector < Zeitwerk::Inflector
11
12
  def camelize(basename, _abspath)
@@ -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(connection: connection, version: api_version, object_identifier: object_identifier)
19
+ @sdr ||= SDR.new(parent_params)
20
20
  end
21
21
 
22
22
  def metadata
23
- @metadata ||= Metadata.new(connection: connection, version: api_version, object_identifier: object_identifier)
23
+ @metadata ||= Metadata.new(parent_params)
24
24
  end
25
25
 
26
26
  def files
27
- @files ||= Files.new(connection: connection, version: api_version, object_identifier: object_identifier)
27
+ @files ||= Files.new(parent_params)
28
28
  end
29
29
 
30
30
  def workspace
31
- @workspace ||= Workspace.new(connection: connection, version: api_version, object_identifier: object_identifier)
31
+ @workspace ||= Workspace.new(parent_params)
32
32
  end
33
33
 
34
34
  def release_tags
35
- @release_tags ||= ReleaseTags.new(connection: connection, version: api_version, object_identifier: object_identifier)
35
+ @release_tags ||= ReleaseTags.new(parent_params)
36
36
  end
37
37
 
38
38
  def version
39
- @version ||= ObjectVersion.new(connection: connection, version: api_version, object_identifier: object_identifier)
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 give object
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
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '2.4.0'
6
+ VERSION = '2.5.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: 2.4.0
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-08-27 00:00:00.000000000 Z
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.8
242
+ rubygems_version: 2.7.6
213
243
  signing_key:
214
244
  specification_version: 4
215
245
  summary: A client for dor-services-app