globus_client 0.5.0 → 0.6.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 +7 -7
- data/README.md +4 -0
- data/api_test.rb +3 -0
- data/lib/globus_client/endpoint.rb +21 -0
- data/lib/globus_client/version.rb +1 -1
- data/lib/globus_client.rb +6 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48a7e0a937ea5e51b5803b69237c2d03afdc95a14a26008b6df31b708b086600
|
4
|
+
data.tar.gz: 431c01307b660f6cab3240963e508f57d1d1a8412e75b3468b7c16a48fc220c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccb73a4b9709b88f4bcf2bfcd59775beeee645c3b79b7c9a1083cb922ea4cb014ed07141579bf92532be103eb79bf23b7a65b727f0343b8f4ecec9f294fdfd05
|
7
|
+
data.tar.gz: 4aa6ff81e7ac5109526ca7608c089e2b5a1f8f7ce4e4f9a8c4eabaf14805dc22d4c0380624aef82179dee222ef1e7997fd7a485355e152a13fd81f1f64e20425
|
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.6.0)
|
5
5
|
activesupport (>= 4.2, < 8)
|
6
6
|
faraday
|
7
7
|
zeitwerk
|
@@ -30,13 +30,13 @@ GEM
|
|
30
30
|
hashdiff (1.0.1)
|
31
31
|
i18n (1.12.0)
|
32
32
|
concurrent-ruby (~> 1.0)
|
33
|
-
json (2.6.
|
34
|
-
language_server-protocol (3.17.0.
|
33
|
+
json (2.6.3)
|
34
|
+
language_server-protocol (3.17.0.2)
|
35
35
|
minitest (5.16.3)
|
36
36
|
parallel (1.22.1)
|
37
37
|
parser (3.1.3.0)
|
38
38
|
ast (~> 2.4.1)
|
39
|
-
public_suffix (5.0.
|
39
|
+
public_suffix (5.0.1)
|
40
40
|
rainbow (3.1.1)
|
41
41
|
rake (13.0.6)
|
42
42
|
regexp_parser (2.6.1)
|
@@ -50,7 +50,7 @@ GEM
|
|
50
50
|
rspec-expectations (3.12.0)
|
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.1)
|
54
54
|
diff-lcs (>= 1.2.0, < 2.0)
|
55
55
|
rspec-support (~> 3.12.0)
|
56
56
|
rspec-support (3.12.0)
|
@@ -79,8 +79,8 @@ GEM
|
|
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.19.
|
83
|
-
language_server-protocol (
|
82
|
+
standard (1.19.1)
|
83
|
+
language_server-protocol (~> 3.17.0.2)
|
84
84
|
rubocop (= 1.39.0)
|
85
85
|
rubocop-performance (= 1.15.1)
|
86
86
|
tzinfo (2.0.5)
|
data/README.md
CHANGED
@@ -55,6 +55,10 @@ GlobusClient.configure(
|
|
55
55
|
def create_user_directory
|
56
56
|
GlobusClient.mkdir(user_id: 'mjgiarlo@stanford.edu', path: 'mjgiarlo/work1234/version1')
|
57
57
|
end
|
58
|
+
|
59
|
+
def lookup_dir_contents
|
60
|
+
GlobusClient.get_filenames(user_id: 'mjgiarlo@stanford.edu', path: 'mjgiarlo/work1234/version1')
|
61
|
+
end
|
58
62
|
# ...
|
59
63
|
```
|
60
64
|
|
data/api_test.rb
CHANGED
@@ -27,6 +27,8 @@ total_size = GlobusClient.total_size(user_id:, path:)
|
|
27
27
|
|
28
28
|
GlobusClient.disallow_writes(user_id:, path:)
|
29
29
|
|
30
|
+
files_list = GlobusClient.get_filenames(user_id:, path:)
|
31
|
+
|
30
32
|
# Not part of the public API but this allows us to test access changes
|
31
33
|
after_permissions = GlobusClient::Endpoint.new(GlobusClient.config, user_id:, path:).send(:access_rule)["permissions"]
|
32
34
|
|
@@ -34,4 +36,5 @@ puts "User #{user_id} exists: #{user_exists}"
|
|
34
36
|
puts "Initial directory permissions: #{before_permissions}"
|
35
37
|
puts "Number of files in directory: #{files_count}"
|
36
38
|
puts "Total size of files in directory: #{total_size}"
|
39
|
+
puts "List of files in directory: #{files_list}"
|
37
40
|
puts "Final directory permissions: #{after_permissions}"
|
@@ -56,6 +56,10 @@ class GlobusClient
|
|
56
56
|
access_request(permissions: "r")
|
57
57
|
end
|
58
58
|
|
59
|
+
def get_filenames
|
60
|
+
ls_path(full_path, [])
|
61
|
+
end
|
62
|
+
|
59
63
|
private
|
60
64
|
|
61
65
|
attr_reader :config, :path, :user_id
|
@@ -105,6 +109,23 @@ class GlobusClient
|
|
105
109
|
objects["DATA"].select { |object| object["DATA_TYPE"] == "file" }
|
106
110
|
end
|
107
111
|
|
112
|
+
# @param filepath [String] an absolute path to look up contents e.g. /uploads/example/work123/version1
|
113
|
+
# @param filenames [Array<String>] a list of filenames, with absolute filepaths
|
114
|
+
def ls_path(filepath, filenames)
|
115
|
+
# List files recursively at an endpoint https://docs.globus.org/api/transfer/file_operations/#list_directory_contents
|
116
|
+
response = connection.get("#{transfer_path}/ls?path=#{filepath}")
|
117
|
+
if response.success?
|
118
|
+
data = JSON.parse(response.body)["DATA"]
|
119
|
+
data.select { |object| object["type"] == "file" }.map { |file| file["name"] }
|
120
|
+
.each { |file| filenames << "#{filepath}#{file}" }
|
121
|
+
data.select { |object| object["type"] == "dir" }.map { |dir| dir["name"] }
|
122
|
+
.each { |dir| ls_path("#{filepath}#{dir}/", filenames) }
|
123
|
+
else
|
124
|
+
UnexpectedResponse.call(response)
|
125
|
+
end
|
126
|
+
filenames
|
127
|
+
end
|
128
|
+
|
108
129
|
def access_request(permissions:)
|
109
130
|
response = if access_rule_id
|
110
131
|
connection.put("#{access_path}/#{access_rule_id}") do |req|
|
data/lib/globus_client.rb
CHANGED
@@ -32,7 +32,7 @@ class GlobusClient
|
|
32
32
|
self
|
33
33
|
end
|
34
34
|
|
35
|
-
delegate :config, :disallow_writes, :file_count, :mkdir, :total_size, :user_exists?, to: :instance
|
35
|
+
delegate :config, :disallow_writes, :file_count, :mkdir, :total_size, :user_exists?, :get_filenames, to: :instance
|
36
36
|
|
37
37
|
def default_transfer_url
|
38
38
|
"https://transfer.api.globusonline.org"
|
@@ -66,6 +66,11 @@ class GlobusClient
|
|
66
66
|
endpoint.total_size
|
67
67
|
end
|
68
68
|
|
69
|
+
def get_filenames(...)
|
70
|
+
endpoint = Endpoint.new(config, ...)
|
71
|
+
endpoint.get_filenames
|
72
|
+
end
|
73
|
+
|
69
74
|
def user_exists?(...)
|
70
75
|
identity = Identity.new(config)
|
71
76
|
identity.exists?(...)
|
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.6.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: 2022-12-
|
13
|
+
date: 2022-12-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -179,7 +179,7 @@ metadata:
|
|
179
179
|
source_code_uri: https://github.com/sul-dlss/globus_client
|
180
180
|
changelog_uri: https://github.com/sul-dlss/globus_client/releases
|
181
181
|
rubygems_mfa_required: 'true'
|
182
|
-
post_install_message:
|
182
|
+
post_install_message:
|
183
183
|
rdoc_options: []
|
184
184
|
require_paths:
|
185
185
|
- lib
|
@@ -194,8 +194,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
194
|
- !ruby/object:Gem::Version
|
195
195
|
version: '0'
|
196
196
|
requirements: []
|
197
|
-
rubygems_version: 3.3.
|
198
|
-
signing_key:
|
197
|
+
rubygems_version: 3.3.3
|
198
|
+
signing_key:
|
199
199
|
specification_version: 4
|
200
200
|
summary: Interface for interacting with the Globus API.
|
201
201
|
test_files: []
|