globus_client 0.4.0 → 0.5.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 +1 -1
- data/README.md +3 -3
- data/api_test.rb +7 -7
- data/lib/globus_client/endpoint.rb +16 -14
- data/lib/globus_client/identity.rb +4 -4
- data/lib/globus_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23d56c1a01cd643aafec353ff36adf2ad15b4792ebbd3091745415d5fcce68eb
|
4
|
+
data.tar.gz: 0d6acdff1f5a627b6a9030bf1e5154c4efef845bab052c27d4d84206ee04c822
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c6ea6b0df9c20fddb7157cd5c7a0dc3270308ce11805f1fbaebb35f704647e7bc4d097ab5a89edc68c1c87274d3adaa52abd6928d9c5d89a214eb99cf7193ac
|
7
|
+
data.tar.gz: e25b26ab750b5b176279e26de6887bafc9fc25cce8b406d2aabec931978858580d26f816e9c2c6e92e3b7cca81afaf1cee6aa84490f88c152a65c2d35ee8c3ec
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -31,9 +31,9 @@ client = GlobusClient.configure(
|
|
31
31
|
uploads_directory: Settings.globus.uploads_directory,
|
32
32
|
transfer_endpoint_id: Settings.globus.transfer_endpoint_id
|
33
33
|
)
|
34
|
-
client.mkdir(user_id: 'mjgiarlo',
|
34
|
+
client.mkdir(user_id: 'mjgiarlo@stanford.edu', path: 'mjgiarlo/work1234/version1')
|
35
35
|
|
36
|
-
result = client.user_exists?('mjgiarlo')
|
36
|
+
result = client.user_exists?('mjgiarlo@stanford.edu')
|
37
37
|
```
|
38
38
|
|
39
39
|
You can also invoke methods directly on the client class, which is useful in a
|
@@ -53,7 +53,7 @@ GlobusClient.configure(
|
|
53
53
|
# app/services/my_globus_service.rb
|
54
54
|
# ...
|
55
55
|
def create_user_directory
|
56
|
-
GlobusClient.mkdir(user_id: 'mjgiarlo',
|
56
|
+
GlobusClient.mkdir(user_id: 'mjgiarlo@stanford.edu', path: 'mjgiarlo/work1234/version1')
|
57
57
|
end
|
58
58
|
# ...
|
59
59
|
```
|
data/api_test.rb
CHANGED
@@ -11,24 +11,24 @@ GlobusClient.configure(
|
|
11
11
|
transfer_endpoint_id: ENV["GLOBUS_ENDPOINT"]
|
12
12
|
)
|
13
13
|
|
14
|
-
user_id,
|
14
|
+
user_id, path = *ARGV
|
15
15
|
|
16
16
|
# Test public API methods here.
|
17
|
-
GlobusClient.mkdir(user_id:,
|
17
|
+
GlobusClient.mkdir(user_id:, path:)
|
18
18
|
|
19
19
|
user_exists = GlobusClient.user_exists?(user_id)
|
20
20
|
|
21
21
|
# Not part of the public API but this allows us to test access changes
|
22
|
-
before_permissions = GlobusClient::Endpoint.new(GlobusClient.config, user_id
|
22
|
+
before_permissions = GlobusClient::Endpoint.new(GlobusClient.config, user_id:, path:).send(:access_rule)["permissions"]
|
23
23
|
|
24
|
-
files_count = GlobusClient.file_count(user_id:,
|
24
|
+
files_count = GlobusClient.file_count(user_id:, path:)
|
25
25
|
|
26
|
-
total_size = GlobusClient.total_size(user_id:,
|
26
|
+
total_size = GlobusClient.total_size(user_id:, path:)
|
27
27
|
|
28
|
-
GlobusClient.disallow_writes(user_id:,
|
28
|
+
GlobusClient.disallow_writes(user_id:, path:)
|
29
29
|
|
30
30
|
# Not part of the public API but this allows us to test access changes
|
31
|
-
after_permissions = GlobusClient::Endpoint.new(GlobusClient.config, user_id
|
31
|
+
after_permissions = GlobusClient::Endpoint.new(GlobusClient.config, user_id:, path:).send(:access_rule)["permissions"]
|
32
32
|
|
33
33
|
puts "User #{user_id} exists: #{user_exists}"
|
34
34
|
puts "Initial directory permissions: #{before_permissions}"
|
@@ -3,15 +3,15 @@
|
|
3
3
|
class GlobusClient
|
4
4
|
# The namespace for endpoint API operations
|
5
5
|
class Endpoint
|
6
|
+
PATH_SEPARATOR = "/"
|
7
|
+
|
6
8
|
# @param config [#token, #uploads_directory, #transfer_endpoint_id, #transfer_url, #auth_url] configuration for the gem
|
7
|
-
# @param
|
8
|
-
# @param
|
9
|
-
|
10
|
-
def initialize(config, user_id:, work_id:, work_version:)
|
9
|
+
# @param path [String] the path to operate on
|
10
|
+
# @param user_id [String] a Globus user ID (e.g., a @stanford.edu email address)
|
11
|
+
def initialize(config, path:, user_id:)
|
11
12
|
@config = config
|
12
13
|
@user_id = user_id
|
13
|
-
@
|
14
|
-
@work_version = work_version
|
14
|
+
@path = path
|
15
15
|
end
|
16
16
|
|
17
17
|
def file_count
|
@@ -58,7 +58,7 @@ class GlobusClient
|
|
58
58
|
|
59
59
|
private
|
60
60
|
|
61
|
-
attr_reader :config, :
|
61
|
+
attr_reader :config, :path, :user_id
|
62
62
|
|
63
63
|
def connection
|
64
64
|
# Transfer API connection
|
@@ -68,17 +68,19 @@ class GlobusClient
|
|
68
68
|
)
|
69
69
|
end
|
70
70
|
|
71
|
-
def
|
71
|
+
def globus_identity_id
|
72
72
|
Identity.new(config).get_identity_id(user_id)
|
73
73
|
end
|
74
74
|
|
75
75
|
# Builds up a path from a list of path elements. E.g., input would look like:
|
76
|
-
#
|
76
|
+
# "mjgiarlo/work123/version1"
|
77
77
|
# And this method returns:
|
78
78
|
# ["/uploads/mjgiarlo/", "/uploads/mjgiarlo/work123/", "/uploads/mjgiarlo/work123/version1/"]
|
79
79
|
def paths
|
80
80
|
path_segments.map.with_index do |_segment, index|
|
81
|
-
File
|
81
|
+
File
|
82
|
+
.join(config.uploads_directory, path_segments.slice(..index))
|
83
|
+
.concat(PATH_SEPARATOR)
|
82
84
|
end
|
83
85
|
end
|
84
86
|
|
@@ -88,7 +90,7 @@ class GlobusClient
|
|
88
90
|
end
|
89
91
|
|
90
92
|
def path_segments
|
91
|
-
|
93
|
+
path.split(PATH_SEPARATOR)
|
92
94
|
end
|
93
95
|
|
94
96
|
def objects
|
@@ -117,16 +119,16 @@ class GlobusClient
|
|
117
119
|
req.body = {
|
118
120
|
DATA_TYPE: "access",
|
119
121
|
principal_type: "identity",
|
120
|
-
principal:
|
122
|
+
principal: globus_identity_id,
|
121
123
|
path: full_path,
|
122
124
|
permissions:,
|
123
|
-
notify_email:
|
125
|
+
notify_email: user_id
|
124
126
|
}.to_json
|
125
127
|
req.headers["Content-Type"] = "application/json"
|
126
128
|
end
|
127
129
|
end
|
128
130
|
|
129
|
-
return
|
131
|
+
return true if response.success?
|
130
132
|
|
131
133
|
UnexpectedResponse.call(response)
|
132
134
|
end
|
@@ -7,8 +7,8 @@ class GlobusClient
|
|
7
7
|
@config = config
|
8
8
|
end
|
9
9
|
|
10
|
-
def get_identity_id(
|
11
|
-
@email =
|
10
|
+
def get_identity_id(user_id)
|
11
|
+
@email = user_id
|
12
12
|
|
13
13
|
response = lookup_identity
|
14
14
|
UnexpectedResponse.call(response) unless response.success?
|
@@ -17,8 +17,8 @@ class GlobusClient
|
|
17
17
|
extract_id(data)
|
18
18
|
end
|
19
19
|
|
20
|
-
def exists?(
|
21
|
-
get_identity_id(
|
20
|
+
def exists?(user_id)
|
21
|
+
get_identity_id(user_id)
|
22
22
|
true
|
23
23
|
rescue
|
24
24
|
false
|
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.
|
4
|
+
version: 0.5.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: 2022-12-
|
13
|
+
date: 2022-12-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|