preservation-client 5.2.0 → 6.0.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 +6 -5
- data/lib/preservation/client/catalog.rb +2 -11
- data/lib/preservation/client/version.rb +1 -1
- data/lib/preservation/client/versioned_api_service.rb +13 -2
- data/lib/preservation/client.rb +3 -0
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f564cb04f2c454690324230f40e8876d752f7eb405e1dcde3671d9cd573556e
|
4
|
+
data.tar.gz: f86ce941a43ca660099a67424b21450b1b83e34be79033e4dac3d99eef41c5b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b30b8db76ff51c9c1bda3c574da09e4acf294b1151b234addb1c3da66c0bbf7ba034bc11160d02b50766ededd6927bcb4945d6de759fd2e10d274fd7bdffedc3
|
7
|
+
data.tar.gz: 54ef26cec8442266b9f2b0ffb7dabd0f7df0c10b1eb18f7c05819e9b52cbda741990db9271a650b2fb6f505b66a43de736d20175289714e1cefec669822f3458
|
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 (
|
4
|
+
preservation-client (6.0.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 (6.
|
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)
|
@@ -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
|
@@ -23,18 +23,9 @@ module Preservation
|
|
23
23
|
private
|
24
24
|
|
25
25
|
def request(druid:, version:, http_args:)
|
26
|
-
|
27
|
-
connection.post "/#{api_version}/catalog", http_args
|
28
|
-
else
|
29
|
-
connection.patch "/#{api_version}/catalog/#{druid}", http_args
|
30
|
-
end
|
31
|
-
unless result.success?
|
32
|
-
raise UnexpectedResponseError, "response was not successful. Received status #{result.status}"
|
33
|
-
end
|
26
|
+
return post('catalog', http_args) if version == 1
|
34
27
|
|
35
|
-
|
36
|
-
rescue Faraday::Error => e
|
37
|
-
raise UnexpectedResponseError, e
|
28
|
+
patch("catalog/#{druid}", http_args)
|
38
29
|
end
|
39
30
|
end
|
40
31
|
end
|
@@ -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
|
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:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naomi Dushay
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -240,7 +240,7 @@ metadata:
|
|
240
240
|
homepage_uri: https://github.com/sul-dlss/preservation-client
|
241
241
|
source_code_uri: https://github.com/sul-dlss/preservation-client.
|
242
242
|
rubygems_mfa_required: 'true'
|
243
|
-
post_install_message:
|
243
|
+
post_install_message:
|
244
244
|
rdoc_options: []
|
245
245
|
require_paths:
|
246
246
|
- lib
|
@@ -256,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
256
256
|
version: '0'
|
257
257
|
requirements: []
|
258
258
|
rubygems_version: 3.2.32
|
259
|
-
signing_key:
|
259
|
+
signing_key:
|
260
260
|
specification_version: 4
|
261
261
|
summary: A thin client for getting info from SDR preservation.
|
262
262
|
test_files: []
|