aspera-cli 4.29.1 → 4.30.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
- checksums.yaml.gz.sig +4 -4
- data/CHANGELOG.md +119 -0
- data/CONTRIBUTING.md +8 -1
- data/README.md +2 -0
- data/TODO.md +4 -5
- data/bin/asession +2 -2
- data/docs/README.md +616 -86
- data/docs/test-mcp-with-ai.md +4 -0
- data/lib/aspera/agent/base.rb +62 -6
- data/lib/aspera/agent/factory.rb +127 -20
- data/lib/aspera/ascp/data_repository.rb +71 -0
- data/lib/aspera/ascp/installation.rb +16 -11
- data/lib/aspera/ascp/log_analyzer/lines.rb +4 -4
- data/lib/aspera/ascp/log_analyzer/log_file.rb +5 -3
- data/lib/aspera/ascp/log_analyzer/records.rb +11 -6
- data/lib/aspera/ascp/log_analyzer.rb +43 -18
- data/lib/aspera/ascp/log_locations.rb +2 -2
- data/lib/aspera/assert.rb +8 -0
- data/lib/aspera/bundle_registry.rb +528 -0
- data/lib/aspera/cli/argument.rb +110 -0
- data/lib/aspera/cli/bool_value.rb +41 -0
- data/lib/aspera/cli/bootstrapper.rb +31 -24
- data/lib/aspera/cli/command/mount.rb +53 -0
- data/lib/aspera/cli/command/registry.rb +434 -0
- data/lib/aspera/cli/command.rb +95 -0
- data/lib/aspera/cli/command_line.rb +91 -91
- data/lib/aspera/cli/complete.rb +22 -0
- data/lib/aspera/cli/completion_actions.rb +28 -26
- data/lib/aspera/cli/context.rb +29 -6
- data/lib/aspera/cli/error.rb +39 -0
- data/lib/aspera/cli/extended_value.rb +25 -4
- data/lib/aspera/cli/formatter.rb +8 -8
- data/lib/aspera/cli/hints.rb +17 -52
- data/lib/aspera/cli/http.rb +17 -12
- data/lib/aspera/cli/mailer.rb +7 -24
- data/lib/aspera/cli/mcp/tool.rb +10 -2
- data/lib/aspera/cli/option/declarator.rb +80 -0
- data/lib/aspera/cli/option/registry.rb +74 -0
- data/lib/aspera/cli/option/source.rb +38 -0
- data/lib/aspera/cli/option/type.rb +37 -0
- data/lib/aspera/cli/option/value.rb +376 -0
- data/lib/aspera/cli/option.rb +78 -0
- data/lib/aspera/cli/options.schema.yaml +28 -783
- data/lib/aspera/cli/parser.rb +73 -41
- data/lib/aspera/cli/plugins/base.rb +122 -42
- data/lib/aspera/cli/plugins/basic_auth.rb +13 -2
- data/lib/aspera/cli/plugins/config.rb +101 -167
- data/lib/aspera/cli/plugins/factory.rb +139 -43
- data/lib/aspera/cli/plugins/mcp.rb +61 -54
- data/lib/aspera/cli/plugins/oauth.rb +19 -6
- data/lib/aspera/cli/poll.rb +14 -20
- data/lib/aspera/cli/preset_actions.rb +11 -3
- data/lib/aspera/cli/preset_manager.rb +16 -6
- data/lib/aspera/cli/result.rb +2 -2
- data/lib/aspera/cli/runner.rb +71 -99
- data/lib/aspera/cli/secret_finder.rb +1 -1
- data/lib/aspera/cli/security.rb +102 -4
- data/lib/aspera/{preview/terminal.rb → cli/terminal_image.rb} +93 -94
- data/lib/aspera/cli/vault_manager.rb +3 -3
- data/lib/aspera/cli/version.rb +1 -1
- data/lib/aspera/cli/wizard.rb +9 -3
- data/lib/aspera/coverage.rb +1 -2
- data/lib/aspera/line_logger.rb +35 -6
- data/lib/aspera/log.rb +3 -2
- data/lib/aspera/oauth/client/base.rb +19 -1
- data/lib/aspera/oauth/client/factory.rb +1 -7
- data/lib/aspera/plugin.schema.yaml +178 -0
- data/lib/aspera/plugins/alee/api.rb +25 -0
- data/lib/aspera/{cli/plugins/alee.rb → plugins/alee/commands.rb} +10 -8
- data/lib/aspera/plugins/alee/plugin.yaml +3 -0
- data/lib/aspera/plugins/aoc/admin_resources.rb +148 -0
- data/lib/aspera/plugins/aoc/api.rb +783 -0
- data/lib/aspera/{cli/plugins/aoc.rb → plugins/aoc/commands.rb} +404 -330
- data/lib/aspera/plugins/aoc/graphql.rb +45 -0
- data/lib/aspera/plugins/aoc/plugin.yaml +31 -0
- data/lib/aspera/{schema → plugins/aoc/schemas}/IBM Aspera on Cloud API-0.2.6-enhanced.yaml +15042 -7076
- data/lib/aspera/plugins/aoc/schemas/options.yaml +47 -0
- data/lib/aspera/plugins/ats/api.rb +51 -0
- data/lib/aspera/{cli/plugins/ats.rb → plugins/ats/commands.rb} +33 -33
- data/lib/aspera/plugins/ats/plugin.yaml +6 -0
- data/lib/aspera/plugins/connect/agent.rb +199 -0
- data/lib/aspera/plugins/connect/plugin.yaml +11 -0
- data/lib/aspera/plugins/connect/schemas/agent_options.yaml +6 -0
- data/lib/aspera/{cli/plugins/console.rb → plugins/console/commands.rb} +41 -33
- data/lib/aspera/plugins/console/plugin.yaml +8 -0
- data/lib/aspera/plugins/cos/api.rb +114 -0
- data/lib/aspera/{cli/plugins/cos.rb → plugins/cos/commands.rb} +19 -16
- data/lib/aspera/plugins/cos/plugin.yaml +9 -0
- data/lib/aspera/plugins/cos/schemas/options.yaml +30 -0
- data/lib/aspera/plugins/desktop/agent.rb +165 -0
- data/lib/aspera/plugins/desktop/plugin.yaml +11 -0
- data/lib/aspera/plugins/desktop/schemas/agent_options.yaml +6 -0
- data/lib/aspera/plugins/direct/agent.rb +518 -0
- data/lib/aspera/plugins/direct/plugin.yaml +11 -0
- data/lib/aspera/plugins/direct/schemas/agent_options.yaml +86 -0
- data/lib/aspera/plugins/faspex4/gateway_options.rb +18 -0
- data/lib/aspera/plugins/faspex4/gw_servlet.rb +122 -0
- data/lib/aspera/plugins/faspex4/plugin.yaml +7 -0
- data/lib/aspera/plugins/faspex4/schemas/options.yaml +57 -0
- data/lib/aspera/plugins/faspex5/api.rb +269 -0
- data/lib/aspera/{cli/plugins/faspex5.rb → plugins/faspex5/commands.rb} +152 -114
- data/lib/aspera/plugins/faspex5/faspex4_post_proc_servlet.rb +241 -0
- data/lib/aspera/plugins/faspex5/plugin.yaml +14 -0
- data/lib/aspera/{schema → plugins/faspex5/schemas}/IBM Aspera Faspex API-5.0-enhanced.yaml +279 -76
- data/lib/aspera/plugins/faspex5/schemas/options.yaml +87 -0
- data/lib/aspera/{cli/plugins/faspio.rb → plugins/faspio/commands.rb} +11 -7
- data/lib/aspera/plugins/faspio/plugin.yaml +8 -0
- data/lib/aspera/{schema → plugins/faspio/schemas}/IBM Aspera faspio Gateway API-1.0.0-enhanced.yaml +4 -2
- data/lib/aspera/plugins/httpgw/agent.rb +126 -0
- data/lib/aspera/plugins/httpgw/api.rb +411 -0
- data/lib/aspera/{cli/plugins/httpgw.rb → plugins/httpgw/commands.rb} +9 -9
- data/lib/aspera/plugins/httpgw/plugin.yaml +12 -0
- data/lib/aspera/plugins/httpgw/schemas/agent_options.yaml +24 -0
- data/lib/aspera/plugins/node/agent.rb +184 -0
- data/lib/aspera/plugins/node/api.rb +699 -0
- data/lib/aspera/{cli/plugins/node.rb → plugins/node/commands.rb} +166 -141
- data/lib/aspera/plugins/node/emulator.rb +774 -0
- data/lib/aspera/plugins/node/plugin.yaml +20 -0
- data/lib/aspera/plugins/node/schemas/agent_options.yaml +20 -0
- data/lib/aspera/plugins/node/schemas/options.yaml +190 -0
- data/lib/aspera/{cli/plugins/orchestrator.rb → plugins/orchestrator/commands.rb} +139 -110
- data/lib/aspera/plugins/orchestrator/plugin.yaml +34 -0
- data/lib/aspera/{schema → plugins/orchestrator/schemas}/IBM Aspera Orchestrator API-v1-enhanced.yaml +486 -16
- data/lib/aspera/plugins/orchestrator/schemas/options.yaml +143 -0
- data/lib/aspera/plugins/orchestrator/workflow_checker.rb +692 -0
- data/lib/aspera/{cli/plugins/preview.rb → plugins/preview/commands.rb} +53 -51
- data/lib/aspera/plugins/preview/file_types.rb +121 -0
- data/lib/aspera/plugins/preview/generator.rb +350 -0
- data/lib/aspera/plugins/preview/plugin.yaml +12 -0
- data/lib/aspera/{preview/options.schema.yaml → plugins/preview/schemas/options.yaml} +1 -1
- data/lib/aspera/plugins/preview/utils.rb +213 -0
- data/lib/aspera/plugins/server/ascmd.rb +374 -0
- data/lib/aspera/{cli/plugins/server.rb → plugins/server/commands.rb} +48 -32
- data/lib/aspera/plugins/server/plugin.yaml +9 -0
- data/lib/aspera/plugins/server/schemas/options.yaml +30 -0
- data/lib/aspera/{cli/plugins/shares.rb → plugins/shares/commands.rb} +29 -21
- data/lib/aspera/plugins/shares/plugin.yaml +10 -0
- data/lib/aspera/plugins/shares/shares_web.rb +97 -0
- data/lib/aspera/plugins/transferd/agent.rb +258 -0
- data/lib/aspera/plugins/transferd/api.rb +180 -0
- data/lib/aspera/plugins/transferd/client.rb +67 -0
- data/lib/aspera/{cli/plugins/transferd.rb → plugins/transferd/commands.rb} +43 -42
- data/lib/aspera/plugins/transferd/config_commands.rb +38 -0
- data/lib/aspera/plugins/transferd/plugin.yaml +27 -0
- data/lib/aspera/plugins/transferd/product.rb +146 -0
- data/lib/aspera/plugins/transferd/schemas/agent_options.yaml +31 -0
- data/lib/aspera/plugins/transferd/schemas/options.yaml +80 -0
- data/lib/aspera/plugins/transferd/service.rb +617 -0
- data/lib/aspera/plugins/xfer/ascp_actions.rb +131 -0
- data/lib/aspera/plugins/xfer/ascp_logs_actions.rb +198 -0
- data/lib/aspera/plugins/xfer/async_transfer_store.rb +131 -0
- data/lib/aspera/plugins/xfer/config_commands.rb +119 -0
- data/lib/aspera/plugins/xfer/helper.rb +19 -0
- data/lib/aspera/plugins/xfer/plugin.yaml +42 -0
- data/lib/aspera/plugins/xfer/schemas/agent_extension.schema.yaml +26 -0
- data/lib/aspera/plugins/xfer/schemas/options.yaml +125 -0
- data/lib/aspera/plugins/xfer/sync_actions.rb +253 -0
- data/lib/aspera/plugins/xfer/transfer_actions.rb +176 -0
- data/lib/aspera/plugins/xfer/transfer_agent.rb +505 -0
- data/lib/aspera/products/cli_v3.rb +34 -0
- data/lib/aspera/products/connect.rb +1 -1
- data/lib/aspera/products/drive.rb +29 -0
- data/lib/aspera/products/hsts.rb +34 -0
- data/lib/aspera/products/transferd.rb +25 -3
- data/lib/aspera/products.rb +54 -0
- data/lib/aspera/prompt.rb +184 -0
- data/lib/aspera/proxy_auto_config.rb +3 -3
- data/lib/aspera/rest/aspera_errors.rb +4 -38
- data/lib/aspera/rest/error_analyzer.rb +6 -2
- data/lib/aspera/rest/list.rb +4 -5
- data/lib/aspera/schema/reader.rb +15 -0
- data/lib/aspera/schema/registry.rb +239 -45
- data/lib/aspera/schema/validator.rb +63 -17
- data/lib/aspera/sealed_hash.rb +4 -0
- data/lib/aspera/secret/hider.rb +159 -24
- data/lib/aspera/secret/reference.rb +8 -0
- data/lib/aspera/secret/resolver.rb +8 -4
- data/lib/aspera/secret/store/base.rb +10 -9
- data/lib/aspera/secret/store/encrypted_hash.rb +6 -6
- data/lib/aspera/secret/store/hashicorp_vault.rb +3 -3
- data/lib/aspera/secret/store/keeper.rb +2 -2
- data/lib/aspera/secret/store/macos_security.rb +2 -3
- data/lib/aspera/secret/store/one_password_api.rb +2 -2
- data/lib/aspera/secret/store/one_password_cli.rb +3 -3
- data/lib/aspera/secret/store/secret_service.rb +2 -2
- data/lib/aspera/ssl.rb +3 -3
- data/lib/aspera/standard_input.rb +20 -0
- data/lib/aspera/{schema → sync}/async_tables.yaml +1 -1
- data/lib/aspera/sync/database.rb +7 -0
- data/lib/aspera/sync/log_parser.rb +138 -0
- data/lib/aspera/sync/operations.rb +59 -34
- data/lib/aspera/transfer/command_line_builder.rb +248 -0
- data/lib/aspera/transfer/command_line_converter.rb +37 -0
- data/lib/aspera/transfer/faux_file.rb +2 -2
- data/lib/aspera/transfer/parameters.rb +9 -10
- data/lib/aspera/transfer/spec.rb +28 -1
- data/lib/aspera/transfer/spec.schema.yaml +30 -5
- data/lib/aspera/units/decimal.rb +1 -1
- data/lib/aspera/units/timestamp.rb +84 -0
- data/lib/aspera/uri_reader.rb +2 -2
- data/lib/aspera/web_auth/paste.rb +2 -2
- data/lib/aspera/web_server_simple.rb +10 -4
- data.tar.gz.sig +0 -0
- metadata +137 -80
- metadata.gz.sig +0 -0
- data/lib/aspera/agent/connect.rb +0 -188
- data/lib/aspera/agent/desktop.rb +0 -154
- data/lib/aspera/agent/direct.rb +0 -496
- data/lib/aspera/agent/httpgw.rb +0 -100
- data/lib/aspera/agent/node.rb +0 -166
- data/lib/aspera/agent/transferd.rb +0 -341
- data/lib/aspera/api/alee.rb +0 -19
- data/lib/aspera/api/aoc.rb +0 -776
- data/lib/aspera/api/ats.rb +0 -49
- data/lib/aspera/api/cos_node.rb +0 -107
- data/lib/aspera/api/faspex.rb +0 -258
- data/lib/aspera/api/httpgw.rb +0 -409
- data/lib/aspera/api/node.rb +0 -684
- data/lib/aspera/ascmd.rb +0 -248
- data/lib/aspera/cli/ascp_actions.rb +0 -113
- data/lib/aspera/cli/ascp_logs_actions.rb +0 -188
- data/lib/aspera/cli/async_transfer_store.rb +0 -129
- data/lib/aspera/cli/command_registry.rb +0 -371
- data/lib/aspera/cli/command_spec.rb +0 -273
- data/lib/aspera/cli/option_declarator.rb +0 -74
- data/lib/aspera/cli/option_registry.rb +0 -72
- data/lib/aspera/cli/option_types.rb +0 -120
- data/lib/aspera/cli/option_value.rb +0 -345
- data/lib/aspera/cli/prompt.rb +0 -186
- data/lib/aspera/cli/sync_actions.rb +0 -181
- data/lib/aspera/cli/transfer_actions.rb +0 -98
- data/lib/aspera/cli/transfer_agent.rb +0 -348
- data/lib/aspera/command_line_builder.rb +0 -244
- data/lib/aspera/command_line_converter.rb +0 -35
- data/lib/aspera/data_repository.rb +0 -69
- data/lib/aspera/faspex_gw.rb +0 -172
- data/lib/aspera/faspex_postproc.rb +0 -237
- data/lib/aspera/graphql.rb +0 -41
- data/lib/aspera/node_emulator.rb +0 -758
- data/lib/aspera/oauth/client/shares_web.rb +0 -94
- data/lib/aspera/orchestrator_workflow_checker.rb +0 -688
- data/lib/aspera/preview/file_types.rb +0 -119
- data/lib/aspera/preview/generator.rb +0 -345
- data/lib/aspera/preview/utils.rb +0 -211
- data/lib/aspera/products/other.rb +0 -92
- data/lib/aspera/products/transferd_service.rb +0 -610
- /data/lib/aspera/{data → ascp/data}/1 +0 -0
- /data/lib/aspera/{data → ascp/data}/2 +0 -0
- /data/lib/aspera/{data → ascp/data}/3 +0 -0
- /data/lib/aspera/{data → ascp/data}/4 +0 -0
- /data/lib/aspera/{data → ascp/data}/5 +0 -0
- /data/lib/aspera/{data → ascp/data}/6 +0 -0
- /data/lib/aspera/{api → plugins/aoc}/queries/bss_subscription_account.graphql +0 -0
- /data/lib/aspera/{api → plugins/aoc}/queries/bss_subscription_usage.graphql +0 -0
- /data/lib/aspera/{schema → plugins/aoc/schemas}/IBM Aspera on Cloud Automation API-1.0.5-enhanced.yaml +0 -0
- /data/lib/aspera/{schema → plugins/console/schemas}/IBM Aspera Console-enhanced.yaml +0 -0
- /data/lib/aspera/{schema → plugins/node/schemas}/IBM Aspera Node API-4.4.6.yaml +0 -0
- /data/lib/aspera/{preview → plugins/preview}/image_error.png +0 -0
- /data/lib/aspera/{preview → plugins/preview}/video_error.png +0 -0
- /data/lib/aspera/{schema → plugins/shares/schemas}/IBM_Aspera_Shares.yaml +0 -0
- /data/lib/{transferd_pb.rb → aspera/plugins/transferd/grpc/transferd_pb.rb} +0 -0
- /data/lib/{transferd_services_pb.rb → aspera/plugins/transferd/grpc/transferd_services_pb.rb} +0 -0
- /data/lib/aspera/{schema → plugins/transferd/schemas}/transferd-config.schema.json +0 -0
|
@@ -6,29 +6,37 @@
|
|
|
6
6
|
# cspell:ignore asperabrowserurl
|
|
7
7
|
require_relative '../../schema/registry'
|
|
8
8
|
require_relative '../../sealed_hash'
|
|
9
|
-
require_relative 'basic_auth'
|
|
10
|
-
require_relative '
|
|
11
|
-
require_relative '../
|
|
9
|
+
require_relative '../../cli/plugins/basic_auth'
|
|
10
|
+
require_relative '../../cli/hints'
|
|
11
|
+
require_relative '../xfer/sync_actions'
|
|
12
|
+
require_relative '../../cli/special_values'
|
|
12
13
|
require_relative '../../transfer/spec'
|
|
13
14
|
require_relative '../../nagios'
|
|
14
15
|
require_relative '../../hash_ext'
|
|
15
16
|
require_relative '../../id_generator'
|
|
16
|
-
require_relative '
|
|
17
|
+
require_relative 'api'
|
|
17
18
|
require_relative '../../oauth/client/factory'
|
|
18
19
|
require_relative '../../rest/list'
|
|
19
20
|
require_relative '../../assert'
|
|
21
|
+
require_relative '../xfer/transfer_agent'
|
|
20
22
|
require 'base64'
|
|
21
23
|
|
|
22
24
|
module Aspera
|
|
23
|
-
module
|
|
24
|
-
module
|
|
25
|
-
class
|
|
26
|
-
include
|
|
25
|
+
module Plugins
|
|
26
|
+
module Node
|
|
27
|
+
class Commands < Cli::Plugins::Base
|
|
28
|
+
include Cli::Plugins::BasicAuth
|
|
29
|
+
|
|
30
|
+
include Aspera::Plugins::Xfer::SyncActions
|
|
27
31
|
|
|
28
32
|
application_name 'HSTS Node API'
|
|
29
33
|
|
|
30
34
|
SESSION_TIME_FIELDS = %i[start end].freeze
|
|
31
35
|
private_constant :SESSION_TIME_FIELDS
|
|
36
|
+
# Keys of the schemas of the bundle (manifest): Node API, options of the commands
|
|
37
|
+
API_SCHEMA = 'node'
|
|
38
|
+
EMULATOR_OPTIONS = 'node_opts:components.schemas.NodeEmulatorOptions'
|
|
39
|
+
API_OPTIONS = 'node_opts:components.schemas.NodeApiOptions'
|
|
32
40
|
|
|
33
41
|
class << self
|
|
34
42
|
# directory: node, container: shares
|
|
@@ -77,10 +85,9 @@ module Aspera
|
|
|
77
85
|
# Included by other plugins (Ats, Cos, Aoc) via `use_options Node`.
|
|
78
86
|
option :validator, description: 'Identifier of validator (optional for central)'
|
|
79
87
|
option :asperabrowserurl, description: 'URL of Aspera Browser, web application to browse the node', default: 'https://laurent-martin.github.io/aspera-browser-react/'
|
|
80
|
-
option :node_api, description: 'Gen4:
|
|
81
|
-
allowed: Hash, on_set: Api::Node.method(:api_options=)
|
|
88
|
+
option :node_api, description: 'Gen4: use of the Node API (dot-notation: cache, standard_ports, accept_v4)', schema: API_OPTIONS, on_set: Api.method(:api_options=)
|
|
82
89
|
option :root_id, description: 'Gen4: File id of top folder when using access key (override AK root id)'
|
|
83
|
-
option :dynamic_key, description: 'Private key PEM to use for dynamic key auth', on_set: Api
|
|
90
|
+
option :dynamic_key, description: 'Private key PEM to use for dynamic key auth', on_set: Api.method(:use_dynamic_key=)
|
|
84
91
|
|
|
85
92
|
# @param wizard [Wizard] The wizard object
|
|
86
93
|
# @param app_url [String] Tested URL
|
|
@@ -173,23 +180,23 @@ module Aspera
|
|
|
173
180
|
# @param api [Rest::Client] an existing API object for the Node API
|
|
174
181
|
def initialize(context:, api: nil)
|
|
175
182
|
super(context: context)
|
|
176
|
-
# Api
|
|
183
|
+
# Api or Rest::Client (Shares), when provided by the host plugin
|
|
177
184
|
@api_node = api
|
|
178
185
|
end
|
|
179
186
|
|
|
180
187
|
# Node API: provided by the host plugin, or built from CLI options on first use.
|
|
181
|
-
# @return [Api
|
|
188
|
+
# @return [Api, Rest::Client]
|
|
182
189
|
def api_node
|
|
183
190
|
@api_node ||=
|
|
184
191
|
if OAuth::Factory.bearer_auth?(options.get_option(:password, mandatory: true))
|
|
185
192
|
# info is provided like node_info of aoc
|
|
186
|
-
Api
|
|
193
|
+
Api.new(
|
|
187
194
|
base_url: options.get_option(:url, mandatory: true),
|
|
188
|
-
headers: Api
|
|
195
|
+
headers: Api.bearer_headers(options.get_option(:password, mandatory: true))
|
|
189
196
|
)
|
|
190
197
|
else
|
|
191
198
|
# this is normal case
|
|
192
|
-
Api
|
|
199
|
+
Api.new(
|
|
193
200
|
base_url: options.get_option(:url, mandatory: true),
|
|
194
201
|
auth: {
|
|
195
202
|
type: :basic,
|
|
@@ -228,7 +235,7 @@ module Aspera
|
|
|
228
235
|
# example: send_result={'items'=>[{'file'=>"filename1","permissions"=>[{'name'=>'read'},{'name'=>'write'}]}]}
|
|
229
236
|
response = api_node.create('files/browse', query)
|
|
230
237
|
# 'file','symbolic_link'
|
|
231
|
-
return Result::SingleObject.new(response['self']) if !
|
|
238
|
+
return Cli::Result::SingleObject.new(response['self']) if !Commands.gen3_entry_folder?(response['self']) || only_path
|
|
232
239
|
items = response['items']
|
|
233
240
|
total_count ||= response['total_count']
|
|
234
241
|
all_items.concat(items)
|
|
@@ -236,7 +243,7 @@ module Aspera
|
|
|
236
243
|
formatter.display_item_count(response['item_count'], total_count)
|
|
237
244
|
break
|
|
238
245
|
end
|
|
239
|
-
folders_to_process.concat(items.select { |i|
|
|
246
|
+
folders_to_process.concat(items.select { |i| Commands.gen3_entry_folder?(i) }.map { |i| i['path'] }) if recursive
|
|
240
247
|
if !max_items.nil? && (all_items.count >= max_items)
|
|
241
248
|
all_items = all_items.slice(0, max_items) if all_items.count > max_items
|
|
242
249
|
break
|
|
@@ -248,7 +255,7 @@ module Aspera
|
|
|
248
255
|
end
|
|
249
256
|
query.delete('skip')
|
|
250
257
|
end
|
|
251
|
-
return Result::ObjectList.new(all_items)
|
|
258
|
+
return Cli::Result::ObjectList.new(all_items)
|
|
252
259
|
ensure
|
|
253
260
|
Rest::Parameters.instance.spinner_cb.call(action: :success)
|
|
254
261
|
end
|
|
@@ -289,10 +296,10 @@ module Aspera
|
|
|
289
296
|
# @param top_file_id [String] root file id for path resolution
|
|
290
297
|
# @param path [String] plain path or %id:<file_id> selector
|
|
291
298
|
def apifid_from_path(top_file_id, path)
|
|
292
|
-
if (m = Parser.percent_selector(path))
|
|
293
|
-
Aspera.assert_values(m[:field], ['id'], type: BadArgument) { 'file id' }
|
|
299
|
+
if (m = Cli::Parser.percent_selector(path))
|
|
300
|
+
Aspera.assert_values(m[:field], ['id'], type: Cli::BadArgument) { 'file id' }
|
|
294
301
|
val = m[:value]
|
|
295
|
-
return
|
|
302
|
+
return NodeFileId.new(api_node, val.nil? || val.empty? ? top_file_id : val)
|
|
296
303
|
end
|
|
297
304
|
api_node.resolve_api_fid(top_file_id, path)
|
|
298
305
|
end
|
|
@@ -316,7 +323,7 @@ module Aspera
|
|
|
316
323
|
# @param value [String] must be 'self'
|
|
317
324
|
# @return [String] the resolved access key id
|
|
318
325
|
def lookup_access_key_self_id(field, value, **)
|
|
319
|
-
Aspera.assert(field.eql?('id') && value.eql?('self'), type: BadArgument) { 'only selector: %id:self' }
|
|
326
|
+
Aspera.assert(field.eql?('id') && value.eql?('self'), type: Cli::BadArgument) { 'only selector: %id:self' }
|
|
320
327
|
api_node.read('access_keys/self')['id']
|
|
321
328
|
end
|
|
322
329
|
|
|
@@ -341,13 +348,13 @@ module Aspera
|
|
|
341
348
|
# :sync is declared separately (intermediate node with sub-commands).
|
|
342
349
|
GEN3_NODE_ACTIONS = {
|
|
343
350
|
ls: ->(path:, **) { browse_gen3(path) },
|
|
344
|
-
transport: ->(**) { Result::SingleObject.new(api_node.transport_params) },
|
|
345
|
-
spec: ->(**) { Result::SingleObject.new(api_node.base_spec, fields: Formatter.all_but(*Transfer::Spec::SPECIFIC)) },
|
|
346
|
-
api_details: ->(**) { Result::SingleObject.new({base_url: api_node.base_url}.merge(api_node.params)) },
|
|
347
|
-
events: ->(**) { Result::ObjectList.new(api_node.read('events', query_read_delete(schema: Schema::Registry.query_params(
|
|
348
|
-
info: ->(**) { Result::SingleObject.new(api_node.read('info')) },
|
|
349
|
-
slash: ->(**) { Result::SingleObject.new(api_node.read('')) },
|
|
350
|
-
license: ->(**) { Result::SingleObject.new(api_node.read('license')) }
|
|
351
|
+
transport: ->(**) { Cli::Result::SingleObject.new(api_node.transport_params) },
|
|
352
|
+
spec: ->(**) { Cli::Result::SingleObject.new(api_node.base_spec, fields: Cli::Formatter.all_but(*Aspera::Transfer::Spec::SPECIFIC)) },
|
|
353
|
+
api_details: ->(**) { Cli::Result::SingleObject.new({base_url: api_node.base_url}.merge(api_node.params)) },
|
|
354
|
+
events: ->(**) { Cli::Result::ObjectList.new(api_node.read('events', query_read_delete(schema: Schema::Registry.query_params(API_SCHEMA, 'events'))), fields: ->(f) { !f.start_with?('data') }) },
|
|
355
|
+
info: ->(**) { Cli::Result::SingleObject.new(api_node.read('info')) },
|
|
356
|
+
slash: ->(**) { Cli::Result::SingleObject.new(api_node.read('')) },
|
|
357
|
+
license: ->(**) { Cli::Result::SingleObject.new(api_node.read('license')) }
|
|
351
358
|
}.freeze
|
|
352
359
|
private_constant :GEN3_NODE_ACTIONS
|
|
353
360
|
COMMANDS_GEN3_SPEC.each do |cmd, spec|
|
|
@@ -358,9 +365,10 @@ module Aspera
|
|
|
358
365
|
command :sync, description: 'Synchronize folders (Gen3)'
|
|
359
366
|
commands_under :sync do
|
|
360
367
|
Sync::Operations::DIRECTIONS.each do |dir|
|
|
361
|
-
command dir, description: "#{dir.capitalize}-sync (Gen3)", transfer_paths: :send, arguments: SyncActions::PATH_AND_INFO_ARGS
|
|
368
|
+
command dir, description: "#{dir.capitalize}-sync (Gen3)", transfer_paths: :send, arguments: Aspera::Plugins::Xfer::SyncActions::PATH_AND_INFO_ARGS
|
|
362
369
|
end
|
|
363
370
|
sync_admin_commands :admin
|
|
371
|
+
sync_logs_command :logs
|
|
364
372
|
end
|
|
365
373
|
# access_keys sub-tree
|
|
366
374
|
command :access_keys, description: 'Manage access keys'
|
|
@@ -373,7 +381,7 @@ module Aspera
|
|
|
373
381
|
crud_commands entity: 'access_keys',
|
|
374
382
|
api: :api_node,
|
|
375
383
|
|
|
376
|
-
body_component:
|
|
384
|
+
body_component: API_SCHEMA,
|
|
377
385
|
lookup: :lookup_access_key_self_id
|
|
378
386
|
end
|
|
379
387
|
|
|
@@ -388,16 +396,17 @@ module Aspera
|
|
|
388
396
|
command :sync, description: 'Synchronize folders'
|
|
389
397
|
commands_under :sync do
|
|
390
398
|
Sync::Operations::DIRECTIONS.each do |dir|
|
|
391
|
-
command dir, description: "#{dir.capitalize}-sync", transfer_paths: :send, arguments: SyncActions::PATH_AND_INFO_ARGS
|
|
399
|
+
command dir, description: "#{dir.capitalize}-sync", transfer_paths: :send, arguments: Aspera::Plugins::Xfer::SyncActions::PATH_AND_INFO_ARGS
|
|
392
400
|
end
|
|
393
401
|
sync_admin_commands :admin
|
|
402
|
+
sync_logs_command :logs
|
|
394
403
|
end
|
|
395
404
|
end
|
|
396
405
|
commands_under %i[access_keys do permission] do
|
|
397
406
|
command :list, description: 'List permissions on a file'
|
|
398
407
|
command :show, description: 'Show a permission',
|
|
399
408
|
arguments: [{name: :permission_id, type: :identifier}],
|
|
400
|
-
action: ->(apifid:, permission_id:, **) { Result::SingleObject.new(apifid.node_api.read("permissions/#{permission_id}")) }
|
|
409
|
+
action: ->(apifid:, permission_id:, **) { Cli::Result::SingleObject.new(apifid.node_api.read("permissions/#{permission_id}")) }
|
|
401
410
|
command :create, description: 'Create a permission',
|
|
402
411
|
arguments: [{name: :permission, type: Hash, schema: 'node:components.schemas.permissions-post-request'}]
|
|
403
412
|
command(
|
|
@@ -405,7 +414,7 @@ module Aspera
|
|
|
405
414
|
arguments: [{name: :permission_id, type: :identifier}, {name: :permission, type: Hash, schema: 'node:components.schemas.permissions-id-put-request'}],
|
|
406
415
|
action: lambda do |permission:, apifid:, permission_id:, **|
|
|
407
416
|
apifid.node_api.update("permissions/#{permission_id}", permission)
|
|
408
|
-
Result::Status.new('Updated')
|
|
417
|
+
Cli::Result::Status.new('Updated')
|
|
409
418
|
end
|
|
410
419
|
)
|
|
411
420
|
command :delete, description: 'Delete permissions',
|
|
@@ -413,15 +422,15 @@ module Aspera
|
|
|
413
422
|
end
|
|
414
423
|
# async (legacy /async)
|
|
415
424
|
commands_under :async, description: 'Manage legacy synchronizations (/async)' do
|
|
416
|
-
command :list, description: 'List async sync IDs', action: ->(**) { Result::ValueList.new(api_node.read('async/list')['sync_ids']) }
|
|
425
|
+
command :list, description: 'List async sync IDs', action: ->(**) { Cli::Result::ValueList.new(api_node.read('async/list')['sync_ids']) }
|
|
417
426
|
command :show, description: 'Show async summary',
|
|
418
427
|
arguments: [{name: :async_id, type: :identifier, lookup: :async_lookup}]
|
|
419
428
|
command(
|
|
420
429
|
:delete, description: 'Delete async',
|
|
421
430
|
arguments: [{name: :async_id, type: :identifier, lookup: :async_lookup}],
|
|
422
431
|
action: lambda do |async_id:, **|
|
|
423
|
-
async_ids = async_id.eql?(SpecialValues::ALL) ? api_node.read('async/list')['sync_ids'] : [async_id]
|
|
424
|
-
Result::SingleObject.new(api_node.create('async/delete', {'syncs' => async_ids}))
|
|
432
|
+
async_ids = async_id.eql?(Cli::SpecialValues::ALL) ? api_node.read('async/list')['sync_ids'] : [async_id]
|
|
433
|
+
Cli::Result::SingleObject.new(api_node.create('async/delete', {'syncs' => async_ids}))
|
|
425
434
|
end
|
|
426
435
|
)
|
|
427
436
|
command :bandwidth, description: 'Show async bandwidth',
|
|
@@ -444,48 +453,48 @@ module Aspera
|
|
|
444
453
|
:start, description: 'Start a sync', arguments: [{name: :ssync_id, type: :identifier, lookup: :ssync_lookup}],
|
|
445
454
|
action: lambda do |ssync_id:, **|
|
|
446
455
|
api_node.call(operation: 'POST', subpath: "asyncs/#{ssync_id}/start", content_type: Mime::TEXT, body: '', ret: :resp).body
|
|
447
|
-
Result::Status.new('Done')
|
|
456
|
+
Cli::Result::Status.new('Done')
|
|
448
457
|
end
|
|
449
458
|
)
|
|
450
459
|
command(
|
|
451
460
|
:stop, description: 'Stop a sync', arguments: [{name: :ssync_id, type: :identifier, lookup: :ssync_lookup}],
|
|
452
461
|
action: lambda do |ssync_id:, **|
|
|
453
462
|
api_node.call(operation: 'POST', subpath: "asyncs/#{ssync_id}/stop", content_type: Mime::TEXT, body: '', ret: :resp).body
|
|
454
|
-
Result::Status.new('Done')
|
|
463
|
+
Cli::Result::Status.new('Done')
|
|
455
464
|
end
|
|
456
465
|
)
|
|
457
466
|
command :bandwidth, read_only: true, description: 'Show sync bandwidth',
|
|
458
467
|
arguments: [{name: :ssync_id, type: :identifier, lookup: :ssync_lookup}],
|
|
459
|
-
action: ->(ssync_id:, **) { Result::SingleObject.new(api_node.read("asyncs/#{ssync_id}/bandwidth", query_read_delete(default: {}))) }
|
|
468
|
+
action: ->(ssync_id:, **) { Cli::Result::SingleObject.new(api_node.read("asyncs/#{ssync_id}/bandwidth", query_read_delete(default: {}))) }
|
|
460
469
|
command :counters, read_only: true, description: 'Show sync counters',
|
|
461
470
|
arguments: [{name: :ssync_id, type: :identifier, lookup: :ssync_lookup}],
|
|
462
|
-
action: ->(ssync_id:, **) { Result::SingleObject.new(api_node.read("asyncs/#{ssync_id}/counters", query_read_delete(default: {}))) }
|
|
471
|
+
action: ->(ssync_id:, **) { Cli::Result::SingleObject.new(api_node.read("asyncs/#{ssync_id}/counters", query_read_delete(default: {}))) }
|
|
463
472
|
command :files, read_only: true, description: 'List sync files',
|
|
464
473
|
arguments: [{name: :ssync_id, type: :identifier, lookup: :ssync_lookup}],
|
|
465
|
-
action: ->(ssync_id:, **) { Result::SingleObject.new(api_node.read("asyncs/#{ssync_id}/files", query_read_delete(default: {}))) }
|
|
474
|
+
action: ->(ssync_id:, **) { Cli::Result::SingleObject.new(api_node.read("asyncs/#{ssync_id}/files", query_read_delete(default: {}))) }
|
|
466
475
|
command :state, read_only: true, description: 'Show sync state',
|
|
467
476
|
arguments: [{name: :ssync_id, type: :identifier, lookup: :ssync_lookup}],
|
|
468
|
-
action: ->(ssync_id:, **) { Result::SingleObject.new(api_node.read("asyncs/#{ssync_id}/state")) }
|
|
477
|
+
action: ->(ssync_id:, **) { Cli::Result::SingleObject.new(api_node.read("asyncs/#{ssync_id}/state")) }
|
|
469
478
|
command :summary, read_only: true, description: 'Show sync summary',
|
|
470
479
|
arguments: [{name: :ssync_id, type: :identifier, lookup: :ssync_lookup}],
|
|
471
|
-
action: ->(ssync_id:, **) { Result::SingleObject.new(api_node.read("asyncs/#{ssync_id}/summary")) }
|
|
480
|
+
action: ->(ssync_id:, **) { Cli::Result::SingleObject.new(api_node.read("asyncs/#{ssync_id}/summary")) }
|
|
472
481
|
end
|
|
473
482
|
# stream
|
|
474
483
|
command :stream, description: 'Manage stream operations'
|
|
475
484
|
commands_under :stream do
|
|
476
|
-
command :list, description: 'List streams', action: ->(**) { Result::ObjectList.new(api_node.read('ops/transfers', query_read_delete), fields: %w[id status]) }
|
|
485
|
+
command :list, description: 'List streams', action: ->(**) { Cli::Result::ObjectList.new(api_node.read('ops/transfers', query_read_delete), fields: %w[id status]) }
|
|
477
486
|
command :create, description: 'Create a stream',
|
|
478
487
|
arguments: [{name: :stream, type: Hash, schema: 'node:components.schemas.transferPostRequest'}],
|
|
479
|
-
action: ->(stream:, **) { Result::SingleObject.new(api_node.create('streams', stream)) }
|
|
488
|
+
action: ->(stream:, **) { Cli::Result::SingleObject.new(api_node.create('streams', stream)) }
|
|
480
489
|
command :show, description: 'Show a stream',
|
|
481
490
|
arguments: [{name: :transfer_id, type: :identifier}],
|
|
482
|
-
action: ->(transfer_id:, **) { Result::SingleObject.new(api_node.read("ops/transfers/#{transfer_id}")) }
|
|
491
|
+
action: ->(transfer_id:, **) { Cli::Result::SingleObject.new(api_node.read("ops/transfers/#{transfer_id}")) }
|
|
483
492
|
command :modify, description: 'Modify a stream',
|
|
484
493
|
arguments: [{name: :transfer_id, type: :identifier}, {name: :stream, type: Hash, schema: 'node:components.schemas.transferPutRequest'}],
|
|
485
|
-
action: ->(stream:, transfer_id:, **) { Result::SingleObject.new(api_node.update("streams/#{transfer_id}", stream)) }
|
|
494
|
+
action: ->(stream:, transfer_id:, **) { Cli::Result::SingleObject.new(api_node.update("streams/#{transfer_id}", stream)) }
|
|
486
495
|
command :cancel, description: 'Cancel a stream',
|
|
487
496
|
arguments: [{name: :transfer_id, type: :identifier}],
|
|
488
|
-
action: ->(transfer_id:, **) { Result::SingleObject.new(api_node.cancel("streams/#{transfer_id}")) }
|
|
497
|
+
action: ->(transfer_id:, **) { Cli::Result::SingleObject.new(api_node.cancel("streams/#{transfer_id}")) }
|
|
489
498
|
end
|
|
490
499
|
# transfer
|
|
491
500
|
command :transfer, description: 'Manage transfer operations'
|
|
@@ -496,18 +505,18 @@ module Aspera
|
|
|
496
505
|
arguments: [{name: :transfer_id, type: :identifier}],
|
|
497
506
|
action: lambda do |transfer_id:, **|
|
|
498
507
|
api_node.cancel("ops/transfers/#{transfer_id}")
|
|
499
|
-
Result::Status.new('Cancelled')
|
|
508
|
+
Cli::Result::Status.new('Cancelled')
|
|
500
509
|
end
|
|
501
510
|
)
|
|
502
511
|
command :show, description: 'Show a transfer',
|
|
503
512
|
arguments: [{name: :transfer_id, type: :identifier}],
|
|
504
|
-
action: ->(transfer_id:, **) { Result::SingleObject.new(api_node.read("ops/transfers/#{transfer_id}")) }
|
|
513
|
+
action: ->(transfer_id:, **) { Cli::Result::SingleObject.new(api_node.read("ops/transfers/#{transfer_id}")) }
|
|
505
514
|
command(
|
|
506
515
|
:modify, description: 'Modify a transfer',
|
|
507
516
|
arguments: [{name: :transfer_id, type: :identifier}, {name: :transfer, type: Hash, schema: 'node:components.schemas.transferPutRequest'}],
|
|
508
517
|
action: lambda do |transfer:, transfer_id:, **|
|
|
509
518
|
api_node.update("ops/transfers/#{transfer_id}", transfer)
|
|
510
|
-
Result::Status.new('Modified')
|
|
519
|
+
Cli::Result::Status.new('Modified')
|
|
511
520
|
end
|
|
512
521
|
)
|
|
513
522
|
command :bandwidth_average, description: 'Show average bandwidth per period'
|
|
@@ -516,13 +525,13 @@ module Aspera
|
|
|
516
525
|
# service
|
|
517
526
|
command :service, description: 'Manage services'
|
|
518
527
|
commands_under :service do
|
|
519
|
-
command :list, description: 'List services', action: ->(**) { Result::ObjectList.new(api_node.read('rund/services')['services']) }
|
|
528
|
+
command :list, description: 'List services', action: ->(**) { Cli::Result::ObjectList.new(api_node.read('rund/services')['services']) }
|
|
520
529
|
command(
|
|
521
530
|
:create, description: 'Create a service',
|
|
522
531
|
arguments: [{name: :service, type: Hash}],
|
|
523
532
|
action: lambda do |service:, **|
|
|
524
533
|
resp = api_node.create('rund/services', service)
|
|
525
|
-
Result::Status.new("#{resp['id']} created")
|
|
534
|
+
Cli::Result::Status.new("#{resp['id']} created")
|
|
526
535
|
end
|
|
527
536
|
)
|
|
528
537
|
command(
|
|
@@ -530,7 +539,7 @@ module Aspera
|
|
|
530
539
|
arguments: [{name: :service_id, type: :identifier}],
|
|
531
540
|
action: lambda do |service_id:, **|
|
|
532
541
|
api_node.delete("rund/services/#{service_id}")
|
|
533
|
-
Result::Status.new("#{service_id} deleted")
|
|
542
|
+
Cli::Result::Status.new("#{service_id} deleted")
|
|
534
543
|
end
|
|
535
544
|
)
|
|
536
545
|
end
|
|
@@ -539,18 +548,18 @@ module Aspera
|
|
|
539
548
|
commands_under :watch_folder do
|
|
540
549
|
command :create, description: 'Create a watch folder',
|
|
541
550
|
arguments: [{name: :watch_folder, type: Hash}],
|
|
542
|
-
action: ->(watch_folder:, **) { Result::Status.new("#{api_node.create('v3/watchfolders', watch_folder)['id']} created") }
|
|
551
|
+
action: ->(watch_folder:, **) { Cli::Result::Status.new("#{api_node.create('v3/watchfolders', watch_folder)['id']} created") }
|
|
543
552
|
command :list, description: 'List watch folders',
|
|
544
|
-
action: ->(**) { Result::ValueList.new(api_node.read('v3/watchfolders', query_read_delete)['ids']) }
|
|
553
|
+
action: ->(**) { Cli::Result::ValueList.new(api_node.read('v3/watchfolders', query_read_delete)['ids']) }
|
|
545
554
|
command :show, description: 'Show a watch folder',
|
|
546
555
|
arguments: [{name: :watch_folder_id, type: :identifier}],
|
|
547
|
-
action: ->(watch_folder_id:, **) { Result::SingleObject.new(api_node.read("v3/watchfolders/#{watch_folder_id}")) }
|
|
556
|
+
action: ->(watch_folder_id:, **) { Cli::Result::SingleObject.new(api_node.read("v3/watchfolders/#{watch_folder_id}")) }
|
|
548
557
|
command(
|
|
549
558
|
:modify, description: 'Modify a watch folder',
|
|
550
559
|
arguments: [{name: :watch_folder_id, type: :identifier}, {name: :watch_folder, type: Hash}],
|
|
551
560
|
action: lambda do |watch_folder:, watch_folder_id:, **|
|
|
552
561
|
api_node.update("v3/watchfolders/#{watch_folder_id}", watch_folder)
|
|
553
|
-
Result::Status.new("#{watch_folder_id} updated")
|
|
562
|
+
Cli::Result::Status.new("#{watch_folder_id} updated")
|
|
554
563
|
end
|
|
555
564
|
)
|
|
556
565
|
command(
|
|
@@ -558,12 +567,12 @@ module Aspera
|
|
|
558
567
|
arguments: [{name: :watch_folder_id, type: :identifier}],
|
|
559
568
|
action: lambda do |watch_folder_id:, **|
|
|
560
569
|
api_node.delete("v3/watchfolders/#{watch_folder_id}")
|
|
561
|
-
Result::Status.new("#{watch_folder_id} deleted")
|
|
570
|
+
Cli::Result::Status.new("#{watch_folder_id} deleted")
|
|
562
571
|
end
|
|
563
572
|
)
|
|
564
573
|
command :state, read_only: true, description: 'Show watch folder state',
|
|
565
574
|
arguments: [{name: :watch_folder_id, type: :identifier}],
|
|
566
|
-
action: ->(watch_folder_id:, **) { Result::SingleObject.new(api_node.read("v3/watchfolders/#{watch_folder_id}/state")) }
|
|
575
|
+
action: ->(watch_folder_id:, **) { Cli::Result::SingleObject.new(api_node.read("v3/watchfolders/#{watch_folder_id}/state")) }
|
|
567
576
|
end
|
|
568
577
|
# central
|
|
569
578
|
command :central, description: 'Query Central service'
|
|
@@ -583,21 +592,21 @@ module Aspera
|
|
|
583
592
|
end
|
|
584
593
|
# Standalone leaf commands
|
|
585
594
|
command :asperabrowser, description: 'Open Aspera Browser on this node (the password is optional: it is then entered in the application)'
|
|
586
|
-
command :basic_token, description: 'Generate basic auth token', action: ->(**) { Result::Text.new(Rest.basic_authorization(options.get_option(:username, mandatory: true), options.get_option(:password, mandatory: true))) }
|
|
595
|
+
command :basic_token, description: 'Generate basic auth token', action: ->(**) { Cli::Result::Text.new(Rest.basic_authorization(options.get_option(:username, mandatory: true), options.get_option(:password, mandatory: true))) }
|
|
587
596
|
command(
|
|
588
597
|
:bearer_token, description: 'Generate bearer token',
|
|
589
|
-
arguments: [{name: :private_key_pem}, {name: :token, type: Hash, schema: '
|
|
598
|
+
arguments: [{name: :private_key_pem}, {name: :token, type: Hash, schema: 'node_opts:components.schemas.NodeBearerTokenOptions'}],
|
|
590
599
|
action: lambda do |private_key_pem:, token:, **|
|
|
591
600
|
private_key = OpenSSL::PKey::RSA.new(private_key_pem)
|
|
592
601
|
access_key = options.get_option(:username, mandatory: true)
|
|
593
|
-
Result::Text.new(Api
|
|
602
|
+
Cli::Result::Text.new(Api.bearer_token(payload: token, access_key: access_key, private_key: private_key))
|
|
594
603
|
end
|
|
595
604
|
)
|
|
596
|
-
command :emulator, description: 'Start node emulator',
|
|
605
|
+
command :emulator, description: 'Start node emulator', security: :low,
|
|
597
606
|
aliases: [:simulator],
|
|
598
|
-
arguments: [{name: :parameters, type: Hash, mandatory: false, default: {}, schema:
|
|
607
|
+
arguments: [{name: :parameters, type: Hash, mandatory: false, default: {}, schema: EMULATOR_OPTIONS}]
|
|
599
608
|
command :telemetry, description: 'Report telemetry to external system',
|
|
600
|
-
arguments: [{name: :parameters, type: Hash, mandatory: false, default: {}, schema: '
|
|
609
|
+
arguments: [{name: :parameters, type: Hash, mandatory: false, default: {}, schema: 'node_opts:components.schemas.NodeTelemetryOptions'}]
|
|
601
610
|
|
|
602
611
|
# --- Handler methods (Gen3) ---
|
|
603
612
|
|
|
@@ -614,17 +623,17 @@ module Aspera
|
|
|
614
623
|
other_options = options.get_option(:query)
|
|
615
624
|
parameters.merge!(other_options) unless other_options.nil?
|
|
616
625
|
resp = api_node.create('files/search', parameters)
|
|
617
|
-
return Result::Empty.new if resp['items'].empty?
|
|
626
|
+
return Cli::Result::Empty.new if resp['items'].empty?
|
|
618
627
|
fields = resp['items'].first.keys.reject { |i| SEARCH_REMOVE_FIELDS.include?(i) }
|
|
619
628
|
formatter.display_item_count(resp['item_count'], resp['total_count'])
|
|
620
629
|
formatter.display_status("params: #{resp['parameters'].keys.map { |k| "#{k}:#{resp['parameters'][k]}" }.join(',')}")
|
|
621
|
-
Result::ObjectList.new(resp['items'], fields: fields)
|
|
630
|
+
Cli::Result::ObjectList.new(resp['items'], fields: fields)
|
|
622
631
|
end
|
|
623
632
|
|
|
624
633
|
def action_space(paths:, **)
|
|
625
634
|
paths = Array(paths)
|
|
626
635
|
resp = api_node.create('space', {'paths' => paths.map { |i| {path: i} }})
|
|
627
|
-
Result::ObjectList.new(resp['paths'])
|
|
636
|
+
Cli::Result::ObjectList.new(resp['paths'])
|
|
628
637
|
end
|
|
629
638
|
|
|
630
639
|
def action_mkdir(paths:, **)
|
|
@@ -672,15 +681,15 @@ module Aspera
|
|
|
672
681
|
def action_upload(**)
|
|
673
682
|
# empty transfer spec for authorization request
|
|
674
683
|
request_transfer_spec = {}
|
|
675
|
-
request_transfer_spec[:paths] = [{destination: transfer.destination_folder(Transfer::Spec::DIRECTION_SEND)}]
|
|
684
|
+
request_transfer_spec[:paths] = [{destination: transfer.destination_folder(Aspera::Transfer::Spec::DIRECTION_SEND)}]
|
|
676
685
|
# add fixed parameters if any (for COS)
|
|
677
686
|
api_node.add_tspec_info(request_transfer_spec) if api_node.respond_to?(:add_tspec_info)
|
|
678
|
-
Api
|
|
687
|
+
Api.add_public_key(request_transfer_spec)
|
|
679
688
|
setup_payload = {transfer_requests: [{transfer_request: request_transfer_spec}]}
|
|
680
689
|
transfer_spec = api_node.create('files/upload_setup', setup_payload)['transfer_specs'].first&.fetch('transfer_spec')
|
|
681
|
-
Api
|
|
690
|
+
Api.add_private_key(transfer_spec)
|
|
682
691
|
transfer_spec.delete('paths')
|
|
683
|
-
|
|
692
|
+
Xfer::TransferAgent.result_transfer(transfer.start(transfer_spec))
|
|
684
693
|
end
|
|
685
694
|
|
|
686
695
|
def action_download(**)
|
|
@@ -689,16 +698,16 @@ module Aspera
|
|
|
689
698
|
request_transfer_spec[:paths] = transfer.ts_source_paths
|
|
690
699
|
# add fixed parameters if any (for COS)
|
|
691
700
|
api_node.add_tspec_info(request_transfer_spec) if api_node.respond_to?(:add_tspec_info)
|
|
692
|
-
Api
|
|
701
|
+
Api.add_public_key(request_transfer_spec)
|
|
693
702
|
setup_payload = {transfer_requests: [{transfer_request: request_transfer_spec}]}
|
|
694
703
|
transfer_spec = api_node.create('files/download_setup', setup_payload)['transfer_specs'].first&.fetch('transfer_spec')
|
|
695
|
-
Api
|
|
696
|
-
|
|
704
|
+
Api.add_private_key(transfer_spec)
|
|
705
|
+
Xfer::TransferAgent.result_transfer(transfer.start(transfer_spec))
|
|
697
706
|
end
|
|
698
707
|
|
|
699
708
|
def action_cat(path:, **)
|
|
700
709
|
http = api_node.read("files/#{URI.encode_www_form_component(path)}/contents", ret: :resp)
|
|
701
|
-
Result::Text.new(http.body)
|
|
710
|
+
Cli::Result::Text.new(http.body)
|
|
702
711
|
end
|
|
703
712
|
|
|
704
713
|
def action_health(**)
|
|
@@ -724,7 +733,7 @@ module Aspera
|
|
|
724
733
|
rescue StandardError => e
|
|
725
734
|
nagios.add_critical('central', e.to_s)
|
|
726
735
|
end
|
|
727
|
-
Result::ObjectList.new(nagios.status_list)
|
|
736
|
+
Cli::Result::ObjectList.new(nagios.status_list)
|
|
728
737
|
end
|
|
729
738
|
|
|
730
739
|
# watch_folder setup: inject required API header (avoids "Unable to convert 2016_09_14 configuration")
|
|
@@ -760,55 +769,55 @@ module Aspera
|
|
|
760
769
|
# access_keys > do > ls
|
|
761
770
|
def action_access_keys_do_ls(path:, do_root_file_id:, **)
|
|
762
771
|
apifid = apifid_from_path(do_root_file_id, path)
|
|
763
|
-
file_info = apifid.node_api.read("files/#{apifid.file_id}", headers: Api
|
|
764
|
-
return Result::ObjectList.new([file_info], fields: GEN4_LS_FIELDS) unless file_info['type'].eql?('folder')
|
|
765
|
-
Result::ObjectList.new(apifid.node_api.list_files(apifid.file_id, query: query_read_delete), fields: GEN4_LS_FIELDS)
|
|
772
|
+
file_info = apifid.node_api.read("files/#{apifid.file_id}", headers: Api.add_cache_control)
|
|
773
|
+
return Cli::Result::ObjectList.new([file_info], fields: GEN4_LS_FIELDS) unless file_info['type'].eql?('folder')
|
|
774
|
+
Cli::Result::ObjectList.new(apifid.node_api.list_files(apifid.file_id, query: query_read_delete), fields: GEN4_LS_FIELDS)
|
|
766
775
|
end
|
|
767
776
|
|
|
768
777
|
# access_keys > do > find
|
|
769
778
|
def action_access_keys_do_find(path:, filter: nil, do_root_file_id:, **)
|
|
770
779
|
apifid = apifid_from_path(do_root_file_id, path)
|
|
771
|
-
Result::ObjectList.new(api_node.find_files(apifid.file_id, Base.file_matcher(filter)), fields: ['path'])
|
|
780
|
+
Cli::Result::ObjectList.new(api_node.find_files(apifid.file_id, Cli::Plugins::Base.file_matcher(filter)), fields: ['path'])
|
|
772
781
|
end
|
|
773
782
|
|
|
774
783
|
# access_keys > do > cat
|
|
775
784
|
def action_access_keys_do_cat(path:, do_root_file_id:, **)
|
|
776
785
|
apifid = apifid_from_path(do_root_file_id, path)
|
|
777
|
-
Result::Text.new(apifid.node_api.read("files/#{apifid.file_id}/content", ret: :resp).body)
|
|
786
|
+
Cli::Result::Text.new(apifid.node_api.read("files/#{apifid.file_id}/content", ret: :resp).body)
|
|
778
787
|
end
|
|
779
788
|
|
|
780
789
|
# access_keys > do > show
|
|
781
790
|
def action_access_keys_do_show(path:, do_root_file_id:, **)
|
|
782
791
|
apifid = apifid_from_path(do_root_file_id, path)
|
|
783
|
-
Result::SingleObject.new(apifid.node_api.read("files/#{apifid.file_id}", headers: Api
|
|
792
|
+
Cli::Result::SingleObject.new(apifid.node_api.read("files/#{apifid.file_id}", headers: Api.add_cache_control))
|
|
784
793
|
end
|
|
785
794
|
|
|
786
795
|
# access_keys > do > modify
|
|
787
796
|
def action_access_keys_do_modify(path:, file:, do_root_file_id:, **)
|
|
788
797
|
apifid = apifid_from_path(do_root_file_id, path)
|
|
789
798
|
apifid.node_api.update("files/#{apifid.file_id}", file)
|
|
790
|
-
Result::Status.new('Done')
|
|
799
|
+
Cli::Result::Status.new('Done')
|
|
791
800
|
end
|
|
792
801
|
|
|
793
802
|
# access_keys > do > thumbnail
|
|
794
803
|
def action_access_keys_do_thumbnail(path:, do_root_file_id:, **)
|
|
795
804
|
apifid = apifid_from_path(do_root_file_id, path)
|
|
796
|
-
Result::Image.new(apifid.node_api.read("files/#{apifid.file_id}/preview", headers: Api
|
|
805
|
+
Cli::Result::Image.new(apifid.node_api.read("files/#{apifid.file_id}/preview", headers: Api.add_cache_control({'Accept' => 'image/png'}), ret: :resp).body)
|
|
797
806
|
end
|
|
798
807
|
|
|
799
808
|
# access_keys > do > rename
|
|
800
809
|
def action_access_keys_do_rename(source_path:, new_name:, do_root_file_id:, **)
|
|
801
810
|
apifid = api_node.resolve_api_fid(do_root_file_id, source_path)
|
|
802
811
|
apifid.node_api.update("files/#{apifid.file_id}", {name: new_name})
|
|
803
|
-
Result::Status.new("renamed to #{new_name}")
|
|
812
|
+
Cli::Result::Status.new("renamed to #{new_name}")
|
|
804
813
|
end
|
|
805
814
|
|
|
806
815
|
# access_keys > do > delete
|
|
807
816
|
def action_access_keys_do_delete(path:, do_root_file_id:, **)
|
|
808
817
|
bulk_result(path, command: :delete, id_result: 'path') do |l_path|
|
|
809
|
-
apifid = if (m = Parser.percent_selector(l_path))
|
|
810
|
-
Aspera.assert_values(m[:field], ['id'], type: BadIdentifier)
|
|
811
|
-
|
|
818
|
+
apifid = if (m = Cli::Parser.percent_selector(l_path))
|
|
819
|
+
Aspera.assert_values(m[:field], ['id'], type: Cli::BadIdentifier)
|
|
820
|
+
NodeFileId.new(api_node, m[:value])
|
|
812
821
|
else
|
|
813
822
|
api_node.resolve_api_fid(do_root_file_id, l_path)
|
|
814
823
|
end
|
|
@@ -820,7 +829,7 @@ module Aspera
|
|
|
820
829
|
# Shared Gen4 sync block: obtains a transfer spec via the Gen4 API for the given direction/remote_path.
|
|
821
830
|
def sync_gen4_block(do_root_file_id)
|
|
822
831
|
lambda do |direction, _local_path, remote_path|
|
|
823
|
-
ts_direction = direction.eql?(:pull) ? Transfer::Spec::DIRECTION_RECEIVE : Transfer::Spec::DIRECTION_SEND
|
|
832
|
+
ts_direction = direction.eql?(:pull) ? Aspera::Transfer::Spec::DIRECTION_RECEIVE : Aspera::Transfer::Spec::DIRECTION_SEND
|
|
824
833
|
apifid = api_node.resolve_api_fid(do_root_file_id, remote_path)
|
|
825
834
|
apifid.node_api.transfer_spec_gen4(apifid.file_id, ts_direction)
|
|
826
835
|
end
|
|
@@ -834,20 +843,20 @@ module Aspera
|
|
|
834
843
|
|
|
835
844
|
# access_keys > do > upload
|
|
836
845
|
def action_access_keys_do_upload(do_root_file_id:, **)
|
|
837
|
-
apifid = api_node.resolve_api_fid(do_root_file_id, transfer.destination_folder(Transfer::Spec::DIRECTION_SEND), true)
|
|
838
|
-
|
|
846
|
+
apifid = api_node.resolve_api_fid(do_root_file_id, transfer.destination_folder(Aspera::Transfer::Spec::DIRECTION_SEND), true)
|
|
847
|
+
Xfer::TransferAgent.result_transfer(transfer.start(apifid.node_api.transfer_spec_gen4(apifid.file_id, Aspera::Transfer::Spec::DIRECTION_SEND)))
|
|
839
848
|
end
|
|
840
849
|
|
|
841
850
|
# access_keys > do > download
|
|
842
851
|
def action_access_keys_do_download(do_root_file_id:, **)
|
|
843
852
|
apifid, source_paths = api_node.resolve_api_fid_paths(do_root_file_id, transfer.ts_source_paths)
|
|
844
|
-
|
|
853
|
+
Xfer::TransferAgent.result_transfer(transfer.start(apifid.node_api.transfer_spec_gen4(apifid.file_id, Aspera::Transfer::Spec::DIRECTION_RECEIVE, {'paths'=>source_paths})))
|
|
845
854
|
end
|
|
846
855
|
|
|
847
856
|
# access_keys > do > v3 - mount target: Node plugin on the node hosting the root file
|
|
848
857
|
# @return [Node]
|
|
849
858
|
def v3_node_plugin(do_root_file_id:, **)
|
|
850
|
-
|
|
859
|
+
Commands.new(context: context, api: api_node.resolve_api_fid(do_root_file_id, '').node_api)
|
|
851
860
|
end
|
|
852
861
|
|
|
853
862
|
# access_keys > do > node_info / bearer_token_node — shared helper builds the result hash
|
|
@@ -859,7 +868,7 @@ module Aspera
|
|
|
859
868
|
result[:username] = apifid.node_api.auth_params[:username]
|
|
860
869
|
result[:password] = apifid.node_api.auth_params[:password]
|
|
861
870
|
when :oauth2
|
|
862
|
-
result[:username] = apifid.node_api.params[:headers][Api::
|
|
871
|
+
result[:username] = apifid.node_api.params[:headers][Api::HEADER_X_ASPERA_ACCESS_KEY]
|
|
863
872
|
result[:password] = apifid.node_api.oauth.authorization
|
|
864
873
|
else Aspera.error_unexpected_value(apifid.node_api.auth_params[:type]) { 'Node API Auth type' }
|
|
865
874
|
end
|
|
@@ -868,15 +877,15 @@ module Aspera
|
|
|
868
877
|
|
|
869
878
|
def action_access_keys_do_node_info(path:, do_root_file_id:, **)
|
|
870
879
|
_apifid, result = gen4_apifid_info(do_root_file_id, path)
|
|
871
|
-
Result::SingleObject.new(result)
|
|
880
|
+
Cli::Result::SingleObject.new(result)
|
|
872
881
|
end
|
|
873
882
|
|
|
874
883
|
def action_access_keys_do_bearer_token_node(path:, do_root_file_id:, **)
|
|
875
884
|
apifid, result = gen4_apifid_info(do_root_file_id, path)
|
|
876
885
|
Log.dump(:result, result)
|
|
877
|
-
Aspera.assert(apifid.node_api.auth_params[:type].eql?(:oauth2), type: BadArgument) { "Cannot get bearer token if authenticating with secret (#{apifid.node_api.auth_params[:type]})" }
|
|
886
|
+
Aspera.assert(apifid.node_api.auth_params[:type].eql?(:oauth2), type: Cli::BadArgument) { "Cannot get bearer token if authenticating with secret (#{apifid.node_api.auth_params[:type]})" }
|
|
878
887
|
Aspera.assert(OAuth::Factory.bearer_auth?(result[:password]), 'Not using bearer token auth')
|
|
879
|
-
Result::Text.new(result[:password])
|
|
888
|
+
Cli::Result::Text.new(result[:password])
|
|
880
889
|
end
|
|
881
890
|
|
|
882
891
|
# access_keys > do > mkdir / mklink / mkfile — shared helper: resolve parent folder,
|
|
@@ -884,7 +893,7 @@ module Aspera
|
|
|
884
893
|
# @return [Array(NodeFileId, Hash)] parent apifid and payload with :name set
|
|
885
894
|
# @param path [String] full path (folder/name)
|
|
886
895
|
def gen4_mk_resolve(top_file_id, path)
|
|
887
|
-
containing_folder_path, new_item = Api
|
|
896
|
+
containing_folder_path, new_item = Api.split_folder(path)
|
|
888
897
|
apifid = api_node.resolve_api_fid(top_file_id, containing_folder_path, true)
|
|
889
898
|
# not a URL query: special keys `check` and `target`, rest merged into the POST body
|
|
890
899
|
query = options.get_option(:query)
|
|
@@ -911,22 +920,22 @@ module Aspera
|
|
|
911
920
|
def action_access_keys_do_mkdir(path:, do_root_file_id:, **)
|
|
912
921
|
apifid, payload = gen4_mk_resolve(do_root_file_id, path)
|
|
913
922
|
payload[:type] = :folder
|
|
914
|
-
Result::SingleObject.new(apifid.node_api.create("files/#{apifid.file_id}/files", payload))
|
|
923
|
+
Cli::Result::SingleObject.new(apifid.node_api.create("files/#{apifid.file_id}/files", payload))
|
|
915
924
|
end
|
|
916
925
|
|
|
917
926
|
def action_access_keys_do_mklink(path:, do_root_file_id:, **)
|
|
918
927
|
apifid, payload = gen4_mk_resolve(do_root_file_id, path)
|
|
919
928
|
payload[:type] = :link
|
|
920
|
-
Aspera.assert(payload[:target_id], 'Missing target_id')
|
|
921
|
-
Aspera.assert(payload[:target_node_id], 'Missing target_node_id')
|
|
922
|
-
Result::SingleObject.new(apifid.node_api.create("files/#{apifid.file_id}/files", payload))
|
|
929
|
+
Aspera.assert(payload[:target_id], 'Missing target_id', type: Cli::BadArgument)
|
|
930
|
+
Aspera.assert(payload[:target_node_id], 'Missing target_node_id', type: Cli::BadArgument)
|
|
931
|
+
Cli::Result::SingleObject.new(apifid.node_api.create("files/#{apifid.file_id}/files", payload))
|
|
923
932
|
end
|
|
924
933
|
|
|
925
934
|
def action_access_keys_do_mkfile(path:, contents:, do_root_file_id:, **)
|
|
926
935
|
apifid, payload = gen4_mk_resolve(do_root_file_id, path)
|
|
927
936
|
payload[:type] = :file
|
|
928
937
|
payload[:contents] = contents.nil? ? '' : Base64.strict_encode64(contents)
|
|
929
|
-
Result::SingleObject.new(apifid.node_api.create("files/#{apifid.file_id}/files", payload))
|
|
938
|
+
Cli::Result::SingleObject.new(apifid.node_api.create("files/#{apifid.file_id}/files", payload))
|
|
930
939
|
end
|
|
931
940
|
|
|
932
941
|
# access_keys > do > permission > list/show/create/modify/delete
|
|
@@ -935,7 +944,7 @@ module Aspera
|
|
|
935
944
|
# Specify file to get permissions for unless not specified (then, get all permissions)
|
|
936
945
|
list_query['file_id'] = apifid.file_id unless apifid.file_id.to_s.empty?
|
|
937
946
|
list_query['inherited'] = false if list_query.key?('file_id') && !list_query.key?('inherited')
|
|
938
|
-
Result::ObjectList.new(apifid.node_api.read_with_pages('permissions', list_query))
|
|
947
|
+
Cli::Result::ObjectList.new(apifid.node_api.read_with_pages('permissions', list_query))
|
|
939
948
|
end
|
|
940
949
|
|
|
941
950
|
def action_access_keys_do_permission_delete(permission_id:, apifid:, **)
|
|
@@ -951,12 +960,12 @@ module Aspera
|
|
|
951
960
|
create_param = permission
|
|
952
961
|
Aspera.assert(!create_param.key?('file_id'), type: Cli::BadArgument) { 'no file_id' }
|
|
953
962
|
create_param['file_id'] = apifid.file_id
|
|
954
|
-
create_param['access_levels'] = Api::
|
|
963
|
+
create_param['access_levels'] = Api::ACCESS_LEVELS unless create_param.key?('access_levels')
|
|
955
964
|
the_app = apifid.node_api.app_info
|
|
956
965
|
the_app&.api&.permissions_set_create_params(perm_data: create_param, app_info: the_app)
|
|
957
966
|
created_data = apifid.node_api.create('permissions', create_param)
|
|
958
967
|
the_app&.api&.permissions_send_event(event_data: created_data, app_info: the_app)
|
|
959
|
-
Result::SingleObject.new(created_data)
|
|
968
|
+
Cli::Result::SingleObject.new(created_data)
|
|
960
969
|
end
|
|
961
970
|
|
|
962
971
|
# access_keys > set_bearer_key
|
|
@@ -965,21 +974,21 @@ module Aspera
|
|
|
965
974
|
key = OpenSSL::PKey.read(bearer_key_pem)
|
|
966
975
|
key = key.public_key if key.private?
|
|
967
976
|
api_node.update("access_keys/#{access_key_id}", {token_verification_key: key.to_pem})
|
|
968
|
-
Result::Status.new('public key updated')
|
|
977
|
+
Cli::Result::Status.new('public key updated')
|
|
969
978
|
end
|
|
970
979
|
|
|
971
980
|
# async sub-commands: individual handlers
|
|
972
981
|
def action_async_show(async_id:, **)
|
|
973
982
|
async_ids = api_node.read('async/list')['sync_ids']
|
|
974
|
-
if async_id.eql?(SpecialValues::ALL)
|
|
983
|
+
if async_id.eql?(Cli::SpecialValues::ALL)
|
|
975
984
|
resp = api_node.create('async/summary', {'syncs' => async_ids})['sync_summaries']
|
|
976
|
-
return Result::Empty.new if resp.empty?
|
|
977
|
-
return Result::ObjectList.new(resp, fields: %w[snid name local_dir remote_dir])
|
|
985
|
+
return Cli::Result::Empty.new if resp.empty?
|
|
986
|
+
return Cli::Result::ObjectList.new(resp, fields: %w[snid name local_dir remote_dir])
|
|
978
987
|
end
|
|
979
988
|
Integer(async_id)
|
|
980
989
|
resp = api_node.create('async/summary', {'syncs' => [async_id]})['sync_summaries']
|
|
981
|
-
return Result::Empty.new if resp.empty?
|
|
982
|
-
Result::SingleObject.new(resp.first)
|
|
990
|
+
return Cli::Result::Empty.new if resp.empty?
|
|
991
|
+
Cli::Result::SingleObject.new(resp.first)
|
|
983
992
|
end
|
|
984
993
|
|
|
985
994
|
def action_async_bandwidth(async_id:, **)
|
|
@@ -987,8 +996,8 @@ module Aspera
|
|
|
987
996
|
post_data = {'syncs' => [async_id], 'seconds' => 100}
|
|
988
997
|
resp = api_node.create('async/bandwidth', post_data)
|
|
989
998
|
data = resp['bandwidth_data']
|
|
990
|
-
return Result::Empty.new if data.empty?
|
|
991
|
-
Result::ObjectList.new(data.first[async_id]['data'])
|
|
999
|
+
return Cli::Result::Empty.new if data.empty?
|
|
1000
|
+
Cli::Result::ObjectList.new(data.first[async_id]['data'])
|
|
992
1001
|
end
|
|
993
1002
|
|
|
994
1003
|
def action_async_files(async_id:, **)
|
|
@@ -1011,21 +1020,21 @@ module Aspera
|
|
|
1011
1020
|
data.select! { |l| l['fnid'].to_i > iteration_data.first } unless iteration_data.first.nil?
|
|
1012
1021
|
iteration_data[0] = data.last['fnid'].to_i unless data.empty?
|
|
1013
1022
|
end
|
|
1014
|
-
return Result::Empty.new if data.empty?
|
|
1023
|
+
return Cli::Result::Empty.new if data.empty?
|
|
1015
1024
|
skip_ids_persistency&.save
|
|
1016
|
-
Result::ObjectList.new(data)
|
|
1025
|
+
Cli::Result::ObjectList.new(data)
|
|
1017
1026
|
end
|
|
1018
1027
|
|
|
1019
1028
|
def action_async_counters(async_id:, **)
|
|
1020
1029
|
Integer(async_id)
|
|
1021
1030
|
resp = api_node.create('async/counters', {'syncs' => [async_id]})['sync_counters'].first&.[](async_id)&.last
|
|
1022
|
-
return Result::Empty.new if resp.nil?
|
|
1023
|
-
Result::SingleObject.new(resp)
|
|
1031
|
+
return Cli::Result::Empty.new if resp.nil?
|
|
1032
|
+
Cli::Result::SingleObject.new(resp)
|
|
1024
1033
|
end
|
|
1025
1034
|
|
|
1026
1035
|
# transfer sub-commands
|
|
1027
1036
|
def action_transfer_list(**)
|
|
1028
|
-
transfer_filter = query_read_delete(default: {}, schema: Schema::Registry.query_params(
|
|
1037
|
+
transfer_filter = query_read_delete(default: {}, schema: Schema::Registry.query_params(API_SCHEMA, 'ops/transfers'))
|
|
1029
1038
|
iteration_persistency = nil
|
|
1030
1039
|
if options.get_option(:once_only, mandatory: true)
|
|
1031
1040
|
iteration_persistency = PersistencyActionOnce.new(
|
|
@@ -1036,29 +1045,29 @@ module Aspera
|
|
|
1036
1045
|
if transfer_filter.delete('reset')
|
|
1037
1046
|
iteration_persistency.data.clear
|
|
1038
1047
|
iteration_persistency.save
|
|
1039
|
-
return Result::Status.new('Persistency reset')
|
|
1048
|
+
return Cli::Result::Status.new('Persistency reset')
|
|
1040
1049
|
end
|
|
1041
1050
|
else
|
|
1042
1051
|
Aspera.assert(!transfer_filter.key?('reset'), 'reset only with once_only', type: Cli::BadArgument)
|
|
1043
1052
|
end
|
|
1044
1053
|
transfers_data = api_node.read_with_paging('ops/transfers', transfer_filter, iteration: iteration_persistency&.data)
|
|
1045
1054
|
iteration_persistency&.save
|
|
1046
|
-
Result::ObjectList.new(transfers_data, fields: %w[id status start_spec.direction start_spec.remote_user start_spec.remote_host start_spec.destination_path])
|
|
1055
|
+
Cli::Result::ObjectList.new(transfers_data, fields: %w[id status start_spec.direction start_spec.remote_user start_spec.remote_host start_spec.destination_path])
|
|
1047
1056
|
end
|
|
1048
1057
|
|
|
1049
1058
|
def action_transfer_sessions(**)
|
|
1050
|
-
transfers_data = api_node.read('ops/transfers', query_read_delete(schema: Schema::Registry.query_params(
|
|
1059
|
+
transfers_data = api_node.read('ops/transfers', query_read_delete(schema: Schema::Registry.query_params(API_SCHEMA, 'ops/transfers')))
|
|
1051
1060
|
sessions = transfers_data.flat_map { |t| t['sessions'] }
|
|
1052
1061
|
sessions.each do |session|
|
|
1053
1062
|
SESSION_TIME_FIELDS.each do |what|
|
|
1054
1063
|
session["#{what}_time"] = session["#{what}_time_usec"] ? Time.at(session["#{what}_time_usec"] / 1_000_000.0).utc.iso8601(0) : nil
|
|
1055
1064
|
end
|
|
1056
1065
|
end
|
|
1057
|
-
Result::ObjectList.new(sessions, fields: %w[id status start_time end_time target_rate_kbps])
|
|
1066
|
+
Cli::Result::ObjectList.new(sessions, fields: %w[id status start_time end_time target_rate_kbps])
|
|
1058
1067
|
end
|
|
1059
1068
|
|
|
1060
1069
|
def action_transfer_bandwidth_average(**)
|
|
1061
|
-
transfers_data = api_node.read('ops/transfers', query_read_delete(schema: Schema::Registry.query_params(
|
|
1070
|
+
transfers_data = api_node.read('ops/transfers', query_read_delete(schema: Schema::Registry.query_params(API_SCHEMA, 'ops/transfers')))
|
|
1062
1071
|
bandwidth_period = {}
|
|
1063
1072
|
dir_info = %i[avg_kbps sessions].freeze
|
|
1064
1073
|
transfers_data.each do |t|
|
|
@@ -1071,7 +1080,7 @@ module Aspera
|
|
|
1071
1080
|
all_dates.each_with_index do |start_date, index|
|
|
1072
1081
|
end_date = all_dates[index + 1]
|
|
1073
1082
|
break if end_date.nil?
|
|
1074
|
-
period_bandwidth = Transfer::Spec::DIRECTION_ENUM_VALUES.map(&:to_sym).to_h do |dir|
|
|
1083
|
+
period_bandwidth = Aspera::Transfer::Spec::DIRECTION_ENUM_VALUES.map(&:to_sym).to_h do |dir|
|
|
1075
1084
|
[dir, dir_info.to_h { |k2| [k2, 0] }]
|
|
1076
1085
|
end
|
|
1077
1086
|
transfers_data.each do |t|
|
|
@@ -1081,10 +1090,10 @@ module Aspera
|
|
|
1081
1090
|
info[:avg_kbps] += t['avg_rate_kbps']
|
|
1082
1091
|
info[:sessions] += 1
|
|
1083
1092
|
end
|
|
1084
|
-
next if Transfer::Spec::DIRECTION_ENUM_VALUES.map(&:to_sym).all? { |dir| period_bandwidth[dir][:sessions].zero? }
|
|
1093
|
+
next if Aspera::Transfer::Spec::DIRECTION_ENUM_VALUES.map(&:to_sym).all? { |dir| period_bandwidth[dir][:sessions].zero? }
|
|
1085
1094
|
result.push({start: Time.at(start_date / 1_000_000), end: Time.at(end_date / 1_000_000)}.merge(period_bandwidth))
|
|
1086
1095
|
end
|
|
1087
|
-
Result::ObjectList.new(result)
|
|
1096
|
+
Cli::Result::ObjectList.new(result)
|
|
1088
1097
|
end
|
|
1089
1098
|
|
|
1090
1099
|
# central: shared helper
|
|
@@ -1099,7 +1108,7 @@ module Aspera
|
|
|
1099
1108
|
validation = central_validation
|
|
1100
1109
|
criteria.deep_merge!({'validation' => validation}) unless validation.nil?
|
|
1101
1110
|
resp = api_node.create('services/rest/transfers/v1/sessions', criteria)
|
|
1102
|
-
Result::ObjectList.new(resp['session_info_result']['session_info'], fields: %w[session_uuid status transport direction bytes_transferred])
|
|
1111
|
+
Cli::Result::ObjectList.new(resp['session_info_result']['session_info'], fields: %w[session_uuid status transport direction bytes_transferred])
|
|
1103
1112
|
end
|
|
1104
1113
|
|
|
1105
1114
|
# central > file > list
|
|
@@ -1110,7 +1119,7 @@ module Aspera
|
|
|
1110
1119
|
resp = api_node.create('services/rest/transfers/v1/files', criteria)
|
|
1111
1120
|
resp = JSON.parse(resp) if resp.is_a?(String)
|
|
1112
1121
|
Log.dump(:resp, resp)
|
|
1113
|
-
Result::ObjectList.new(resp['file_transfer_info_result']['file_transfer_info'], fields: %w[session_uuid file_id status path])
|
|
1122
|
+
Cli::Result::ObjectList.new(resp['file_transfer_info_result']['file_transfer_info'], fields: %w[session_uuid file_id status path])
|
|
1114
1123
|
end
|
|
1115
1124
|
|
|
1116
1125
|
# central > file > modify
|
|
@@ -1119,7 +1128,7 @@ module Aspera
|
|
|
1119
1128
|
validation = central_validation
|
|
1120
1129
|
file.deep_merge!(validation) unless validation.nil?
|
|
1121
1130
|
api_node.update('services/rest/transfers/v1/files', file)
|
|
1122
|
-
Result::Status.new('updated')
|
|
1131
|
+
Cli::Result::Status.new('updated')
|
|
1123
1132
|
end
|
|
1124
1133
|
|
|
1125
1134
|
def action_asperabrowser(**)
|
|
@@ -1131,15 +1140,15 @@ module Aspera
|
|
|
1131
1140
|
# Not encrypted (decoded by the web application), in the fragment: it is not sent to the web server
|
|
1132
1141
|
encoded_params = SealedHash.seal(browse_params, encrypt: false, reverse: true)
|
|
1133
1142
|
Environment.instance.open_uri("#{options.get_option(:asperabrowserurl)}##{URI.encode_www_form(goto: encoded_params)}")
|
|
1134
|
-
return Result::Status.new('done')
|
|
1143
|
+
return Cli::Result::Status.new('done')
|
|
1135
1144
|
end
|
|
1136
1145
|
|
|
1137
1146
|
def action_emulator(parameters: {}, **)
|
|
1138
1147
|
require_relative '../../secret/strength'
|
|
1139
1148
|
require_relative '../../web_server_simple'
|
|
1140
|
-
require_relative '
|
|
1149
|
+
require_relative 'emulator'
|
|
1141
1150
|
# missing parameters take the default of the schema
|
|
1142
|
-
defaults = Schema::Registry.instance.reader(
|
|
1151
|
+
defaults = Schema::Registry.instance.reader(EMULATOR_OPTIONS).current['properties'].each_with_object({}) do |(name, property), result|
|
|
1143
1152
|
result[name.to_sym] = property['default'] if property.key?('default')
|
|
1144
1153
|
end
|
|
1145
1154
|
parameters = defaults.merge(parameters.symbolize_keys)
|
|
@@ -1151,10 +1160,10 @@ module Aspera
|
|
|
1151
1160
|
Secret::Strength.assert_strong(config[:password], name: 'password', min_bits: password_min_bits, type: Cli::BadArgument) unless config[:password].nil?
|
|
1152
1161
|
# Files of the docroot can be sent to, or received from, any host by anyone who can reach the server
|
|
1153
1162
|
WebServerSimple.serve(parameters, NodeEmulatorServlet, protected: !config[:username].nil?, what: 'username and password', type: Cli::BadArgument) do
|
|
1154
|
-
Log.log.warn('No username and password: emulator accepts requests without authentication') if config[:username].nil?
|
|
1155
|
-
[config,
|
|
1163
|
+
Log.log.warn('No username and password: emulator accepts requests without authentication') if config[:username].nil? # HashiCorpIgnore
|
|
1164
|
+
[config, Emulator.new(docroot: docroot, retention_sec: retention_sec)]
|
|
1156
1165
|
end
|
|
1157
|
-
return Result::Status.new('Emulator terminated')
|
|
1166
|
+
return Cli::Result::Status.new('Emulator terminated')
|
|
1158
1167
|
end
|
|
1159
1168
|
|
|
1160
1169
|
def action_telemetry(parameters: {}, **)
|
|
@@ -1256,9 +1265,25 @@ module Aspera
|
|
|
1256
1265
|
# Translates paths results into CLI result, and removes prefix
|
|
1257
1266
|
def cli_result_from_paths_response(response, success_msg)
|
|
1258
1267
|
obj_list = response_to_result(response, success_msg)
|
|
1259
|
-
return Result::ObjectList.new(obj_list, fields: %w[path result])
|
|
1268
|
+
return Cli::Result::ObjectList.new(obj_list, fields: %w[path result])
|
|
1260
1269
|
end
|
|
1261
1270
|
end
|
|
1271
|
+
# Hints of errors of the Node API on configuration of the server
|
|
1272
|
+
Cli::Hints.add(
|
|
1273
|
+
exception: Rest::CallError,
|
|
1274
|
+
match: /Server is not configured for this request/,
|
|
1275
|
+
remediation: [
|
|
1276
|
+
'Transfer user shall have those parameters in aspera.conf set to: token',
|
|
1277
|
+
'authorization_transfer_in_value authorization_transfer_out_value'
|
|
1278
|
+
]
|
|
1279
|
+
)
|
|
1280
|
+
Cli::Hints.add(
|
|
1281
|
+
exception: Rest::CallError,
|
|
1282
|
+
match: /Please configure ACLs for this URI/,
|
|
1283
|
+
remediation: [
|
|
1284
|
+
'server must have: asnodeadmin -mu <node user> --acl-add=internal --internal'
|
|
1285
|
+
]
|
|
1286
|
+
)
|
|
1262
1287
|
end
|
|
1263
1288
|
end
|
|
1264
1289
|
end
|