preservation-client 5.1.1 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/Gemfile.lock +9 -8
- data/lib/preservation/client/version.rb +1 -1
- data/lib/preservation/client/versioned_api_service.rb +13 -2
- data/lib/preservation/client.rb +14 -4
- 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: fecead20f03947d189027e250689d1af848866f889dadfd81f553ee3bb00d07b
|
4
|
+
data.tar.gz: fa4aa6b61ac54291a787e91eef05fa63b4c3fb607a4dbbb8e9f29068194510ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fbb241aa2b6422213de3b5b54a76c38a96d1c892b901384472087ee684718b269130522931d806536abea3e30b51edc2396c55b6cdbb00d76ce34c7a17c14c7
|
7
|
+
data.tar.gz: '0986527f81fec0dfdad8faefbcfbcc03dde1066b46382ac34babe5dec7da5459733eec8a6c7bf09c79e0f5b8ac291e177749b7a13f2337f2ac0ae81832bbe5f2'
|
data/.circleci/config.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
preservation-client (5.
|
4
|
+
preservation-client (5.3.0)
|
5
5
|
activesupport (>= 4.2, < 8)
|
6
6
|
faraday (~> 2.0)
|
7
7
|
moab-versioning (>= 5.0.0, < 7)
|
@@ -36,14 +36,14 @@ GEM
|
|
36
36
|
json (2.6.3)
|
37
37
|
method_source (1.0.0)
|
38
38
|
minitest (5.17.0)
|
39
|
-
moab-versioning (
|
39
|
+
moab-versioning (6.1.0)
|
40
40
|
druid-tools (>= 1.0.0)
|
41
41
|
json
|
42
42
|
nokogiri
|
43
43
|
nokogiri-happymapper
|
44
|
-
nokogiri (1.14.
|
44
|
+
nokogiri (1.14.1-x86_64-darwin)
|
45
45
|
racc (~> 1.4)
|
46
|
-
nokogiri (1.14.
|
46
|
+
nokogiri (1.14.1-x86_64-linux)
|
47
47
|
racc (~> 1.4)
|
48
48
|
nokogiri-happymapper (0.9.0)
|
49
49
|
nokogiri (~> 1.5)
|
@@ -66,7 +66,7 @@ GEM
|
|
66
66
|
rspec-core (~> 3.12.0)
|
67
67
|
rspec-expectations (~> 3.12.0)
|
68
68
|
rspec-mocks (~> 3.12.0)
|
69
|
-
rspec-core (3.12.
|
69
|
+
rspec-core (3.12.1)
|
70
70
|
rspec-support (~> 3.12.0)
|
71
71
|
rspec-expectations (3.12.2)
|
72
72
|
diff-lcs (>= 1.2.0, < 2.0)
|
@@ -75,7 +75,7 @@ GEM
|
|
75
75
|
diff-lcs (>= 1.2.0, < 2.0)
|
76
76
|
rspec-support (~> 3.12.0)
|
77
77
|
rspec-support (3.12.0)
|
78
|
-
rubocop (1.
|
78
|
+
rubocop (1.44.1)
|
79
79
|
json (~> 2.3)
|
80
80
|
parallel (~> 1.10)
|
81
81
|
parser (>= 3.2.0.0)
|
@@ -102,7 +102,7 @@ GEM
|
|
102
102
|
simplecov_json_formatter (~> 0.1)
|
103
103
|
simplecov-html (0.12.3)
|
104
104
|
simplecov_json_formatter (0.1.4)
|
105
|
-
tzinfo (2.0.
|
105
|
+
tzinfo (2.0.6)
|
106
106
|
concurrent-ruby (~> 1.0)
|
107
107
|
unicode-display_width (2.4.2)
|
108
108
|
webmock (3.18.1)
|
@@ -113,6 +113,7 @@ GEM
|
|
113
113
|
|
114
114
|
PLATFORMS
|
115
115
|
x86_64-darwin-19
|
116
|
+
x86_64-darwin-20
|
116
117
|
x86_64-linux
|
117
118
|
|
118
119
|
DEPENDENCIES
|
@@ -128,4 +129,4 @@ DEPENDENCIES
|
|
128
129
|
webmock
|
129
130
|
|
130
131
|
BUNDLED WITH
|
131
|
-
2.
|
132
|
+
2.4.6
|
@@ -95,8 +95,19 @@ module Preservation
|
|
95
95
|
rescue Faraday::Error => e
|
96
96
|
errmsg = "Preservation::Client.#{caller_locations.first.label} " \
|
97
97
|
"got #{e.response[:status]} from Preservation at #{req_url}: #{e.response[:body]}"
|
98
|
-
|
99
|
-
|
98
|
+
raise http_exception_class(e.response[:status]), errmsg
|
99
|
+
end
|
100
|
+
|
101
|
+
# @param status_code [Integer] the HTTP status code to translate to an exception class
|
102
|
+
def http_exception_class(status_code)
|
103
|
+
case status_code
|
104
|
+
when 423
|
105
|
+
LockedError
|
106
|
+
when 409
|
107
|
+
ConflictError
|
108
|
+
else
|
109
|
+
UnexpectedResponseError
|
110
|
+
end
|
100
111
|
end
|
101
112
|
end
|
102
113
|
end
|
data/lib/preservation/client.rb
CHANGED
@@ -23,6 +23,9 @@ module Preservation
|
|
23
23
|
# Error raised when server returns 423 Locked
|
24
24
|
class LockedError < Error; end
|
25
25
|
|
26
|
+
# Error raised when server returns 409 Conflict
|
27
|
+
class ConflictError < Error; end
|
28
|
+
|
26
29
|
# Error raised when server returns an unexpected response
|
27
30
|
# e.g., 4xx or 5xx status not otherwise handled
|
28
31
|
class UnexpectedResponseError < Error; end
|
@@ -32,6 +35,7 @@ module Preservation
|
|
32
35
|
class ConnectionFailedError < Error; end
|
33
36
|
|
34
37
|
DEFAULT_API_VERSION = 'v1'
|
38
|
+
DEFAULT_TIMEOUT = 300
|
35
39
|
TOKEN_HEADER = 'Authorization'
|
36
40
|
|
37
41
|
include Singleton
|
@@ -47,11 +51,13 @@ module Preservation
|
|
47
51
|
end
|
48
52
|
|
49
53
|
class << self
|
50
|
-
# @param [String] url
|
54
|
+
# @param [String] url the endpoint URL
|
51
55
|
# @param [String] token a bearer token for HTTP authentication
|
52
|
-
|
56
|
+
# @param [Integer] read_timeout the value in seconds of the read timeout
|
57
|
+
def configure(url:, token:, read_timeout: DEFAULT_TIMEOUT)
|
53
58
|
instance.url = url
|
54
59
|
instance.token = token
|
60
|
+
instance.read_timeout = read_timeout
|
55
61
|
|
56
62
|
# Force connection to be re-established when `.configure` is called
|
57
63
|
instance.connection = nil
|
@@ -62,7 +68,7 @@ module Preservation
|
|
62
68
|
delegate :objects, :update, to: :instance
|
63
69
|
end
|
64
70
|
|
65
|
-
attr_writer :
|
71
|
+
attr_writer :connection, :read_timeout, :token, :url
|
66
72
|
|
67
73
|
delegate :update, to: :catalog
|
68
74
|
|
@@ -76,8 +82,12 @@ module Preservation
|
|
76
82
|
@token || raise(Error, 'auth token has not been configured')
|
77
83
|
end
|
78
84
|
|
85
|
+
def read_timeout
|
86
|
+
@read_timeout || raise(Error, 'read timeout has not been configured')
|
87
|
+
end
|
88
|
+
|
79
89
|
def connection
|
80
|
-
@connection ||= Faraday.new(url, request: { read_timeout:
|
90
|
+
@connection ||= Faraday.new(url, request: { read_timeout: read_timeout }) do |builder|
|
81
91
|
builder.use ErrorFaradayMiddleware
|
82
92
|
builder.use Faraday::Request::UrlEncoded
|
83
93
|
builder.use Faraday::Response::RaiseError # raise exceptions on 40x, 50x responses
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: preservation-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naomi Dushay
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -255,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
255
255
|
- !ruby/object:Gem::Version
|
256
256
|
version: '0'
|
257
257
|
requirements: []
|
258
|
-
rubygems_version: 3.
|
258
|
+
rubygems_version: 3.2.32
|
259
259
|
signing_key:
|
260
260
|
specification_version: 4
|
261
261
|
summary: A thin client for getting info from SDR preservation.
|