globus_client 0.16.0 → 0.18.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: 9e2a9f5ea8b86fba80105171529f3c22b751e00703905d0ba3b20d08ea61111c
4
- data.tar.gz: 1376671b1dbd3dd2adba6bf2e076097f8c96d13f9773a0a976270dfd4592cf4b
3
+ metadata.gz: e7af86d10638224774c4bef0d85c4cbbe4e80c67edf432e6194ba097c8cb1cbe
4
+ data.tar.gz: 7d2cb00fa8d76638fd8f6c0581766b5d9aaf5c3ed6a0322c69c12a64b1ebbf0d
5
5
  SHA512:
6
- metadata.gz: bde893f245af7928af36da0676452bd503cfd3c9d847b1d66efb9be18591563ab1d09ef12b8341223968fa1c0534c31a90263689b392f739539a4fadbf1b091c
7
- data.tar.gz: b37a773e0005668970a04895e47d4f188cc53d38991283c717eb5d9a52a756218b666538c5ce9da1ee6559b71facaace57ca9eae3d0fc2094e47b373d047ba2f
6
+ metadata.gz: 82be27face7403bf3e05f0c7356cd49fbae59afe06a37aabde60ba9a713237d144d116a57a3aff81c19cfeae046c418d8d828e6864053e8d56a72213213331f5
7
+ data.tar.gz: dc6fff3543f1d5b5a0d56ac83c49a1285fc0e28a1949a25234aa4aecfa65d65850444ac3418d69f0c4c9c772ddc4b86d3b225bff14e813d306bb20d10ca64ef6
data/.rubocop.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
- require:
3
+ plugins:
4
4
  - rubocop-performance
5
5
  - rubocop-rspec
6
6
 
@@ -22,7 +22,7 @@ Layout/LineLength:
22
22
  Max: 150
23
23
 
24
24
  # Naming
25
- Naming/PredicateName:
25
+ Naming/PredicatePrefix:
26
26
  ForbiddenPrefixes:
27
27
  - is_
28
28
  - have_
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- globus_client (0.16.0)
4
+ globus_client (0.18.0)
5
5
  activesupport (>= 4.2)
6
6
  faraday
7
7
  faraday-retry
@@ -26,9 +26,9 @@ GEM
26
26
  addressable (2.8.7)
27
27
  public_suffix (>= 2.0.2, < 7.0)
28
28
  ast (2.4.3)
29
- base64 (0.2.0)
30
- benchmark (0.4.0)
31
- bigdecimal (3.1.9)
29
+ base64 (0.3.0)
30
+ benchmark (0.4.1)
31
+ bigdecimal (3.2.2)
32
32
  byebug (12.0.0)
33
33
  concurrent-ruby (1.3.5)
34
34
  connection_pool (2.5.3)
@@ -38,13 +38,13 @@ GEM
38
38
  diff-lcs (1.6.2)
39
39
  docile (1.4.1)
40
40
  drb (2.2.3)
41
- faraday (2.13.1)
41
+ faraday (2.13.2)
42
42
  faraday-net_http (>= 2.0, < 3.5)
43
43
  json
44
44
  logger
45
- faraday-net_http (3.4.0)
45
+ faraday-net_http (3.4.1)
46
46
  net-http (>= 0.5.0)
47
- faraday-retry (2.3.1)
47
+ faraday-retry (2.3.2)
48
48
  faraday (~> 2.0)
49
49
  hashdiff (1.2.0)
50
50
  i18n (1.14.7)
@@ -64,23 +64,23 @@ GEM
64
64
  public_suffix (6.0.2)
65
65
  racc (1.8.1)
66
66
  rainbow (3.1.1)
67
- rake (13.2.1)
67
+ rake (13.3.0)
68
68
  regexp_parser (2.10.0)
69
69
  rexml (3.4.1)
70
- rspec (3.13.0)
70
+ rspec (3.13.1)
71
71
  rspec-core (~> 3.13.0)
72
72
  rspec-expectations (~> 3.13.0)
73
73
  rspec-mocks (~> 3.13.0)
74
- rspec-core (3.13.3)
74
+ rspec-core (3.13.5)
75
75
  rspec-support (~> 3.13.0)
76
- rspec-expectations (3.13.4)
76
+ rspec-expectations (3.13.5)
77
77
  diff-lcs (>= 1.2.0, < 2.0)
78
78
  rspec-support (~> 3.13.0)
79
- rspec-mocks (3.13.4)
79
+ rspec-mocks (3.13.5)
80
80
  diff-lcs (>= 1.2.0, < 2.0)
81
81
  rspec-support (~> 3.13.0)
82
- rspec-support (3.13.3)
83
- rubocop (1.75.7)
82
+ rspec-support (3.13.4)
83
+ rubocop (1.78.0)
84
84
  json (~> 2.3)
85
85
  language_server-protocol (~> 3.17.0.2)
86
86
  lint_roller (~> 1.1.0)
@@ -88,10 +88,10 @@ GEM
88
88
  parser (>= 3.3.0.2)
89
89
  rainbow (>= 2.2.2, < 4.0)
90
90
  regexp_parser (>= 2.9.3, < 3.0)
91
- rubocop-ast (>= 1.44.0, < 2.0)
91
+ rubocop-ast (>= 1.45.1, < 2.0)
92
92
  ruby-progressbar (~> 1.7)
93
93
  unicode-display_width (>= 2.4.0, < 4.0)
94
- rubocop-ast (1.44.1)
94
+ rubocop-ast (1.45.1)
95
95
  parser (>= 3.3.7.2)
96
96
  prism (~> 1.4)
97
97
  rubocop-performance (1.25.0)
@@ -53,7 +53,7 @@ class GlobusClient
53
53
 
54
54
  # Delete the access rule https://docs.globus.org/api/transfer/acl/#delete_access_rule
55
55
  def delete_access_rule
56
- raise(StandardError, "Access rule not found for #{path}") unless access_rule_id
56
+ raise GlobusClient::AccessRuleNotFound, "Access rule not found for #{path}" unless access_rule_id
57
57
 
58
58
  GlobusClient.instance.delete(
59
59
  base_url: GlobusClient.config.transfer_url,
@@ -79,7 +79,7 @@ class GlobusClient
79
79
  params: { path: }
80
80
  )
81
81
  true
82
- rescue GlobusClient::UnexpectedResponse::ResourceNotFound
82
+ rescue GlobusClient::ResourceNotFound
83
83
  false
84
84
  end
85
85
 
@@ -88,7 +88,7 @@ class GlobusClient
88
88
  attr_reader :path, :user_id, :notify_email
89
89
 
90
90
  def globus_identity_id
91
- Identity.new.get_identity_id(user_id)
91
+ @globus_identity_id ||= Identity.new.get_identity_id(user_id)
92
92
  end
93
93
 
94
94
  # Builds up a path from a list of path elements. E.g., input would look like:
@@ -168,7 +168,7 @@ class GlobusClient
168
168
  end
169
169
 
170
170
  def update_access_request(permissions:)
171
- raise(StandardError, "Access rule not found for #{path}") unless access_rule_id
171
+ raise GlobusClient::AccessRuleNotFound, "Access rule not found for #{path}" unless access_rule_id
172
172
 
173
173
  GlobusClient.instance.put(
174
174
  base_url: GlobusClient.config.transfer_url,
@@ -187,7 +187,7 @@ class GlobusClient
187
187
  content_type: 'application/json'
188
188
  )
189
189
 
190
- response.fetch('DATA').find { |acl| acl['path'] == full_path }
190
+ response.fetch('DATA').find { |acl| acl['path'] == full_path && acl['principal'] == globus_identity_id }
191
191
  end
192
192
 
193
193
  def access_rule_id
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ class GlobusClient
4
+ # Holds all of the client's custom exception classes
5
+ module Errors
6
+ # Error raised when the Globus Auth or Transfer API returns a 400 error
7
+ class BadRequestError < StandardError; end
8
+
9
+ # Error raised by the Globus Auth API returns a 401 Unauthorized
10
+ class UnauthorizedError < StandardError; end
11
+
12
+ # Error raised when the Globus Auth or Transfer API returns a 403 Forbidden
13
+ class ForbiddenError < StandardError; end
14
+
15
+ # Error raised when the Globus Auth or Transfer API returns a 404 NotFound
16
+ class ResourceNotFound < StandardError; end
17
+
18
+ # Error raised when a consumer acts upon an access rule that was not found
19
+ class AccessRuleNotFound < StandardError; end
20
+
21
+ # Error raised when response has an unexpected error (e.g., an HTTP 500)
22
+ class InternalServerError < StandardError; end
23
+
24
+ # Error raised when the Globus Transfer API returns a 502 Bad Gateway
25
+ class EndpointError < StandardError; end
26
+
27
+ # Error raised when the remote server returns a 503 Bad Gateway
28
+ class ServiceUnavailable < StandardError; end
29
+ end
30
+ end
@@ -3,24 +3,6 @@
3
3
  class GlobusClient
4
4
  # Handles unexpected responses when communicating with Globus
5
5
  class UnexpectedResponse
6
- # Error raised when the Globus Auth or Transfer API returns a 400 error
7
- class BadRequestError < StandardError; end
8
-
9
- # Error raised by the Globus Auth API returns a 401 Unauthorized
10
- class UnauthorizedError < StandardError; end
11
-
12
- # Error raised when the Globus Auth or Transfer API returns a 403 Forbidden
13
- class ForbiddenError < StandardError; end
14
-
15
- # Error raised when the Globus Auth or Transfer API returns a 404 NotFound
16
- class ResourceNotFound < StandardError; end
17
-
18
- # Error raised when the Globus Transfer API returns a 502 Bad Gateway
19
- class EndpointError < StandardError; end
20
-
21
- # Error raised when the remote server returns a 503 Bad Gateway
22
- class ServiceUnavailable < StandardError; end
23
-
24
6
  # @param [Faraday::Response] response
25
7
  # https://docs.globus.org/api/transfer/file_operations/#common_errors
26
8
  # https://docs.globus.org/api/transfer/file_operations/#errors
@@ -29,19 +11,19 @@ class GlobusClient
29
11
  def self.call(response)
30
12
  case response.status
31
13
  when 400
32
- raise BadRequestError, "Invalid path or another error with the request: #{response.body}"
14
+ raise GlobusClient::BadRequestError, "Invalid path or another error with the request: #{response.body}"
33
15
  when 401
34
- raise UnauthorizedError, "There was a problem with the access token: #{response.body} "
16
+ raise GlobusClient::UnauthorizedError, "There was a problem with the access token: #{response.body} "
35
17
  when 403
36
- raise ForbiddenError, "The operation requires privileges which the client does not have: #{response.body}"
18
+ raise GlobusClient::ForbiddenError, "The operation requires privileges which the client does not have: #{response.body}"
37
19
  when 404
38
- raise ResourceNotFound, "Endpoint ID not found or resource does not exist: #{response.body}"
20
+ raise GlobusClient::ResourceNotFound, "Endpoint ID not found or resource does not exist: #{response.body}"
39
21
  when 502
40
- raise EndpointError, "Other error with endpoint: #{response.status} #{response.body}."
22
+ raise GlobusClient::EndpointError, "Other error with endpoint: #{response.status} #{response.body}."
41
23
  when 503
42
- raise ServiceUnavailable, 'The service is down for maintenance.'
24
+ raise GlobusClient::ServiceUnavailable, 'The service is down for maintenance.'
43
25
  else
44
- raise StandardError, "Unexpected response: #{response.status} #{response.body}."
26
+ raise GlobusClient::InternalServerError, "Unexpected response: #{response.status} #{response.body}."
45
27
  end
46
28
  end
47
29
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class GlobusClient
4
- VERSION = '0.16.0'
4
+ VERSION = '0.18.0'
5
5
  end
data/lib/globus_client.rb CHANGED
@@ -12,6 +12,7 @@ Zeitwerk::Loader.for_gem.setup
12
12
 
13
13
  # Client for interacting with the Globus API
14
14
  class GlobusClient # rubocop:disable Metrics/ClassLength
15
+ include Errors
15
16
  include Singleton
16
17
 
17
18
  class << self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: globus_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Collier
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2025-05-28 00:00:00.000000000 Z
13
+ date: 2025-07-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -91,6 +91,7 @@ files:
91
91
  - lib/globus_client/authenticator.rb
92
92
  - lib/globus_client/endpoint.rb
93
93
  - lib/globus_client/endpoint_manager.rb
94
+ - lib/globus_client/errors.rb
94
95
  - lib/globus_client/identity.rb
95
96
  - lib/globus_client/unexpected_response.rb
96
97
  - lib/globus_client/version.rb