globus_client 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +16 -16
- data/lib/globus_client/identity.rb +2 -1
- data/lib/globus_client/token_wrapper.rb +13 -0
- data/lib/globus_client/version.rb +1 -1
- data/lib/globus_client.rb +31 -15
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40f9903f67d10be16104fe3664bf68dd467b24414cb7f0c84bfb6539cd2acee5
|
4
|
+
data.tar.gz: bbcc3c1f811df83d8a4d473ff3cd646b33d6f7f950aaa99c0f86e0e10165130d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5334d262c97ac5512d5a6bbaf9a0927e98fea577a318ba0b08c3dbac33bfbb53c01bdb95205df271886c36df2ce7144c078e7ae8deadc5bea8af9a8d9180479
|
7
|
+
data.tar.gz: a850d0854a936f24653d0ebf0bfd96be478ab2a0c6be908c1cd47defb3872b306281a35d56b76cff898cc48ba9340d20dde4d4a96051d36007d6c29d3f5a4a53
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
globus_client (0.
|
4
|
+
globus_client (0.8.0)
|
5
5
|
activesupport (>= 4.2, < 8)
|
6
6
|
faraday
|
7
7
|
zeitwerk
|
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
rexml
|
24
24
|
diff-lcs (1.5.0)
|
25
25
|
docile (1.4.0)
|
26
|
-
faraday (2.7.
|
26
|
+
faraday (2.7.2)
|
27
27
|
faraday-net_http (>= 2.0, < 3.1)
|
28
28
|
ruby2_keywords (>= 0.0.4)
|
29
29
|
faraday-net_http (3.0.2)
|
@@ -32,9 +32,9 @@ GEM
|
|
32
32
|
concurrent-ruby (~> 1.0)
|
33
33
|
json (2.6.3)
|
34
34
|
language_server-protocol (3.17.0.2)
|
35
|
-
minitest (5.
|
35
|
+
minitest (5.17.0)
|
36
36
|
parallel (1.22.1)
|
37
|
-
parser (3.
|
37
|
+
parser (3.2.0.0)
|
38
38
|
ast (~> 2.4.1)
|
39
39
|
public_suffix (5.0.1)
|
40
40
|
rainbow (3.1.1)
|
@@ -47,45 +47,45 @@ GEM
|
|
47
47
|
rspec-mocks (~> 3.12.0)
|
48
48
|
rspec-core (3.12.0)
|
49
49
|
rspec-support (~> 3.12.0)
|
50
|
-
rspec-expectations (3.12.
|
50
|
+
rspec-expectations (3.12.2)
|
51
51
|
diff-lcs (>= 1.2.0, < 2.0)
|
52
52
|
rspec-support (~> 3.12.0)
|
53
|
-
rspec-mocks (3.12.
|
53
|
+
rspec-mocks (3.12.2)
|
54
54
|
diff-lcs (>= 1.2.0, < 2.0)
|
55
55
|
rspec-support (~> 3.12.0)
|
56
56
|
rspec-support (3.12.0)
|
57
|
-
rubocop (1.
|
57
|
+
rubocop (1.42.0)
|
58
58
|
json (~> 2.3)
|
59
59
|
parallel (~> 1.10)
|
60
60
|
parser (>= 3.1.2.1)
|
61
61
|
rainbow (>= 2.2.2, < 4.0)
|
62
62
|
regexp_parser (>= 1.8, < 3.0)
|
63
63
|
rexml (>= 3.2.5, < 4.0)
|
64
|
-
rubocop-ast (>= 1.
|
64
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
65
65
|
ruby-progressbar (~> 1.7)
|
66
66
|
unicode-display_width (>= 1.4.0, < 3.0)
|
67
|
-
rubocop-ast (1.24.
|
67
|
+
rubocop-ast (1.24.1)
|
68
68
|
parser (>= 3.1.1.0)
|
69
|
-
rubocop-performance (1.15.
|
69
|
+
rubocop-performance (1.15.2)
|
70
70
|
rubocop (>= 1.7.0, < 2.0)
|
71
71
|
rubocop-ast (>= 0.4.0)
|
72
|
-
rubocop-rspec (2.
|
72
|
+
rubocop-rspec (2.16.0)
|
73
73
|
rubocop (~> 1.33)
|
74
74
|
ruby-progressbar (1.11.0)
|
75
75
|
ruby2_keywords (0.0.5)
|
76
|
-
simplecov (0.
|
76
|
+
simplecov (0.22.0)
|
77
77
|
docile (~> 1.1)
|
78
78
|
simplecov-html (~> 0.11)
|
79
79
|
simplecov_json_formatter (~> 0.1)
|
80
80
|
simplecov-html (0.12.3)
|
81
81
|
simplecov_json_formatter (0.1.4)
|
82
|
-
standard (1.
|
82
|
+
standard (1.21.1)
|
83
83
|
language_server-protocol (~> 3.17.0.2)
|
84
|
-
rubocop (= 1.
|
85
|
-
rubocop-performance (= 1.15.
|
84
|
+
rubocop (= 1.42.0)
|
85
|
+
rubocop-performance (= 1.15.2)
|
86
86
|
tzinfo (2.0.5)
|
87
87
|
concurrent-ruby (~> 1.0)
|
88
|
-
unicode-display_width (2.
|
88
|
+
unicode-display_width (2.4.2)
|
89
89
|
webmock (3.18.1)
|
90
90
|
addressable (>= 2.8.0)
|
91
91
|
crack (>= 0.3.2)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GlobusClient
|
4
|
+
# Wraps API operations to request new access token if expired
|
5
|
+
class TokenWrapper
|
6
|
+
def self.refresh(config, &block)
|
7
|
+
yield
|
8
|
+
rescue UnexpectedResponse::UnauthorizedError
|
9
|
+
config.token = Authenticator.token(config.client_id, config.client_secret, config.auth_url)
|
10
|
+
yield
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/globus_client.rb
CHANGED
@@ -23,6 +23,8 @@ class GlobusClient
|
|
23
23
|
def configure(client_id:, client_secret:, uploads_directory:, transfer_endpoint_id:, transfer_url: default_transfer_url, auth_url: default_auth_url)
|
24
24
|
instance.config = OpenStruct.new(
|
25
25
|
token: Authenticator.token(client_id, client_secret, auth_url),
|
26
|
+
client_id:,
|
27
|
+
client_secret:,
|
26
28
|
uploads_directory:,
|
27
29
|
transfer_endpoint_id:,
|
28
30
|
transfer_url:,
|
@@ -46,41 +48,55 @@ class GlobusClient
|
|
46
48
|
attr_accessor :config
|
47
49
|
|
48
50
|
def mkdir(...)
|
49
|
-
|
50
|
-
|
51
|
-
|
51
|
+
TokenWrapper.refresh(config) do
|
52
|
+
endpoint = Endpoint.new(config, ...)
|
53
|
+
endpoint.mkdir
|
54
|
+
endpoint.allow_writes
|
55
|
+
end
|
52
56
|
end
|
53
57
|
|
54
58
|
def disallow_writes(...)
|
55
|
-
|
56
|
-
|
59
|
+
TokenWrapper.refresh(config) do
|
60
|
+
endpoint = Endpoint.new(config, ...)
|
61
|
+
endpoint.disallow_writes
|
62
|
+
end
|
57
63
|
end
|
58
64
|
|
59
65
|
# NOTE: Can't use the `...` (argument forwarding) operator here because we
|
60
66
|
# want to route the keyword args to `Endpoint#new` and the block arg to
|
61
67
|
# `Endpoint#list_files`
|
62
68
|
def list_files(**keywords, &block)
|
63
|
-
|
64
|
-
|
69
|
+
TokenWrapper.refresh(config) do
|
70
|
+
endpoint = Endpoint.new(config, **keywords)
|
71
|
+
endpoint.list_files(&block)
|
72
|
+
end
|
65
73
|
end
|
66
74
|
|
67
75
|
def file_count(...)
|
68
|
-
|
69
|
-
|
76
|
+
TokenWrapper.refresh(config) do
|
77
|
+
endpoint = Endpoint.new(config, ...)
|
78
|
+
endpoint.list_files { |files| return files.count }
|
79
|
+
end
|
70
80
|
end
|
71
81
|
|
72
82
|
def total_size(...)
|
73
|
-
|
74
|
-
|
83
|
+
TokenWrapper.refresh(config) do
|
84
|
+
endpoint = Endpoint.new(config, ...)
|
85
|
+
endpoint.list_files { |files| return files.sum(&:size) }
|
86
|
+
end
|
75
87
|
end
|
76
88
|
|
77
89
|
def get_filenames(...)
|
78
|
-
|
79
|
-
|
90
|
+
TokenWrapper.refresh(config) do
|
91
|
+
endpoint = Endpoint.new(config, ...)
|
92
|
+
endpoint.list_files { |files| return files.map(&:name) }
|
93
|
+
end
|
80
94
|
end
|
81
95
|
|
82
96
|
def user_exists?(...)
|
83
|
-
|
84
|
-
|
97
|
+
TokenWrapper.refresh(config) do
|
98
|
+
identity = Identity.new(config)
|
99
|
+
identity.exists?(...)
|
100
|
+
end
|
85
101
|
end
|
86
102
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: globus_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Collier
|
8
8
|
- Laura Wrubel
|
9
9
|
- Mike Giarlo
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-01-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -170,6 +170,7 @@ files:
|
|
170
170
|
- lib/globus_client/authenticator.rb
|
171
171
|
- lib/globus_client/endpoint.rb
|
172
172
|
- lib/globus_client/identity.rb
|
173
|
+
- lib/globus_client/token_wrapper.rb
|
173
174
|
- lib/globus_client/unexpected_response.rb
|
174
175
|
- lib/globus_client/version.rb
|
175
176
|
homepage: https://github.com/sul-dlss/globus_client
|
@@ -179,7 +180,7 @@ metadata:
|
|
179
180
|
source_code_uri: https://github.com/sul-dlss/globus_client
|
180
181
|
changelog_uri: https://github.com/sul-dlss/globus_client/releases
|
181
182
|
rubygems_mfa_required: 'true'
|
182
|
-
post_install_message:
|
183
|
+
post_install_message:
|
183
184
|
rdoc_options: []
|
184
185
|
require_paths:
|
185
186
|
- lib
|
@@ -194,8 +195,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
195
|
- !ruby/object:Gem::Version
|
195
196
|
version: '0'
|
196
197
|
requirements: []
|
197
|
-
rubygems_version: 3.3.
|
198
|
-
signing_key:
|
198
|
+
rubygems_version: 3.3.3
|
199
|
+
signing_key:
|
199
200
|
specification_version: 4
|
200
201
|
summary: Interface for interacting with the Globus API.
|
201
202
|
test_files: []
|