globus_client 0.15.0 → 0.16.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 +4 -4
- data/Gemfile.lock +42 -35
- data/lib/globus_client/endpoint.rb +22 -0
- data/lib/globus_client/endpoint_manager.rb +45 -0
- data/lib/globus_client/version.rb +1 -1
- data/lib/globus_client.rb +33 -2
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e2a9f5ea8b86fba80105171529f3c22b751e00703905d0ba3b20d08ea61111c
|
4
|
+
data.tar.gz: 1376671b1dbd3dd2adba6bf2e076097f8c96d13f9773a0a976270dfd4592cf4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bde893f245af7928af36da0676452bd503cfd3c9d847b1d66efb9be18591563ab1d09ef12b8341223968fa1c0534c31a90263689b392f739539a4fadbf1b091c
|
7
|
+
data.tar.gz: b37a773e0005668970a04895e47d4f188cc53d38991283c717eb5d9a52a756218b666538c5ce9da1ee6559b71facaace57ca9eae3d0fc2094e47b373d047ba2f
|
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.16.0)
|
5
5
|
activesupport (>= 4.2)
|
6
6
|
faraday
|
7
7
|
faraday-retry
|
@@ -10,7 +10,7 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activesupport (8.0.
|
13
|
+
activesupport (8.0.2)
|
14
14
|
base64
|
15
15
|
benchmark (>= 0.3)
|
16
16
|
bigdecimal
|
@@ -25,76 +25,82 @@ GEM
|
|
25
25
|
uri (>= 0.13.1)
|
26
26
|
addressable (2.8.7)
|
27
27
|
public_suffix (>= 2.0.2, < 7.0)
|
28
|
-
ast (2.4.
|
28
|
+
ast (2.4.3)
|
29
29
|
base64 (0.2.0)
|
30
30
|
benchmark (0.4.0)
|
31
31
|
bigdecimal (3.1.9)
|
32
|
-
byebug (
|
32
|
+
byebug (12.0.0)
|
33
33
|
concurrent-ruby (1.3.5)
|
34
|
-
connection_pool (2.5.
|
34
|
+
connection_pool (2.5.3)
|
35
35
|
crack (1.0.0)
|
36
36
|
bigdecimal
|
37
37
|
rexml
|
38
|
-
diff-lcs (1.
|
38
|
+
diff-lcs (1.6.2)
|
39
39
|
docile (1.4.1)
|
40
|
-
drb (2.2.
|
41
|
-
faraday (2.
|
40
|
+
drb (2.2.3)
|
41
|
+
faraday (2.13.1)
|
42
42
|
faraday-net_http (>= 2.0, < 3.5)
|
43
43
|
json
|
44
44
|
logger
|
45
45
|
faraday-net_http (3.4.0)
|
46
46
|
net-http (>= 0.5.0)
|
47
|
-
faraday-retry (2.
|
47
|
+
faraday-retry (2.3.1)
|
48
48
|
faraday (~> 2.0)
|
49
|
-
hashdiff (1.
|
49
|
+
hashdiff (1.2.0)
|
50
50
|
i18n (1.14.7)
|
51
51
|
concurrent-ruby (~> 1.0)
|
52
|
-
json (2.
|
53
|
-
language_server-protocol (3.17.0.
|
54
|
-
|
55
|
-
|
52
|
+
json (2.12.2)
|
53
|
+
language_server-protocol (3.17.0.5)
|
54
|
+
lint_roller (1.1.0)
|
55
|
+
logger (1.7.0)
|
56
|
+
minitest (5.25.5)
|
56
57
|
net-http (0.6.0)
|
57
58
|
uri
|
58
|
-
parallel (1.
|
59
|
-
parser (3.3.
|
59
|
+
parallel (1.27.0)
|
60
|
+
parser (3.3.8.0)
|
60
61
|
ast (~> 2.4.1)
|
61
62
|
racc
|
62
|
-
|
63
|
+
prism (1.4.0)
|
64
|
+
public_suffix (6.0.2)
|
63
65
|
racc (1.8.1)
|
64
66
|
rainbow (3.1.1)
|
65
67
|
rake (13.2.1)
|
66
68
|
regexp_parser (2.10.0)
|
67
|
-
rexml (3.4.
|
69
|
+
rexml (3.4.1)
|
68
70
|
rspec (3.13.0)
|
69
71
|
rspec-core (~> 3.13.0)
|
70
72
|
rspec-expectations (~> 3.13.0)
|
71
73
|
rspec-mocks (~> 3.13.0)
|
72
74
|
rspec-core (3.13.3)
|
73
75
|
rspec-support (~> 3.13.0)
|
74
|
-
rspec-expectations (3.13.
|
76
|
+
rspec-expectations (3.13.4)
|
75
77
|
diff-lcs (>= 1.2.0, < 2.0)
|
76
78
|
rspec-support (~> 3.13.0)
|
77
|
-
rspec-mocks (3.13.
|
79
|
+
rspec-mocks (3.13.4)
|
78
80
|
diff-lcs (>= 1.2.0, < 2.0)
|
79
81
|
rspec-support (~> 3.13.0)
|
80
|
-
rspec-support (3.13.
|
81
|
-
rubocop (1.
|
82
|
+
rspec-support (3.13.3)
|
83
|
+
rubocop (1.75.7)
|
82
84
|
json (~> 2.3)
|
83
|
-
language_server-protocol (
|
85
|
+
language_server-protocol (~> 3.17.0.2)
|
86
|
+
lint_roller (~> 1.1.0)
|
84
87
|
parallel (~> 1.10)
|
85
88
|
parser (>= 3.3.0.2)
|
86
89
|
rainbow (>= 2.2.2, < 4.0)
|
87
90
|
regexp_parser (>= 2.9.3, < 3.0)
|
88
|
-
rubocop-ast (>= 1.
|
91
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
89
92
|
ruby-progressbar (~> 1.7)
|
90
93
|
unicode-display_width (>= 2.4.0, < 4.0)
|
91
|
-
rubocop-ast (1.
|
92
|
-
parser (>= 3.3.
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
rubocop (
|
94
|
+
rubocop-ast (1.44.1)
|
95
|
+
parser (>= 3.3.7.2)
|
96
|
+
prism (~> 1.4)
|
97
|
+
rubocop-performance (1.25.0)
|
98
|
+
lint_roller (~> 1.1)
|
99
|
+
rubocop (>= 1.75.0, < 2.0)
|
100
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
101
|
+
rubocop-rspec (3.6.0)
|
102
|
+
lint_roller (~> 1.1)
|
103
|
+
rubocop (~> 1.72, >= 1.72.1)
|
98
104
|
ruby-progressbar (1.13.0)
|
99
105
|
securerandom (0.4.1)
|
100
106
|
simplecov (0.22.0)
|
@@ -108,14 +114,15 @@ GEM
|
|
108
114
|
unicode-display_width (3.1.4)
|
109
115
|
unicode-emoji (~> 4.0, >= 4.0.4)
|
110
116
|
unicode-emoji (4.0.4)
|
111
|
-
uri (1.0.
|
112
|
-
webmock (3.25.
|
117
|
+
uri (1.0.3)
|
118
|
+
webmock (3.25.1)
|
113
119
|
addressable (>= 2.8.0)
|
114
120
|
crack (>= 0.3.2)
|
115
121
|
hashdiff (>= 0.4.0, < 2.0.0)
|
116
|
-
zeitwerk (2.7.
|
122
|
+
zeitwerk (2.7.3)
|
117
123
|
|
118
124
|
PLATFORMS
|
125
|
+
arm64-darwin-23
|
119
126
|
x86_64-darwin-19
|
120
127
|
x86_64-darwin-20
|
121
128
|
x86_64-darwin-21
|
@@ -133,4 +140,4 @@ DEPENDENCIES
|
|
133
140
|
webmock
|
134
141
|
|
135
142
|
BUNDLED WITH
|
136
|
-
2.
|
143
|
+
2.6.9
|
@@ -61,6 +61,28 @@ class GlobusClient
|
|
61
61
|
)
|
62
62
|
end
|
63
63
|
|
64
|
+
# Renames a directory https://docs.globus.org/api/transfer/file_operations/#rename
|
65
|
+
def rename(new_path:)
|
66
|
+
GlobusClient.instance.post(
|
67
|
+
base_url: GlobusClient.config.transfer_url,
|
68
|
+
path: "#{transfer_path}/rename",
|
69
|
+
body: { DATA_TYPE: 'rename', old_path: path, new_path: }
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
73
|
+
# @returns true if the file / directory exists at the path
|
74
|
+
# See https://docs.globus.org/api/transfer/file_operations/#stat
|
75
|
+
def exists?
|
76
|
+
GlobusClient.instance.get(
|
77
|
+
base_url: GlobusClient.config.transfer_url,
|
78
|
+
path: "#{transfer_path}/stat",
|
79
|
+
params: { path: }
|
80
|
+
)
|
81
|
+
true
|
82
|
+
rescue GlobusClient::UnexpectedResponse::ResourceNotFound
|
83
|
+
false
|
84
|
+
end
|
85
|
+
|
64
86
|
private
|
65
87
|
|
66
88
|
attr_reader :path, :user_id, :notify_email
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class GlobusClient
|
4
|
+
# The namespace for endpoint management API operations
|
5
|
+
class EndpointManager
|
6
|
+
IN_PROGRESS_STATUSES = %w[ACTIVE INACTIVE].freeze
|
7
|
+
|
8
|
+
# List tasks for the configured transfer endpoint
|
9
|
+
# https://docs.globus.org/api/transfer/advanced_collection_management/#get_tasks
|
10
|
+
# Note that this method does not support pagination, as there are unlikely to be many tasks.
|
11
|
+
# Also note that if destination_path is provided, only transfer tasks will be returned.
|
12
|
+
# @param owner_id [String] the Globus user ID (a UUID, not email address)
|
13
|
+
# @param status [Array] the status of the tasks to filter on. Values are ACTIVE, INACTIVE, SUCCEEDED, or FAILED.
|
14
|
+
# @param destination_path [String] the destination path to filter tasks by
|
15
|
+
# @return [Array] list of task documents
|
16
|
+
def task_list(owner_id: nil, status: [], destination_path: nil)
|
17
|
+
tasks = GlobusClient.instance.get(
|
18
|
+
base_url: GlobusClient.config.transfer_url,
|
19
|
+
path: '/v0.10/endpoint_manager/task_list',
|
20
|
+
params: task_list_params(owner_id:, status:)
|
21
|
+
)['DATA']
|
22
|
+
return tasks unless destination_path
|
23
|
+
|
24
|
+
destination_base_path = destination_path.delete_suffix('/') << '/'
|
25
|
+
tasks.select { |task| task['destination_base_path']&.start_with?(destination_base_path) }
|
26
|
+
end
|
27
|
+
|
28
|
+
# @param owner_id [String] the Globus user ID (a UUID, not email address)
|
29
|
+
# @param destination_path [String] the destination path to filter tasks by
|
30
|
+
# @return [boolean] true if there are tasks in progress
|
31
|
+
def tasks_in_progress?(owner_id: nil, destination_path: nil)
|
32
|
+
task_list(owner_id:, destination_path:, status: IN_PROGRESS_STATUSES).present?
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def task_list_params(owner_id:, status:)
|
38
|
+
{
|
39
|
+
filter_endpoint: GlobusClient.config.transfer_endpoint_id,
|
40
|
+
filter_owner_id: owner_id,
|
41
|
+
filter_status: Array(status).join(',').presence
|
42
|
+
}.compact
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/globus_client.rb
CHANGED
@@ -48,8 +48,9 @@ class GlobusClient # rubocop:disable Metrics/ClassLength
|
|
48
48
|
end
|
49
49
|
# rubocop:enable Metrics/ParameterLists
|
50
50
|
|
51
|
-
delegate :config, :disallow_writes, :delete_access_rule, :file_count, :list_files, :mkdir, :total_size,
|
52
|
-
:user_valid?, :get_filenames, :has_files?, :
|
51
|
+
delegate :config, :disallow_writes, :allow_writes, :delete_access_rule, :file_count, :list_files, :mkdir, :rename, :total_size,
|
52
|
+
:user_valid?, :get_filenames, :has_files?, :exists?, :task_list, :tasks_in_progress?,
|
53
|
+
:delete, :get, :post, :put, to: :instance
|
53
54
|
|
54
55
|
def default_transfer_url
|
55
56
|
'https://transfer.api.globusonline.org'
|
@@ -152,12 +153,24 @@ class GlobusClient # rubocop:disable Metrics/ClassLength
|
|
152
153
|
.disallow_writes
|
153
154
|
end
|
154
155
|
|
156
|
+
def allow_writes(...)
|
157
|
+
Endpoint
|
158
|
+
.new(...)
|
159
|
+
.allow_writes
|
160
|
+
end
|
161
|
+
|
155
162
|
def delete_access_rule(...)
|
156
163
|
Endpoint
|
157
164
|
.new(...)
|
158
165
|
.delete_access_rule
|
159
166
|
end
|
160
167
|
|
168
|
+
def rename(new_path:, **args)
|
169
|
+
Endpoint
|
170
|
+
.new(**args)
|
171
|
+
.rename(new_path:)
|
172
|
+
end
|
173
|
+
|
161
174
|
# NOTE: Can't use the `...` (argument forwarding) operator here because we
|
162
175
|
# want to route the keyword args to `Endpoint#new` and the block arg to
|
163
176
|
# `Endpoint#list_files`
|
@@ -191,12 +204,30 @@ class GlobusClient # rubocop:disable Metrics/ClassLength
|
|
191
204
|
.has_files?
|
192
205
|
end
|
193
206
|
|
207
|
+
def exists?(...)
|
208
|
+
Endpoint
|
209
|
+
.new(...)
|
210
|
+
.exists?
|
211
|
+
end
|
212
|
+
|
194
213
|
def user_valid?(...)
|
195
214
|
Identity
|
196
215
|
.new
|
197
216
|
.valid?(...)
|
198
217
|
end
|
199
218
|
|
219
|
+
def task_list(...)
|
220
|
+
EndpointManager
|
221
|
+
.new
|
222
|
+
.task_list(...)
|
223
|
+
end
|
224
|
+
|
225
|
+
def tasks_in_progress?(...)
|
226
|
+
EndpointManager
|
227
|
+
.new
|
228
|
+
.tasks_in_progress?(...)
|
229
|
+
end
|
230
|
+
|
200
231
|
private
|
201
232
|
|
202
233
|
Config = Struct.new(:client_id, :auth_url, :client_secret, :transfer_endpoint_id, :transfer_url, :uploads_directory, :token, keyword_init: true)
|
metadata
CHANGED
@@ -1,15 +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.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Collier
|
8
8
|
- Laura Wrubel
|
9
9
|
- Mike Giarlo
|
10
|
+
autorequire:
|
10
11
|
bindir: exe
|
11
12
|
cert_chain: []
|
12
|
-
date: 2025-
|
13
|
+
date: 2025-05-28 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: activesupport
|
@@ -89,6 +90,7 @@ files:
|
|
89
90
|
- lib/globus_client.rb
|
90
91
|
- lib/globus_client/authenticator.rb
|
91
92
|
- lib/globus_client/endpoint.rb
|
93
|
+
- lib/globus_client/endpoint_manager.rb
|
92
94
|
- lib/globus_client/identity.rb
|
93
95
|
- lib/globus_client/unexpected_response.rb
|
94
96
|
- lib/globus_client/version.rb
|
@@ -99,6 +101,7 @@ metadata:
|
|
99
101
|
source_code_uri: https://github.com/sul-dlss/globus_client
|
100
102
|
changelog_uri: https://github.com/sul-dlss/globus_client/releases
|
101
103
|
rubygems_mfa_required: 'true'
|
104
|
+
post_install_message:
|
102
105
|
rdoc_options: []
|
103
106
|
require_paths:
|
104
107
|
- lib
|
@@ -113,7 +116,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
116
|
- !ruby/object:Gem::Version
|
114
117
|
version: '0'
|
115
118
|
requirements: []
|
116
|
-
rubygems_version: 3.
|
119
|
+
rubygems_version: 3.5.11
|
120
|
+
signing_key:
|
117
121
|
specification_version: 4
|
118
122
|
summary: Interface for interacting with the Globus API.
|
119
123
|
test_files: []
|