preservation-client 2.2.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +5 -3
- data/lib/preservation/client.rb +10 -2
- data/lib/preservation/client/version.rb +1 -1
- 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: dfb058593a0636a69c8a496a846dbfdcee34ebe79475545c80999642dffc5ffd
|
4
|
+
data.tar.gz: c0c4a0d3c0994116ff61648fcba67575adcc144edaacac0e6986dc81cf4fd117
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d742c45557b5bd9e2c8bcdee76bd24149ab6b4b225772cbbbcb7ab1f1e35a28b6f6951869c9a4e3443970562824a824dd9cdc83f06a4499fbdcdf560f992d79a
|
7
|
+
data.tar.gz: 8d0983ba3bc0d3c0def903983a118a462b496b1397d5b235c08bca37a63186a3a169fca293657acaa0c8039b52480d13f7485d2d29ba65bbba48248510e70f22
|
data/.travis.yml
CHANGED
@@ -8,7 +8,7 @@ env:
|
|
8
8
|
- "RAILS_VERSION=5.2.3"
|
9
9
|
- "RAILS_VERSION=6.0.0"
|
10
10
|
|
11
|
-
before_install: gem install bundler -v 2.
|
11
|
+
before_install: gem install bundler -v 2.1.2
|
12
12
|
|
13
13
|
before_script:
|
14
14
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
data/README.md
CHANGED
@@ -37,7 +37,7 @@ end
|
|
37
37
|
private
|
38
38
|
|
39
39
|
def client
|
40
|
-
@client ||= Preservation::Client.configure(url: Settings.preservation_catalog.url)
|
40
|
+
@client ||= Preservation::Client.configure(url: Settings.preservation_catalog.url, token: Settings.preservation_catalog.token)
|
41
41
|
end
|
42
42
|
```
|
43
43
|
|
@@ -47,7 +47,7 @@ OR
|
|
47
47
|
require 'preservation/client'
|
48
48
|
|
49
49
|
def initialize
|
50
|
-
Preservation::Client.configure(url: Settings.preservation_catalog.url)
|
50
|
+
Preservation::Client.configure(url: Settings.preservation_catalog.url, token: Settings.preservation_catalog.token)
|
51
51
|
end
|
52
52
|
|
53
53
|
def do_the_thing
|
@@ -55,7 +55,9 @@ def do_the_thing
|
|
55
55
|
end
|
56
56
|
```
|
57
57
|
|
58
|
-
Note that the client may **not** be used without first having been configured, and the `url`
|
58
|
+
Note that the client may **not** be used without first having been configured, and both the `url` and `token` keywords are **required**.
|
59
|
+
|
60
|
+
See https://github.com/sul-dlss/preservation_catalog#api for info on obtaining a valid API token.
|
59
61
|
|
60
62
|
Note that the preservation service is behind a firewall.
|
61
63
|
|
data/lib/preservation/client.rb
CHANGED
@@ -27,6 +27,7 @@ module Preservation
|
|
27
27
|
class ConnectionFailedError < Error; end
|
28
28
|
|
29
29
|
DEFAULT_API_VERSION = 'v1'
|
30
|
+
TOKEN_HEADER = 'Authorization'
|
30
31
|
|
31
32
|
include Singleton
|
32
33
|
|
@@ -42,8 +43,10 @@ module Preservation
|
|
42
43
|
|
43
44
|
class << self
|
44
45
|
# @param [String] url
|
45
|
-
|
46
|
+
# @param [String] token a bearer token for HTTP authentication
|
47
|
+
def configure(url:, token:)
|
46
48
|
instance.url = url
|
49
|
+
instance.token = token
|
47
50
|
|
48
51
|
# Force connection to be re-established when `.configure` is called
|
49
52
|
instance.connection = nil
|
@@ -54,7 +57,7 @@ module Preservation
|
|
54
57
|
delegate :objects, :update, to: :instance
|
55
58
|
end
|
56
59
|
|
57
|
-
attr_writer :url, :connection
|
60
|
+
attr_writer :url, :connection, :token
|
58
61
|
delegate :update, to: :catalog
|
59
62
|
|
60
63
|
private
|
@@ -63,6 +66,10 @@ module Preservation
|
|
63
66
|
@url || raise(Error, 'url has not yet been configured')
|
64
67
|
end
|
65
68
|
|
69
|
+
def token
|
70
|
+
@token || raise(Error, 'auth token has not been configured')
|
71
|
+
end
|
72
|
+
|
66
73
|
def connection
|
67
74
|
@connection ||= Faraday.new(url) do |builder|
|
68
75
|
builder.use ErrorFaradayMiddleware
|
@@ -70,6 +77,7 @@ module Preservation
|
|
70
77
|
builder.use Faraday::Response::RaiseError # raise exceptions on 40x, 50x responses
|
71
78
|
builder.adapter Faraday.default_adapter
|
72
79
|
builder.headers[:user_agent] = user_agent
|
80
|
+
builder.headers[TOKEN_HEADER] = "Bearer #{token}"
|
73
81
|
end
|
74
82
|
end
|
75
83
|
|
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: 3.0.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: 2020-01-
|
11
|
+
date: 2020-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -225,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
225
|
- !ruby/object:Gem::Version
|
226
226
|
version: '0'
|
227
227
|
requirements: []
|
228
|
-
rubygems_version: 3.
|
228
|
+
rubygems_version: 3.1.2
|
229
229
|
signing_key:
|
230
230
|
specification_version: 4
|
231
231
|
summary: A thin client for getting info from SDR preservation.
|