Class: GlobusClient::Endpoint
- Inherits:
-
Object
- Object
- GlobusClient::Endpoint
- Defined in:
- lib/globus_client/endpoint.rb
Overview
The namespace for endpoint API operations
Defined Under Namespace
Classes: FileInfo
Constant Summary collapse
- PATH_SEPARATOR =
rubocop:disable Metrics/ClassLength
'/'
Instance Method Summary collapse
-
#allow_writes ⇒ Object
Assign a user read/write permissions for a directory docs.globus.org/api/transfer/acl/#rest_access_create.
-
#delete_access_rule ⇒ Object
Delete the access rule docs.globus.org/api/transfer/acl/#delete_access_rule.
-
#disallow_writes ⇒ Object
Assign a user read-only permissions for a directory docs.globus.org/api/transfer/acl/#rest_access_create.
- #has_files? ⇒ Boolean
-
#initialize(client, path:, user_id:, notify_email: true) ⇒ Endpoint
constructor
A new instance of Endpoint.
- #list_files ⇒ Object
-
#mkdir ⇒ Object
Create a directory docs.globus.org/api/transfer/file_operations/#make_directory.
Constructor Details
#initialize(client, path:, user_id:, notify_email: true) ⇒ Endpoint
Returns a new instance of Endpoint.
14 15 16 17 18 19 |
# File 'lib/globus_client/endpoint.rb', line 14 def initialize(client, path:, user_id:, notify_email: true) @client = client @user_id = user_id @path = path @notify_email = notify_email end |
Instance Method Details
#allow_writes ⇒ Object
Assign a user read/write permissions for a directory docs.globus.org/api/transfer/acl/#rest_access_create
47 48 49 |
# File 'lib/globus_client/endpoint.rb', line 47 def allow_writes access_request(permissions: 'rw') end |
#delete_access_rule ⇒ Object
Delete the access rule docs.globus.org/api/transfer/acl/#delete_access_rule
57 58 59 60 61 62 63 64 |
# File 'lib/globus_client/endpoint.rb', line 57 def delete_access_rule raise(StandardError, "Access rule not found for #{path}") unless access_rule_id client.delete( base_url: client.config.transfer_url, path: "#{access_path}/#{access_rule_id}" ) end |
#disallow_writes ⇒ Object
Assign a user read-only permissions for a directory docs.globus.org/api/transfer/acl/#rest_access_create
52 53 54 |
# File 'lib/globus_client/endpoint.rb', line 52 def disallow_writes update_access_request(permissions: 'r') end |
#has_files? ⇒ Boolean
21 22 23 |
# File 'lib/globus_client/endpoint.rb', line 21 def has_files? ls_path(full_path, [], return_presence: true) end |
#list_files ⇒ Object
25 26 27 28 29 |
# File 'lib/globus_client/endpoint.rb', line 25 def list_files ls_path(full_path, []).tap do |files| yield files if block_given? end end |
#mkdir ⇒ Object
Create a directory docs.globus.org/api/transfer/file_operations/#make_directory
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/globus_client/endpoint.rb', line 32 def mkdir # transfer API does not support recursive directory creation paths.each do |path| client.post( base_url: client.config.transfer_url, path: "#{transfer_path}/mkdir", body: { DATA_TYPE: 'mkdir', path: }, expected_response: lambda { |resp| resp.status == 502 && JSON.parse(resp.body)['code'] == 'ExternalError.MkdirFailed.Exists' } ) end end |