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,28 +6,37 @@
|
|
|
6
6
|
# spellchecker: ignore workgroups mypackages passcode
|
|
7
7
|
|
|
8
8
|
require_relative '../../schema/registry'
|
|
9
|
-
require_relative 'oauth'
|
|
10
|
-
require_relative '
|
|
11
|
-
require_relative '
|
|
9
|
+
require_relative '../../cli/plugins/oauth'
|
|
10
|
+
require_relative '../../cli/extended_value'
|
|
11
|
+
require_relative '../../cli/formatter'
|
|
12
12
|
require_relative '../../transfer/result'
|
|
13
|
-
require_relative '
|
|
14
|
-
require_relative '
|
|
15
|
-
require_relative '
|
|
13
|
+
require_relative '../../cli/special_values'
|
|
14
|
+
require_relative '../../cli/wizard'
|
|
15
|
+
require_relative 'api'
|
|
16
16
|
require_relative '../../persistency_action_once'
|
|
17
17
|
require_relative '../../id_generator'
|
|
18
18
|
require_relative '../../nagios'
|
|
19
|
+
require_relative '../../mime'
|
|
19
20
|
require_relative '../../environment'
|
|
20
21
|
require_relative '../../assert'
|
|
21
22
|
require_relative '../../rainbow'
|
|
23
|
+
require_relative '../xfer/transfer_agent'
|
|
24
|
+
require_relative '../faspex4/gateway_options'
|
|
22
25
|
require 'securerandom'
|
|
23
26
|
require 'digest'
|
|
24
27
|
require 'json'
|
|
25
28
|
using Rainbow
|
|
26
29
|
|
|
27
30
|
module Aspera
|
|
28
|
-
module
|
|
29
|
-
module
|
|
30
|
-
class
|
|
31
|
+
module Plugins
|
|
32
|
+
module Faspex5
|
|
33
|
+
class Commands < Cli::Plugins::Base
|
|
34
|
+
include Cli::Plugins::Oauth
|
|
35
|
+
|
|
36
|
+
# Key of the Faspex 5 API in the schemas of the bundle (manifest)
|
|
37
|
+
API_SCHEMA = 'faspex'
|
|
38
|
+
# Options of the Faspex 4 post-processing servlet, in the schemas of the bundle
|
|
39
|
+
POSTPROC_OPTIONS = 'faspex5_opts:components.schemas.Faspex4PostProcOptions'
|
|
31
40
|
application_name 'Faspex v5'
|
|
32
41
|
# Commands that may carry a query_schema annotation
|
|
33
42
|
QUERY_SCHEMA_COMMANDS = %i[list delete].freeze
|
|
@@ -38,19 +47,19 @@ module Aspera
|
|
|
38
47
|
# add scheme if missing
|
|
39
48
|
address_or_url = "https://#{address_or_url}" unless address_or_url.match?(%r{^[a-z]{1,6}://})
|
|
40
49
|
urls = [address_or_url]
|
|
41
|
-
urls.push("#{address_or_url}#{Api::
|
|
50
|
+
urls.push("#{address_or_url}#{Api::PATH_STANDARD_ROOT}") unless address_or_url.end_with?(Api::PATH_STANDARD_ROOT)
|
|
42
51
|
error = nil
|
|
43
52
|
urls.each do |base_url|
|
|
44
53
|
# Faspex is always HTTPS
|
|
45
54
|
next unless base_url.start_with?('https://')
|
|
46
55
|
api = Rest::Client.new(base_url: base_url, redirect_max: 1)
|
|
47
|
-
response = api.read(Api::
|
|
56
|
+
response = api.read(Api::PATH_API_DETECT, ret: :resp)
|
|
48
57
|
next unless response.code.start_with?('2') && response.body.strip.empty?
|
|
49
58
|
# end is at -1, and subtract 1 for "/"
|
|
50
|
-
url_length = -2 - Api::
|
|
59
|
+
url_length = -2 - Api::PATH_API_DETECT.length
|
|
51
60
|
# take redirect if any
|
|
52
61
|
return {
|
|
53
|
-
version: response[Api::
|
|
62
|
+
version: response[Api::HEADER_FASPEX_VERSION] || '5',
|
|
54
63
|
url: response.uri.to_s[0..url_length]
|
|
55
64
|
}
|
|
56
65
|
rescue StandardError => e
|
|
@@ -62,7 +71,7 @@ module Aspera
|
|
|
62
71
|
end
|
|
63
72
|
end
|
|
64
73
|
|
|
65
|
-
# @param wizard [Wizard] The wizard object
|
|
74
|
+
# @param wizard [Cli::Wizard] The wizard object
|
|
66
75
|
# @param app_url [String] Tested URL
|
|
67
76
|
# @return [Hash] :preset_value, :test_args
|
|
68
77
|
def wizard(wizard, app_url)
|
|
@@ -101,7 +110,7 @@ module Aspera
|
|
|
101
110
|
}
|
|
102
111
|
end
|
|
103
112
|
|
|
104
|
-
option :box, description: "Package inbox, either shared inbox name or one of: #{Api::
|
|
113
|
+
option :box, description: "Package inbox, either shared inbox name or one of: #{Api::API_LIST_MAILBOX_TYPES.join(', ')} or #{Cli::SpecialValues::ALL}", default: 'inbox_all'
|
|
105
114
|
option :shared_folder, description: 'Send package with files from shared folder'
|
|
106
115
|
option :group_type, description: 'Type of shared box', allowed: %i[shared_inboxes workgroups], default: :shared_inboxes
|
|
107
116
|
|
|
@@ -109,8 +118,8 @@ module Aspera
|
|
|
109
118
|
def normalize_recipients(parameters, type)
|
|
110
119
|
type = type.to_s
|
|
111
120
|
return unless parameters.key?(type)
|
|
112
|
-
Aspera.assert_type(parameters[type], Array) { type }
|
|
113
|
-
recipient_types = Api::
|
|
121
|
+
Aspera.assert_type(parameters[type], Array, type: Cli::BadArgument) { type }
|
|
122
|
+
recipient_types = Api::RECIPIENT_TYPES
|
|
114
123
|
if parameters.key?('recipient_types')
|
|
115
124
|
recipient_types = Array(parameters.delete('recipient_types'))
|
|
116
125
|
Aspera.assert_array_all(recipient_types, String) { 'recipient_types' }
|
|
@@ -130,7 +139,7 @@ module Aspera
|
|
|
130
139
|
end
|
|
131
140
|
|
|
132
141
|
# wait for package status to be in provided list
|
|
133
|
-
def wait_package_status(id, status_list: Api::
|
|
142
|
+
def wait_package_status(id, status_list: Api::PACKAGE_TERMINATED)
|
|
134
143
|
total_sent = false
|
|
135
144
|
loop do
|
|
136
145
|
status = api_v5.read("packages/#{id}/upload_details")
|
|
@@ -161,7 +170,7 @@ module Aspera
|
|
|
161
170
|
result = nil
|
|
162
171
|
loop do
|
|
163
172
|
result = api_v5.read("jobs/#{job_id}", {type: :formatted})
|
|
164
|
-
break unless Api::
|
|
173
|
+
break unless Api::JOB_RUNNING.include?(result['status'])
|
|
165
174
|
Rest::Parameters.instance.spinner_cb.call(result['status'])
|
|
166
175
|
sleep(0.5)
|
|
167
176
|
end
|
|
@@ -182,14 +191,14 @@ module Aspera
|
|
|
182
191
|
# Translate box name to API prefix (with ending slash)
|
|
183
192
|
entity =
|
|
184
193
|
case box
|
|
185
|
-
when SpecialValues::ALL then 'packages' # only admin can list all packages globally
|
|
186
|
-
when *Api::
|
|
194
|
+
when Cli::SpecialValues::ALL then 'packages' # only admin can list all packages globally
|
|
195
|
+
when *Api::API_LIST_MAILBOX_TYPES then "#{box}/packages"
|
|
187
196
|
else
|
|
188
197
|
group_type = options.get_option(:group_type)
|
|
189
198
|
"#{group_type}/#{api_v5.lookup_entity_by_field(entity: group_type, value: box)['id']}/packages"
|
|
190
199
|
end
|
|
191
200
|
# Merge default query with user-provided query: user values take precedence, but defaults are preserved
|
|
192
|
-
user_query = query_read_delete(schema: Schema::Registry.query_params(
|
|
201
|
+
user_query = query_read_delete(schema: Schema::Registry.query_params(API_SCHEMA, 'packages'))
|
|
193
202
|
merged_query = user_query.nil? ? query.dup : query.merge(user_query)
|
|
194
203
|
# Extract `max` before the API call so callers can apply it after post-API filtering
|
|
195
204
|
max_items = merged_query.delete(Rest::List::MAX_ITEMS)&.to_i
|
|
@@ -237,12 +246,12 @@ module Aspera
|
|
|
237
246
|
end
|
|
238
247
|
packages = []
|
|
239
248
|
case package_ids
|
|
240
|
-
when SpecialValues::INIT
|
|
241
|
-
Aspera.assert(skip_ids_persistency, 'Only with option once_only')
|
|
249
|
+
when Cli::SpecialValues::INIT
|
|
250
|
+
Aspera.assert(skip_ids_persistency, 'Only with option once_only', type: Cli::BadArgument)
|
|
242
251
|
skip_ids_persistency.data.clear.concat(list_packages_with_filter.first.map { |p| p['id'] }) # no filter: all packages, max ignored
|
|
243
252
|
skip_ids_persistency.save
|
|
244
|
-
return Result::Status.new("Initialized skip for #{skip_ids_persistency.data.count} package(s)")
|
|
245
|
-
when SpecialValues::ALL
|
|
253
|
+
return Cli::Result::Status.new("Initialized skip for #{skip_ids_persistency.data.count} package(s)")
|
|
254
|
+
when Cli::SpecialValues::ALL
|
|
246
255
|
# TODO: if packages have same name, they will overwrite ?
|
|
247
256
|
packages, max_items = list_packages_with_filter(query: {'status' => 'completed'}) # no filter: all completed packages
|
|
248
257
|
Log.dump(:package_ids, level: :trace1) { packages.map { |p| p['id'] } }
|
|
@@ -254,7 +263,7 @@ module Aspera
|
|
|
254
263
|
else
|
|
255
264
|
# a single id was provided, or a list of ids
|
|
256
265
|
package_ids = Array(package_ids)
|
|
257
|
-
Aspera.assert_array_all(package_ids, String) { 'Package id(s)' }
|
|
266
|
+
Aspera.assert_array_all(package_ids, String, type: Cli::BadArgument) { 'Package id(s)' }
|
|
258
267
|
# packages = package_ids.map{|pkg_id|api_v5.read("packages/#{pkg_id}")}
|
|
259
268
|
packages = package_ids.map { |pkg_id| {'id'=>pkg_id} }
|
|
260
269
|
# The package of a public link is received only once, like with `ALL`
|
|
@@ -269,10 +278,10 @@ module Aspera
|
|
|
269
278
|
end
|
|
270
279
|
box = options.get_option(:box)
|
|
271
280
|
download_params = {
|
|
272
|
-
type: Api
|
|
273
|
-
transfer_type: Api::
|
|
281
|
+
type: Api.box_type(box),
|
|
282
|
+
transfer_type: Api::TRANSFER_CONNECT
|
|
274
283
|
}
|
|
275
|
-
# download_params[:recipient_workgroup_id] = api_v5.lookup_entity_by_field(entity: options.get_option(:group_type), value: box)['id'] if !Api::
|
|
284
|
+
# download_params[:recipient_workgroup_id] = api_v5.lookup_entity_by_field(entity: options.get_option(:group_type), value: box)['id'] if !Api::API_LIST_MAILBOX_TYPES.include?(box) && box != Cli::SpecialValues::ALL
|
|
276
285
|
packages.each do |package|
|
|
277
286
|
pkg_id = package['id']
|
|
278
287
|
formatter.display_status("Receiving package #{pkg_id}")
|
|
@@ -288,14 +297,14 @@ module Aspera
|
|
|
288
297
|
# delete flag for Connect Client
|
|
289
298
|
transfer_spec.delete('authentication')
|
|
290
299
|
statuses = transfer.start(transfer_spec)
|
|
291
|
-
result_transfer.push({'package' => pkg_id,
|
|
300
|
+
result_transfer.push({'package' => pkg_id, Xfer::TransferAgent::STATUS_FIELD => statuses})
|
|
292
301
|
# skip only if all sessions completed
|
|
293
|
-
if statuses.is_a?(Transfer::Result::Success) && skip_ids_persistency
|
|
302
|
+
if statuses.is_a?(Aspera::Transfer::Result::Success) && skip_ids_persistency
|
|
294
303
|
skip_ids_persistency.data.push(pkg_id)
|
|
295
304
|
skip_ids_persistency.save
|
|
296
305
|
end
|
|
297
306
|
end
|
|
298
|
-
return
|
|
307
|
+
return Xfer::TransferAgent.result_transfer_multiple(result_transfer)
|
|
299
308
|
end
|
|
300
309
|
|
|
301
310
|
def package_send(parameters)
|
|
@@ -322,14 +331,14 @@ module Aspera
|
|
|
322
331
|
transfer_spec = api_v5.create(
|
|
323
332
|
"packages/#{package['id']}/transfer_spec/upload",
|
|
324
333
|
{paths: transfer.source_list},
|
|
325
|
-
query: {transfer_type: Api::
|
|
334
|
+
query: {transfer_type: Api::TRANSFER_CONNECT}
|
|
326
335
|
)
|
|
327
336
|
# well, we asked a TS for connect, but we actually want a generic one
|
|
328
337
|
transfer_spec.delete('authentication')
|
|
329
|
-
return
|
|
338
|
+
return Xfer::TransferAgent.result_object_transfer(package, transfer.start(transfer_spec))
|
|
330
339
|
else
|
|
331
340
|
# send from remote shared folder
|
|
332
|
-
if (m = Parser.percent_selector(shared_folder))
|
|
341
|
+
if (m = Cli::Parser.percent_selector(shared_folder))
|
|
333
342
|
shared_folder = api_v5.lookup_entity_by_field(
|
|
334
343
|
entity: 'shared_folders',
|
|
335
344
|
field: m[:field],
|
|
@@ -344,7 +353,7 @@ module Aspera
|
|
|
344
353
|
formatter.display_status("Package #{package['id']}")
|
|
345
354
|
result = wait_package_status(package['id'])
|
|
346
355
|
end
|
|
347
|
-
return Result::SingleObject.new(result)
|
|
356
|
+
return Cli::Result::SingleObject.new(result)
|
|
348
357
|
end
|
|
349
358
|
end
|
|
350
359
|
|
|
@@ -355,9 +364,9 @@ module Aspera
|
|
|
355
364
|
folders_to_process = [folder_path]
|
|
356
365
|
query = base_query.merge(query_read_delete(default: {}))
|
|
357
366
|
filters = query.delete('filters') { {} }
|
|
358
|
-
Aspera.assert_type(filters, Hash)
|
|
367
|
+
Aspera.assert_type(filters, Hash, type: Cli::BadArgument) { 'filters' }
|
|
359
368
|
filters['basenames'] ||= []
|
|
360
|
-
Aspera.assert_type(filters, Hash) { 'filters' }
|
|
369
|
+
Aspera.assert_type(filters, Hash, type: Cli::BadArgument) { 'filters' }
|
|
361
370
|
max_items = query.delete(Rest::List::MAX_ITEMS)
|
|
362
371
|
recursive = query.delete('recursive')
|
|
363
372
|
use_paging = query.delete('paging') { true }
|
|
@@ -389,7 +398,7 @@ module Aspera
|
|
|
389
398
|
end
|
|
390
399
|
folders_to_process.concat(data['items'].select { |i| i['type'].eql?('directory') }.map { |i| i['path'] }) if recursive
|
|
391
400
|
if use_paging
|
|
392
|
-
iteration_token = http[Api::
|
|
401
|
+
iteration_token = http[Api::HEADER_X_NEXT_ITER_TOKEN]
|
|
393
402
|
break if iteration_token.nil? || iteration_token.empty?
|
|
394
403
|
query['iteration_token'] = iteration_token
|
|
395
404
|
else
|
|
@@ -402,7 +411,7 @@ module Aspera
|
|
|
402
411
|
query.delete('iteration_token')
|
|
403
412
|
end
|
|
404
413
|
Rest::Parameters.instance.spinner_cb.call(action: :success)
|
|
405
|
-
return Result::ObjectList.new(all_items, total: total_count)
|
|
414
|
+
return Cli::Result::ObjectList.new(all_items, total: total_count)
|
|
406
415
|
end
|
|
407
416
|
|
|
408
417
|
# Per-resource configuration for admin CRUD sub-trees.
|
|
@@ -410,23 +419,23 @@ module Aspera
|
|
|
410
419
|
# @return [Hash{Symbol => Hash}]
|
|
411
420
|
RESOURCE_CONFIG = {
|
|
412
421
|
accounts: {
|
|
413
|
-
display_fields: Formatter.all_but('user_profile_data_attributes'),
|
|
414
|
-
extra_commands: {reset_password: {description: 'Send password reset email to account', arguments: [{name: :account_id, type: :identifier, lookup: ->(field, value, **) { res_lookup_id(:accounts, field, value) }}]}},
|
|
415
|
-
query_component:
|
|
416
|
-
body_component:
|
|
422
|
+
display_fields: Cli::Formatter.all_but('user_profile_data_attributes'),
|
|
423
|
+
extra_commands: {reset_password: {description: 'Send password reset email to account', arguments: [{name: :account_id, type: :identifier, lookup: ->(field, value, **) { res_lookup_id(:accounts, field, value) }}]}}, # HashiCorpIgnore
|
|
424
|
+
query_component: API_SCHEMA,
|
|
425
|
+
body_component: API_SCHEMA
|
|
417
426
|
},
|
|
418
|
-
alternate_addresses: {entity: 'configuration/alternate_addresses', query_component:
|
|
419
|
-
contacts: {query_component:
|
|
420
|
-
distribution_lists: {entity: 'account/distribution_lists', delete_style: 'ids', query_component:
|
|
421
|
-
email_notifications: {id_as_arg: 'type', query_component:
|
|
427
|
+
alternate_addresses: {entity: 'configuration/alternate_addresses', query_component: API_SCHEMA, body_component: API_SCHEMA},
|
|
428
|
+
contacts: {query_component: API_SCHEMA},
|
|
429
|
+
distribution_lists: {entity: 'account/distribution_lists', delete_style: 'ids', query_component: API_SCHEMA, body_component: API_SCHEMA},
|
|
430
|
+
email_notifications: {id_as_arg: 'type', query_component: API_SCHEMA},
|
|
422
431
|
file_processing: {
|
|
423
432
|
commands: %i[modify],
|
|
424
433
|
extra_commands: {next: {description: 'List next files to process'}},
|
|
425
|
-
body_component:
|
|
434
|
+
body_component: API_SCHEMA,
|
|
426
435
|
is_singleton: true
|
|
427
436
|
},
|
|
428
|
-
jobs: {display_fields: %w[id job_name job_type status], query_component:
|
|
429
|
-
metadata_profiles: {entity: 'configuration/metadata_profiles', items_key: 'profiles', query_component:
|
|
437
|
+
jobs: {display_fields: %w[id job_name job_type status], query_component: API_SCHEMA},
|
|
438
|
+
metadata_profiles: {entity: 'configuration/metadata_profiles', items_key: 'profiles', query_component: API_SCHEMA, body_component: API_SCHEMA},
|
|
430
439
|
nodes: {
|
|
431
440
|
extra_commands: {
|
|
432
441
|
browse: {
|
|
@@ -435,21 +444,21 @@ module Aspera
|
|
|
435
444
|
{name: :folder_path, mandatory: false, default: '/'}]
|
|
436
445
|
}
|
|
437
446
|
},
|
|
438
|
-
query_component:
|
|
439
|
-
body_component:
|
|
447
|
+
query_component: API_SCHEMA,
|
|
448
|
+
body_component: API_SCHEMA
|
|
440
449
|
},
|
|
441
450
|
oauth_clients: {
|
|
442
|
-
display_fields: Formatter.all_but('public_key'),
|
|
443
|
-
api: -> { Api
|
|
451
|
+
display_fields: Cli::Formatter.all_but('public_key'),
|
|
452
|
+
api: -> { Api.new(root: Api::PATH_AUTH, **Cli::Plugins::Oauth.kwargs_from_options(options)) },
|
|
444
453
|
list_query: {'expand': true, 'no_api_path': true, 'client_types[]': 'public'},
|
|
445
|
-
query_component:
|
|
446
|
-
body_component:
|
|
454
|
+
query_component: API_SCHEMA,
|
|
455
|
+
body_component: API_SCHEMA
|
|
447
456
|
},
|
|
448
|
-
registrations: {query_component:
|
|
449
|
-
saml_configs: {query_component:
|
|
450
|
-
shared_inboxes: {res_id_query: {'all': true}, query_component:
|
|
451
|
-
webhooks: {query_component:
|
|
452
|
-
workgroups: {res_id_query: {'all': true}, query_component:
|
|
457
|
+
registrations: {query_component: API_SCHEMA},
|
|
458
|
+
saml_configs: {query_component: API_SCHEMA, body_component: API_SCHEMA},
|
|
459
|
+
shared_inboxes: {res_id_query: {'all': true}, query_component: API_SCHEMA, body_component: API_SCHEMA},
|
|
460
|
+
webhooks: {query_component: API_SCHEMA, body_component: API_SCHEMA},
|
|
461
|
+
workgroups: {res_id_query: {'all': true}, query_component: API_SCHEMA, body_component: API_SCHEMA}
|
|
453
462
|
}.freeze
|
|
454
463
|
private_constant :RESOURCE_CONFIG
|
|
455
464
|
|
|
@@ -491,7 +500,7 @@ module Aspera
|
|
|
491
500
|
end
|
|
492
501
|
|
|
493
502
|
# Dynamically define lookup methods for admin resources (used by crud_commands)
|
|
494
|
-
Api::
|
|
503
|
+
Api::ADMIN_RESOURCES.each do |res|
|
|
495
504
|
define_method(:"lookup_admin_#{res}_id") do |field, value, **|
|
|
496
505
|
res_lookup_id(res, field, value)
|
|
497
506
|
end
|
|
@@ -501,8 +510,8 @@ module Aspera
|
|
|
501
510
|
|
|
502
511
|
# :health and :postprocessing work without authentication: they do not use api_v5.
|
|
503
512
|
command :health, description: 'Check Faspex 5 health'
|
|
504
|
-
command :version, read_only: true, description: 'Show Faspex 5 version', action: ->(**) { Result::SingleObject.new(api_v5.read('version')) }
|
|
505
|
-
command :bearer_token, description: 'Show OAuth bearer token', action: ->(**) { Result::Text.new(api_v5.oauth.authorization) }
|
|
513
|
+
command :version, read_only: true, description: 'Show Faspex 5 version', action: ->(**) { Cli::Result::SingleObject.new(api_v5.read('version')) }
|
|
514
|
+
command :bearer_token, description: 'Show OAuth bearer token', action: ->(**) { Cli::Result::Text.new(api_v5.oauth.authorization) }
|
|
506
515
|
# Package id argument; with a public link to a package, setup_package_id provides it instead
|
|
507
516
|
PACKAGE_ID_ARG = [{name: :package_id, type: :identifier}].freeze
|
|
508
517
|
private_constant :PACKAGE_ID_ARG
|
|
@@ -511,31 +520,31 @@ module Aspera
|
|
|
511
520
|
command :list, description: 'List packages',
|
|
512
521
|
arguments: [{name: :filter, mandatory: false, default: nil, type: Proc}]
|
|
513
522
|
command :send, description: 'Send a package', transfer_paths: :send,
|
|
514
|
-
arguments: [{name: :package, type: Hash, schema: Schema::Registry.req_body(
|
|
523
|
+
arguments: [{name: :package, type: Hash, schema: Schema::Registry.req_body(API_SCHEMA, 'packages.post')}],
|
|
515
524
|
action: ->(package:, **) { package_send(package) }
|
|
516
525
|
command :show, description: 'Show a package', setup: :setup_package_id, arguments: PACKAGE_ID_ARG,
|
|
517
|
-
action: ->(package_id:, **) { Result::SingleObject.new(api_v5.read("packages/#{package_id}", query_read_delete)) }
|
|
526
|
+
action: ->(package_id:, **) { Cli::Result::SingleObject.new(api_v5.read("packages/#{package_id}", query_read_delete)) }
|
|
518
527
|
command :browse, description: 'Browse package files', setup: :setup_package_id,
|
|
519
528
|
arguments: PACKAGE_ID_ARG + [{name: :folder_path, mandatory: false, default: '/'}],
|
|
520
|
-
action: ->(folder_path:, package_id:, **) { browse_folder("packages/#{package_id}/files/#{Api
|
|
529
|
+
action: ->(folder_path:, package_id:, **) { browse_folder("packages/#{package_id}/files/#{Api.box_type(options.get_option(:box))}", recipient_query(package_id), folder_path: folder_path) }
|
|
521
530
|
command :status, description: 'Wait for package status', setup: :setup_package_id,
|
|
522
531
|
arguments: PACKAGE_ID_ARG + [{name: :status_list, type: Array, mandatory: false, default: nil}],
|
|
523
|
-
action: ->(status_list:, package_id:, **) { Result::SingleObject.new(wait_package_status(package_id, status_list: status_list)) }
|
|
532
|
+
action: ->(status_list:, package_id:, **) { Cli::Result::SingleObject.new(wait_package_status(package_id, status_list: status_list)) }
|
|
524
533
|
command :delete, description: 'Delete packages', setup: :setup_package_id, arguments: PACKAGE_ID_ARG
|
|
525
534
|
command :receive, description: 'Receive a package', setup: :setup_package_id, transfer_paths: :receive, arguments: PACKAGE_ID_ARG,
|
|
526
535
|
action: ->(package_id:, **) { package_receive(package_id) }
|
|
527
536
|
command(:file_processing, description: 'Show file processing status', setup: :setup_package_id, arguments: PACKAGE_ID_ARG, action: lambda do |package_id:, **|
|
|
528
537
|
result, count = api_v5.list_entities_limit_offset_total_count(entity: "packages/#{package_id}/file_statuses", items_key: 'files')
|
|
529
|
-
Result::ObjectList.new(result, total: count)
|
|
538
|
+
Cli::Result::ObjectList.new(result, total: count)
|
|
530
539
|
end)
|
|
531
540
|
end
|
|
532
541
|
command :admin, description: 'Administer Faspex 5'
|
|
533
542
|
command :user, description: 'Manage current user'
|
|
534
543
|
command :shared_folders, description: 'Browse shared folders'
|
|
535
|
-
command :gateway, description: 'Start Faspex 4 gateway emulation',
|
|
536
|
-
arguments: [{name: :parameters, type: Hash, mandatory: false, default: {}, schema:
|
|
544
|
+
command :gateway, description: 'Start Faspex 4 gateway emulation', security: :low,
|
|
545
|
+
arguments: [{name: :parameters, type: Hash, mandatory: false, default: {}, schema: Faspex4::GatewayOptions::SCHEMA}]
|
|
537
546
|
command :postprocessing, description: 'Start Faspex 4 post-processing server', security: :low,
|
|
538
|
-
arguments: [{name: :parameters, type: Hash, mandatory: false, default: {}, schema:
|
|
547
|
+
arguments: [{name: :parameters, type: Hash, mandatory: false, default: {}, schema: POSTPROC_OPTIONS}]
|
|
539
548
|
command :invitations, description: 'Manage invitations'
|
|
540
549
|
|
|
541
550
|
commands_under :invitations do
|
|
@@ -546,7 +555,7 @@ module Aspera
|
|
|
546
555
|
arguments: [{name: :invitation_id, type: :identifier}],
|
|
547
556
|
action: lambda do |invitation_id:, **|
|
|
548
557
|
api_v5.create("invitations/#{invitation_id}/resend", nil)
|
|
549
|
-
Result::Status.new('Invitation resent')
|
|
558
|
+
Cli::Result::Status.new('Invitation resent')
|
|
550
559
|
end
|
|
551
560
|
)
|
|
552
561
|
crud_commands entity: 'invitations',
|
|
@@ -557,25 +566,25 @@ module Aspera
|
|
|
557
566
|
end
|
|
558
567
|
|
|
559
568
|
commands_under :user do
|
|
560
|
-
command :account, description: 'Show account information', action: ->(**) { Result::SingleObject.new(api_v5.read('account', query_read_delete)) }
|
|
569
|
+
command :account, description: 'Show account information', action: ->(**) { Cli::Result::SingleObject.new(api_v5.read('account', query_read_delete)) }
|
|
561
570
|
command :profile, description: 'Manage user profile'
|
|
562
571
|
end
|
|
563
572
|
|
|
564
573
|
commands_under %i[user profile] do
|
|
565
|
-
command :show, description: 'Show user profile', action: ->(**) { Result::SingleObject.new(api_v5.read('account/preferences')) }
|
|
574
|
+
command :show, description: 'Show user profile', action: ->(**) { Cli::Result::SingleObject.new(api_v5.read('account/preferences')) }
|
|
566
575
|
command(
|
|
567
576
|
:modify,
|
|
568
577
|
description: 'Modify user profile',
|
|
569
578
|
arguments: [{name: :profile, type: Hash}],
|
|
570
579
|
action: lambda do |profile:, **|
|
|
571
580
|
api_v5.update('account/preferences', profile)
|
|
572
|
-
Result::Status.new('modified')
|
|
581
|
+
Cli::Result::Status.new('modified')
|
|
573
582
|
end
|
|
574
583
|
)
|
|
575
584
|
end
|
|
576
585
|
|
|
577
586
|
commands_under :shared_folders do
|
|
578
|
-
command :list, description: 'List shared folders', action: ->(**) { Result::ObjectList.new(api_v5.read('shared_folders')['shared_folders']) }
|
|
587
|
+
command :list, description: 'List shared folders', action: ->(**) { Cli::Result::ObjectList.new(api_v5.read('shared_folders')['shared_folders']) }
|
|
579
588
|
command :browse, description: 'Browse a shared folder',
|
|
580
589
|
arguments: [{name: :shared_folder_id, type: :identifier, lookup: :lookup_shared_folder_id},
|
|
581
590
|
{name: :folder_path, mandatory: false, default: '/'}]
|
|
@@ -591,10 +600,10 @@ module Aspera
|
|
|
591
600
|
arguments: [{name: :parameters, type: Hash, mandatory: false, default: {}}],
|
|
592
601
|
action: lambda do |parameters: {}, **|
|
|
593
602
|
parameters = api_v5.read('configuration').slice('days_before_deleting_package_records') if parameters.empty?
|
|
594
|
-
Result::SingleObject.new(api_v5.create('internal/packages/clean_deleted', parameters))
|
|
603
|
+
Cli::Result::SingleObject.new(api_v5.create('internal/packages/clean_deleted', parameters))
|
|
595
604
|
end
|
|
596
605
|
)
|
|
597
|
-
Api::
|
|
606
|
+
Api::ADMIN_RESOURCES.each do |res|
|
|
598
607
|
cfg = RESOURCE_CONFIG.fetch(res, {})
|
|
599
608
|
extra = cfg[:extra_commands] || {}
|
|
600
609
|
is_singleton = cfg[:is_singleton] || false
|
|
@@ -711,25 +720,25 @@ module Aspera
|
|
|
711
720
|
end
|
|
712
721
|
|
|
713
722
|
commands_under %i[admin configuration] do
|
|
714
|
-
command :show, description: 'Show configuration', action: ->(**) { Result::SingleObject.new(api_v5.read('configuration')) }
|
|
723
|
+
command :show, description: 'Show configuration', action: ->(**) { Cli::Result::SingleObject.new(api_v5.read('configuration')) }
|
|
715
724
|
command :modify, description: 'Modify configuration',
|
|
716
725
|
arguments: [{name: :configuration, type: Hash}],
|
|
717
|
-
action: ->(configuration:, **) { Result::SingleObject.new(api_v5.update('configuration', configuration)) }
|
|
726
|
+
action: ->(configuration:, **) { Cli::Result::SingleObject.new(api_v5.update('configuration', configuration)) }
|
|
718
727
|
end
|
|
719
728
|
|
|
720
729
|
commands_under %i[admin smtp] do
|
|
721
|
-
command :show, description: 'Show SMTP configuration', action: ->(**) { Result::SingleObject.new(api_v5.read('configuration/smtp')) }
|
|
730
|
+
command :show, description: 'Show SMTP configuration', action: ->(**) { Cli::Result::SingleObject.new(api_v5.read('configuration/smtp')) }
|
|
722
731
|
command :create, description: 'Create SMTP configuration',
|
|
723
732
|
arguments: [{name: :smtp, type: Hash}],
|
|
724
|
-
action: ->(smtp:, **) { Result::SingleObject.new(api_v5.create('configuration/smtp', smtp)) }
|
|
733
|
+
action: ->(smtp:, **) { Cli::Result::SingleObject.new(api_v5.create('configuration/smtp', smtp)) }
|
|
725
734
|
command :modify, description: 'Modify SMTP configuration',
|
|
726
735
|
arguments: [{name: :smtp, type: Hash}],
|
|
727
|
-
action: ->(smtp:, **) { Result::SingleObject.new(api_v5.update('configuration/smtp', smtp)) }
|
|
736
|
+
action: ->(smtp:, **) { Cli::Result::SingleObject.new(api_v5.update('configuration/smtp', smtp)) }
|
|
728
737
|
command(
|
|
729
738
|
:delete, description: 'Delete SMTP configuration',
|
|
730
739
|
action: lambda do |**|
|
|
731
740
|
api_v5.delete('configuration/smtp')
|
|
732
|
-
Result::Status.new('SMTP configuration deleted')
|
|
741
|
+
Cli::Result::Status.new('SMTP configuration deleted')
|
|
733
742
|
end
|
|
734
743
|
)
|
|
735
744
|
command :test, description: 'Test SMTP configuration',
|
|
@@ -740,25 +749,25 @@ module Aspera
|
|
|
740
749
|
command(
|
|
741
750
|
:application, description: 'List application events',
|
|
742
751
|
action: lambda do |**|
|
|
743
|
-
list, total = api_v5.list_entities_limit_offset_total_count(entity: 'application_events', query: query_read_delete(schema: Schema::Registry.query_params(
|
|
744
|
-
Result::ObjectList.new(list, total: total, fields: %w[event_type created_at application user.name])
|
|
752
|
+
list, total = api_v5.list_entities_limit_offset_total_count(entity: 'application_events', query: query_read_delete(schema: Schema::Registry.query_params(API_SCHEMA, 'application_events')))
|
|
753
|
+
Cli::Result::ObjectList.new(list, total: total, fields: %w[event_type created_at application user.name])
|
|
745
754
|
end
|
|
746
755
|
)
|
|
747
756
|
command(
|
|
748
757
|
:webhook, description: 'List webhook events',
|
|
749
758
|
action: lambda do |**|
|
|
750
|
-
list, total = api_v5.list_entities_limit_offset_total_count(entity: 'all_webhooks_events', query: query_read_delete(schema: Schema::Registry.query_params(
|
|
751
|
-
Result::ObjectList.new(list, total: total)
|
|
759
|
+
list, total = api_v5.list_entities_limit_offset_total_count(entity: 'all_webhooks_events', query: query_read_delete(schema: Schema::Registry.query_params(API_SCHEMA, 'all_webhooks_events')), items_key: 'events')
|
|
760
|
+
Cli::Result::ObjectList.new(list, total: total)
|
|
752
761
|
end
|
|
753
762
|
)
|
|
754
763
|
end
|
|
755
764
|
|
|
756
765
|
# admin > <resource> > list
|
|
757
|
-
Api::
|
|
766
|
+
Api::ADMIN_RESOURCES.each do |res|
|
|
758
767
|
define_action_method([:admin, res, :list]) do |**|
|
|
759
768
|
args = res_exec_args(res)
|
|
760
769
|
# Special case: email_notifications list returns a fixed value list
|
|
761
|
-
next Result::ValueList.new(Api::
|
|
770
|
+
next Cli::Result::ValueList.new(Api::EMAIL_NOTIF_LIST, name: 'email_id') if res.eql?(:email_notifications)
|
|
762
771
|
data, total = args[:api].list_entities_limit_offset_total_count(
|
|
763
772
|
entity: args[:entity], items_key: args[:items_key],
|
|
764
773
|
query: query_read_delete(
|
|
@@ -766,7 +775,7 @@ module Aspera
|
|
|
766
775
|
schema: args[:query_component] ? Schema::Registry.query_params(args[:query_component], args[:entity]) : nil
|
|
767
776
|
)
|
|
768
777
|
)
|
|
769
|
-
Result::ObjectList.new(data, total: total, fields: args[:display_fields])
|
|
778
|
+
Cli::Result::ObjectList.new(data, total: total, fields: args[:display_fields])
|
|
770
779
|
end
|
|
771
780
|
end
|
|
772
781
|
|
|
@@ -779,20 +788,20 @@ module Aspera
|
|
|
779
788
|
rescue JSON::ParserError
|
|
780
789
|
# keep as string if not valid JSON
|
|
781
790
|
end
|
|
782
|
-
Result::SingleObject.new(result)
|
|
791
|
+
Cli::Result::SingleObject.new(result)
|
|
783
792
|
end
|
|
784
793
|
|
|
785
794
|
# admin > accounts > reset_password
|
|
786
795
|
def action_admin_accounts_reset_password(account_id:, **)
|
|
787
796
|
api_v5.create("accounts/#{account_id}/reset_password", {})
|
|
788
|
-
Result::Status.new('password reset, user shall check email')
|
|
797
|
+
Cli::Result::Status.new('password reset, user shall check email')
|
|
789
798
|
end
|
|
790
799
|
|
|
791
800
|
# admin > file_processing > next
|
|
792
801
|
def action_admin_file_processing_next(**)
|
|
793
802
|
args = res_exec_args(:file_processing)
|
|
794
803
|
result, count = api_v5.list_entities_limit_offset_total_count(entity: args[:entity], operation: 'POST', items_key: 'files')
|
|
795
|
-
Result::ObjectList.new(result, total: count)
|
|
804
|
+
Cli::Result::ObjectList.new(result, total: count)
|
|
796
805
|
end
|
|
797
806
|
|
|
798
807
|
# admin > nodes > browse
|
|
@@ -838,9 +847,9 @@ module Aspera
|
|
|
838
847
|
# @return [Array<String>] resolved user ids
|
|
839
848
|
def resolve_member_user_ids(users)
|
|
840
849
|
users = Array(users)
|
|
841
|
-
Aspera.assert_array_all(users, String) { 'users' }
|
|
850
|
+
Aspera.assert_array_all(users, String, type: Cli::BadArgument) { 'users' }
|
|
842
851
|
users.map do |user|
|
|
843
|
-
if (m = Parser.percent_selector(user))
|
|
852
|
+
if (m = Cli::Parser.percent_selector(user))
|
|
844
853
|
api_v5.lookup_entity_by_field(entity: 'accounts', field: m[:field], value: m[:value], query: Rest.php_style({type: ACCOUNT_TYPES}))['id']
|
|
845
854
|
else
|
|
846
855
|
user
|
|
@@ -891,17 +900,17 @@ module Aspera
|
|
|
891
900
|
res_instance_path = "#{res}/#{kwargs[:"#{RES_SINGULAR[res]}_id"]}"
|
|
892
901
|
result = api_v5.create("#{res_instance_path}/external_collaborator", collaborator)
|
|
893
902
|
formatter.display_status(result['message'])
|
|
894
|
-
Result::SingleObject.new(api_v5.lookup_entity_by_field(entity: "#{res_instance_path}/members", items_key: 'members', value: collaborator['email_address'], query: {}))
|
|
903
|
+
Cli::Result::SingleObject.new(api_v5.lookup_entity_by_field(entity: "#{res_instance_path}/members", items_key: 'members', value: collaborator['email_address'], query: {}))
|
|
895
904
|
end
|
|
896
905
|
end
|
|
897
906
|
|
|
898
907
|
# --- API ---
|
|
899
908
|
|
|
900
909
|
# Faspex 5 API, built from CLI options on first use.
|
|
901
|
-
# @return [Api
|
|
910
|
+
# @return [Api]
|
|
902
911
|
def api_v5
|
|
903
912
|
return @api_v5 if @api_v5
|
|
904
|
-
@api_v5 = Api
|
|
913
|
+
@api_v5 = Api.new(**Cli::Plugins::Oauth.kwargs_from_options(options))
|
|
905
914
|
# in case user wants to use HTTPGW tell transfer agent how to get address
|
|
906
915
|
transfer.httpgw_url_cb = lambda { @api_v5.read('account')['gateway_url'] }
|
|
907
916
|
@api_v5
|
|
@@ -921,12 +930,12 @@ module Aspera
|
|
|
921
930
|
fields = %w[id title status sender.name recipients.0.name release_date total_bytes total_files]
|
|
922
931
|
fields.delete('recipients.0.name') if %w[inbox inbox_history].include?(options.get_option(:box))
|
|
923
932
|
fields.delete('sender.name') if %w[outbox outbox_history].include?(options.get_option(:box))
|
|
924
|
-
Result::ObjectList.new(list, total: total, fields: fields)
|
|
933
|
+
Cli::Result::ObjectList.new(list, total: total, fields: fields)
|
|
925
934
|
end
|
|
926
935
|
|
|
927
936
|
def action_packages_delete(package_id:, **)
|
|
928
937
|
ids = package_id.is_a?(Array) ? package_id : [package_id]
|
|
929
|
-
Aspera.assert_array_all(ids, String) { 'Package id(s)' }
|
|
938
|
+
Aspera.assert_array_all(ids, String, type: Cli::BadArgument) { 'Package id(s)' }
|
|
930
939
|
# API returns 204, empty on success
|
|
931
940
|
api_v5.call(
|
|
932
941
|
operation: 'DELETE',
|
|
@@ -935,7 +944,7 @@ module Aspera
|
|
|
935
944
|
body: {ids: ids},
|
|
936
945
|
headers: {'Accept' => Mime::JSON}
|
|
937
946
|
)
|
|
938
|
-
Result::Status.new('Package(s) deleted')
|
|
947
|
+
Cli::Result::Status.new('Package(s) deleted')
|
|
939
948
|
end
|
|
940
949
|
|
|
941
950
|
# --- handlers ---
|
|
@@ -952,7 +961,7 @@ module Aspera
|
|
|
952
961
|
rescue StandardError => e
|
|
953
962
|
nagios.add_critical('core', e.to_s)
|
|
954
963
|
end
|
|
955
|
-
Result::ObjectList.new(nagios.status_list)
|
|
964
|
+
Cli::Result::ObjectList.new(nagios.status_list)
|
|
956
965
|
end
|
|
957
966
|
|
|
958
967
|
# Lookup a shared folder id by field/value.
|
|
@@ -960,15 +969,14 @@ module Aspera
|
|
|
960
969
|
def lookup_shared_folder_id(field, value, **)
|
|
961
970
|
all = api_v5.read('shared_folders')['shared_folders']
|
|
962
971
|
matches = all.select { |i| i[field].eql?(value) }
|
|
963
|
-
|
|
964
|
-
Aspera.assert(matches.length == 1) { "multiple matches for #{field} = #{value}" }
|
|
972
|
+
raise Cli::BadIdentifier.new('Shared folder', value, field: field, count: matches.length) unless matches.length.eql?(1)
|
|
965
973
|
matches.first['id']
|
|
966
974
|
end
|
|
967
975
|
|
|
968
976
|
def action_shared_folders_browse(folder_path:, shared_folder_id:, **)
|
|
969
977
|
all_shared_folders = api_v5.read('shared_folders')['shared_folders']
|
|
970
978
|
node = all_shared_folders.find { |i| i['id'].eql?(shared_folder_id) }
|
|
971
|
-
|
|
979
|
+
raise Cli::BadIdentifier.new('Shared folder', shared_folder_id) if node.nil?
|
|
972
980
|
browse_folder("nodes/#{node['node_id']}/shared_folders/#{shared_folder_id}/browse", {}, folder_path: folder_path)
|
|
973
981
|
end
|
|
974
982
|
|
|
@@ -982,15 +990,45 @@ module Aspera
|
|
|
982
990
|
end
|
|
983
991
|
|
|
984
992
|
def action_gateway(parameters: {}, **)
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
993
|
+
# Loaded on use: web server
|
|
994
|
+
require_relative '../faspex4/gw_servlet'
|
|
995
|
+
Faspex4::GWServlet.serve(parameters.symbolize_keys, type: Cli::BadArgument) do
|
|
996
|
+
# evaluated before the server listens: invalid options fail at startup, and no lazy memo is shared by request threads
|
|
997
|
+
api_v5
|
|
998
|
+
->(faspex_pkg_parameters) { faspex4_send_to_faspex5(faspex_pkg_parameters) }
|
|
999
|
+
end
|
|
1000
|
+
Cli::Result::Status.new('Gateway terminated')
|
|
1001
|
+
end
|
|
1002
|
+
|
|
1003
|
+
# Map Faspex 4 /send API to Faspex 5 package create
|
|
1004
|
+
# @param faspex_pkg_parameters [Hash] Faspex 4 package creation
|
|
1005
|
+
# @return [Hash] Transfer spec to upload the package files
|
|
1006
|
+
def faspex4_send_to_faspex5(faspex_pkg_parameters)
|
|
1007
|
+
faspex_pkg_delivery = faspex_pkg_parameters['delivery']
|
|
1008
|
+
package_data = {
|
|
1009
|
+
'title' => faspex_pkg_delivery['title'],
|
|
1010
|
+
'note' => faspex_pkg_delivery['note'],
|
|
1011
|
+
'recipients' => faspex_pkg_delivery['recipients'].map { |name| {'name'=>name} }
|
|
1012
|
+
}
|
|
1013
|
+
package = api_v5.create('packages', package_data)
|
|
1014
|
+
# TODO: option to send from remote source or httpgw
|
|
1015
|
+
transfer_spec = api_v5.call(
|
|
1016
|
+
operation: 'POST',
|
|
1017
|
+
subpath: "packages/#{package['id']}/transfer_spec/upload",
|
|
1018
|
+
query: {transfer_type: Api::TRANSFER_CONNECT},
|
|
1019
|
+
content_type: Mime::JSON,
|
|
1020
|
+
body: {paths: [{'destination'=>'/'}]},
|
|
1021
|
+
headers: {'Accept' => Mime::JSON}
|
|
1022
|
+
)
|
|
1023
|
+
transfer_spec.delete('authentication')
|
|
1024
|
+
transfer_spec
|
|
988
1025
|
end
|
|
1026
|
+
private :faspex4_send_to_faspex5
|
|
989
1027
|
|
|
990
1028
|
def action_postprocessing(parameters: {}, **)
|
|
991
|
-
require_relative '
|
|
1029
|
+
require_relative 'faspex4_post_proc_servlet'
|
|
992
1030
|
Faspex4PostProcServlet.serve(parameters.symbolize_keys, type: Cli::BadArgument)
|
|
993
|
-
Result::Status.new('Post-processing terminated')
|
|
1031
|
+
Cli::Result::Status.new('Post-processing terminated')
|
|
994
1032
|
end
|
|
995
1033
|
ACCOUNT_TYPES = %w{local_user saml_user self_registered_user external_user}.freeze
|
|
996
1034
|
WORKGROUP_TYPES = %w{workgroup shared_inbox}.freeze
|