preservation-client 5.1.1 → 5.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c2de24ad9435d7b9ae73d7973f54f2b2f2fd5fdae08d0e2e7e958feec532658
4
- data.tar.gz: 5c08e269ef3d3b2f6c4e0d5094dcd563ac474fd9d4631cdf9dfe343b2608c3b9
3
+ metadata.gz: fecead20f03947d189027e250689d1af848866f889dadfd81f553ee3bb00d07b
4
+ data.tar.gz: fa4aa6b61ac54291a787e91eef05fa63b4c3fb607a4dbbb8e9f29068194510ee
5
5
  SHA512:
6
- metadata.gz: 8a7ac074a5e6b1f621a2ed02986e7233f2195fe7bba3eeb7682f201c49bf0006e815a0f7923aa4efe595ae814427c3e2a7e5d897fa4268f8030cacbdc934df56
7
- data.tar.gz: 38a734aad0ff248bde114ee4d26dd89c72c5acd7de352f9abee2d2b98a3d8d523801b5cf7c0c65231bc5d59f7a5a7a2d76ffb15a5cca195c6a3e5cdc06bb2861
6
+ metadata.gz: 2fbb241aa2b6422213de3b5b54a76c38a96d1c892b901384472087ee684718b269130522931d806536abea3e30b51edc2396c55b6cdbb00d76ce34c7a17c14c7
7
+ data.tar.gz: '0986527f81fec0dfdad8faefbcfbcc03dde1066b46382ac34babe5dec7da5459733eec8a6c7bf09c79e0f5b8ac291e177749b7a13f2337f2ac0ae81832bbe5f2'
data/.circleci/config.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  version: 2.1
2
2
  orbs:
3
- ruby-rails: sul-dlss/ruby-rails@3.1.2
3
+ ruby-rails: sul-dlss/ruby-rails@3.2.0
4
4
  workflows:
5
5
  build:
6
6
  jobs:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- preservation-client (5.1.1)
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 (5.2.0)
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.0-x86_64-darwin)
44
+ nokogiri (1.14.1-x86_64-darwin)
45
45
  racc (~> 1.4)
46
- nokogiri (1.14.0-x86_64-linux)
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.0)
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.43.0)
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.5)
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.3.26
132
+ 2.4.6
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Preservation
4
4
  class Client
5
- VERSION = '5.1.1'
5
+ VERSION = '5.3.0'
6
6
  end
7
7
  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
- exception_class = e.response[:status] == 423 ? LockedError : UnexpectedResponseError
99
- raise exception_class, errmsg
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
@@ -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
- def configure(url:, token:)
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 :url, :connection, :token
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: 300 }) do |builder|
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.1.1
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-01-26 00:00:00.000000000 Z
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.3.10
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.