sdr-client 0.60.0 → 0.63.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78ea65d3c9a57d94b5c1e0ec9570d8d46de57b6b96a241075bad23fe2d5f6951
|
4
|
+
data.tar.gz: 19f5e7b0f327b74654f6affd1aa2d1af63c3638574aa8b7c2aecd66d9596e5db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57d3cfa7e333339a774fdba3085cbf7323d6d9fca9804f74382198cbaac9d2210de654345baddfccdfc6b412a9ab619c8c800217da30e849b551912cacd25269
|
7
|
+
data.tar.gz: d04753f61d433a8c5f80317e1a8e7ebda1c70f1b361096d07fdc934950819316918165e5f466b53724a29a062cdb48882f4263d0d42b066cca20a0aa47b8949f
|
data/.circleci/config.yml
CHANGED
@@ -5,14 +5,16 @@ module SdrClient
|
|
5
5
|
class Connection
|
6
6
|
include Dry::Monads[:result]
|
7
7
|
|
8
|
-
|
8
|
+
# @param [Integer] read_timeout the value in seconds to set the read timeout
|
9
|
+
def initialize(url:, token: Credentials.read, read_timeout: 360)
|
9
10
|
@url = url
|
10
11
|
@token = token
|
12
|
+
@request_options = { read_timeout: read_timeout }
|
11
13
|
end
|
12
14
|
|
13
15
|
def connection
|
14
|
-
@connection ||= Faraday.new(url: url) do |conn|
|
15
|
-
conn.authorization :Bearer, token
|
16
|
+
@connection ||= Faraday.new(url: url, request: request_options) do |conn|
|
17
|
+
conn.request :authorization, :Bearer, token
|
16
18
|
conn.adapter :net_http
|
17
19
|
end
|
18
20
|
end
|
@@ -36,6 +38,6 @@ module SdrClient
|
|
36
38
|
|
37
39
|
private
|
38
40
|
|
39
|
-
attr_reader :url, :token
|
41
|
+
attr_reader :url, :token, :request_options
|
40
42
|
end
|
41
43
|
end
|
@@ -4,12 +4,21 @@ module SdrClient
|
|
4
4
|
module Deposit
|
5
5
|
# Handles unexpected responses when manipulating resources
|
6
6
|
class UnexpectedResponse
|
7
|
+
# Raised when there is a request error (e.g.: a cocina-models version mismatch)
|
8
|
+
class BadRequest < StandardError; end
|
9
|
+
# Raised when there is a problem with the credentials
|
10
|
+
class Unauthorized < StandardError; end
|
11
|
+
|
7
12
|
# @param [Faraday::Response] response
|
8
13
|
def self.call(response)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
14
|
+
case response.status
|
15
|
+
when 400
|
16
|
+
raise BadRequest, "There was an error with your request: #{response.body}"
|
17
|
+
when 401
|
18
|
+
raise Unauthorized, 'There was an error with your credentials. Perhaps they have expired?'
|
19
|
+
else
|
20
|
+
raise "unexpected response: #{response.status} #{response.body}"
|
21
|
+
end
|
13
22
|
end
|
14
23
|
end
|
15
24
|
end
|
@@ -38,6 +38,8 @@ module SdrClient
|
|
38
38
|
Hash[file_metadata.map { |filename, metadata| [filename, direct_upload(metadata.to_json)] }]
|
39
39
|
end
|
40
40
|
|
41
|
+
# This creates a signed token that we can use to upload the file. This token has an expiration set in sdr-api,
|
42
|
+
# so we have to use it before it expires.
|
41
43
|
def direct_upload(metadata_json)
|
42
44
|
logger.info("Starting an upload request: #{metadata_json}")
|
43
45
|
response = connection.post(BLOB_PATH, metadata_json, 'Content-Type' => 'application/json')
|
data/lib/sdr_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sdr-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.63.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -239,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
239
|
- !ruby/object:Gem::Version
|
240
240
|
version: '0'
|
241
241
|
requirements: []
|
242
|
-
rubygems_version: 3.
|
242
|
+
rubygems_version: 3.2.32
|
243
243
|
signing_key:
|
244
244
|
specification_version: 4
|
245
245
|
summary: The CLI for https://github.com/sul-dlss/sdr-api
|