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
|
@@ -4,57 +4,42 @@
|
|
|
4
4
|
# SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
|
|
6
6
|
require_relative '../../schema/registry'
|
|
7
|
-
require_relative 'oauth'
|
|
8
|
-
require_relative '
|
|
9
|
-
require_relative '
|
|
10
|
-
require_relative '../
|
|
11
|
-
require_relative '
|
|
7
|
+
require_relative '../../cli/plugins/oauth'
|
|
8
|
+
require_relative '../../cli/hints'
|
|
9
|
+
require_relative '../node/commands'
|
|
10
|
+
require_relative '../ats/commands'
|
|
11
|
+
require_relative '../../cli/special_values'
|
|
12
12
|
require_relative '../../environment'
|
|
13
|
-
require_relative '
|
|
14
|
-
require_relative '
|
|
13
|
+
require_relative '../../cli/wizard'
|
|
14
|
+
require_relative '../node/agent'
|
|
15
15
|
require_relative '../../transfer/result'
|
|
16
16
|
require_relative '../../transfer/spec'
|
|
17
|
-
require_relative '
|
|
18
|
-
require_relative '
|
|
17
|
+
require_relative 'api'
|
|
18
|
+
require_relative 'admin_resources'
|
|
19
|
+
require_relative '../node/api'
|
|
19
20
|
require_relative '../../persistency_action_once'
|
|
20
21
|
require_relative '../../id_generator'
|
|
21
22
|
require_relative '../../assert'
|
|
22
|
-
require_relative '
|
|
23
|
+
require_relative 'graphql'
|
|
23
24
|
require_relative '../../rainbow'
|
|
25
|
+
require_relative '../xfer/transfer_agent'
|
|
26
|
+
require_relative '../faspex4/gateway_options'
|
|
24
27
|
require 'securerandom'
|
|
25
28
|
require 'date'
|
|
26
29
|
using Rainbow
|
|
27
30
|
|
|
28
31
|
module Aspera
|
|
29
|
-
module
|
|
30
|
-
module
|
|
31
|
-
class
|
|
32
|
+
module Plugins
|
|
33
|
+
module Aoc
|
|
34
|
+
class Commands < Cli::Plugins::Base
|
|
35
|
+
# Keys of the schemas of the bundle (see `plugin.yaml`): AoC API, AoC Automation API, options
|
|
36
|
+
AOC_SCHEMA = 'aoc'
|
|
37
|
+
AUTOMATION_SCHEMA = 'automation'
|
|
38
|
+
PACKAGE_FOLDER_OPTIONS = 'aoc_opts:components.schemas.PackageFolderOptions'
|
|
32
39
|
# default redirect for AoC web auth
|
|
33
40
|
REDIRECT_LOCALHOST = 'http://localhost:12345'
|
|
34
|
-
# admin objects that can be manipulated
|
|
35
|
-
ADMIN_OBJECTS =
|
|
36
|
-
client
|
|
37
|
-
client_access_key
|
|
38
|
-
client_registration_token
|
|
39
|
-
configuration_policy
|
|
40
|
-
contact
|
|
41
|
-
dropbox
|
|
42
|
-
dropbox_membership
|
|
43
|
-
group
|
|
44
|
-
group_membership
|
|
45
|
-
kms_profile
|
|
46
|
-
network_policy
|
|
47
|
-
node
|
|
48
|
-
operation
|
|
49
|
-
organization
|
|
50
|
-
package
|
|
51
|
-
saml_configuration
|
|
52
|
-
self
|
|
53
|
-
short_link
|
|
54
|
-
user
|
|
55
|
-
workspace
|
|
56
|
-
workspace_membership
|
|
57
|
-
].freeze
|
|
41
|
+
# admin objects that can be manipulated (see admin_resources.rb)
|
|
42
|
+
ADMIN_OBJECTS = AdminResources::OBJECTS
|
|
58
43
|
# query to list fully received packages
|
|
59
44
|
PACKAGE_RECEIVED_BASE_QUERY = {
|
|
60
45
|
'archived' => false,
|
|
@@ -73,17 +58,17 @@ module Aspera
|
|
|
73
58
|
# no protocol ?
|
|
74
59
|
base_url = "https://#{base_url}" unless base_url.match?(%r{^[a-z]{1,6}://})
|
|
75
60
|
# only org provided ?
|
|
76
|
-
base_url = "#{base_url}.#{Api::
|
|
61
|
+
base_url = "#{base_url}.#{Api::SAAS_DOMAIN_PROD}" unless base_url.include?('.')
|
|
77
62
|
# AoC is only https
|
|
78
63
|
return unless base_url.start_with?('https://')
|
|
79
64
|
location = Rest::Client.new(base_url: base_url, redirect_max: 0).call(operation: 'GET', subpath: 'auth/ping', exception: false, ret: :resp)['Location']
|
|
80
65
|
return if location.nil?
|
|
81
66
|
redirect_uri = URI.parse(location)
|
|
82
|
-
od = Api
|
|
67
|
+
od = Api.split_org_domain(URI.parse(base_url))
|
|
83
68
|
return unless redirect_uri.path.end_with?("oauth2/#{od[:organization]}/login")
|
|
84
69
|
# either in standard domain, or product name in page
|
|
85
70
|
return {
|
|
86
|
-
version: Api
|
|
71
|
+
version: Api.saas_url?(base_url) ? 'SaaS' : 'Self-managed',
|
|
87
72
|
url: base_url
|
|
88
73
|
}
|
|
89
74
|
end
|
|
@@ -109,8 +94,8 @@ module Aspera
|
|
|
109
94
|
# @param fld [Array] List of fields of package
|
|
110
95
|
# @return [String] Folder path in destination folder
|
|
111
96
|
def unique_folder(package_info, destination_folder, fld: nil, seq: false, opt: false)
|
|
112
|
-
Aspera.assert_array_all(fld, String, type: BadArgument) { 'fld' }
|
|
113
|
-
Aspera.assert_values(fld.length, [1, 2]) { 'fld length' }
|
|
97
|
+
Aspera.assert_array_all(fld, String, type: Cli::BadArgument) { 'fld' }
|
|
98
|
+
Aspera.assert_values(fld.length, [1, 2], type: Cli::BadArgument) { 'fld length' }
|
|
114
99
|
# Existence is checked in the destination folder
|
|
115
100
|
folder = File.join(destination_folder, Environment.instance.sanitized_filename(package_info[fld[0]].to_s))
|
|
116
101
|
if seq
|
|
@@ -126,23 +111,34 @@ module Aspera
|
|
|
126
111
|
def aoc_res_path(res)
|
|
127
112
|
cfg = ADMIN_OBJECT_CONFIG.fetch(res, {})
|
|
128
113
|
return cfg[:path] if cfg[:path]
|
|
114
|
+
return res.to_s if cfg[:singleton]
|
|
129
115
|
"#{res}s".gsub(/ys$/, 'ies')
|
|
130
116
|
end
|
|
131
117
|
|
|
132
|
-
#
|
|
118
|
+
# Path of an endpoint in the OpenAPI description: AoC accepts the prefix `admin/` on all endpoints, the description has none
|
|
119
|
+
# @param path [String] REST path, e.g. `admin/client_access_keys`
|
|
120
|
+
# @return [String] path in the OpenAPI description, e.g. `client_access_keys`
|
|
121
|
+
def aoc_schema_path(path) = path.delete_prefix('admin/')
|
|
122
|
+
|
|
123
|
+
# @return [Hash] {path:, create_path:, schema_path:, ops:, id_result:, require_ws_id:, list_fields:, schema:, modify_schema:, query_component:}
|
|
133
124
|
def aoc_res_cfg(res)
|
|
134
|
-
cfg
|
|
135
|
-
path
|
|
136
|
-
|
|
137
|
-
|
|
125
|
+
cfg = ADMIN_OBJECT_CONFIG.fetch(res, {})
|
|
126
|
+
path = aoc_res_path(res)
|
|
127
|
+
create_path = cfg[:create_path] || path
|
|
128
|
+
schema_path = aoc_schema_path(path)
|
|
129
|
+
ops = cfg[:ops] || (cfg[:singleton] ? %i[show] : Cli::Plugins::Base::Operations::ALL + (cfg[:extra_ops] || []))
|
|
130
|
+
in_schema = cfg[:schema] != false
|
|
138
131
|
{
|
|
139
132
|
path: path,
|
|
133
|
+
create_path: create_path,
|
|
134
|
+
schema_path: schema_path,
|
|
140
135
|
ops: ops,
|
|
141
136
|
id_result: cfg[:id_result] || 'id',
|
|
142
137
|
require_ws_id: cfg[:require_ws_id] || false,
|
|
143
138
|
list_fields: cfg.key?(:list_fields) ? cfg[:list_fields] : %w[id name],
|
|
144
|
-
schema:
|
|
145
|
-
|
|
139
|
+
schema: (Schema::Registry.req_body(AOC_SCHEMA, "#{aoc_schema_path(create_path)}.post") if in_schema),
|
|
140
|
+
modify_schema: (Schema::Registry.req_body(AOC_SCHEMA, "#{schema_path}#{'/{id}' unless cfg[:singleton]}.put") if in_schema),
|
|
141
|
+
query_component: AOC_SCHEMA
|
|
146
142
|
}
|
|
147
143
|
end
|
|
148
144
|
|
|
@@ -153,7 +149,7 @@ module Aspera
|
|
|
153
149
|
{
|
|
154
150
|
name: :short_link, type: Hash, mandatory: false, default: {},
|
|
155
151
|
description: 'Merged into the request body, and: `password` (link password), `access_levels` (shared folder only)',
|
|
156
|
-
schema: Schema::Registry.req_body(
|
|
152
|
+
schema: Schema::Registry.req_body(AOC_SCHEMA, endpoint)
|
|
157
153
|
}
|
|
158
154
|
end
|
|
159
155
|
|
|
@@ -190,11 +186,11 @@ module Aspera
|
|
|
190
186
|
end
|
|
191
187
|
end
|
|
192
188
|
|
|
193
|
-
# @param wizard [Wizard] The wizard object
|
|
189
|
+
# @param wizard [Cli::Wizard] The wizard object
|
|
194
190
|
# @param app_url [String] Tested URL
|
|
195
191
|
# @return [Hash] :preset_value, :test_args
|
|
196
192
|
def wizard(wizard, app_url)
|
|
197
|
-
pub_link_info = Api
|
|
193
|
+
pub_link_info = Api.link_info(app_url)
|
|
198
194
|
# public link case
|
|
199
195
|
if pub_link_info.key?(:token)
|
|
200
196
|
pub_api = Rest::Client.new(base_url: "https://#{URI.parse(pub_link_info[:url]).host}/api/v1")
|
|
@@ -227,7 +223,7 @@ module Aspera
|
|
|
227
223
|
if client_id.nil? || client_secret.nil?
|
|
228
224
|
use_generic_client = options.get_option(:use_generic_client)
|
|
229
225
|
# Default depends on URL
|
|
230
|
-
use_generic_client = Api
|
|
226
|
+
use_generic_client = Api.saas_url?(app_url) if use_generic_client.nil?
|
|
231
227
|
if use_generic_client
|
|
232
228
|
client_id = client_secret = nil
|
|
233
229
|
formatter.display_status('Using global client_id.')
|
|
@@ -252,12 +248,12 @@ module Aspera
|
|
|
252
248
|
auto_set_jwt = true
|
|
253
249
|
Aspera.error_not_implemented
|
|
254
250
|
# aoc_api.oauth.grant_method = :web
|
|
255
|
-
# aoc_api.oauth.scope = Api::
|
|
251
|
+
# aoc_api.oauth.scope = Api::Scope::ADMIN
|
|
256
252
|
# aoc_api.oauth.specific_parameters[:redirect_uri] = REDIRECT_LOCALHOST
|
|
257
253
|
end
|
|
258
254
|
myself = aoc_api.read('self')
|
|
259
255
|
if auto_set_pub_key
|
|
260
|
-
Aspera.assert(myself['public_key'].empty?, 'Public key is already set in profile (use wizard key override=yes)', type: Error) unless option_override
|
|
256
|
+
Aspera.assert(myself['public_key'].empty?, 'Public key is already set in profile (use wizard key override=yes)', type: Cli::Error) unless option_override
|
|
261
257
|
formatter.display_status('Updating profile with the public key.')
|
|
262
258
|
aoc_api.update("users/#{myself['id']}", {'public_key' => pub_key_pem})
|
|
263
259
|
end
|
|
@@ -279,20 +275,22 @@ module Aspera
|
|
|
279
275
|
}
|
|
280
276
|
end
|
|
281
277
|
|
|
282
|
-
option :workspace, description: 'Name of workspace', allowed: [String, NilClass], default: Api::
|
|
278
|
+
option :workspace, description: 'Name of workspace', allowed: [String, NilClass], default: Api::DEFAULT_WORKSPACE
|
|
283
279
|
option :new_user_option, description: 'New user creation option for unknown package recipients', allowed: [Hash, NilClass]
|
|
284
|
-
option :validate_metadata, description: 'Validate shared inbox metadata', allowed: Type::BOOLEAN, default: true
|
|
285
|
-
option :package_folder, schema:
|
|
286
|
-
option :use_generic_client, description: 'Wizard: AoC: use global or org specific jwt client id (default: global for SaaS URL)', allowed: Type::BOOLEAN
|
|
280
|
+
option :validate_metadata, description: 'Validate shared inbox metadata', allowed: Cli::Option::Type::BOOLEAN, default: true
|
|
281
|
+
option :package_folder, schema: PACKAGE_FOLDER_OPTIONS
|
|
282
|
+
option :use_generic_client, description: 'Wizard: AoC: use global or org specific jwt client id (default: global for SaaS URL)', allowed: Cli::Option::Type::BOOLEAN
|
|
287
283
|
|
|
288
|
-
use_options Node
|
|
284
|
+
use_options Node::Commands
|
|
285
|
+
# After `use_options`: options of the plugin, then of `Oauth`
|
|
286
|
+
include Cli::Plugins::Oauth
|
|
289
287
|
|
|
290
288
|
def initialize(**_)
|
|
291
289
|
super
|
|
292
290
|
@cache_workspace_info = nil
|
|
293
291
|
@cache_home_node_file = nil
|
|
294
292
|
@cache_api_aoc = nil
|
|
295
|
-
@scope = Api::
|
|
293
|
+
@scope = Api::Scope::USER
|
|
296
294
|
end
|
|
297
295
|
|
|
298
296
|
# Change API scope for subsequent calls, re-instantiate API object
|
|
@@ -306,19 +304,19 @@ module Aspera
|
|
|
306
304
|
|
|
307
305
|
# Create an API object with the options from CLI, but with a different subpath
|
|
308
306
|
# @param base_path [String] Base path for APIs.
|
|
309
|
-
# @return [Api
|
|
307
|
+
# @return [Api] API object for AoC (is Rest::Client)
|
|
310
308
|
def api_from_options(base_path)
|
|
311
309
|
# Get all existing OAuth kwargs from `options`.
|
|
312
|
-
api = Api
|
|
310
|
+
api = Api.new(
|
|
313
311
|
scope: @scope,
|
|
314
312
|
subpath: base_path,
|
|
315
313
|
secret_finder: context.secret_finder,
|
|
316
|
-
**Oauth.kwargs_from_options(options)
|
|
314
|
+
**Cli::Plugins::Oauth.kwargs_from_options(options)
|
|
317
315
|
)
|
|
318
316
|
# User set a workspace ?
|
|
319
317
|
# @type [String, nil]
|
|
320
318
|
workspace = options.get_option(:workspace)
|
|
321
|
-
if !workspace.nil? && (m = Parser.percent_selector(workspace))
|
|
319
|
+
if !workspace.nil? && (m = Cli::Parser.percent_selector(workspace))
|
|
322
320
|
case m[:field]
|
|
323
321
|
when 'name' then api.ws_ids[:name] = m[:value]
|
|
324
322
|
when 'id' then api.ws_ids[:id] = m[:value]
|
|
@@ -331,10 +329,10 @@ module Aspera
|
|
|
331
329
|
end
|
|
332
330
|
|
|
333
331
|
# AoC Rest object
|
|
334
|
-
# @return [Api
|
|
332
|
+
# @return [Api] API object for AoC (is Rest::Client)
|
|
335
333
|
def aoc_api
|
|
336
334
|
if @cache_api_aoc.nil?
|
|
337
|
-
@cache_api_aoc = api_from_options(Api::
|
|
335
|
+
@cache_api_aoc = api_from_options(Api::API_V1)
|
|
338
336
|
transfer.httpgw_url_cb = lambda do
|
|
339
337
|
organization = @cache_api_aoc.read('organization')
|
|
340
338
|
# @cache_api_aoc.current_user_info['connect_disabled']
|
|
@@ -372,22 +370,45 @@ module Aspera
|
|
|
372
370
|
# @param default_query [Hash] default query unless overridden by user
|
|
373
371
|
# @param query_component [String, nil] registry component key; when set, --query=help shows filter schema
|
|
374
372
|
# @yieldparam query [Hash] The user's or default query for modification
|
|
375
|
-
|
|
373
|
+
# @param schema_path [String, nil] path in the API description, when the REST path has identifiers (e.g. `packages/{id}/download_counts`)
|
|
374
|
+
def result_list(resource_class_path, fields: nil, base_query: {}, default_query: {}, query_component: nil, schema_path: nil)
|
|
376
375
|
Aspera.assert_type(base_query, Hash)
|
|
377
376
|
Aspera.assert_type(default_query, Hash)
|
|
378
|
-
qs_path = query_component ? Schema::Registry.query_params(query_component, resource_class_path) : nil
|
|
377
|
+
qs_path = query_component ? Schema::Registry.query_params(query_component, schema_path || aoc_schema_path(resource_class_path)) : nil
|
|
379
378
|
query = query_read_delete(default: default_query, schema: qs_path)
|
|
380
379
|
# caller may add specific modifications or checks to query
|
|
381
380
|
yield(query) if block_given?
|
|
382
|
-
result = aoc_api.read_with_paging(resource_class_path, base_query
|
|
383
|
-
return Result::ObjectList.new(result[:items], fields: fields, total: result[:total])
|
|
381
|
+
result = aoc_api.read_with_paging(resource_class_path, with_base_query(base_query, query).compact)
|
|
382
|
+
return Cli::Result::ObjectList.new(result[:items], fields: fields, total: result[:total])
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
# Query of a command: the parameters that it sets (e.g. the identifier of its argument) cannot be changed by the query of the user
|
|
386
|
+
# @param base_query [Hash] Parameters set by the command
|
|
387
|
+
# @param query [Hash, nil] Query of the user (option `query`), or default query
|
|
388
|
+
# @return [Hash] Both, with `String` keys: for a parameter with several values (name ending with `[]`, e.g. `embed[]`), the values of the user are added
|
|
389
|
+
# @raise [Cli::BadArgument] If the query of the user gives another value to a parameter set by the command
|
|
390
|
+
def with_base_query(base_query, query)
|
|
391
|
+
result = base_query.transform_keys(&:to_s)
|
|
392
|
+
return result if query.nil?
|
|
393
|
+
Aspera.assert_type(query, Hash, type: Cli::BadArgument) { 'query' }
|
|
394
|
+
query.each do |key, value|
|
|
395
|
+
key = key.to_s
|
|
396
|
+
if !result.key?(key) || result[key].eql?(value)
|
|
397
|
+
result[key] = value
|
|
398
|
+
elsif key.end_with?('[]')
|
|
399
|
+
result[key] = (Array(result[key]) + Array(value)).uniq
|
|
400
|
+
else
|
|
401
|
+
raise Cli::BadArgument, "query: parameter #{key} is set by the command (#{result[key]}): remove it from option query"
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
result
|
|
384
405
|
end
|
|
385
406
|
|
|
386
407
|
# Translates `dropbox_name` to `dropbox_id` and fills current workspace_id
|
|
387
408
|
def resolve_dropbox_name_default_ws_id(query)
|
|
388
409
|
if query.key?('dropbox_name')
|
|
389
410
|
# convenience: specify name instead of id
|
|
390
|
-
Aspera.assert(!query.key?('dropbox_id'), type: BadArgument) { 'Use field dropbox_name or dropbox_id, not both' }
|
|
411
|
+
Aspera.assert(!query.key?('dropbox_id'), type: Cli::BadArgument) { 'Use field dropbox_name or dropbox_id, not both' }
|
|
391
412
|
# TODO : craft a query that looks for dropbox only in current workspace
|
|
392
413
|
query['dropbox_id'] = aoc_api.lookup_with_q('dropboxes', value: query.delete('dropbox_name'))['id']
|
|
393
414
|
end
|
|
@@ -402,8 +423,8 @@ module Aspera
|
|
|
402
423
|
# after filtering rather than before.
|
|
403
424
|
# @return [Array(Hash, Integer, nil)] [{items:,total:} paging result, max (or nil)]
|
|
404
425
|
def list_all_packages_with_query
|
|
405
|
-
query = query_read_delete(default: {}, schema: Schema::Registry.query_params(
|
|
406
|
-
Aspera.assert_type(query, Hash) { 'query' }
|
|
426
|
+
query = query_read_delete(default: {}, schema: Schema::Registry.query_params(AOC_SCHEMA, 'packages'))
|
|
427
|
+
Aspera.assert_type(query, Hash, type: Cli::BadArgument) { 'query' }
|
|
407
428
|
PACKAGE_RECEIVED_BASE_QUERY.each { |k, v| query[k] = v unless query.key?(k) }
|
|
408
429
|
resolve_dropbox_name_default_ws_id(query)
|
|
409
430
|
# Extract `max` before paging so callers can apply it after post-API filtering
|
|
@@ -414,7 +435,7 @@ module Aspera
|
|
|
414
435
|
# Arguments of the node-to-node `transfer` command (files, admin node do, shared folder node)
|
|
415
436
|
TRANSFER_ARGS = [{name: :direction, allowed: %i[push pull]}, {name: :source_folder}].freeze
|
|
416
437
|
# Mount of the Node plugin Gen4 commands (`node access_keys do <id> ...`), instance: set per mount point
|
|
417
|
-
NODE_GEN4_MOUNT =
|
|
438
|
+
NODE_GEN4_MOUNT = AdminResources::NODE_GEN4_MOUNT
|
|
418
439
|
# Package identifier argument, `%name:` selector (lookup method shared with `admin package`)
|
|
419
440
|
PACKAGE_ID_ARG = {name: :package_id, type: :identifier, lookup: :lookup_aoc_package_id}.freeze
|
|
420
441
|
# Resource of analytics events (`admin analytics transfers|files`)
|
|
@@ -425,8 +446,8 @@ module Aspera
|
|
|
425
446
|
# Node API on a Gen4 node, and its root file id.
|
|
426
447
|
# @param node_id [String] Node identifier
|
|
427
448
|
# @param file_id [String, nil] Root file id; if nil, the access key root file id is used
|
|
428
|
-
# @param scope [String, nil] node scope (Api::
|
|
429
|
-
# @return [Array(Api
|
|
449
|
+
# @param scope [String, nil] node scope (Node::Api::Scope::USER/ADMIN), or nil (requires secret)
|
|
450
|
+
# @return [Array(Node::Api, String)]
|
|
430
451
|
def nodegen4_root(node_id, file_id: nil, scope: nil)
|
|
431
452
|
node_api = aoc_api.node_api_from(
|
|
432
453
|
node_id: node_id,
|
|
@@ -442,7 +463,7 @@ module Aspera
|
|
|
442
463
|
# @return [Array(Node, Hash)]
|
|
443
464
|
def nodegen4_plugin(node_id, file_id: nil, scope: nil)
|
|
444
465
|
node_api, file_id = nodegen4_root(node_id, file_id: file_id, scope: scope)
|
|
445
|
-
[Node.new(context: context, api: node_api), {do_root_file_id: file_id}]
|
|
466
|
+
[Node::Commands.new(context: context, api: node_api), {do_root_file_id: file_id}]
|
|
446
467
|
end
|
|
447
468
|
|
|
448
469
|
# Node-to-node transfer: client side is agent, server side is transfer server, in same workspace.
|
|
@@ -453,11 +474,11 @@ module Aspera
|
|
|
453
474
|
top_node_api, file_id = nodegen4_root(node_id, file_id: file_id, scope: scope)
|
|
454
475
|
case direction
|
|
455
476
|
when :push
|
|
456
|
-
client_direction = Transfer::Spec::DIRECTION_SEND
|
|
477
|
+
client_direction = Aspera::Transfer::Spec::DIRECTION_SEND
|
|
457
478
|
client_folder = source_folder
|
|
458
479
|
server_folder = transfer.destination_folder(client_direction)
|
|
459
480
|
when :pull
|
|
460
|
-
client_direction = Transfer::Spec::DIRECTION_RECEIVE
|
|
481
|
+
client_direction = Aspera::Transfer::Spec::DIRECTION_RECEIVE
|
|
461
482
|
client_folder = transfer.destination_folder(client_direction)
|
|
462
483
|
server_folder = source_folder
|
|
463
484
|
else Aspera.error_unexpected_value(direction) { 'direction' }
|
|
@@ -465,7 +486,7 @@ module Aspera
|
|
|
465
486
|
client_apifid = top_node_api.resolve_api_fid(file_id, client_folder)
|
|
466
487
|
server_apifid = top_node_api.resolve_api_fid(file_id, server_folder)
|
|
467
488
|
# force node as transfer agent
|
|
468
|
-
transfer.agent_instance = Agent
|
|
489
|
+
transfer.agent_instance = Node::Agent.new(
|
|
469
490
|
url: client_apifid.node_api.base_url,
|
|
470
491
|
username: client_apifid.node_api.app_info.node_info['access_key'],
|
|
471
492
|
password: client_apifid.node_api.oauth.authorization,
|
|
@@ -477,83 +498,39 @@ module Aspera
|
|
|
477
498
|
'destination_root_id' => server_apifid.file_id,
|
|
478
499
|
'source_root_id' => client_apifid.file_id
|
|
479
500
|
}
|
|
480
|
-
|
|
501
|
+
Xfer::TransferAgent.result_transfer(transfer.start(server_apifid.node_api.transfer_spec_gen4(
|
|
481
502
|
server_apifid.file_id,
|
|
482
503
|
client_direction,
|
|
483
504
|
add_ts
|
|
484
505
|
)))
|
|
485
506
|
end
|
|
486
507
|
|
|
487
|
-
# Per-resource configuration for admin CRUD resources.
|
|
488
|
-
|
|
489
|
-
# Ops other than `create` and `list` read the identifier `<res>_id` (argument of the op node).
|
|
490
|
-
# op_setup: Hash of op => setup method name, for ops that need context derived from the identifier.
|
|
491
|
-
# op_mount: Hash of op => mount: of that op's node.
|
|
492
|
-
# op_descriptions: Hash of op => description, for ops other than standard ones.
|
|
493
|
-
ADMIN_OBJECT_CONFIG = {
|
|
494
|
-
client: {
|
|
495
|
-
extra_ops: %i[set_pub_key],
|
|
496
|
-
extra_op_args: {set_pub_key: [{name: :private_key_pem}]},
|
|
497
|
-
op_descriptions: {set_pub_key: 'Set public key of client from a private key'}
|
|
498
|
-
},
|
|
499
|
-
client_access_key: {path: 'admin/client_access_keys'},
|
|
500
|
-
client_registration_token: {path: 'admin/client_registration_tokens', list_fields: %w[id value data.client_subject_scopes data.name created_at], id_result: 'token'},
|
|
501
|
-
configuration_policy: {list_fields: nil},
|
|
502
|
-
contact: {list_fields: %w[source_type source_id name email]},
|
|
503
|
-
dropbox: {path: 'dropboxes', require_ws_id: true},
|
|
504
|
-
dropbox_membership: {},
|
|
505
|
-
group: {create_schema: false},
|
|
506
|
-
group_membership: {list_fields: %w[id group_id member_type member_id], create_schema: false},
|
|
507
|
-
kms_profile: {path: 'integrations/kms_profiles', create_schema: false},
|
|
508
|
-
network_policy: {list_fields: nil},
|
|
509
|
-
node: {
|
|
510
|
-
list_fields: %w[id name host access_key],
|
|
511
|
-
extra_ops: %i[do bearer_token update_status],
|
|
512
|
-
extra_op_args: {bearer_token: [{name: :scope, mandatory: false, default: nil}]},
|
|
513
|
-
op_mount: {do: NODE_GEN4_MOUNT.merge(instance: :admin_node_do_plugin)},
|
|
514
|
-
op_descriptions: {do: 'Execute command on node', bearer_token: 'Generate bearer token for node', update_status: 'Ask AoC to scan node and update its status'}
|
|
515
|
-
},
|
|
516
|
-
operation: {list_fields: %w[id type status created_at updated_at workspace_id user_id workspace_membership_id group_membership_id], ops: %i[list show modify]},
|
|
517
|
-
organization: {singleton: true},
|
|
518
|
-
package: {},
|
|
519
|
-
saml_configuration: {create_schema: false},
|
|
520
|
-
self: {singleton: true, op_descriptions: {show: 'Show current user'}},
|
|
521
|
-
short_link: {list_fields: %w[id short_url data.url_token_data.purpose password_enabled password_protected updated_by_user_id updated_at]},
|
|
522
|
-
user: {
|
|
523
|
-
list_fields: %w[id name email],
|
|
524
|
-
extra_ops: %i[preferences notifications],
|
|
525
|
-
op_descriptions: {preferences: 'Manage user preferences', notifications: 'Manage user notification preferences'}
|
|
526
|
-
},
|
|
527
|
-
workspace: {
|
|
528
|
-
extra_ops: %i[shared_folder dropbox],
|
|
529
|
-
op_setup: {shared_folder: :setup_admin_workspace_shared_folder, dropbox: :setup_admin_workspace_dropbox},
|
|
530
|
-
op_descriptions: {shared_folder: 'Manage shared folders of workspace', dropbox: 'Manage shared inboxes of workspace'}
|
|
531
|
-
},
|
|
532
|
-
workspace_membership: {list_fields: %w[id workspace_id member_type member_id]}
|
|
533
|
-
}.freeze
|
|
508
|
+
# Per-resource configuration for admin CRUD resources (see admin_resources.rb)
|
|
509
|
+
ADMIN_OBJECT_CONFIG = AdminResources::CONFIG
|
|
534
510
|
private_constant :ADMIN_OBJECT_CONFIG
|
|
535
511
|
|
|
536
|
-
# Instance delegators so instance methods can call aoc_res_path/aoc_res_cfg without self.class.
|
|
537
|
-
def aoc_res_path(res)
|
|
538
|
-
def aoc_res_cfg(res)
|
|
512
|
+
# Instance delegators so instance methods can call aoc_res_path/aoc_res_cfg/aoc_schema_path without self.class.
|
|
513
|
+
def aoc_res_path(res) = self.class.aoc_res_path(res)
|
|
514
|
+
def aoc_res_cfg(res) = self.class.aoc_res_cfg(res)
|
|
515
|
+
def aoc_schema_path(path) = self.class.aoc_schema_path(path)
|
|
539
516
|
|
|
540
517
|
# Known fixed set of AoC application types (verified against API: activity, automation, files, packages)
|
|
541
518
|
APP_TYPES = %i[activity automation files packages].freeze
|
|
542
519
|
|
|
543
|
-
ADMIN_ACTIONS = (%i[bearer_token application ats usage_reports analytics subscription auth_providers] + ADMIN_OBJECTS).freeze
|
|
520
|
+
ADMIN_ACTIONS = (%i[bearer_token application ats usage_reports analytics subscription auth_providers integrations] + ADMIN_OBJECTS).freeze
|
|
544
521
|
|
|
545
522
|
# Build analytics REST API (shared by action_admin_analytics_*)
|
|
546
523
|
def build_analytics_api
|
|
547
524
|
Rest::Client.new(**aoc_api.params.deep_merge({
|
|
548
525
|
base_url: "#{aoc_api.base_url.gsub('/api/v1', '')}/analytics/v2",
|
|
549
|
-
auth: {params: {scope: Api::
|
|
526
|
+
auth: {params: {scope: Api::Scope::ADMIN_USER}}
|
|
550
527
|
}))
|
|
551
528
|
end
|
|
552
529
|
|
|
553
530
|
# Purpose of a short link, by link type (the purpose of its URL token depends on the shared resource)
|
|
554
531
|
SHORT_LINK_PURPOSES = {public: 'token_auth_redirection', private: 'shared_folder_auth_link'}.freeze
|
|
555
532
|
# Query parameters of short link list
|
|
556
|
-
SHORT_LINK_QUERY_SCHEMA = Schema::Registry.query_params(
|
|
533
|
+
SHORT_LINK_QUERY_SCHEMA = Schema::Registry.query_params(AOC_SCHEMA, 'short_links')
|
|
557
534
|
|
|
558
535
|
# Build the list_params hash used by delete/list/show/modify short link operations.
|
|
559
536
|
# @return [Hash]
|
|
@@ -599,32 +576,33 @@ module Aspera
|
|
|
599
576
|
command(
|
|
600
577
|
:servers, description: 'List AoC servers (no auth)',
|
|
601
578
|
action: lambda do |**|
|
|
602
|
-
no_auth_api = Api
|
|
603
|
-
Result::ObjectList.new(no_auth_api.read('servers'))
|
|
579
|
+
no_auth_api = Api.new(url: options.get_option(:url), auth: :none)
|
|
580
|
+
Cli::Result::ObjectList.new(no_auth_api.read('servers'))
|
|
604
581
|
end
|
|
605
582
|
)
|
|
606
583
|
command :bearer_token, description: 'Show bearer token',
|
|
607
|
-
action: ->(**) { Result::Text.new(aoc_api.oauth.authorization) }
|
|
584
|
+
action: ->(**) { Cli::Result::Text.new(aoc_api.oauth.authorization) }
|
|
608
585
|
command :organization, description: 'Show organization info',
|
|
609
|
-
action: ->(**) { Result::SingleObject.new(aoc_api.read('organization')) }
|
|
586
|
+
action: ->(**) { Cli::Result::SingleObject.new(aoc_api.read('organization')) }
|
|
610
587
|
command :tier_restrictions, description: 'Show tier restrictions',
|
|
611
|
-
action: ->(**) { Result::SingleObject.new(aoc_api.read('tier_restrictions')) }
|
|
588
|
+
action: ->(**) { Cli::Result::SingleObject.new(aoc_api.read('tier_restrictions')) }
|
|
612
589
|
command :user, description: 'Manage current user'
|
|
613
590
|
# Node Gen4 read-only commands on packages: `packages <command> <package_id> ...`
|
|
614
591
|
command :packages, description: 'Manage packages', setup: :setup_workspace_display,
|
|
615
|
-
mount: NODE_GEN4_MOUNT.merge(instance: :package_node_plugin, only: Node::NODE4_READ_ACTIONS, arguments: [PACKAGE_ID_ARG])
|
|
592
|
+
mount: NODE_GEN4_MOUNT.merge(instance: :package_node_plugin, only: Node::Commands::NODE4_READ_ACTIONS, arguments: [PACKAGE_ID_ARG])
|
|
616
593
|
command :files, description: 'Manage files (workspace-aware)', setup: :setup_workspace_display,
|
|
617
594
|
mount: NODE_GEN4_MOUNT.merge(instance: :files_node_plugin)
|
|
618
595
|
command :admin, description: 'Administer AoC', setup: :setup_admin_scope
|
|
619
596
|
commands_under :admin do
|
|
620
597
|
command :bearer_token, description: 'Show admin bearer token',
|
|
621
|
-
action: ->(**) { Result::Text.new(aoc_api.oauth.authorization) }
|
|
598
|
+
action: ->(**) { Cli::Result::Text.new(aoc_api.oauth.authorization) }
|
|
622
599
|
command :application, description: 'Manage applications'
|
|
623
600
|
command :ats, description: 'Manage ATS (Aspera Transfer Service)',
|
|
624
|
-
mount: {plugin: Ats, instance: :build_ats_plugin}
|
|
601
|
+
mount: {plugin: Ats::Commands, instance: :build_ats_plugin}
|
|
625
602
|
command :usage_reports, description: 'List usage reports',
|
|
626
603
|
action: ->(**) { result_list('usage_reports', base_query: workspace_id_hash) }
|
|
627
604
|
command :auth_providers, description: 'Manage auth providers'
|
|
605
|
+
command :integrations, description: 'List integrations, find the user of a watermark'
|
|
628
606
|
command :subscription, description: 'Show subscription info'
|
|
629
607
|
command :analytics, description: 'Query analytics'
|
|
630
608
|
ADMIN_OBJECTS.each do |res|
|
|
@@ -634,13 +612,7 @@ module Aspera
|
|
|
634
612
|
extra_op_args = cfg[:extra_op_args] || {}
|
|
635
613
|
is_singleton = cfg[:singleton]
|
|
636
614
|
id_arg_spec = is_singleton ? [] : [{name: :"#{res}_id", type: :identifier, lookup: :"lookup_aoc_#{res}_id"}]
|
|
637
|
-
ops =
|
|
638
|
-
cfg[:ops]
|
|
639
|
-
elsif is_singleton
|
|
640
|
-
%i[show]
|
|
641
|
-
else
|
|
642
|
-
Operations::ALL + (cfg[:extra_ops] || [])
|
|
643
|
-
end
|
|
615
|
+
ops = aoc_res_cfg(res)[:ops]
|
|
644
616
|
command res, description: "Manage #{entity_noun(res, singular: false)}"
|
|
645
617
|
commands_under res do
|
|
646
618
|
ops.each do |op|
|
|
@@ -651,9 +623,9 @@ module Aspera
|
|
|
651
623
|
if !is_singleton && op.eql?(:create)
|
|
652
624
|
c = aoc_res_cfg(res)
|
|
653
625
|
[{name: res, type: Hash, bulk: true, schema: c[:schema]}]
|
|
654
|
-
elsif
|
|
626
|
+
elsif op.eql?(:modify)
|
|
655
627
|
c = aoc_res_cfg(res)
|
|
656
|
-
[{name: res, type: Hash, schema: c[:
|
|
628
|
+
[{name: res, type: Hash, schema: c[:modify_schema]}]
|
|
657
629
|
elsif extra_op_args.key?(op)
|
|
658
630
|
extra_op_args[op]
|
|
659
631
|
else
|
|
@@ -662,10 +634,10 @@ module Aspera
|
|
|
662
634
|
# For non-global ops, prepend the identifier spec
|
|
663
635
|
arg_list = (Operations::GLOBAL.include?(op) ? [] : id_arg_spec) + extra_arg_list
|
|
664
636
|
merged = arg_list.empty? ? base_attrs : base_attrs.merge(arguments: arg_list)
|
|
665
|
-
# Attach query_schema (full path) to :list
|
|
637
|
+
# Attach query_schema (full path) to :list Command so --help shows the tip
|
|
666
638
|
if op.eql?(:list)
|
|
667
639
|
c = aoc_res_cfg(res)
|
|
668
|
-
merged = merged.merge(query_schema: Schema::Registry.query_params(c[:query_component], c[:
|
|
640
|
+
merged = merged.merge(query_schema: Schema::Registry.query_params(c[:query_component], c[:schema_path]))
|
|
669
641
|
end
|
|
670
642
|
description = cfg.dig(:op_descriptions, op) ||
|
|
671
643
|
(Operations::ALL.include?(op) ? operation_description(op, entity_noun(res, singular: false)) : op.to_s.tr('_', ' ').capitalize)
|
|
@@ -677,7 +649,7 @@ module Aspera
|
|
|
677
649
|
# admin > workspace > shared_folder sub-tree
|
|
678
650
|
commands_under %i[admin workspace shared_folder] do
|
|
679
651
|
command :list, description: 'List shared folders',
|
|
680
|
-
action: ->(shared_folders:, **) { Result::ObjectList.new(shared_folders, fields: %w[id node_name node_id file_id file.path tags.aspera.files.workspace.share_as]) }
|
|
652
|
+
action: ->(shared_folders:, **) { Cli::Result::ObjectList.new(shared_folders, fields: %w[id node_name node_id file_id file.path tags.aspera.files.workspace.share_as]) }
|
|
681
653
|
command :node, description: 'Execute node command on shared folder',
|
|
682
654
|
arguments: [{name: :shared_folder_id, type: :identifier}],
|
|
683
655
|
setup: :setup_admin_workspace_shared_folder_node,
|
|
@@ -689,7 +661,7 @@ module Aspera
|
|
|
689
661
|
# admin > workspace > shared_folder > node: Gen4 commands are mounted, plus node-to-node transfer
|
|
690
662
|
commands_under %i[admin workspace shared_folder node] do
|
|
691
663
|
command :transfer, description: 'Transfer files (node-to-node)', arguments: TRANSFER_ARGS,
|
|
692
|
-
action: ->(sf_item:, direction:, source_folder:, **) { nodegen4_transfer(sf_item['node_id'], file_id: sf_item['file_id'], scope: Api::
|
|
664
|
+
action: ->(sf_item:, direction:, source_folder:, **) { nodegen4_transfer(sf_item['node_id'], file_id: sf_item['file_id'], scope: Node::Api::Scope::ADMIN, direction: direction, source_folder: source_folder) }
|
|
693
665
|
end
|
|
694
666
|
commands_under %i[admin workspace shared_folder member] do
|
|
695
667
|
command :list, description: 'List members of a shared folder'
|
|
@@ -699,28 +671,83 @@ module Aspera
|
|
|
699
671
|
command(
|
|
700
672
|
:list, description: 'List dropboxes in workspace',
|
|
701
673
|
action: lambda do |ws_res_id:, **|
|
|
702
|
-
query = query_read_delete(default: {}, schema: Schema::Registry.query_params(
|
|
703
|
-
Result::ObjectList.new(aoc_api.read('dropboxes', query.merge({'workspace_id' => ws_res_id})), fields: %w[id name description])
|
|
674
|
+
query = query_read_delete(default: {}, schema: Schema::Registry.query_params(AOC_SCHEMA, 'dropboxes'))
|
|
675
|
+
Cli::Result::ObjectList.new(aoc_api.read('dropboxes', query.merge({'workspace_id' => ws_res_id})), fields: %w[id name description])
|
|
704
676
|
end
|
|
705
677
|
)
|
|
706
678
|
end
|
|
707
679
|
# admin > node > do: Gen4 commands are mounted (op_mount), plus node-to-node transfer
|
|
708
680
|
commands_under %i[admin node do] do
|
|
709
681
|
command :transfer, description: 'Transfer files (node-to-node)', arguments: TRANSFER_ARGS,
|
|
710
|
-
action: ->(node_id:, direction:, source_folder:, **) { nodegen4_transfer(node_id, scope: Api::
|
|
682
|
+
action: ->(node_id:, direction:, source_folder:, **) { nodegen4_transfer(node_id, scope: Node::Api::Scope::ADMIN, direction: direction, source_folder: source_folder) }
|
|
711
683
|
end
|
|
684
|
+
# API path of the preferences of a user, by command
|
|
685
|
+
USER_PREF_PATHS = {preferences: 'user_interaction_preferences', notifications: 'notification_preferences'}.freeze
|
|
686
|
+
private_constant :USER_PREF_PATHS
|
|
712
687
|
# admin > user > preferences|notifications sub-trees
|
|
713
|
-
|
|
688
|
+
USER_PREF_PATHS.each do |pref, pref_path|
|
|
714
689
|
commands_under [:admin, :user, pref] do
|
|
715
690
|
command :show, description: "Show user #{pref}"
|
|
716
691
|
command :modify, description: "Modify user #{pref}",
|
|
717
|
-
arguments: [{name: pref, type: Hash}]
|
|
718
|
-
end
|
|
692
|
+
arguments: [{name: pref, type: Hash, schema: Schema::Registry.req_body(AOC_SCHEMA, "users/{id}/#{pref_path}.put")}]
|
|
693
|
+
end
|
|
694
|
+
end
|
|
695
|
+
# admin > dropbox > join_request (dropbox_id: argument of the join_request node)
|
|
696
|
+
commands_under %i[admin dropbox join_request] do
|
|
697
|
+
join_request_id = {name: :join_request_id, type: :identifier}
|
|
698
|
+
jr_path = ->(dropbox_id) { "admin/dropboxes/#{dropbox_id}/dropbox_join_requests" }
|
|
699
|
+
command :list, description: 'List the join requests', query_schema: Schema::Registry.query_params(AOC_SCHEMA, 'dropboxes/{id}/dropbox_join_requests'),
|
|
700
|
+
action: ->(dropbox_id:, **) { result_list(jr_path.call(dropbox_id), fields: %w[id name email], query_component: AOC_SCHEMA, schema_path: 'dropboxes/{id}/dropbox_join_requests') }
|
|
701
|
+
command :show, description: 'Show a join request', arguments: [join_request_id],
|
|
702
|
+
action: ->(dropbox_id:, join_request_id:, **) { Cli::Result::SingleObject.new(aoc_api.read("#{jr_path.call(dropbox_id)}/#{join_request_id}")) }
|
|
703
|
+
command :approve, description: 'Approve a join request (emails sent)', arguments: [join_request_id],
|
|
704
|
+
action: ->(dropbox_id:, join_request_id:, **) { aoc_api.create("#{jr_path.call(dropbox_id)}/#{join_request_id}/approve", {}).then { Cli::Result::Status.new('approved') } }
|
|
705
|
+
command :delete, description: 'Reject a join request (email sent)', arguments: [join_request_id],
|
|
706
|
+
action: ->(dropbox_id:, join_request_id:, **) { aoc_api.delete("#{jr_path.call(dropbox_id)}/#{join_request_id}").then { Cli::Result::Status.new('deleted') } }
|
|
707
|
+
end
|
|
708
|
+
# admin > network_policy > initiation_rule|access_control_rule (network_policy_id: argument of the rule node)
|
|
709
|
+
target_node_arg = {name: :target_node_id, type: :identifier, lookup: :lookup_aoc_node_id}
|
|
710
|
+
{
|
|
711
|
+
initiation_rule: ['initiation_policies', [target_node_arg]],
|
|
712
|
+
access_control_rule: ['access_control_policies', [target_node_arg, {name: :policy_setting, allowed: %i[allow disallow], mandatory: false}]]
|
|
713
|
+
}.each do |rule, (rule_path, create_args)|
|
|
714
|
+
commands_under [:admin, :network_policy, rule] do
|
|
715
|
+
command :list, description: 'List the rules of the policy',
|
|
716
|
+
action: ->(network_policy_id:, **) { Cli::Result::ObjectList.new(aoc_api.read("admin/network_policies/#{network_policy_id}").fetch(rule_path)) }
|
|
717
|
+
command :create, description: 'Add a node to the rules of the policy',
|
|
718
|
+
arguments: create_args,
|
|
719
|
+
action: lambda { |network_policy_id:, target_node_id:, policy_setting: nil, **|
|
|
720
|
+
rule_body = {'target_node_id' => target_node_id}
|
|
721
|
+
rule_body['policy_setting'] = (policy_setting || access_control_setting(network_policy_id)).to_s if rule.eql?(:access_control_rule)
|
|
722
|
+
Cli::Result::SingleObject.new(aoc_api.create("admin/network_policies/#{network_policy_id}/#{rule_path}", rule_body))
|
|
723
|
+
}
|
|
724
|
+
command :delete, description: 'Delete a rule of the policy', arguments: [{name: :rule_id}],
|
|
725
|
+
action: ->(network_policy_id:, rule_id:, **) { aoc_api.delete("admin/network_policies/#{network_policy_id}/#{rule_path}/#{rule_id}").then { Cli::Result::Status.new('deleted') } }
|
|
726
|
+
end
|
|
727
|
+
end
|
|
728
|
+
commands_under %i[admin integrations] do
|
|
729
|
+
command :list, description: 'List the integrations available, with their options',
|
|
730
|
+
action: ->(**) { Cli::Result::ObjectList.new(aoc_api.read('admin/integrations')) }
|
|
731
|
+
command :watermark_identity, description: 'Find the user of a watermark identity', arguments: [{name: :identity_id}],
|
|
732
|
+
action: ->(identity_id:, **) { Cli::Result::ObjectList.new(aoc_api.read('admin/integrations/watermark/identities', {'identity_id' => identity_id}).fetch('identities')) }
|
|
733
|
+
end
|
|
734
|
+
# Without `source_type`, the global templates (one page)
|
|
735
|
+
commands_under %i[admin email_template] do
|
|
736
|
+
command :effective, description: 'List the email templates used for a source', query_schema: Schema::Registry.query_params(AOC_SCHEMA, 'effective_templates'),
|
|
737
|
+
action: lambda { |**|
|
|
738
|
+
query = query_read_delete(default: {}, schema: Schema::Registry.query_params(AOC_SCHEMA, 'effective_templates'))
|
|
739
|
+
Cli::Result::ObjectList.new(aoc_api.read('admin/effective_templates', query), fields: %w[id email_type source_type source_id subject])
|
|
740
|
+
}
|
|
719
741
|
end
|
|
720
742
|
commands_under %i[admin auth_providers] do
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
743
|
+
auth_provider_id = {name: :auth_provider_id, type: :identifier}
|
|
744
|
+
command :list, description: operation_description(:list, 'auth provider'), query_schema: Schema::Registry.query_params(AOC_SCHEMA, 'auth_providers'),
|
|
745
|
+
action: ->(**) { result_list('admin/auth_providers', query_component: AOC_SCHEMA) }
|
|
746
|
+
command :show, description: operation_description(:show, 'auth provider'), arguments: [auth_provider_id],
|
|
747
|
+
action: ->(auth_provider_id:, **) { Cli::Result::SingleObject.new(aoc_api.read("admin/auth_providers/#{auth_provider_id}")) }
|
|
748
|
+
command :modify, description: operation_description(:modify, 'auth provider'),
|
|
749
|
+
arguments: [auth_provider_id, {name: :auth_provider, type: Hash, schema: Schema::Registry.req_body(AOC_SCHEMA, 'auth_providers/{id}.put')}],
|
|
750
|
+
action: ->(auth_provider_id:, auth_provider:, **) { aoc_api.update("admin/auth_providers/#{auth_provider_id}", auth_provider).then { Cli::Result::Status.new('modified') } }
|
|
724
751
|
end
|
|
725
752
|
commands_under %i[admin subscription] do
|
|
726
753
|
command(
|
|
@@ -728,7 +755,7 @@ module Aspera
|
|
|
728
755
|
action: lambda do |**|
|
|
729
756
|
org = aoc_api.read('organization')
|
|
730
757
|
result = GraphQL.execute(api_from_options('bss/platform/graphql'), 'bss_subscription_account', {organization_id: org['id']})
|
|
731
|
-
Result::SingleObject.new(result['aoc']['bssSubscription'])
|
|
758
|
+
Cli::Result::SingleObject.new(result['aoc']['bssSubscription'])
|
|
732
759
|
end
|
|
733
760
|
)
|
|
734
761
|
command :usage, description: 'Show subscription usage',
|
|
@@ -743,7 +770,7 @@ module Aspera
|
|
|
743
770
|
:application_events, description: 'List application events',
|
|
744
771
|
action: lambda do |**|
|
|
745
772
|
events = build_analytics_api.read("organizations/#{aoc_api.current_user_info['organization_id']}/application_events")['application_events']
|
|
746
|
-
Result::ObjectList.new(events)
|
|
773
|
+
Cli::Result::ObjectList.new(events)
|
|
747
774
|
end
|
|
748
775
|
)
|
|
749
776
|
command :transfers, read_only: true, description: 'List transfer events',
|
|
@@ -761,7 +788,7 @@ module Aspera
|
|
|
761
788
|
# application sub-commands
|
|
762
789
|
commands_under %i[admin application] do
|
|
763
790
|
command :types, description: 'List application types',
|
|
764
|
-
action: ->(**) { Result::ObjectList.new(aoc_api.read('admin/apps')) }
|
|
791
|
+
action: ->(**) { Cli::Result::ObjectList.new(aoc_api.read('admin/apps')) }
|
|
765
792
|
command :settings, description: 'Manage per-app-type settings'
|
|
766
793
|
command :instance, description: 'Manage app instances'
|
|
767
794
|
command :membership, description: 'Manage app memberships'
|
|
@@ -774,13 +801,13 @@ module Aspera
|
|
|
774
801
|
command app_type, description: "Manage settings of #{app_type} app"
|
|
775
802
|
commands_under app_type do
|
|
776
803
|
command :show, description: "Show #{app_type} settings",
|
|
777
|
-
action: ->(**) { Result::SingleObject.new(aoc_api.read("/apps/#{app_type}/settings")) }
|
|
804
|
+
action: ->(**) { Cli::Result::SingleObject.new(aoc_api.read("/apps/#{app_type}/settings")) }
|
|
778
805
|
command(
|
|
779
806
|
:modify, description: "Modify #{app_type} settings",
|
|
780
807
|
arguments: [{name: :settings, type: Hash}],
|
|
781
808
|
action: lambda do |settings:, **|
|
|
782
809
|
aoc_api.update("/apps/#{app_type}/settings", settings)
|
|
783
|
-
Result::Status.new('modified')
|
|
810
|
+
Cli::Result::Status.new('modified')
|
|
784
811
|
end
|
|
785
812
|
)
|
|
786
813
|
end
|
|
@@ -801,49 +828,49 @@ module Aspera
|
|
|
801
828
|
commands_under %i[admin application membership] do
|
|
802
829
|
command :list, description: 'List app memberships', action: ->(**) { result_list('apps/app_memberships') }
|
|
803
830
|
command :show, description: 'Show an app membership', arguments: [{name: :membership_id, type: :identifier}],
|
|
804
|
-
action: ->(membership_id:, **) { Result::SingleObject.new(aoc_api.read("apps/app_memberships/#{membership_id}", query_read_delete)) }
|
|
831
|
+
action: ->(membership_id:, **) { Cli::Result::SingleObject.new(aoc_api.read("apps/app_memberships/#{membership_id}", query_read_delete)) }
|
|
805
832
|
command(
|
|
806
833
|
:delete, description: 'Delete an app membership', arguments: [{name: :membership_id, type: :identifier}],
|
|
807
834
|
action: lambda do |membership_id:, **|
|
|
808
835
|
aoc_api.delete("apps/app_memberships/#{membership_id}")
|
|
809
|
-
Result::Status.new('deleted')
|
|
836
|
+
Cli::Result::Status.new('deleted')
|
|
810
837
|
end
|
|
811
838
|
)
|
|
812
839
|
command :create, description: 'Create an app membership', arguments: [{name: :membership, type: Hash}]
|
|
813
840
|
end
|
|
814
841
|
command :automation, description: 'Manage automation'
|
|
815
|
-
command :gateway, description: 'Start AoC Faspex4 gateway',
|
|
816
|
-
arguments: [{name: :parameters, type: Hash, mandatory: false, default: {}, schema:
|
|
842
|
+
command :gateway, description: 'Start AoC Faspex4 gateway', security: :low,
|
|
843
|
+
arguments: [{name: :parameters, type: Hash, mandatory: false, default: {}, schema: Faspex4::GatewayOptions::SCHEMA}]
|
|
817
844
|
|
|
818
845
|
# user sub-commands
|
|
819
846
|
commands_under :user do
|
|
820
847
|
commands_under :workspaces, description: "Manage user's workspaces" do
|
|
821
848
|
command :list, description: 'List workspaces', action: ->(**) { result_list('workspaces', fields: %w[id name]) }
|
|
822
|
-
command :current, description: 'Show current workspace', action: ->(**) { Result::SingleObject.new(aoc_api.workspace_info) }
|
|
849
|
+
command :current, description: 'Show current workspace', action: ->(**) { Cli::Result::SingleObject.new(aoc_api.workspace_info) }
|
|
823
850
|
end
|
|
824
851
|
commands_under :profile, description: "Manage user's profile" do
|
|
825
|
-
command :show, description: 'Show user profile', action: ->(**) { Result::SingleObject.new(aoc_api.current_user_info(exception: true)) }
|
|
852
|
+
command :show, description: 'Show user profile', action: ->(**) { Cli::Result::SingleObject.new(aoc_api.current_user_info(exception: true)) }
|
|
826
853
|
command(
|
|
827
854
|
:modify, description: 'Modify user profile',
|
|
828
855
|
arguments: [{name: :profile, type: Hash}],
|
|
829
856
|
action: lambda do |profile:, **|
|
|
830
857
|
aoc_api.update("users/#{aoc_api.current_user_info(exception: true)['id']}", profile)
|
|
831
|
-
Result::Status.new('modified')
|
|
858
|
+
Cli::Result::Status.new('modified')
|
|
832
859
|
end
|
|
833
860
|
)
|
|
834
861
|
end
|
|
835
862
|
command :preferences, description: 'Manage interaction preferences'
|
|
836
863
|
command :notifications, description: 'Manage notification preferences'
|
|
837
864
|
command :contacts, description: 'Manage contacts'
|
|
838
|
-
|
|
865
|
+
command :file_upload_notifications, description: 'Manage file upload notifications'
|
|
866
|
+
commands_under %i[file_upload_notifications] do
|
|
867
|
+
crud_commands api: :aoc_api, entity: 'file_upload_notifications', name: 'file upload notification', operations: %i[create list modify delete],
|
|
868
|
+
body_component: AOC_SCHEMA, query_component: AOC_SCHEMA
|
|
869
|
+
end
|
|
870
|
+
# user > contacts sub-commands (same as admin > contact)
|
|
839
871
|
commands_under %i[contacts] do
|
|
840
|
-
contact_id = {name: :contact_id, type: :identifier, lookup: :lookup_aoc_contact_id}
|
|
841
|
-
contact_schema = aoc_res_cfg(:contact)[:schema]
|
|
842
872
|
command :list, description: operation_description(:list, 'contact')
|
|
843
|
-
command :
|
|
844
|
-
command :create, description: operation_description(:create, 'contact'), arguments: [{name: :contact, type: Hash, bulk: true, schema: contact_schema}]
|
|
845
|
-
command :modify, description: operation_description(:modify, 'contact'), arguments: [contact_id, {name: :contact, type: Hash, schema: contact_schema}]
|
|
846
|
-
command :delete, description: operation_description(:delete, 'contact'), arguments: [contact_id]
|
|
873
|
+
command :create, description: operation_description(:create, 'contact'), arguments: [{name: :contact, type: Hash, bulk: true, schema: aoc_res_cfg(:contact)[:schema]}]
|
|
847
874
|
end
|
|
848
875
|
command :settings, description: 'Manage client settings'
|
|
849
876
|
commands_under %i[settings] do
|
|
@@ -851,42 +878,19 @@ module Aspera
|
|
|
851
878
|
end
|
|
852
879
|
end
|
|
853
880
|
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
Result::SingleObject.new(aoc_api.read("users/#{
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
aoc_api.update("users/#{user_id}/user_interaction_preferences", preferences)
|
|
868
|
-
Result::Status.new('modified')
|
|
869
|
-
end
|
|
870
|
-
)
|
|
871
|
-
end
|
|
872
|
-
|
|
873
|
-
commands_under %i[user notifications] do
|
|
874
|
-
command(
|
|
875
|
-
:show, description: 'Show notification preferences',
|
|
876
|
-
action: lambda do |**|
|
|
877
|
-
user_id = aoc_api.current_user_info(exception: true)['id']
|
|
878
|
-
Result::SingleObject.new(aoc_api.read("users/#{user_id}/notification_preferences"))
|
|
879
|
-
end
|
|
880
|
-
)
|
|
881
|
-
command(
|
|
882
|
-
:modify, description: 'Modify notification preferences',
|
|
883
|
-
arguments: [{name: :notifications, type: Hash}],
|
|
884
|
-
action: lambda do |notifications:, **|
|
|
885
|
-
user_id = aoc_api.current_user_info(exception: true)['id']
|
|
886
|
-
aoc_api.update("users/#{user_id}/notification_preferences", notifications)
|
|
887
|
-
Result::Status.new('modified')
|
|
888
|
-
end
|
|
889
|
-
)
|
|
881
|
+
# user > preferences|notifications > show|modify (preferences of the current user)
|
|
882
|
+
{preferences: 'user preferences', notifications: 'notification preferences'}.each do |pref, label|
|
|
883
|
+
pref_path = USER_PREF_PATHS[pref]
|
|
884
|
+
commands_under [:user, pref] do
|
|
885
|
+
command :show, description: "Show #{label}",
|
|
886
|
+
action: ->(**) { Cli::Result::SingleObject.new(aoc_api.read("users/#{aoc_api.current_user_info(exception: true)['id']}/#{pref_path}")) }
|
|
887
|
+
command :modify, description: "Modify #{label}",
|
|
888
|
+
arguments: [{name: pref, type: Hash, schema: Schema::Registry.req_body(AOC_SCHEMA, "users/{id}/#{pref_path}.put")}],
|
|
889
|
+
action: lambda { |**kwargs|
|
|
890
|
+
aoc_api.update("users/#{aoc_api.current_user_info(exception: true)['id']}/#{pref_path}", kwargs.fetch(pref))
|
|
891
|
+
Cli::Result::Status.new('modified')
|
|
892
|
+
}
|
|
893
|
+
end
|
|
890
894
|
end
|
|
891
895
|
|
|
892
896
|
# packages sub-commands — instance commands consume package_id
|
|
@@ -894,13 +898,15 @@ module Aspera
|
|
|
894
898
|
commands_under :packages do
|
|
895
899
|
command :shared_inboxes, description: 'Manage shared inboxes'
|
|
896
900
|
command :send, description: 'Send a package', transfer_paths: :send,
|
|
897
|
-
arguments: [{name: :package, type: Hash, schema: Schema::Registry.req_body(
|
|
901
|
+
arguments: [{name: :package, type: Hash, schema: Schema::Registry.req_body(AOC_SCHEMA, 'packages.post')}]
|
|
898
902
|
command :receive, description: 'Receive packages', aliases: [:recv], transfer_paths: :receive,
|
|
899
903
|
arguments: [PACKAGE_ID_ARG]
|
|
900
904
|
command :list, description: 'List packages'
|
|
901
905
|
command :show, description: 'Show a package',
|
|
902
906
|
arguments: [PACKAGE_ID_ARG],
|
|
903
|
-
action: ->(package_id:, **) { Result::SingleObject.new(aoc_api.read("packages/#{package_id}")) }
|
|
907
|
+
action: ->(package_id:, **) { Cli::Result::SingleObject.new(aoc_api.read("packages/#{package_id}")) }
|
|
908
|
+
command :download_counts, description: 'List the downloads of a package by user', arguments: [PACKAGE_ID_ARG],
|
|
909
|
+
action: ->(**ctx) { action_admin_package_download_counts(**ctx) }
|
|
904
910
|
command :delete, description: 'Delete packages',
|
|
905
911
|
arguments: [PACKAGE_ID_ARG.merge(bulk: true)]
|
|
906
912
|
command(
|
|
@@ -908,7 +914,7 @@ module Aspera
|
|
|
908
914
|
arguments: [PACKAGE_ID_ARG, {name: :package, type: Hash}],
|
|
909
915
|
action: lambda do |package:, package_id:, **|
|
|
910
916
|
aoc_api.update("packages/#{package_id}", package)
|
|
911
|
-
Result::Status.new('modified')
|
|
917
|
+
Cli::Result::Status.new('modified')
|
|
912
918
|
end
|
|
913
919
|
)
|
|
914
920
|
end
|
|
@@ -917,7 +923,7 @@ module Aspera
|
|
|
917
923
|
command :list, description: 'List shared inboxes'
|
|
918
924
|
command :show, description: 'Show a shared inbox',
|
|
919
925
|
arguments: [{name: :dropbox_id, type: :identifier, lookup: :lookup_aoc_dropbox_id}],
|
|
920
|
-
action: ->(dropbox_id:, **) { Result::SingleObject.new(aoc_api.read("dropboxes/#{dropbox_id}")) }
|
|
926
|
+
action: ->(dropbox_id:, **) { Cli::Result::SingleObject.new(aoc_api.read("dropboxes/#{dropbox_id}")) }
|
|
921
927
|
command :short_link, description: 'Manage shared inbox short links',
|
|
922
928
|
arguments: [{name: :link_type, allowed: %i[public]}, {name: :dropbox_id, type: :identifier, lookup: :lookup_aoc_dropbox_id}],
|
|
923
929
|
setup: :setup_packages_short_link
|
|
@@ -931,12 +937,12 @@ module Aspera
|
|
|
931
937
|
setup: :setup_files_short_link
|
|
932
938
|
short_link_commands :short_link
|
|
933
939
|
command :transfer, description: 'Transfer files (node-to-node)', arguments: TRANSFER_ARGS,
|
|
934
|
-
action: ->(direction:, source_folder:, **) { nodegen4_transfer(aoc_api.home[:node_id], file_id: aoc_api.home[:file_id], scope: Api::
|
|
940
|
+
action: ->(direction:, source_folder:, **) { nodegen4_transfer(aoc_api.home[:node_id], file_id: aoc_api.home[:file_id], scope: Node::Api::Scope::USER, direction: direction, source_folder: source_folder) }
|
|
935
941
|
end
|
|
936
942
|
|
|
937
943
|
# automation sub-commands
|
|
938
944
|
# Automation API: a workflow has ordered steps (step_order), a step has ordered actions (action_order)
|
|
939
|
-
AUTOMATION_CRUD = {api: :@automation_api, body_component:
|
|
945
|
+
AUTOMATION_CRUD = {api: :@automation_api, body_component: AUTOMATION_SCHEMA}.freeze
|
|
940
946
|
private_constant :AUTOMATION_CRUD
|
|
941
947
|
AOC_AUTOMATION_GUIDE_URLS = [
|
|
942
948
|
'https://raw.githubusercontent.com/laurent-martin/aspera-orchestrator-plugins-doc/main/docs/aoc/aoc-automation-development-guide.md'
|
|
@@ -953,39 +959,39 @@ module Aspera
|
|
|
953
959
|
arguments: [{name: :level, type: Integer, mandatory: false, default: 3}],
|
|
954
960
|
action: ->(level: 3, **) { automation_guide_toc(level) }
|
|
955
961
|
command :full, description: 'Display the whole AoC Automation Development Guide',
|
|
956
|
-
action: ->(**) { Result::Text.new(automation_guide_document) }
|
|
962
|
+
action: ->(**) { Cli::Result::Text.new(automation_guide_document) }
|
|
957
963
|
command :section, description: 'Display one section of the guide (anchor given by `toc`)',
|
|
958
964
|
arguments: [{name: :anchor, type: String}],
|
|
959
965
|
action: ->(anchor:, **) { automation_guide_section(anchor) }
|
|
960
966
|
end
|
|
961
967
|
commands_under :workflows do
|
|
962
|
-
crud_commands(**AUTOMATION_CRUD, entity: 'workflows', items_key: 'workflows', query_component:
|
|
968
|
+
crud_commands(**AUTOMATION_CRUD, entity: 'workflows', items_key: 'workflows', query_component: AUTOMATION_SCHEMA)
|
|
963
969
|
command :details, description: 'Get full workflow structure with all steps and actions',
|
|
964
970
|
arguments: [{name: :workflow_id, type: :identifier}],
|
|
965
|
-
action: ->(workflow_id:, **) { Result::SingleObject.new(workflow_details(workflow_id)) }
|
|
971
|
+
action: ->(workflow_id:, **) { Cli::Result::SingleObject.new(workflow_details(workflow_id)) }
|
|
966
972
|
command :export, description: 'Export workflow definition to a portable structure',
|
|
967
973
|
arguments: [{name: :workflow_id, type: :identifier}],
|
|
968
|
-
action: ->(workflow_id:, **) { Result::SingleObject.new(workflow_export_data(workflow_id)) }
|
|
974
|
+
action: ->(workflow_id:, **) { Cli::Result::SingleObject.new(workflow_export_data(workflow_id)) }
|
|
969
975
|
command :import, description: 'Import workflow definition and create steps and actions',
|
|
970
976
|
arguments: [{name: :workflow, type: Hash, description: 'Workflow structure with steps and actions'}],
|
|
971
|
-
action: ->(workflow:, **) { Result::SingleObject.new(workflow_import_data(workflow)) }
|
|
977
|
+
action: ->(workflow:, **) { Cli::Result::SingleObject.new(workflow_import_data(workflow)) }
|
|
972
978
|
command :duplicate, description: 'Duplicate workflow and all its steps and actions',
|
|
973
979
|
arguments: [{name: :workflow_id, type: :identifier},
|
|
974
980
|
{name: :name, type: String, mandatory: false, default: nil, description: 'New workflow name'}],
|
|
975
|
-
action: ->(workflow_id:, name:, **) { Result::SingleObject.new(workflow_duplicate(workflow_id, new_name: name)) }
|
|
981
|
+
action: ->(workflow_id:, name:, **) { Cli::Result::SingleObject.new(workflow_duplicate(workflow_id, new_name: name)) }
|
|
976
982
|
command :launch, description: 'Launch a workflow',
|
|
977
983
|
arguments: [{name: :workflow_id, type: :identifier}],
|
|
978
|
-
action: ->(workflow_id:, **) { Result::SingleObject.new(@automation_api.create("workflows/#{workflow_id}/launch", {})) }
|
|
984
|
+
action: ->(workflow_id:, **) { Cli::Result::SingleObject.new(@automation_api.create("workflows/#{workflow_id}/launch", {})) }
|
|
979
985
|
command :update_state, description: 'Update state of workflow',
|
|
980
986
|
arguments: [{name: :workflow_id, type: :identifier},
|
|
981
|
-
{name: :state, type: Hash, schema: Schema::Registry.req_body(
|
|
982
|
-
action: ->(workflow_id:, state:, **) { Result::SingleObject.new(@automation_api.update("workflows/#{workflow_id}/update_state", state)) }
|
|
987
|
+
{name: :state, type: Hash, schema: Schema::Registry.req_body(AUTOMATION_SCHEMA, 'workflows/{id}/update_state.put')}],
|
|
988
|
+
action: ->(workflow_id:, state:, **) { Cli::Result::SingleObject.new(@automation_api.update("workflows/#{workflow_id}/update_state", state)) }
|
|
983
989
|
command(
|
|
984
990
|
:cancel_instances, description: 'Cancel all jobs of workflow',
|
|
985
991
|
arguments: [{name: :workflow_id, type: :identifier}],
|
|
986
992
|
action: lambda do |workflow_id:, **|
|
|
987
993
|
@automation_api.update("workflows/#{workflow_id}/cancel_instances", {})
|
|
988
|
-
Result::Status.new('canceled')
|
|
994
|
+
Cli::Result::Status.new('canceled')
|
|
989
995
|
end
|
|
990
996
|
)
|
|
991
997
|
command(
|
|
@@ -993,7 +999,7 @@ module Aspera
|
|
|
993
999
|
arguments: [{name: :workflow_id, type: :identifier}],
|
|
994
1000
|
action: lambda do |workflow_id:, **|
|
|
995
1001
|
@automation_api.delete("workflows/#{workflow_id}/delete_instances")
|
|
996
|
-
Result::Status.new('deleted')
|
|
1002
|
+
Cli::Result::Status.new('deleted')
|
|
997
1003
|
end
|
|
998
1004
|
)
|
|
999
1005
|
command :action, description: 'Manage actions of workflow',
|
|
@@ -1005,22 +1011,22 @@ module Aspera
|
|
|
1005
1011
|
commands_under %i[workflows action] do
|
|
1006
1012
|
command :list, description: 'List actions of all steps of workflow'
|
|
1007
1013
|
command :create, description: 'Add a step with one action at the end of workflow',
|
|
1008
|
-
arguments: [{name: :action, type: Hash, mandatory: false, default: {}, schema: Schema::Registry.req_body(
|
|
1014
|
+
arguments: [{name: :action, type: Hash, mandatory: false, default: {}, schema: Schema::Registry.req_body(AUTOMATION_SCHEMA, 'actions.post')}]
|
|
1009
1015
|
end
|
|
1010
1016
|
commands_under %i[workflows permissions] do
|
|
1011
1017
|
# API requires query parameter workflow_id
|
|
1012
1018
|
command(
|
|
1013
1019
|
:list, description: 'List permissions of workflow',
|
|
1014
|
-
query_schema: Schema::Registry.query_params(
|
|
1020
|
+
query_schema: Schema::Registry.query_params(AUTOMATION_SCHEMA, 'workflow_permissions'),
|
|
1015
1021
|
action: lambda do |workflow_id:, **|
|
|
1016
|
-
schema = Schema::Registry.query_params(
|
|
1022
|
+
schema = Schema::Registry.query_params(AUTOMATION_SCHEMA, 'workflow_permissions')
|
|
1017
1023
|
query = (query_read_delete(schema: schema) || {}).merge('workflow_id' => workflow_id)
|
|
1018
|
-
Result::ObjectList.new(@automation_api.read('workflow_permissions', query))
|
|
1024
|
+
Cli::Result::ObjectList.new(@automation_api.read('workflow_permissions', query))
|
|
1019
1025
|
end
|
|
1020
1026
|
)
|
|
1021
1027
|
command(
|
|
1022
1028
|
:create, description: 'Create a permission on workflow',
|
|
1023
|
-
arguments: [{name: :workflow_permission, type: Hash, bulk: true, schema: Schema::Registry.req_body(
|
|
1029
|
+
arguments: [{name: :workflow_permission, type: Hash, bulk: true, schema: Schema::Registry.req_body(AUTOMATION_SCHEMA, 'workflow_permissions.post')}],
|
|
1024
1030
|
action: lambda do |workflow_id:, workflow_permission:, **|
|
|
1025
1031
|
bulk_result(workflow_permission, command: :create) do |params|
|
|
1026
1032
|
@automation_api.create('workflow_permissions', params.merge('workflow_id' => workflow_id))
|
|
@@ -1032,14 +1038,14 @@ module Aspera
|
|
|
1032
1038
|
commands_under :instances do
|
|
1033
1039
|
crud_commands(
|
|
1034
1040
|
**AUTOMATION_CRUD, entity: 'workflow_instances', name: 'workflow instance', operations: %i[list delete],
|
|
1035
|
-
items_key: 'workflow_instances', query_component:
|
|
1041
|
+
items_key: 'workflow_instances', query_component: AUTOMATION_SCHEMA
|
|
1036
1042
|
)
|
|
1037
1043
|
command :show, description: 'Show a workflow instance (job), by identifier or by UUID',
|
|
1038
1044
|
arguments: [{name: :workflow_instance_id, type: :identifier}],
|
|
1039
|
-
action: ->(workflow_instance_id:, **) { Result::SingleObject.new(workflow_instance_find(workflow_instance_id)) }
|
|
1045
|
+
action: ->(workflow_instance_id:, **) { Cli::Result::SingleObject.new(workflow_instance_find(workflow_instance_id)) }
|
|
1040
1046
|
command :cancel, description: 'Cancel workflow instance',
|
|
1041
1047
|
arguments: [{name: :workflow_instance_id, type: :identifier}],
|
|
1042
|
-
action: ->(workflow_instance_id:, **) { Result::SingleObject.new(@automation_api.update("workflow_instances/#{workflow_instance_id}", {'status' => 'canceled'})) }
|
|
1048
|
+
action: ->(workflow_instance_id:, **) { Cli::Result::SingleObject.new(@automation_api.update("workflow_instances/#{workflow_instance_id}", {'status' => 'canceled'})) }
|
|
1043
1049
|
end
|
|
1044
1050
|
commands_under :steps do
|
|
1045
1051
|
crud_commands(**AUTOMATION_CRUD, entity: 'steps', operations: %i[create show modify delete])
|
|
@@ -1064,7 +1070,7 @@ module Aspera
|
|
|
1064
1070
|
|
|
1065
1071
|
# Build automation API and store in @automation_api ivar.
|
|
1066
1072
|
def setup_automation_api(**)
|
|
1067
|
-
change_api_scope(Api::
|
|
1073
|
+
change_api_scope(Api::Scope::ADMIN_USER)
|
|
1068
1074
|
@automation_api = Rest::Client.new(**aoc_api.params, base_url: aoc_api.base_url.gsub('/api/', '/automation/'))
|
|
1069
1075
|
{}
|
|
1070
1076
|
end
|
|
@@ -1073,9 +1079,9 @@ module Aspera
|
|
|
1073
1079
|
|
|
1074
1080
|
def action_reminder(**)
|
|
1075
1081
|
user_email = options.get_option(:username, mandatory: true)
|
|
1076
|
-
no_auth_api = Api
|
|
1082
|
+
no_auth_api = Api.new(url: options.get_option(:url), auth: :none)
|
|
1077
1083
|
no_auth_api.create('organization_reminders', {email: user_email})
|
|
1078
|
-
return Result::Status.new("List of organizations user is member of, has been sent by e-mail to #{user_email}")
|
|
1084
|
+
return Cli::Result::Status.new("List of organizations user is member of, has been sent by e-mail to #{user_email}")
|
|
1079
1085
|
end
|
|
1080
1086
|
|
|
1081
1087
|
# packages > send
|
|
@@ -1094,7 +1100,7 @@ module Aspera
|
|
|
1094
1100
|
end
|
|
1095
1101
|
package_data['encryption_at_rest'] = true if transfer.user_transfer_spec['content_protection'].eql?('encrypt')
|
|
1096
1102
|
created_package = aoc_api.create_package_simple(package_data, option_validate, new_user_option)
|
|
1097
|
-
return
|
|
1103
|
+
return Xfer::TransferAgent.result_object_transfer(created_package[:info], transfer.start(created_package[:spec], oauth_api: created_package[:node]))
|
|
1098
1104
|
end
|
|
1099
1105
|
|
|
1100
1106
|
# packages > receive — package_id: from arguments:(:identifier) (or overridden by public_link)
|
|
@@ -1107,13 +1113,13 @@ module Aspera
|
|
|
1107
1113
|
end
|
|
1108
1114
|
skip_ids_persistency = package_persistency
|
|
1109
1115
|
case ids_to_download
|
|
1110
|
-
when SpecialValues::INIT
|
|
1116
|
+
when Cli::SpecialValues::INIT
|
|
1111
1117
|
all_packages, = list_all_packages_with_query
|
|
1112
|
-
Aspera.assert(skip_ids_persistency, 'INIT requires option once_only')
|
|
1118
|
+
Aspera.assert(skip_ids_persistency, 'INIT requires option once_only', type: Cli::BadArgument)
|
|
1113
1119
|
skip_ids_persistency.data.clear.concat(all_packages[:items].map { |e| e['id'] })
|
|
1114
1120
|
skip_ids_persistency.save
|
|
1115
|
-
return Result::Status.new("Initialized skip for #{skip_ids_persistency.data.count} package(s)")
|
|
1116
|
-
when SpecialValues::ALL
|
|
1121
|
+
return Cli::Result::Status.new("Initialized skip for #{skip_ids_persistency.data.count} package(s)")
|
|
1122
|
+
when Cli::SpecialValues::ALL
|
|
1117
1123
|
all_packages, max_items = list_all_packages_with_query
|
|
1118
1124
|
reject_packages_from_persistency(all_packages[:items], skip_ids_persistency)
|
|
1119
1125
|
all_packages[:items] = all_packages[:items][0, max_items] if max_items
|
|
@@ -1121,12 +1127,12 @@ module Aspera
|
|
|
1121
1127
|
formatter.display_status("Found #{ids_to_download.length} package(s).")
|
|
1122
1128
|
else
|
|
1123
1129
|
ids_to_download = Array(ids_to_download)
|
|
1124
|
-
Aspera.assert_array_all(ids_to_download, String) { 'Package id(s)' }
|
|
1130
|
+
Aspera.assert_array_all(ids_to_download, String, type: Cli::BadArgument) { 'Package id(s)' }
|
|
1125
1131
|
end
|
|
1126
1132
|
ts_paths = transfer.ts_source_paths(default: ['.'])
|
|
1127
1133
|
per_package_def = options.get_option(:package_folder).symbolize_keys
|
|
1128
1134
|
save_metadata = per_package_def.delete(:inf)
|
|
1129
|
-
destination_folder = transfer.destination_folder(Transfer::Spec::DIRECTION_RECEIVE)
|
|
1135
|
+
destination_folder = transfer.destination_folder(Aspera::Transfer::Spec::DIRECTION_RECEIVE)
|
|
1130
1136
|
result_transfer = []
|
|
1131
1137
|
ids_to_download.each do |package_id|
|
|
1132
1138
|
package_info = aoc_api.read("packages/#{package_id}")
|
|
@@ -1137,21 +1143,21 @@ module Aspera
|
|
|
1137
1143
|
)
|
|
1138
1144
|
transfer_spec = package_node_api.transfer_spec_gen4(
|
|
1139
1145
|
package_info['contents_file_id'],
|
|
1140
|
-
Transfer::Spec::DIRECTION_RECEIVE,
|
|
1146
|
+
Aspera::Transfer::Spec::DIRECTION_RECEIVE,
|
|
1141
1147
|
{'paths'=> ts_paths}
|
|
1142
1148
|
)
|
|
1143
1149
|
transfer.user_transfer_spec['destination_root'] = self.class.unique_folder(package_info, destination_folder, **per_package_def) unless per_package_def.empty?
|
|
1144
1150
|
dest_folder = transfer.user_transfer_spec['destination_root'] || destination_folder
|
|
1145
1151
|
formatter.display_status(%Q{Downloading package: [#{package_info['id']}] "#{package_info['name']}" to [#{dest_folder}]})
|
|
1146
1152
|
statuses = transfer.start(transfer_spec, oauth_api: package_node_api)
|
|
1147
|
-
File.write(File.join(dest_folder, "#{package_id}.info.json"), package_info.to_json) if save_metadata && !statuses.is_a?(Transfer::Result::DryRun)
|
|
1148
|
-
result_transfer.push({'package' => package_id,
|
|
1149
|
-
if skip_ids_persistency && statuses.is_a?(Transfer::Result::Success)
|
|
1153
|
+
File.write(File.join(dest_folder, "#{package_id}.info.json"), package_info.to_json) if save_metadata && !statuses.is_a?(Aspera::Transfer::Result::DryRun)
|
|
1154
|
+
result_transfer.push({'package' => package_id, Xfer::TransferAgent::STATUS_FIELD => statuses})
|
|
1155
|
+
if skip_ids_persistency && statuses.is_a?(Aspera::Transfer::Result::Success)
|
|
1150
1156
|
skip_ids_persistency.data.push(package_id)
|
|
1151
1157
|
skip_ids_persistency.save
|
|
1152
1158
|
end
|
|
1153
1159
|
end
|
|
1154
|
-
return
|
|
1160
|
+
return Xfer::TransferAgent.result_transfer_multiple(result_transfer)
|
|
1155
1161
|
end
|
|
1156
1162
|
|
|
1157
1163
|
# packages > list
|
|
@@ -1162,13 +1168,13 @@ module Aspera
|
|
|
1162
1168
|
result[:items] = result[:items][0, max_items] if max_items
|
|
1163
1169
|
display_fields = PACKAGE_LIST_DEFAULT_FIELDS
|
|
1164
1170
|
display_fields += ['workspace_id'] if aoc_api.workspace_info[:id].nil?
|
|
1165
|
-
Result::ObjectList.new(result[:items], fields: display_fields, total: result[:total])
|
|
1171
|
+
Cli::Result::ObjectList.new(result[:items], fields: display_fields, total: result[:total])
|
|
1166
1172
|
end
|
|
1167
1173
|
|
|
1168
1174
|
# packages > delete
|
|
1169
1175
|
def action_packages_delete(package_id:, **)
|
|
1170
1176
|
bulk_result(package_id, command: :delete) do |one_id|
|
|
1171
|
-
Aspera.assert_type(one_id, String, Integer) { 'identifier' }
|
|
1177
|
+
Aspera.assert_type(one_id, String, Integer, type: Cli::BadArgument) { 'identifier' }
|
|
1172
1178
|
aoc_api.delete("packages/#{one_id}")
|
|
1173
1179
|
end
|
|
1174
1180
|
end
|
|
@@ -1179,7 +1185,7 @@ module Aspera
|
|
|
1179
1185
|
package_info = aoc_api.read("packages/#{package_id}")
|
|
1180
1186
|
# An id that is not a single path segment (e.g. `/`) reads the list of packages
|
|
1181
1187
|
Aspera.assert(package_info.is_a?(Hash), type: Cli::BadArgument) { "invalid package id: #{package_id}" }
|
|
1182
|
-
nodegen4_plugin(package_info['node_id'], file_id: package_info['contents_file_id'], scope: Api::
|
|
1188
|
+
nodegen4_plugin(package_info['node_id'], file_id: package_info['contents_file_id'], scope: Node::Api::Scope::USER)
|
|
1183
1189
|
end
|
|
1184
1190
|
|
|
1185
1191
|
# setup: files > short_link
|
|
@@ -1214,7 +1220,7 @@ module Aspera
|
|
|
1214
1220
|
'file_id' => shared_apifid.file_id,
|
|
1215
1221
|
'access_id' => id,
|
|
1216
1222
|
'access_type' => 'user',
|
|
1217
|
-
'access_levels' => Api
|
|
1223
|
+
'access_levels' => Api.expand_access_levels(access_levels),
|
|
1218
1224
|
'tags' => {
|
|
1219
1225
|
'url_token' => true,
|
|
1220
1226
|
'folder_name' => File.basename(folder),
|
|
@@ -1229,11 +1235,11 @@ module Aspera
|
|
|
1229
1235
|
aoc_api.permissions_send_event(event_data: created_data, app_info: shared_apifid.node_api.app_info)
|
|
1230
1236
|
when :update
|
|
1231
1237
|
found = shared_apifid.node_api.read('permissions', {file_id: shared_apifid.file_id, inherited: false, access_type: 'user', access_id: id}).find { |i| i['access_id'].eql?(id) }
|
|
1232
|
-
Aspera.assert(!found.nil?, type: Error) { "Short link not found: #{id}" }
|
|
1233
|
-
shared_apifid.node_api.update("permissions/#{found['id']}", {access_levels: Api
|
|
1238
|
+
Aspera.assert(!found.nil?, type: Cli::Error) { "Short link not found: #{id}" }
|
|
1239
|
+
shared_apifid.node_api.update("permissions/#{found['id']}", {access_levels: Api.expand_access_levels(access_levels)})
|
|
1234
1240
|
when :delete
|
|
1235
1241
|
found = shared_apifid.node_api.read('permissions', {file_id: shared_apifid.file_id, inherited: false, access_type: 'user', access_id: id}).first
|
|
1236
|
-
Aspera.assert(!found.nil?, type: Error) { "Short link not found: #{id}" }
|
|
1242
|
+
Aspera.assert(!found.nil?, type: Cli::Error) { "Short link not found: #{id}" }
|
|
1237
1243
|
shared_apifid.node_api.delete("permissions/#{found['id']}")
|
|
1238
1244
|
else Aspera.error_unexpected_value(op)
|
|
1239
1245
|
end
|
|
@@ -1275,7 +1281,7 @@ module Aspera
|
|
|
1275
1281
|
create_payload.deep_merge!(custom_data)
|
|
1276
1282
|
result_create_short_link = aoc_api.create('short_links', create_payload)
|
|
1277
1283
|
short_link_permission(:create, result_create_short_link['resource_id'], access_levels, **ctx) if link_type.eql?(:public) && ctx.key?(:shared_apifid)
|
|
1278
|
-
Result::SingleObject.new(result_create_short_link)
|
|
1284
|
+
Cli::Result::SingleObject.new(result_create_short_link)
|
|
1279
1285
|
end
|
|
1280
1286
|
|
|
1281
1287
|
# Shared implementation for short_link > delete|list|show|modify: fetch the short_list
|
|
@@ -1293,25 +1299,25 @@ module Aspera
|
|
|
1293
1299
|
one_id = short_link_id
|
|
1294
1300
|
if link_type.eql?(:public)
|
|
1295
1301
|
found = short_list[:items].find { |item| item['id'].eql?(one_id) }
|
|
1296
|
-
raise BadIdentifier.new('Short link', one_id) if found.nil?
|
|
1302
|
+
raise Cli::BadIdentifier.new('Short link', one_id) if found.nil?
|
|
1297
1303
|
short_link_permission(:delete, found['resource_id'], nil, **ctx) if ctx.key?(:shared_apifid)
|
|
1298
1304
|
end
|
|
1299
1305
|
# `edit_access` requires `file_id` and `node_id`: shared folder links only
|
|
1300
1306
|
aoc_api.delete("short_links/#{one_id}", ({edit_access: true, json_query: ws_shared_data.to_json} if ctx.key?(:shared_apifid)))
|
|
1301
|
-
Result::Status.new('deleted')
|
|
1307
|
+
Cli::Result::Status.new('deleted')
|
|
1302
1308
|
end
|
|
1303
1309
|
|
|
1304
1310
|
# Shared implementation for short_link > list
|
|
1305
1311
|
def short_link_list(short_list:, **)
|
|
1306
|
-
Result::ObjectList.new(short_list[:items], fields: Formatter.all_but('data'), total: short_list[:total])
|
|
1312
|
+
Cli::Result::ObjectList.new(short_list[:items], fields: Cli::Formatter.all_but('data'), total: short_list[:total])
|
|
1307
1313
|
end
|
|
1308
1314
|
|
|
1309
1315
|
# Shared implementation for short_link > show
|
|
1310
1316
|
def short_link_show(short_list:, short_link_id: nil, **)
|
|
1311
1317
|
one_id = short_link_id
|
|
1312
1318
|
found = short_list[:items].find { |item| item['id'].eql?(one_id) }
|
|
1313
|
-
raise BadIdentifier.new('Short link', one_id) if found.nil?
|
|
1314
|
-
Result::SingleObject.new(found, fields: Formatter.all_but('data'))
|
|
1319
|
+
raise Cli::BadIdentifier.new('Short link', one_id) if found.nil?
|
|
1320
|
+
Cli::Result::SingleObject.new(found, fields: Cli::Formatter.all_but('data'))
|
|
1315
1321
|
end
|
|
1316
1322
|
|
|
1317
1323
|
# Shared implementation for short_link > modify
|
|
@@ -1331,30 +1337,30 @@ module Aspera
|
|
|
1331
1337
|
end
|
|
1332
1338
|
if (access_levels = custom_data.delete('access_levels'))
|
|
1333
1339
|
found = short_list[:items].find { |item| item['id'].eql?(one_id) }
|
|
1334
|
-
raise BadIdentifier.new('Short link', one_id) if found.nil?
|
|
1340
|
+
raise Cli::BadIdentifier.new('Short link', one_id) if found.nil?
|
|
1335
1341
|
short_link_permission(:update, found['resource_id'], access_levels, **ctx) if ctx.key?(:shared_apifid)
|
|
1336
1342
|
end
|
|
1337
1343
|
modify_payload.deep_merge!(custom_data)
|
|
1338
1344
|
aoc_api.update("short_links/#{one_id}", modify_payload)
|
|
1339
|
-
Result::Status.new('modified')
|
|
1345
|
+
Cli::Result::Status.new('modified')
|
|
1340
1346
|
end
|
|
1341
1347
|
|
|
1342
1348
|
# files - mount target: Gen4 commands on the user's home folder
|
|
1343
1349
|
def files_node_plugin(**)
|
|
1344
|
-
nodegen4_plugin(aoc_api.home[:node_id], file_id: aoc_api.home[:file_id], scope: Api::
|
|
1350
|
+
nodegen4_plugin(aoc_api.home[:node_id], file_id: aoc_api.home[:file_id], scope: Node::Api::Scope::USER)
|
|
1345
1351
|
end
|
|
1346
1352
|
|
|
1347
1353
|
# admin > application > instance > <type> > show|modify
|
|
1348
1354
|
APP_TYPES.each do |app_type|
|
|
1349
1355
|
define_action_method([:admin, :application, :instance, app_type, :show]) do |**kwargs|
|
|
1350
1356
|
app_id = kwargs[:instance_id]
|
|
1351
|
-
Result::SingleObject.new(aoc_api.read("admin/apps_new/#{app_type}/#{app_id}", query_read_delete))
|
|
1357
|
+
Cli::Result::SingleObject.new(aoc_api.read("admin/apps_new/#{app_type}/#{app_id}", query_read_delete))
|
|
1352
1358
|
end
|
|
1353
1359
|
|
|
1354
1360
|
define_action_method([:admin, :application, :instance, app_type, :modify]) do |instance:, **kwargs|
|
|
1355
1361
|
app_id = kwargs[:instance_id]
|
|
1356
1362
|
aoc_api.update("admin/apps_new/#{app_type}/#{app_id}", instance)
|
|
1357
|
-
Result::Status.new('modified')
|
|
1363
|
+
Cli::Result::Status.new('modified')
|
|
1358
1364
|
end
|
|
1359
1365
|
end
|
|
1360
1366
|
|
|
@@ -1377,14 +1383,14 @@ module Aspera
|
|
|
1377
1383
|
def action_admin_application_membership_create(membership:, **)
|
|
1378
1384
|
data = membership.dup
|
|
1379
1385
|
app_type = data.delete('app_type')
|
|
1380
|
-
Aspera.assert_type(app_type, String) { 'app_type' }
|
|
1381
|
-
Aspera.assert_values(app_type.to_sym, APP_TYPES) { 'app_type' }
|
|
1382
|
-
Result::SingleObject.new(aoc_api.create("apps/#{app_type}/app_memberships", data))
|
|
1386
|
+
Aspera.assert_type(app_type, String, type: Cli::BadArgument) { 'app_type' }
|
|
1387
|
+
Aspera.assert_values(app_type.to_sym, APP_TYPES, type: Cli::BadArgument) { 'app_type' }
|
|
1388
|
+
Cli::Result::SingleObject.new(aoc_api.create("apps/#{app_type}/app_memberships", data))
|
|
1383
1389
|
end
|
|
1384
1390
|
|
|
1385
1391
|
# admin - setup: change API scope to admin once
|
|
1386
1392
|
def setup_admin_scope(**)
|
|
1387
|
-
change_api_scope(Api::
|
|
1393
|
+
change_api_scope(Api::Scope::ADMIN)
|
|
1388
1394
|
{}
|
|
1389
1395
|
end
|
|
1390
1396
|
|
|
@@ -1399,7 +1405,7 @@ module Aspera
|
|
|
1399
1405
|
api_from_options('bss/platform/graphql'), 'bss_subscription_usage',
|
|
1400
1406
|
{organization_id: org['id'], aggregate: aggregate, startDate: start_date, endDate: end_date}
|
|
1401
1407
|
)
|
|
1402
|
-
Result::SingleObject.new(result['aoc'])
|
|
1408
|
+
Cli::Result::SingleObject.new(result['aoc'])
|
|
1403
1409
|
end
|
|
1404
1410
|
|
|
1405
1411
|
# @return [String] the given resource id, or the one of the current user if empty
|
|
@@ -1434,7 +1440,7 @@ module Aspera
|
|
|
1434
1440
|
events = build_analytics_api.read("#{event_resource_type}/#{event_resource_id}/transfers", filter)['transfers']
|
|
1435
1441
|
start_date_persistency&.save
|
|
1436
1442
|
events.each { |tr_event| context.mailer.send_email_template(values: {ev: tr_event}) } if !options.get_option(:notify_to).nil?
|
|
1437
|
-
Result::ObjectList.new(events)
|
|
1443
|
+
Cli::Result::ObjectList.new(events)
|
|
1438
1444
|
end
|
|
1439
1445
|
|
|
1440
1446
|
# admin > analytics > files
|
|
@@ -1443,14 +1449,16 @@ module Aspera
|
|
|
1443
1449
|
filter = query_read_delete(default: {})
|
|
1444
1450
|
filter['limit'] ||= 100
|
|
1445
1451
|
events = build_analytics_api.read("#{event_resource_type}/#{event_resource_id}/transfers/#{event_uuid}/files", filter)['files']
|
|
1446
|
-
Result::ObjectList.new(events)
|
|
1452
|
+
Cli::Result::ObjectList.new(events)
|
|
1447
1453
|
end
|
|
1448
1454
|
|
|
1449
1455
|
# Lookup methods for arguments:(:identifier) + lookup: on admin resources.
|
|
1450
|
-
# One method per non-singleton resource: percent selector searches with `q=<value
|
|
1456
|
+
# One method per non-singleton resource: percent selector searches with `q=<value>`, or in the whole list if `q: false`.
|
|
1451
1457
|
ADMIN_OBJECTS.reject { |r| ADMIN_OBJECT_CONFIG.dig(r, :singleton) }.each do |res|
|
|
1452
|
-
define_method(:"lookup_aoc_#{res}_id") do |
|
|
1453
|
-
|
|
1458
|
+
define_method(:"lookup_aoc_#{res}_id") do |field, value, **|
|
|
1459
|
+
path = aoc_res_path(res)
|
|
1460
|
+
next aoc_api.lookup_with_q(path, value: value)['id'] unless ADMIN_OBJECT_CONFIG.dig(res, :q).eql?(false)
|
|
1461
|
+
Rest::List.lookup_entity_generic(field: field, value: value, entity: path) { aoc_api.read_with_paging(path, {})[:items] }['id']
|
|
1454
1462
|
end
|
|
1455
1463
|
end
|
|
1456
1464
|
|
|
@@ -1467,14 +1475,14 @@ module Aspera
|
|
|
1467
1475
|
define_action_method([:admin, res, :show]) do |**kwargs|
|
|
1468
1476
|
res_id = kwargs[:"#{res}_id"]
|
|
1469
1477
|
c = aoc_res_cfg(res)
|
|
1470
|
-
Result::SingleObject.new(aoc_api.read("#{c[:path]}/#{res_id}", query_read_delete), fields: Formatter.all_but('certificate'))
|
|
1478
|
+
Cli::Result::SingleObject.new(aoc_api.read("#{c[:path]}/#{res_id}", query_read_delete), fields: Cli::Formatter.all_but('certificate'))
|
|
1471
1479
|
end
|
|
1472
1480
|
end
|
|
1473
1481
|
|
|
1474
|
-
# admin >
|
|
1475
|
-
|
|
1482
|
+
# admin > <singleton> > show
|
|
1483
|
+
ADMIN_OBJECTS.select { |r| ADMIN_OBJECT_CONFIG.dig(r, :singleton) }.each do |res|
|
|
1476
1484
|
define_action_method([:admin, res, :show]) do |**|
|
|
1477
|
-
Result::SingleObject.new(aoc_api.read(res
|
|
1485
|
+
Cli::Result::SingleObject.new(aoc_api.read(aoc_res_path(res), query_read_delete), fields: Cli::Formatter.all_but('certificate'))
|
|
1478
1486
|
end
|
|
1479
1487
|
end
|
|
1480
1488
|
|
|
@@ -1483,25 +1491,21 @@ module Aspera
|
|
|
1483
1491
|
define_action_method([:admin, res, :create]) do |**kwargs|
|
|
1484
1492
|
data = kwargs.fetch(res)
|
|
1485
1493
|
c = aoc_res_cfg(res)
|
|
1486
|
-
path = c[:path]
|
|
1487
|
-
# Special case: client_registration_token has a different creation URL
|
|
1488
|
-
path = 'admin/client_registration/token' if path.eql?('admin/client_registration_tokens')
|
|
1489
1494
|
workspace_id = aoc_api.workspace_info[:id] if c[:require_ws_id]
|
|
1490
1495
|
bulk_result(data, command: :create, id_result: c[:id_result]) do |params|
|
|
1491
1496
|
params['workspace_id'] = workspace_id if c[:require_ws_id] && workspace_id && !params.key?('workspace_id')
|
|
1492
|
-
aoc_api.create(
|
|
1497
|
+
aoc_api.create(c[:create_path], params)
|
|
1493
1498
|
end
|
|
1494
1499
|
end
|
|
1495
1500
|
end
|
|
1496
1501
|
|
|
1497
|
-
# admin > <res> > modify
|
|
1498
|
-
ADMIN_OBJECTS.
|
|
1502
|
+
# admin > <res> > modify (a singleton has no identifier)
|
|
1503
|
+
ADMIN_OBJECTS.select { |r| aoc_res_cfg(r)[:ops].include?(:modify) }.each do |res|
|
|
1499
1504
|
define_action_method([:admin, res, :modify]) do |**kwargs|
|
|
1500
1505
|
data = kwargs.fetch(res)
|
|
1501
|
-
res_id = kwargs[:"#{res}_id"]
|
|
1502
1506
|
c = aoc_res_cfg(res)
|
|
1503
|
-
aoc_api.update("#{c[:path]}/#{
|
|
1504
|
-
Result::Status.new('modified')
|
|
1507
|
+
aoc_api.update(ADMIN_OBJECT_CONFIG.dig(res, :singleton) ? c[:path] : "#{c[:path]}/#{kwargs[:"#{res}_id"]}", data)
|
|
1508
|
+
Cli::Result::Status.new('modified')
|
|
1505
1509
|
end
|
|
1506
1510
|
end
|
|
1507
1511
|
|
|
@@ -1520,10 +1524,10 @@ module Aspera
|
|
|
1520
1524
|
end
|
|
1521
1525
|
end
|
|
1522
1526
|
|
|
1523
|
-
# user > contacts > list|
|
|
1524
|
-
|
|
1527
|
+
# user > contacts > list|create (same API path as admin > contact)
|
|
1528
|
+
%i[list create].each do |op|
|
|
1525
1529
|
define_action_method([:user, :contacts, op]) do |**ctx|
|
|
1526
|
-
send(
|
|
1530
|
+
send(Cli::Command.action_method([:admin, :contact, op]), **ctx)
|
|
1527
1531
|
end
|
|
1528
1532
|
end
|
|
1529
1533
|
|
|
@@ -1535,7 +1539,7 @@ module Aspera
|
|
|
1535
1539
|
step = @automation_api.read("steps/#{step_id}")
|
|
1536
1540
|
Array(step['action_order']).map { |action_id| @automation_api.read("actions/#{action_id}") }
|
|
1537
1541
|
end
|
|
1538
|
-
Result::ObjectList.new(actions)
|
|
1542
|
+
Cli::Result::ObjectList.new(actions)
|
|
1539
1543
|
end
|
|
1540
1544
|
|
|
1541
1545
|
# automation > workflows > action > create
|
|
@@ -1546,7 +1550,7 @@ module Aspera
|
|
|
1546
1550
|
@automation_api.update("workflows/#{workflow_id}", {'step_order' => Array(workflow['step_order']) + [step['id']]})
|
|
1547
1551
|
new_action = @automation_api.create('actions', {'type' => 'manual'}.merge(action).merge('step_id' => step['id']))
|
|
1548
1552
|
@automation_api.update("steps/#{step['id']}", {'action_order' => [new_action['id']]})
|
|
1549
|
-
Result::SingleObject.new(new_action)
|
|
1553
|
+
Cli::Result::SingleObject.new(new_action)
|
|
1550
1554
|
end
|
|
1551
1555
|
|
|
1552
1556
|
# automation helper methods
|
|
@@ -1568,7 +1572,7 @@ module Aspera
|
|
|
1568
1572
|
found = page['workflow_instances'].find { |job| job[is_uuid ? 'instance_id' : 'id'].eql?(instance_id) }
|
|
1569
1573
|
return found unless found.nil?
|
|
1570
1574
|
offset += limit
|
|
1571
|
-
raise BadIdentifier.new('Workflow instance', instance_id) if is_uuid || offset >= page['total_count'].to_i
|
|
1575
|
+
raise Cli::BadIdentifier.new('Workflow instance', instance_id) if is_uuid || offset >= page['total_count'].to_i
|
|
1572
1576
|
end
|
|
1573
1577
|
end
|
|
1574
1578
|
|
|
@@ -1707,14 +1711,14 @@ module Aspera
|
|
|
1707
1711
|
|
|
1708
1712
|
def automation_guide_toc(level)
|
|
1709
1713
|
require_relative '../../markdown'
|
|
1710
|
-
Result::ObjectList.new(Markdown.toc(automation_guide_document, max_level: level || 3), fields: %w[level title anchor])
|
|
1714
|
+
Cli::Result::ObjectList.new(Markdown.toc(automation_guide_document, max_level: level || 3), fields: %w[level title anchor])
|
|
1711
1715
|
end
|
|
1712
1716
|
|
|
1713
1717
|
def automation_guide_section(anchor)
|
|
1714
1718
|
require_relative '../../markdown'
|
|
1715
1719
|
text = Markdown.extract_section(automation_guide_document, anchor)
|
|
1716
1720
|
Aspera.assert(!text.nil?, type: Cli::Error) { "Section not found: #{anchor}, use `toc` to list anchors" }
|
|
1717
|
-
Result::Text.new(text)
|
|
1721
|
+
Cli::Result::Text.new(text)
|
|
1718
1722
|
end
|
|
1719
1723
|
|
|
1720
1724
|
# admin > client > set_pub_key
|
|
@@ -1722,35 +1726,75 @@ module Aspera
|
|
|
1722
1726
|
c = aoc_res_cfg(:client)
|
|
1723
1727
|
the_public_key = OpenSSL::PKey::RSA.new(private_key_pem).public_key.to_s
|
|
1724
1728
|
aoc_api.update("#{c[:path]}/#{client_id}", {jwt_grant_enabled: true, public_key: the_public_key})
|
|
1725
|
-
Result::Success.new
|
|
1729
|
+
Cli::Result::Success.new
|
|
1726
1730
|
end
|
|
1727
1731
|
|
|
1728
1732
|
# admin > ats — build and return an Ats plugin instance wired to the AoC ATS API.
|
|
1729
1733
|
# Mount target of `admin ats`.
|
|
1730
|
-
# @return [Ats] configured Ats plugin instance
|
|
1734
|
+
# @return [Ats::Commands] configured Ats plugin instance
|
|
1731
1735
|
def build_ats_plugin(**)
|
|
1732
1736
|
ats_api = Rest::Client.new(**aoc_api.params.deep_merge({
|
|
1733
1737
|
base_url: "#{aoc_api.base_url}/admin/ats/pub/v1",
|
|
1734
|
-
auth: {params: {scope: Api::
|
|
1738
|
+
auth: {params: {scope: Api::Scope::ADMIN_USER}}
|
|
1735
1739
|
}))
|
|
1736
|
-
Ats.new(context: context, api: ats_api)
|
|
1740
|
+
Ats::Commands.new(context: context, api: ats_api)
|
|
1737
1741
|
end
|
|
1738
1742
|
|
|
1739
1743
|
# admin > node > do - mount target: Gen4 commands on the node, admin scope
|
|
1740
1744
|
def admin_node_do_plugin(node_id:, **)
|
|
1741
|
-
nodegen4_plugin(node_id, scope: Api::
|
|
1745
|
+
nodegen4_plugin(node_id, scope: Node::Api::Scope::ADMIN)
|
|
1742
1746
|
end
|
|
1743
1747
|
|
|
1744
1748
|
# admin > node > bearer_token
|
|
1745
1749
|
def action_admin_node_bearer_token(scope:, node_id:, **)
|
|
1746
|
-
scope ||= Api::
|
|
1750
|
+
scope ||= Node::Api::Scope::ADMIN
|
|
1747
1751
|
node_api = aoc_api.node_api_from(node_id: node_id, scope: scope)
|
|
1748
|
-
Result::Text.new(node_api.oauth.authorization)
|
|
1752
|
+
Cli::Result::Text.new(node_api.oauth.authorization)
|
|
1753
|
+
end
|
|
1754
|
+
|
|
1755
|
+
# Setting of an access control rule for the type of the policy, as the web app
|
|
1756
|
+
def access_control_setting(network_policy_id)
|
|
1757
|
+
type = aoc_api.read("admin/network_policies/#{network_policy_id}")['access_control_type']
|
|
1758
|
+
case type
|
|
1759
|
+
when 'allow_following' then :allow
|
|
1760
|
+
when 'disallow_following' then :disallow
|
|
1761
|
+
else raise Cli::BadArgument, "policy_setting required: access_control_type of the policy is #{type}"
|
|
1762
|
+
end
|
|
1763
|
+
end
|
|
1764
|
+
|
|
1765
|
+
# admin > dropbox > update_self_registration_link
|
|
1766
|
+
def action_admin_dropbox_update_self_registration_link(dropbox_id:, **)
|
|
1767
|
+
Cli::Result::SingleObject.new(aoc_api.create("admin/dropboxes/#{dropbox_id}/update_self_registration_link", {}), fields: %w[id name self_register_url_id])
|
|
1768
|
+
end
|
|
1769
|
+
|
|
1770
|
+
# admin > user > invite
|
|
1771
|
+
def action_admin_user_invite(user_id:, **)
|
|
1772
|
+
aoc_api.create('admin/invitations', {'user_id' => user_id})
|
|
1773
|
+
Cli::Result::Status.new('invited')
|
|
1774
|
+
end
|
|
1775
|
+
|
|
1776
|
+
# admin > user|group > shared_folders
|
|
1777
|
+
%i[user group].each do |member_type|
|
|
1778
|
+
define_action_method([:admin, member_type, :shared_folders]) do |**kwargs|
|
|
1779
|
+
result_list('admin/shared_folders_memberships', base_query: {'member_type' => member_type.to_s, 'member_id' => kwargs.fetch(:"#{member_type}_id")},
|
|
1780
|
+
fields: %w[node_name file_id share_as workspace_id agg_access_levels], query_component: AOC_SCHEMA)
|
|
1781
|
+
end
|
|
1782
|
+
end
|
|
1783
|
+
|
|
1784
|
+
# admin > kms_profile > nodes
|
|
1785
|
+
def action_admin_kms_profile_nodes(kms_profile_id:, **)
|
|
1786
|
+
Cli::Result::ObjectList.new(aoc_api.read("#{aoc_res_path(:kms_profile)}/#{kms_profile_id}/nodes"))
|
|
1787
|
+
end
|
|
1788
|
+
|
|
1789
|
+
# admin > package > download_counts (also packages > download_counts)
|
|
1790
|
+
def action_admin_package_download_counts(package_id:, **)
|
|
1791
|
+
result_list("packages/#{package_id}/download_counts", base_query: {'embed[]' => 'user'}, fields: %w[user_id user.email full partial failed active],
|
|
1792
|
+
query_component: AOC_SCHEMA, schema_path: 'packages/{id}/download_counts')
|
|
1749
1793
|
end
|
|
1750
1794
|
|
|
1751
1795
|
# admin > node > update_status
|
|
1752
1796
|
def action_admin_node_update_status(node_id:, **)
|
|
1753
|
-
Result::SingleObject.new(aoc_api.read("#{aoc_res_path(:node)}/#{node_id}/update_status"), fields: %w[status error_time error_message])
|
|
1797
|
+
Cli::Result::SingleObject.new(aoc_api.read("#{aoc_res_path(:node)}/#{node_id}/update_status"), fields: %w[status error_time error_message])
|
|
1754
1798
|
end
|
|
1755
1799
|
|
|
1756
1800
|
# admin > workspace > dropbox — res_id: already in ctx via arguments:(:identifier)
|
|
@@ -1761,7 +1805,7 @@ module Aspera
|
|
|
1761
1805
|
# admin > workspace > shared_folder — res_id: already in ctx via arguments:(:identifier)
|
|
1762
1806
|
def setup_admin_workspace_shared_folder(workspace_id:, **)
|
|
1763
1807
|
resource_instance_path = "#{aoc_res_path(:workspace)}/#{workspace_id}"
|
|
1764
|
-
query = query_read_delete(default: Api
|
|
1808
|
+
query = query_read_delete(default: Api.workspace_access(workspace_id).merge({'admin' => true}))
|
|
1765
1809
|
shared_folders = aoc_api.read_with_paging("#{resource_instance_path}/permissions", query)[:items]
|
|
1766
1810
|
{ws_res_id: workspace_id, shared_folders: shared_folders}
|
|
1767
1811
|
end
|
|
@@ -1769,7 +1813,7 @@ module Aspera
|
|
|
1769
1813
|
# admin > workspace > shared_folder > node|member — shared_folder_id: already in ctx via arguments:(:identifier)
|
|
1770
1814
|
def resolve_sf_item(shared_folders:, shared_folder_id:, **)
|
|
1771
1815
|
sf_item = shared_folders.find { |i| i['id'].eql?(shared_folder_id) }
|
|
1772
|
-
|
|
1816
|
+
raise Cli::BadIdentifier.new('Shared folder', shared_folder_id) if sf_item.nil?
|
|
1773
1817
|
{sf_item: sf_item}
|
|
1774
1818
|
end
|
|
1775
1819
|
|
|
@@ -1778,7 +1822,7 @@ module Aspera
|
|
|
1778
1822
|
|
|
1779
1823
|
# admin > workspace > shared_folder > node - mount target: Gen4 commands on the shared folder, admin scope
|
|
1780
1824
|
def admin_workspace_shared_folder_node_plugin(sf_item:, **)
|
|
1781
|
-
nodegen4_plugin(sf_item['node_id'], file_id: sf_item['file_id'], scope: Api::
|
|
1825
|
+
nodegen4_plugin(sf_item['node_id'], file_id: sf_item['file_id'], scope: Node::Api::Scope::ADMIN)
|
|
1782
1826
|
end
|
|
1783
1827
|
|
|
1784
1828
|
# admin > workspace > shared_folder > member > list
|
|
@@ -1787,12 +1831,12 @@ module Aspera
|
|
|
1787
1831
|
node_id: sf_item['node_id'],
|
|
1788
1832
|
workspace_id: ws_res_id,
|
|
1789
1833
|
workspace_name: nil,
|
|
1790
|
-
scope: Api::
|
|
1834
|
+
scope: Node::Api::Scope::USER
|
|
1791
1835
|
)
|
|
1792
1836
|
result = node_api.read('permissions', {'file_id' => sf_item['file_id'], 'tag' => "aspera.files.workspace.id=#{ws_res_id}"})
|
|
1793
1837
|
result.each do |item|
|
|
1794
1838
|
item['member'] = begin
|
|
1795
|
-
if Api
|
|
1839
|
+
if Api.workspace_access?(item)
|
|
1796
1840
|
{'name' => '[Internal permission]'}
|
|
1797
1841
|
else
|
|
1798
1842
|
aoc_api.read("admin/#{item['access_type']}s/#{item['access_id']}")
|
|
@@ -1803,28 +1847,58 @@ module Aspera
|
|
|
1803
1847
|
end
|
|
1804
1848
|
end
|
|
1805
1849
|
# TODO : read users and group name and add, if query "include_members"
|
|
1806
|
-
Result::ObjectList.new(result, fields: %w[access_type access_id access_level last_updated_at member.name member.email member.system_group_type member.system_group])
|
|
1850
|
+
Cli::Result::ObjectList.new(result, fields: %w[access_type access_id access_level last_updated_at member.name member.email member.system_group_type member.system_group])
|
|
1807
1851
|
end
|
|
1808
1852
|
|
|
1809
1853
|
# admin > user > preferences|notifications > show|modify
|
|
1810
1854
|
# (user_id: argument of the preferences|notifications node)
|
|
1811
|
-
|
|
1812
|
-
pref_path = pref.eql?(:preferences) ? 'user_interaction_preferences' : 'notification_preferences'
|
|
1855
|
+
USER_PREF_PATHS.each do |pref, pref_path|
|
|
1813
1856
|
define_action_method([:admin, :user, pref, :show]) do |user_id:, **|
|
|
1814
|
-
Result::SingleObject.new(aoc_api.read("#{aoc_res_path(:user)}/#{user_id}/#{pref_path}"))
|
|
1857
|
+
Cli::Result::SingleObject.new(aoc_api.read("#{aoc_res_path(:user)}/#{user_id}/#{pref_path}"))
|
|
1815
1858
|
end
|
|
1816
1859
|
define_action_method([:admin, :user, pref, :modify]) do |user_id:, **kwargs|
|
|
1817
1860
|
aoc_api.update("#{aoc_res_path(:user)}/#{user_id}/#{pref_path}", kwargs.fetch(pref))
|
|
1818
|
-
Result::Status.new('modified')
|
|
1861
|
+
Cli::Result::Status.new('modified')
|
|
1819
1862
|
end
|
|
1820
1863
|
end
|
|
1821
1864
|
|
|
1822
1865
|
def action_gateway(parameters: {}, **)
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1866
|
+
# Loaded on use: web server
|
|
1867
|
+
require_relative '../faspex4/gw_servlet'
|
|
1868
|
+
Faspex4::GWServlet.serve(parameters.symbolize_keys, type: Cli::BadArgument) do
|
|
1869
|
+
workspace_id = aoc_api.workspace_info[:id]
|
|
1870
|
+
->(faspex_pkg_parameters) { faspex4_send_to_aoc(faspex_pkg_parameters, workspace_id) }
|
|
1871
|
+
end
|
|
1872
|
+
return Cli::Result::Status.new('Gateway terminated')
|
|
1873
|
+
end
|
|
1874
|
+
|
|
1875
|
+
# Map Faspex 4 /send API to AoC package create
|
|
1876
|
+
# parameters from user to Faspex API call
|
|
1877
|
+
# https://developer.ibm.com/apis/catalog/aspera--aspera-faspex-client-sdk/Sending%20Packages%20(API%20v.3)
|
|
1878
|
+
# @param faspex_pkg_parameters [Hash] Faspex 4 package creation
|
|
1879
|
+
# @param workspace_id [String] Workspace of the package
|
|
1880
|
+
# @return [Hash] Transfer spec to upload the package files
|
|
1881
|
+
def faspex4_send_to_aoc(faspex_pkg_parameters, workspace_id)
|
|
1882
|
+
faspex_pkg_delivery = faspex_pkg_parameters['delivery']
|
|
1883
|
+
package_data = {
|
|
1884
|
+
# 'file_names' => faspex_pkg_delivery['sources'][0]['paths'],
|
|
1885
|
+
'name' => faspex_pkg_delivery['title'],
|
|
1886
|
+
'note' => faspex_pkg_delivery['note'],
|
|
1887
|
+
'recipients' => faspex_pkg_delivery['recipients'],
|
|
1888
|
+
'workspace_id' => workspace_id
|
|
1889
|
+
}
|
|
1890
|
+
aoc_api.create_package_simple(package_data, true, nil)[:spec]
|
|
1826
1891
|
end
|
|
1892
|
+
private :faspex4_send_to_aoc
|
|
1827
1893
|
end
|
|
1894
|
+
# Hint of an error of authentication with a private key (JWT)
|
|
1895
|
+
Cli::Hints.add(
|
|
1896
|
+
exception: Rest::CallError,
|
|
1897
|
+
match: /invalid_grant/,
|
|
1898
|
+
remediation: [
|
|
1899
|
+
'Check your public key in your AoC user profile.'
|
|
1900
|
+
]
|
|
1901
|
+
)
|
|
1828
1902
|
end
|
|
1829
1903
|
end
|
|
1830
1904
|
end
|