globus_client 0.9.0 → 0.10.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: 98ab11c317225b75273064fa994c5959d2dd5de9e5276f0c3cc81e264d52140c
4
- data.tar.gz: 445c5c522f4e41a735331f3cf3c47a07a6854cc39c308e028bab616759f07703
3
+ metadata.gz: 5427a4692e19e5eedb9cd6e3e90d6951e5a4adc1135ca713ca72c81ca09f9deb
4
+ data.tar.gz: 25f9816388cf1ca0c9ff908df97f5257a246b94c20ce3ecc7fce98a4d7ca3bbe
5
5
  SHA512:
6
- metadata.gz: 332fdd907867b012edb68cdb145241dcd666f264a8afc806eaf41028af8af3addcd76b16560c79a2db49c69ecce1d9b3cc5cdb4a718e07fe6ede80b117dc7387
7
- data.tar.gz: f614098b8258b8598f92fe4fd1e73257e1b413cb8573bb2ccb84235278ebe93f0c249392a5113bc56dae88f3b55b09dc876ed11c20e40fabd0ee4d55b7ec18a4
6
+ metadata.gz: 476a72181dc845cb4e3b5fa6a16cfc4962d23abdd2b058a544668969db70b9fc46d3f88afcc28e876ada57e92bf00d40bce3b5f6ec2d0567d8dbbf326c48b0c5
7
+ data.tar.gz: d89e245e9f05d6826206ac000f283f50454798771137a3727004027bee771befa498bbe01513dc4c6ba804120c544b1d5268a0886acba1b5369f34e6df9bd00f
data/Gemfile.lock CHANGED
@@ -1,77 +1,89 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- globus_client (0.9.0)
4
+ globus_client (0.10.0)
5
5
  activesupport (>= 4.2, < 8)
6
6
  faraday
7
+ faraday-retry
7
8
  zeitwerk
8
9
 
9
10
  GEM
10
11
  remote: https://rubygems.org/
11
12
  specs:
12
- activesupport (7.0.4)
13
+ activesupport (7.0.5)
13
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
15
  i18n (>= 1.6, < 2)
15
16
  minitest (>= 5.1)
16
17
  tzinfo (~> 2.0)
17
- addressable (2.8.1)
18
+ addressable (2.8.4)
18
19
  public_suffix (>= 2.0.2, < 6.0)
19
20
  ast (2.4.2)
20
21
  byebug (11.1.3)
21
- concurrent-ruby (1.1.10)
22
+ concurrent-ruby (1.2.2)
22
23
  crack (0.4.5)
23
24
  rexml
24
25
  diff-lcs (1.5.0)
25
26
  docile (1.4.0)
26
- faraday (2.7.2)
27
+ faraday (2.7.7)
27
28
  faraday-net_http (>= 2.0, < 3.1)
28
29
  ruby2_keywords (>= 0.0.4)
29
30
  faraday-net_http (3.0.2)
31
+ faraday-retry (2.2.0)
32
+ faraday (~> 2.0)
30
33
  hashdiff (1.0.1)
31
- i18n (1.12.0)
34
+ i18n (1.14.1)
32
35
  concurrent-ruby (~> 1.0)
33
36
  json (2.6.3)
34
- language_server-protocol (3.17.0.2)
35
- minitest (5.17.0)
36
- parallel (1.22.1)
37
- parser (3.2.0.0)
37
+ language_server-protocol (3.17.0.3)
38
+ lint_roller (1.0.0)
39
+ minitest (5.18.1)
40
+ parallel (1.23.0)
41
+ parser (3.2.2.3)
38
42
  ast (~> 2.4.1)
43
+ racc
39
44
  public_suffix (5.0.1)
45
+ racc (1.7.1)
40
46
  rainbow (3.1.1)
41
47
  rake (13.0.6)
42
- regexp_parser (2.6.1)
48
+ regexp_parser (2.8.1)
43
49
  rexml (3.2.5)
44
50
  rspec (3.12.0)
45
51
  rspec-core (~> 3.12.0)
46
52
  rspec-expectations (~> 3.12.0)
47
53
  rspec-mocks (~> 3.12.0)
48
- rspec-core (3.12.0)
54
+ rspec-core (3.12.2)
49
55
  rspec-support (~> 3.12.0)
50
- rspec-expectations (3.12.2)
56
+ rspec-expectations (3.12.3)
51
57
  diff-lcs (>= 1.2.0, < 2.0)
52
58
  rspec-support (~> 3.12.0)
53
- rspec-mocks (3.12.2)
59
+ rspec-mocks (3.12.5)
54
60
  diff-lcs (>= 1.2.0, < 2.0)
55
61
  rspec-support (~> 3.12.0)
56
62
  rspec-support (3.12.0)
57
- rubocop (1.42.0)
63
+ rubocop (1.52.1)
58
64
  json (~> 2.3)
59
65
  parallel (~> 1.10)
60
- parser (>= 3.1.2.1)
66
+ parser (>= 3.2.2.3)
61
67
  rainbow (>= 2.2.2, < 4.0)
62
68
  regexp_parser (>= 1.8, < 3.0)
63
69
  rexml (>= 3.2.5, < 4.0)
64
- rubocop-ast (>= 1.24.1, < 2.0)
70
+ rubocop-ast (>= 1.28.0, < 2.0)
65
71
  ruby-progressbar (~> 1.7)
66
- unicode-display_width (>= 1.4.0, < 3.0)
67
- rubocop-ast (1.24.1)
68
- parser (>= 3.1.1.0)
69
- rubocop-performance (1.15.2)
72
+ unicode-display_width (>= 2.4.0, < 3.0)
73
+ rubocop-ast (1.29.0)
74
+ parser (>= 3.2.1.0)
75
+ rubocop-capybara (2.18.0)
76
+ rubocop (~> 1.41)
77
+ rubocop-factory_bot (2.23.1)
78
+ rubocop (~> 1.33)
79
+ rubocop-performance (1.18.0)
70
80
  rubocop (>= 1.7.0, < 2.0)
71
81
  rubocop-ast (>= 0.4.0)
72
- rubocop-rspec (2.16.0)
82
+ rubocop-rspec (2.22.0)
73
83
  rubocop (~> 1.33)
74
- ruby-progressbar (1.11.0)
84
+ rubocop-capybara (~> 2.17)
85
+ rubocop-factory_bot (~> 2.22)
86
+ ruby-progressbar (1.13.0)
75
87
  ruby2_keywords (0.0.5)
76
88
  simplecov (0.22.0)
77
89
  docile (~> 1.1)
@@ -79,23 +91,31 @@ GEM
79
91
  simplecov_json_formatter (~> 0.1)
80
92
  simplecov-html (0.12.3)
81
93
  simplecov_json_formatter (0.1.4)
82
- standard (1.21.1)
94
+ standard (1.29.0)
83
95
  language_server-protocol (~> 3.17.0.2)
84
- rubocop (= 1.42.0)
85
- rubocop-performance (= 1.15.2)
86
- tzinfo (2.0.5)
96
+ lint_roller (~> 1.0)
97
+ rubocop (~> 1.52.0)
98
+ standard-custom (~> 1.0.0)
99
+ standard-performance (~> 1.1.0)
100
+ standard-custom (1.0.1)
101
+ lint_roller (~> 1.0)
102
+ standard-performance (1.1.0)
103
+ lint_roller (~> 1.0)
104
+ rubocop-performance (~> 1.18.0)
105
+ tzinfo (2.0.6)
87
106
  concurrent-ruby (~> 1.0)
88
107
  unicode-display_width (2.4.2)
89
108
  webmock (3.18.1)
90
109
  addressable (>= 2.8.0)
91
110
  crack (>= 0.3.2)
92
111
  hashdiff (>= 0.4.0, < 2.0.0)
93
- zeitwerk (2.6.6)
112
+ zeitwerk (2.6.8)
94
113
 
95
114
  PLATFORMS
96
115
  x86_64-darwin-19
97
116
  x86_64-darwin-20
98
117
  x86_64-darwin-21
118
+ x86_64-darwin-22
99
119
  x86_64-linux
100
120
 
101
121
  DEPENDENCIES
@@ -109,4 +129,4 @@ DEPENDENCIES
109
129
  webmock
110
130
 
111
131
  BUNDLED WITH
112
- 2.3.26
132
+ 2.4.13
data/README.md CHANGED
@@ -33,7 +33,7 @@ client = GlobusClient.configure(
33
33
  )
34
34
  client.mkdir(user_id: 'mjgiarlo@stanford.edu', path: 'mjgiarlo/work1234/version1')
35
35
 
36
- result = client.user_exists?('mjgiarlo@stanford.edu')
36
+ result = client.user_valid?('mjgiarlo@stanford.edu')
37
37
  ```
38
38
 
39
39
  You can also invoke methods directly on the client class, which is useful in a
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
33
33
 
34
34
  spec.add_dependency "activesupport", ">= 4.2", "< 8"
35
35
  spec.add_dependency "faraday"
36
+ spec.add_dependency "faraday-retry"
36
37
  spec.add_dependency "zeitwerk"
37
38
 
38
39
  spec.add_development_dependency "rake", "~> 13.0"
@@ -65,11 +65,20 @@ class GlobusClient
65
65
  attr_reader :config, :path, :user_id
66
66
 
67
67
  def connection
68
- # Transfer API connection
68
+ # faraday/retry is used here to catch Faraday::ConnectionFailed exceptions
69
+ # see: https://github.com/sul-dlss/happy-heron/issues/3008
69
70
  @connection ||= Faraday.new(
70
71
  url: config.transfer_url,
71
72
  headers: {Authorization: "Bearer #{config.token}"}
72
- )
73
+ ) do |faraday|
74
+ faraday.request :retry, {
75
+ max: 10,
76
+ interval: 0.05,
77
+ interval_randomness: 0.5,
78
+ backoff_factor: 2,
79
+ exceptions: Faraday::Retry::Middleware::DEFAULT_EXCEPTIONS + [Faraday::ConnectionFailed]
80
+ }
81
+ end
73
82
  end
74
83
 
75
84
  def globus_identity_id
@@ -7,9 +7,10 @@ class GlobusClient
7
7
  @config = config
8
8
  end
9
9
 
10
- def get_identity_id(user_id)
10
+ # @param user_id [String] the username in the form of an email addresss
11
+ # @return [Hash] id and status of Globus identity
12
+ def get_identity(user_id)
11
13
  @email = user_id
12
-
13
14
  response = lookup_identity
14
15
  UnexpectedResponse.call(response) unless response.success?
15
16
 
@@ -17,12 +18,16 @@ class GlobusClient
17
18
  extract_id(data)
18
19
  end
19
20
 
20
- def exists?(user_id)
21
- get_identity_id(user_id)
22
- true
23
- # if no active user is returned
24
- rescue RuntimeError
25
- false
21
+ # @param user_id [String] the username in the form of an email addresss
22
+ # @return [Boolean] whether the account has a valid status
23
+ def valid?(user_id)
24
+ ["used", "private", "unused"].include?(get_identity(user_id)["status"])
25
+ end
26
+
27
+ # @param user_id [String] the username in the form of an email addresss
28
+ # @return [String] UUID for Globus identity
29
+ def get_identity_id(user_id)
30
+ get_identity(user_id)["id"]
26
31
  end
27
32
 
28
33
  private
@@ -43,12 +48,7 @@ class GlobusClient
43
48
 
44
49
  def extract_id(data)
45
50
  identities = data["identities"]
46
- # Select identity with "used" or "private" status
47
- matching_users = identities.select { |id| id["username"] == @email }
48
- active_users = matching_users.select { |user| (user["status"] == "used" || user["status"] == "private") }
49
- raise "No matching active Globus user found for #{@email}." if active_users.empty?
50
-
51
- active_users.first["id"]
51
+ identities.find { |id| id["username"] == @email }
52
52
  end
53
53
  end
54
54
  end
@@ -3,7 +3,7 @@
3
3
  class GlobusClient
4
4
  # Wraps API operations to request new access token if expired
5
5
  class TokenWrapper
6
- def self.refresh(config, &block)
6
+ def self.refresh(config)
7
7
  yield
8
8
  rescue UnexpectedResponse::UnauthorizedError
9
9
  config.token = Authenticator.token(config.client_id, config.client_secret, config.auth_url)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class GlobusClient
4
- VERSION = "0.9.0"
4
+ VERSION = "0.10.0"
5
5
  end
data/lib/globus_client.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "active_support/core_ext/module/delegation"
4
4
  require "faraday"
5
+ require "faraday/retry"
5
6
  require "ostruct"
6
7
  require "singleton"
7
8
  require "zeitwerk"
@@ -35,7 +36,7 @@ class GlobusClient
35
36
  end
36
37
 
37
38
  delegate :config, :disallow_writes, :file_count, :list_files, :mkdir, :total_size,
38
- :user_exists?, :get_filenames, :has_files?, to: :instance
39
+ :user_valid?, :get_filenames, :has_files?, to: :instance
39
40
 
40
41
  def default_transfer_url
41
42
  "https://transfer.api.globusonline.org"
@@ -101,10 +102,10 @@ class GlobusClient
101
102
  end
102
103
  end
103
104
 
104
- def user_exists?(...)
105
+ def user_valid?(...)
105
106
  TokenWrapper.refresh(config) do
106
107
  identity = Identity.new(config)
107
- identity.exists?(...)
108
+ identity.valid?(...)
108
109
  end
109
110
  end
110
111
  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.9.0
4
+ version: 0.10.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: 2023-01-12 00:00:00.000000000 Z
13
+ date: 2023-06-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -46,6 +46,20 @@ dependencies:
46
46
  - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
+ - !ruby/object:Gem::Dependency
50
+ name: faraday-retry
51
+ requirement: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ type: :runtime
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
49
63
  - !ruby/object:Gem::Dependency
50
64
  name: zeitwerk
51
65
  requirement: !ruby/object:Gem::Requirement
@@ -180,7 +194,7 @@ metadata:
180
194
  source_code_uri: https://github.com/sul-dlss/globus_client
181
195
  changelog_uri: https://github.com/sul-dlss/globus_client/releases
182
196
  rubygems_mfa_required: 'true'
183
- post_install_message:
197
+ post_install_message:
184
198
  rdoc_options: []
185
199
  require_paths:
186
200
  - lib
@@ -195,8 +209,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
209
  - !ruby/object:Gem::Version
196
210
  version: '0'
197
211
  requirements: []
198
- rubygems_version: 3.3.7
199
- signing_key:
212
+ rubygems_version: 3.4.10
213
+ signing_key:
200
214
  specification_version: 4
201
215
  summary: Interface for interacting with the Globus API.
202
216
  test_files: []