dor-services-client 1.11.0 → 1.12.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/.travis.yml +0 -2
- data/README.md +4 -4
- data/lib/dor/services/client/error_faraday_middleware.rb +1 -1
- data/lib/dor/services/client/object.rb +1 -0
- data/lib/dor/services/client/object_version.rb +17 -1
- data/lib/dor/services/client/version.rb +1 -1
- data/lib/dor/services/client/workflow.rb +2 -2
- data/lib/dor/services/client/workflows.rb +4 -0
- data/lib/dor/services/client.rb +4 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78f715a39b9f224746efdd2cdbbe6bc15ff133d115f5374a0375cb7fe9435774
|
4
|
+
data.tar.gz: c0808ad279301664e35953d8cee374e64a3b5dc2f217480491de71b29539239d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7361d4e2c6ee0e183c5c16ba8c4da4f4437a2abdd90a19f7a979e4244adaaa3f3cd40bfa2751bab746ba2eda1ca267314b2f99216f7176ab9e1cb8cc6ad887fb
|
7
|
+
data.tar.gz: 92f1c9ab4d60ab63146b49aac208969a3c6a0dcd40607be0c960bace46b5248c19c5d2f9720515c076eee3b45dd1cfd6738fadbffb4e89eb9c110824225ae104
|
data/.travis.yml
CHANGED
@@ -9,7 +9,5 @@ before_script:
|
|
9
9
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
10
10
|
- chmod +x ./cc-test-reporter
|
11
11
|
- ./cc-test-reporter before-build
|
12
|
-
script:
|
13
|
-
- bundle exec rspec
|
14
12
|
after_script:
|
15
13
|
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
data/README.md
CHANGED
@@ -40,12 +40,12 @@ private
|
|
40
40
|
|
41
41
|
def client
|
42
42
|
@client ||= Dor::Services::Client.configure(url: Settings.dor_services.url,
|
43
|
-
|
44
|
-
|
43
|
+
token: Settings.dor_services.token,
|
44
|
+
token_header: Settings.dor_services.token_header)
|
45
45
|
end
|
46
46
|
```
|
47
47
|
|
48
|
-
Note that the client may **not** be used without first having been configured, and the `url` keyword is **required**. The `
|
48
|
+
Note that the client may **not** be used without first having been configured, and the `url` keyword is **required**. The `token` and `token_header` arguments are optional (though when using the client with staging and production servers, you will always need to supply these in practice). For more about dor-services-app's token-based authentication, see [its README](https://github.com/sul-dlss/dor-services-app#authentication).
|
49
49
|
|
50
50
|
## API Coverage
|
51
51
|
|
@@ -63,7 +63,7 @@ object_client.publish
|
|
63
63
|
object_client.refresh_metadata
|
64
64
|
object_client.notify_goobi
|
65
65
|
object_client.version.current
|
66
|
-
object_client.version.
|
66
|
+
object_client.version.openable?(**params)
|
67
67
|
object_client.version.open(**params)
|
68
68
|
object_client.version.close(**params)
|
69
69
|
# Get the Dublin Core XML representation
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Dor
|
4
4
|
module Services
|
5
5
|
class Client
|
6
|
-
# This wraps any faraday connection errors with dor-
|
6
|
+
# This wraps any faraday connection errors with dor-services-client errors
|
7
7
|
class ErrorFaradayMiddleware < Faraday::Response::Middleware
|
8
8
|
def call(env)
|
9
9
|
@app.call(env)
|
@@ -1,10 +1,15 @@
|
|
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 versions
|
7
9
|
class ObjectVersion < VersionedService
|
10
|
+
extend Deprecation
|
11
|
+
self.deprecation_horizon = 'dor-services-client 2.0.0'
|
12
|
+
|
8
13
|
# @param object_identifier [String] the pid for the object
|
9
14
|
def initialize(connection:, version:, object_identifier:)
|
10
15
|
super(connection: connection, version: version)
|
@@ -24,14 +29,25 @@ module Dor
|
|
24
29
|
raise_exception_based_on_response!(resp)
|
25
30
|
end
|
26
31
|
|
32
|
+
# TODO: remove this deprecation once
|
33
|
+
# https://github.com/sul-dlss/dor-services-app/issues/322 is
|
34
|
+
# merged and all DSC clients have moved to using `#openable?`
|
35
|
+
def openeable?(**params)
|
36
|
+
openable?(**params)
|
37
|
+
end
|
38
|
+
deprecation_deprecate openeable?: 'use version.openable? instead'
|
39
|
+
|
27
40
|
# Determines if a new version can be opened for a DOR object.
|
28
41
|
# @param params [Hash] optional params (see dor-services-app)
|
29
42
|
# @raise [NotFoundResponse] when the response is a 404 (object not found)
|
30
43
|
# @raise [UnexpectedResponse] when the response is not successful.
|
31
44
|
# @return [Boolean] true if a new version can be opened
|
32
45
|
# rubocop:disable Metrics/MethodLength
|
33
|
-
def
|
46
|
+
def openable?(**params)
|
34
47
|
resp = connection.get do |req|
|
48
|
+
# TODO: correct the typo below once
|
49
|
+
# https://github.com/sul-dlss/dor-services-app/issues/322 is
|
50
|
+
# merged and all running DSA instances have been deployed
|
35
51
|
req.url "#{object_path}/versions/openeable"
|
36
52
|
req.params = params
|
37
53
|
end
|
@@ -6,7 +6,7 @@ module Dor
|
|
6
6
|
# API calls that are about workflow
|
7
7
|
class Workflow < VersionedService
|
8
8
|
extend Deprecation
|
9
|
-
self.deprecation_horizon = 'dor-
|
9
|
+
self.deprecation_horizon = 'dor-services-client version 2.0.0'
|
10
10
|
|
11
11
|
# @param object_identifier [String] the pid for the object
|
12
12
|
def initialize(connection:, version:, object_identifier:)
|
@@ -24,7 +24,7 @@ module Dor
|
|
24
24
|
end
|
25
25
|
raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body})" unless resp.success?
|
26
26
|
end
|
27
|
-
deprecation_deprecate create: 'Create will be removed. Use dor-workflow-
|
27
|
+
deprecation_deprecate create: 'Create will be removed. Use dor-workflow-client instead'
|
28
28
|
|
29
29
|
private
|
30
30
|
|
@@ -5,6 +5,9 @@ module Dor
|
|
5
5
|
class Client
|
6
6
|
# API calls that are about workflows
|
7
7
|
class Workflows < VersionedService
|
8
|
+
extend Deprecation
|
9
|
+
self.deprecation_horizon = 'dor-services-client version 2.0.0'
|
10
|
+
|
8
11
|
# Get the initial XML for a workflow
|
9
12
|
# @param name [String] the name of the xml
|
10
13
|
# @return [String] the response
|
@@ -18,6 +21,7 @@ module Dor
|
|
18
21
|
|
19
22
|
raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body})"
|
20
23
|
end
|
24
|
+
deprecation_deprecate initial: 'Initial will be removed. Use dor-workflow-client instead'
|
21
25
|
end
|
22
26
|
end
|
23
27
|
end
|
data/lib/dor/services/client.rb
CHANGED
@@ -70,15 +70,11 @@ module Dor
|
|
70
70
|
|
71
71
|
class << self
|
72
72
|
# @param [String] url
|
73
|
-
# @param [String] username
|
74
|
-
# @param [String] password
|
75
73
|
# @param [String] token a bearer token for HTTP auth
|
76
74
|
# @param [String] token_header ('Authorization') set this to something if you are also using
|
77
75
|
# basic auth, or the headers will collide
|
78
|
-
def configure(url:,
|
76
|
+
def configure(url:, token: nil, token_header: 'Authorization')
|
79
77
|
instance.url = url
|
80
|
-
instance.username = username
|
81
|
-
instance.password = password
|
82
78
|
instance.token = token
|
83
79
|
instance.token_header = token_header
|
84
80
|
|
@@ -91,31 +87,28 @@ module Dor
|
|
91
87
|
delegate :objects, :object, :workflows, to: :instance
|
92
88
|
end
|
93
89
|
|
94
|
-
attr_writer :url, :
|
90
|
+
attr_writer :url, :token, :token_header, :connection
|
95
91
|
|
96
92
|
private
|
97
93
|
|
98
|
-
attr_reader :
|
94
|
+
attr_reader :token, :token_header
|
99
95
|
|
100
96
|
def url
|
101
97
|
@url || raise(Error, 'url has not yet been configured')
|
102
98
|
end
|
103
99
|
|
104
|
-
# rubocop:disable Metrics/AbcSize
|
105
100
|
def connection
|
106
101
|
@connection ||= Faraday.new(url) do |conn|
|
107
102
|
conn.use ErrorFaradayMiddleware
|
108
103
|
|
109
|
-
# @note when
|
104
|
+
# @note when token & token_header are nil, this line is required else
|
110
105
|
# the Faraday instance will be passed an empty block, which
|
111
106
|
# causes the adapter not to be set. Thus, everything breaks.
|
112
107
|
conn.adapter Faraday.default_adapter
|
113
|
-
conn.basic_auth username, password if username && password
|
114
108
|
conn.headers[:user_agent] = user_agent
|
115
109
|
conn.headers[token_header] = "Bearer #{token}" if token
|
116
110
|
end
|
117
111
|
end
|
118
|
-
# rubocop:enable Metrics/AbcSize
|
119
112
|
|
120
113
|
def user_agent
|
121
114
|
"dor-services-client #{Dor::Services::Client::VERSION}"
|
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: 1.
|
4
|
+
version: 1.12.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-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
224
|
version: '0'
|
225
225
|
requirements: []
|
226
226
|
rubyforge_project:
|
227
|
-
rubygems_version: 2.7.
|
227
|
+
rubygems_version: 2.7.8
|
228
228
|
signing_key:
|
229
229
|
specification_version: 4
|
230
230
|
summary: A client for dor-services-app
|