aspera-cli 4.28.0 → 4.29.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 +0 -0
- data/BUGS.md +5 -10
- data/CHANGELOG.md +143 -2
- data/CODE_OF_CONDUCT.md +18 -0
- data/CONTRIBUTING.md +135 -56
- data/GOVERNANCE.md +30 -0
- data/LICENSE +201 -0
- data/README.md +103 -26
- data/SECURITY.md +70 -0
- data/bin/ascli +8 -5
- data/bin/asession +9 -6
- data/docs/README.md +1633 -609
- data/docs/test-mcp-with-ai.md +8 -8
- data/lib/aspera/agent/base.rb +23 -2
- data/lib/aspera/agent/connect.rb +16 -12
- data/lib/aspera/agent/desktop.rb +10 -7
- data/lib/aspera/agent/direct.rb +20 -19
- data/lib/aspera/agent/factory.rb +6 -3
- data/lib/aspera/agent/httpgw.rb +7 -5
- data/lib/aspera/agent/node.rb +15 -7
- data/lib/aspera/agent/transferd.rb +167 -43
- data/lib/aspera/api/alee.rb +4 -1
- data/lib/aspera/api/aoc.rb +14 -11
- data/lib/aspera/api/ats.rb +4 -2
- data/lib/aspera/api/cos_node.rb +7 -4
- data/lib/aspera/api/faspex.rb +16 -9
- data/lib/aspera/api/httpgw.rb +9 -6
- data/lib/aspera/api/node.rb +20 -20
- data/lib/aspera/ascmd.rb +8 -5
- data/lib/aspera/ascp/installation.rb +71 -65
- data/lib/aspera/ascp/log.schema.yaml +1084 -0
- data/lib/aspera/ascp/log_analyzer/advice.rb +97 -0
- data/lib/aspera/ascp/log_analyzer/diagnostics.rb +344 -0
- data/lib/aspera/ascp/log_analyzer/lines.rb +75 -0
- data/lib/aspera/ascp/log_analyzer/log_file.rb +593 -0
- data/lib/aspera/ascp/log_analyzer/records.rb +379 -0
- data/lib/aspera/ascp/log_analyzer/rules.rb +172 -0
- data/lib/aspera/ascp/log_analyzer/session.rb +782 -0
- data/lib/aspera/ascp/log_analyzer.rb +354 -0
- data/lib/aspera/ascp/management.rb +16 -8
- data/lib/aspera/ascp/session_errors.rb +217 -0
- data/lib/aspera/assert.rb +4 -0
- data/lib/aspera/cli/ascp_actions.rb +12 -19
- data/lib/aspera/cli/ascp_logs_actions.rb +176 -0
- data/lib/aspera/cli/async_transfer_store.rb +7 -4
- data/lib/aspera/cli/bootstrapper.rb +37 -33
- data/lib/aspera/cli/command_line.rb +24 -6
- data/lib/aspera/cli/command_registry.rb +6 -1
- data/lib/aspera/cli/command_spec.rb +34 -7
- data/lib/aspera/cli/completion/ascli.bash +19 -5
- data/lib/aspera/cli/completion/ascli.fish +13 -2
- data/lib/aspera/cli/completion/ascli.ps1 +31 -9
- data/lib/aspera/cli/completion/ascli.zsh +22 -6
- data/lib/aspera/cli/completion_actions.rb +303 -69
- data/lib/aspera/cli/context.rb +9 -4
- data/lib/aspera/cli/deprecation.rb +5 -2
- data/lib/aspera/cli/error.rb +3 -0
- data/lib/aspera/cli/extended_value.rb +61 -27
- data/lib/aspera/cli/formatter.rb +29 -22
- data/lib/aspera/cli/gem_checker.rb +9 -6
- data/lib/aspera/cli/hints.rb +22 -10
- data/lib/aspera/cli/http.rb +12 -9
- data/lib/aspera/cli/info.rb +12 -7
- data/lib/aspera/cli/mailer.rb +6 -3
- data/lib/aspera/cli/mcp/http_servlet.rb +7 -8
- data/lib/aspera/cli/mcp/secrets.rb +8 -5
- data/lib/aspera/cli/mcp/tool.rb +15 -14
- data/lib/aspera/cli/option_declarator.rb +10 -4
- data/lib/aspera/cli/option_registry.rb +6 -3
- data/lib/aspera/cli/option_types.rb +17 -2
- data/lib/aspera/cli/option_value.rb +65 -12
- data/lib/aspera/cli/options.schema.yaml +487 -63
- data/lib/aspera/cli/parser.rb +56 -32
- data/lib/aspera/cli/plugins/alee.rb +7 -4
- data/lib/aspera/cli/plugins/aoc.rb +244 -35
- data/lib/aspera/cli/plugins/ats.rb +9 -8
- data/lib/aspera/cli/plugins/base.rb +17 -12
- data/lib/aspera/cli/plugins/basic_auth.rb +5 -2
- data/lib/aspera/cli/plugins/config.rb +198 -103
- data/lib/aspera/cli/plugins/console.rb +6 -3
- data/lib/aspera/cli/plugins/cos.rb +8 -4
- data/lib/aspera/cli/plugins/factory.rb +21 -7
- data/lib/aspera/cli/plugins/faspex5.rb +28 -25
- data/lib/aspera/cli/plugins/faspio.rb +7 -5
- data/lib/aspera/cli/plugins/httpgw.rb +7 -4
- data/lib/aspera/cli/plugins/mcp.rb +28 -22
- data/lib/aspera/cli/plugins/node.rb +31 -30
- data/lib/aspera/cli/plugins/oauth.rb +5 -1
- data/lib/aspera/cli/plugins/orchestrator.rb +272 -72
- data/lib/aspera/cli/plugins/preview.rb +69 -44
- data/lib/aspera/cli/plugins/server.rb +63 -11
- data/lib/aspera/cli/plugins/shares.rb +86 -16
- data/lib/aspera/cli/plugins/transferd.rb +223 -0
- data/lib/aspera/cli/preset_actions.rb +144 -30
- data/lib/aspera/cli/preset_manager.rb +52 -18
- data/lib/aspera/cli/prompt.rb +4 -1
- data/lib/aspera/cli/result.rb +12 -8
- data/lib/aspera/cli/runner.rb +69 -46
- data/lib/aspera/cli/secret_finder.rb +4 -1
- data/lib/aspera/cli/security.rb +79 -9
- data/lib/aspera/cli/special_values.rb +4 -1
- data/lib/aspera/cli/sync_actions.rb +13 -10
- data/lib/aspera/cli/table_fitter.rb +3 -0
- data/lib/aspera/cli/terminal_formatter.rb +9 -6
- data/lib/aspera/cli/transfer_actions.rb +11 -8
- data/lib/aspera/cli/transfer_agent.rb +29 -20
- data/lib/aspera/cli/transfer_progress.rb +13 -45
- data/lib/aspera/cli/vault_actions.rb +45 -0
- data/lib/aspera/cli/vault_manager.rb +188 -42
- data/lib/aspera/cli/version.rb +4 -1
- data/lib/aspera/cli/web_secret.rb +12 -10
- data/lib/aspera/cli/wizard.rb +42 -39
- data/lib/aspera/command_line_builder.rb +9 -5
- data/lib/aspera/command_line_converter.rb +4 -1
- data/lib/aspera/coverage.rb +103 -33
- data/lib/aspera/data_repository.rb +4 -1
- data/lib/aspera/dot_container.rb +4 -1
- data/lib/aspera/duration.rb +5 -2
- data/lib/aspera/environment.rb +21 -12
- data/lib/aspera/exec_spec.rb +3 -0
- data/lib/aspera/faspex_gw.rb +13 -9
- data/lib/aspera/faspex_postproc.rb +15 -12
- data/lib/aspera/formatter_interface.rb +4 -1
- data/lib/aspera/graphql.rb +5 -1
- data/lib/aspera/hash_ext.rb +3 -0
- data/lib/aspera/id_generator.rb +4 -2
- data/lib/aspera/json_rpc/client.rb +6 -5
- data/lib/aspera/json_rpc/version.rb +3 -0
- data/lib/aspera/line_logger.rb +4 -1
- data/lib/aspera/link_header.rb +4 -1
- data/lib/aspera/log.rb +18 -5
- data/lib/aspera/markdown.rb +5 -2
- data/lib/aspera/mime.rb +3 -0
- data/lib/aspera/nagios.rb +6 -4
- data/lib/aspera/node_emulator.rb +15 -13
- data/lib/aspera/oauth/client/base.rb +91 -70
- data/lib/aspera/oauth/client/boot.rb +7 -4
- data/lib/aspera/oauth/client/factory.rb +6 -3
- data/lib/aspera/oauth/client/generic.rb +5 -1
- data/lib/aspera/oauth/client/json_credentials.rb +4 -1
- data/lib/aspera/oauth/client/jwt.rb +6 -3
- data/lib/aspera/oauth/client/shares_web.rb +85 -0
- data/lib/aspera/oauth/client/url_json.rb +4 -1
- data/lib/aspera/oauth/client/web.rb +39 -12
- data/lib/aspera/oauth/server/pkce.rb +6 -5
- data/lib/aspera/orchestrator_workflow_checker.rb +119 -1
- data/lib/aspera/persistency_action_once.rb +5 -3
- data/lib/aspera/persistency_folder.rb +6 -3
- data/lib/aspera/preview/file_types.rb +6 -3
- data/lib/aspera/preview/generator.rb +9 -5
- data/lib/aspera/preview/options.schema.yaml +3 -3
- data/lib/aspera/preview/terminal.rb +8 -4
- data/lib/aspera/preview/utils.rb +6 -4
- data/lib/aspera/products/connect.rb +5 -2
- data/lib/aspera/products/desktop.rb +4 -1
- data/lib/aspera/products/other.rb +4 -2
- data/lib/aspera/products/transferd.rb +6 -2
- data/lib/aspera/products/transferd_service.rb +610 -0
- data/lib/aspera/proxy_auto_config.js +2 -2
- data/lib/aspera/proxy_auto_config.rb +5 -2
- data/lib/aspera/rainbow.rb +3 -0
- data/lib/aspera/rest/aspera_errors.rb +4 -1
- data/lib/aspera/rest/call_error.rb +3 -0
- data/lib/aspera/rest/client.rb +22 -29
- data/lib/aspera/rest/error_analyzer.rb +5 -2
- data/lib/aspera/rest/list.rb +8 -4
- data/lib/aspera/rest/parameters.rb +3 -0
- data/lib/aspera/rest/util.rb +8 -5
- data/lib/aspera/rest.rb +9 -6
- data/lib/aspera/schema/IBM Aspera Faspex API-5.0-enhanced.yaml +9 -9
- data/lib/aspera/schema/IBM Aspera Orchestrator API-v1-enhanced.yaml +118 -30
- data/lib/aspera/schema/IBM Aspera on Cloud API-0.2.6-enhanced.yaml +11 -11
- data/lib/aspera/schema/IBM Aspera on Cloud Automation API-1.0.5-enhanced.yaml +2437 -1437
- data/lib/aspera/schema/async_tables.yaml +11 -10
- data/lib/aspera/schema/documentation.rb +8 -2
- data/lib/aspera/schema/reader.rb +7 -0
- data/lib/aspera/schema/registry.rb +43 -28
- data/lib/aspera/schema/transferd-config.schema.json +333 -0
- data/lib/aspera/schema/validator.rb +4 -1
- data/lib/aspera/sealed_hash.rb +166 -0
- data/lib/aspera/secret/hider.rb +201 -0
- data/lib/aspera/secret/reference.rb +150 -0
- data/lib/aspera/secret/resolver.rb +212 -0
- data/lib/aspera/secret/store/base.rb +153 -0
- data/lib/aspera/secret/store/encrypted_hash.rb +329 -0
- data/lib/aspera/secret/store/factory.rb +103 -0
- data/lib/aspera/secret/store/hashicorp_vault.rb +390 -0
- data/lib/aspera/secret/store/keeper.rb +141 -0
- data/lib/aspera/secret/store/macos_security.rb +284 -0
- data/lib/aspera/secret/store/one_password_api.rb +99 -0
- data/lib/aspera/secret/store/one_password_base.rb +42 -0
- data/lib/aspera/secret/store/one_password_cli.rb +110 -0
- data/lib/aspera/secret/store/secret_service.rb +125 -0
- data/lib/aspera/secret/strength.rb +119 -0
- data/lib/aspera/servlet_helpers.rb +5 -2
- data/lib/aspera/ssh.rb +10 -7
- data/lib/aspera/ssl.rb +5 -2
- data/lib/aspera/string_ext.rb +3 -0
- data/lib/aspera/sync/args.schema.yaml +3 -0
- data/lib/aspera/sync/conf.schema.yaml +9 -4
- data/lib/aspera/sync/database.rb +3 -0
- data/lib/aspera/sync/operations.rb +16 -14
- data/lib/aspera/temp_file_manager.rb +8 -4
- data/lib/aspera/timer_limiter.rb +3 -0
- data/lib/aspera/transfer/error.rb +4 -1
- data/lib/aspera/transfer/faux_file.rb +4 -1
- data/lib/aspera/transfer/parameters.rb +17 -14
- data/lib/aspera/transfer/result.rb +3 -0
- data/lib/aspera/transfer/resumer.rb +6 -4
- data/lib/aspera/transfer/spec.rb +9 -22
- data/lib/aspera/transfer/units.rb +75 -0
- data/lib/aspera/uri_reader.rb +57 -7
- data/lib/aspera/web_auth/index.html.erb +6 -2
- data/lib/aspera/web_auth/paste.rb +109 -0
- data/lib/aspera/web_auth/receiver.rb +50 -0
- data/lib/aspera/web_auth/relay.rb +76 -0
- data/lib/aspera/web_auth/reply.html.erb +150 -0
- data/lib/aspera/web_auth/server.rb +47 -10
- data/lib/aspera/web_page.rb +7 -2
- data/lib/aspera/web_server_simple.rb +6 -3
- data/lib/aspera/yaml.rb +5 -1
- data/llms.txt +81 -0
- data/skills/ascli/SKILL.md +88 -0
- data.tar.gz.sig +0 -0
- metadata +72 -19
- metadata.gz.sig +0 -0
- data/lib/aspera/keychain/base.rb +0 -30
- data/lib/aspera/keychain/encrypted_hash.rb +0 -192
- data/lib/aspera/keychain/factory.rb +0 -58
- data/lib/aspera/keychain/hashicorp_vault.rb +0 -77
- data/lib/aspera/keychain/macos_security.rb +0 -277
- data/lib/aspera/keychain/one_password_api.rb +0 -91
- data/lib/aspera/keychain/one_password_base.rb +0 -39
- data/lib/aspera/keychain/one_password_cli.rb +0 -100
- data/lib/aspera/secret_hider.rb +0 -196
- data/lib/aspera/secret_strength.rb +0 -114
data/lib/aspera/cli/parser.rb
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative 'preset_manager'
|
|
7
|
+
require_relative 'extended_value'
|
|
8
|
+
require_relative 'error'
|
|
9
|
+
require_relative 'special_values'
|
|
10
|
+
require_relative 'terminal_formatter'
|
|
11
|
+
require_relative 'option_types'
|
|
12
|
+
require_relative 'option_value'
|
|
13
|
+
require_relative 'option_registry'
|
|
14
|
+
require_relative 'command_line'
|
|
15
|
+
require_relative 'prompt'
|
|
16
|
+
require_relative '../schema/validator'
|
|
17
|
+
require_relative '../log'
|
|
18
|
+
require_relative '../assert'
|
|
19
|
+
require_relative '../dot_container'
|
|
20
|
+
require_relative '../rainbow'
|
|
16
21
|
require 'terminal-table'
|
|
17
|
-
require 'aspera/rainbow'
|
|
18
22
|
using Rainbow
|
|
19
23
|
|
|
20
24
|
module Aspera
|
|
@@ -90,16 +94,18 @@ module Aspera
|
|
|
90
94
|
|
|
91
95
|
# Using dotted hash notation, convert value to bool, int, float or extended value
|
|
92
96
|
# `true` and `yes` are converted to `true`, `false` and `no` to `false`
|
|
93
|
-
# @param value
|
|
97
|
+
# @param value [String] The value to convert to appropriate type
|
|
98
|
+
# @param context [String] Where the value comes from, for error messages
|
|
99
|
+
# @param allowed [Class, Array, nil] Types accepted for an extended value
|
|
94
100
|
# @return [Boolean, Integer, Float, String, Array, Hash] the converted value
|
|
95
|
-
def smart_convert(value)
|
|
101
|
+
def smart_convert(value, context: 'dotted expression', allowed: nil)
|
|
96
102
|
case value
|
|
97
103
|
when 'true', BoolValue::YES_SYM.to_s then true
|
|
98
104
|
when 'false', BoolValue::NO_SYM.to_s then false
|
|
99
105
|
else
|
|
100
106
|
Integer(value, 10, exception: false) ||
|
|
101
107
|
Float(value, exception: false) ||
|
|
102
|
-
ExtendedValue.instance.evaluate(value, context:
|
|
108
|
+
ExtendedValue.instance.evaluate(value, context: context, allowed: allowed)
|
|
103
109
|
end
|
|
104
110
|
end
|
|
105
111
|
end
|
|
@@ -146,10 +152,13 @@ module Aspera
|
|
|
146
152
|
# @param on_set [#call] Called with the new value each time the value is set (e.g. a `Method`, or a lambda).
|
|
147
153
|
# For a flag (`Type::NONE`): called without argument when the flag is found
|
|
148
154
|
# @param shorthand [String] For a `Hash` option: a `String` value is stored as `{shorthand => value}`
|
|
155
|
+
# @param convert [#call] For a `Hash` option: called with a new `Hash` value, returns the value to store, before merge (e.g. conversion of a deprecated form)
|
|
149
156
|
# @param deprecation [Hash, nil] deprecation: `{last:, message:}`, see `Deprecation`
|
|
150
157
|
# @param schema [String] schema path documenting the Hash form of this option
|
|
158
|
+
# @param complete [Symbol, nil] values proposed by shell completion, one of `Complete::KINDS`
|
|
159
|
+
# @param security [Symbol, nil] most restrictive security level at which the option is available, see `Security`
|
|
151
160
|
# @param block [Proc] Block to execute when option is found
|
|
152
|
-
def declare(option_symbol, description: nil, short: nil, allowed: nil, default: nil, on_set: nil, shorthand: nil, deprecation: nil, schema: nil, &block)
|
|
161
|
+
def declare(option_symbol, description: nil, short: nil, allowed: nil, default: nil, on_set: nil, shorthand: nil, convert: nil, deprecation: nil, schema: nil, complete: nil, security: nil, &block)
|
|
153
162
|
Aspera.assert_type(option_symbol, Symbol)
|
|
154
163
|
Aspera.assert(!@registry.declared?(option_symbol)) { "#{option_symbol} already declared" }
|
|
155
164
|
if on_set && allowed.eql?(Type::NONE)
|
|
@@ -170,8 +179,11 @@ module Aspera
|
|
|
170
179
|
allowed: allowed,
|
|
171
180
|
on_set: on_set,
|
|
172
181
|
shorthand: shorthand,
|
|
182
|
+
convert: convert,
|
|
173
183
|
deprecation: deprecation,
|
|
174
|
-
schema: schema
|
|
184
|
+
schema: schema,
|
|
185
|
+
complete: complete,
|
|
186
|
+
security: security
|
|
175
187
|
),
|
|
176
188
|
short: short
|
|
177
189
|
)
|
|
@@ -205,9 +217,9 @@ module Aspera
|
|
|
205
217
|
# @param validation [Class, Array, nil] Accepted value type(s) or list of Symbols
|
|
206
218
|
# @param aliases [Hash] map of aliases: key = alias, value = real value
|
|
207
219
|
# @param default [Object] default value
|
|
208
|
-
# @param
|
|
220
|
+
# @param evaluate [Symbol] `:extended`: extended value, `:smart`: also `true`, `yes`, `false`, `no` and numbers, `:none`: as typed
|
|
209
221
|
# @return [Object, Array, nil] one value, list or nil (if optional and no default)
|
|
210
|
-
def get_next_argument(descr, mandatory: true, multiple: false, accept_list: nil, validation: Type::STRING, aliases: nil, default: nil, schema: nil,
|
|
222
|
+
def get_next_argument(descr, mandatory: true, multiple: false, accept_list: nil, validation: Type::STRING, aliases: nil, default: nil, schema: nil, evaluate: :extended)
|
|
211
223
|
ensure_parsed
|
|
212
224
|
Aspera.assert_array_all(accept_list, Symbol) unless accept_list.nil?
|
|
213
225
|
Aspera.assert_hash_all(aliases, Symbol, Symbol) unless aliases.nil?
|
|
@@ -216,7 +228,7 @@ module Aspera
|
|
|
216
228
|
Aspera.assert_array_all(validation, Class) { 'validation' } unless validation.nil?
|
|
217
229
|
descr = "#{descr}#{add_types_info(validation)}"
|
|
218
230
|
result =
|
|
219
|
-
if !@command_line.pending_arguments.empty? then read_arguments(descr, multiple: multiple, validation: validation, accept_list: accept_list, aliases: aliases,
|
|
231
|
+
if !@command_line.pending_arguments.empty? then read_arguments(descr, multiple: multiple, validation: validation, accept_list: accept_list, aliases: aliases, evaluate: evaluate)
|
|
220
232
|
elsif !default.nil? then default
|
|
221
233
|
elsif mandatory then get_interactive(descr, multiple: multiple, accept_list: accept_list, aliases: aliases, schema: schema)
|
|
222
234
|
end
|
|
@@ -250,7 +262,11 @@ module Aspera
|
|
|
250
262
|
# @param command_list [Array<Symbol>] accepted command names
|
|
251
263
|
# @param aliases [Hash, nil] command aliases
|
|
252
264
|
# @return [Symbol] selected command
|
|
253
|
-
def get_next_command(command_list, aliases: nil)
|
|
265
|
+
def get_next_command(command_list, aliases: nil)
|
|
266
|
+
command = get_next_argument('command', accept_list: command_list, aliases: aliases)
|
|
267
|
+
@command_line.mark_command
|
|
268
|
+
command
|
|
269
|
+
end
|
|
254
270
|
|
|
255
271
|
# Check whether an option has already been declared in this manager
|
|
256
272
|
# @param option_symbol [Symbol] name of the option
|
|
@@ -363,8 +379,9 @@ module Aspera
|
|
|
363
379
|
end
|
|
364
380
|
|
|
365
381
|
# Check for unprocessed options or arguments error messages
|
|
382
|
+
# @param after_error [Boolean] `true` if an error was already reported: positional arguments are then not consumed because of this error, not reported
|
|
366
383
|
# @return [Array<String>] list of error messages for unprocessed tokens
|
|
367
|
-
def final_errors
|
|
384
|
+
def final_errors(after_error: false)
|
|
368
385
|
begin
|
|
369
386
|
ensure_parsed
|
|
370
387
|
rescue StandardError => e
|
|
@@ -373,17 +390,18 @@ module Aspera
|
|
|
373
390
|
end
|
|
374
391
|
result = []
|
|
375
392
|
result.push("unprocessed options: #{@command_line.pending_options}") unless @command_line.pending_options.empty?
|
|
376
|
-
result.push("unprocessed values: #{@command_line.pending_arguments}") unless @command_line.pending_arguments.empty?
|
|
393
|
+
result.push("unprocessed values: #{@command_line.pending_arguments}") unless after_error || @command_line.pending_arguments.empty?
|
|
377
394
|
result
|
|
378
395
|
end
|
|
379
396
|
|
|
380
|
-
# Get
|
|
397
|
+
# Get long options with a value from command line, used to generate a config in config file.
|
|
381
398
|
# They are marked as processed.
|
|
399
|
+
# @param after_command [Boolean] `true`: only options placed after the last command word
|
|
382
400
|
# @return [Hash] options with value, dotted notation expanded
|
|
383
|
-
def unprocessed_options_with_value
|
|
401
|
+
def unprocessed_options_with_value(after_command: false)
|
|
384
402
|
ensure_parsed
|
|
385
403
|
result = {}
|
|
386
|
-
@command_line.each_long_option_with_value do |tok|
|
|
404
|
+
@command_line.each_long_option_with_value(after_command: after_command) do |tok|
|
|
387
405
|
path = [tok.name, *tok.dot_path]
|
|
388
406
|
Log.log.debug { "option #{path.join(DotContainer::SEPARATOR)}=#{tok.value}" }
|
|
389
407
|
DotContainer.dotted_to_container(path, Parser.smart_convert(tok.value), result)
|
|
@@ -471,7 +489,7 @@ module Aspera
|
|
|
471
489
|
result = nil
|
|
472
490
|
@command_line.with_arguments_after_current_option do
|
|
473
491
|
get_next_argument('args', multiple: end_marker).each do |argument|
|
|
474
|
-
Aspera.assert(argument.include?(Option::VALUE_SEP)) { "
|
|
492
|
+
Aspera.assert(argument.include?(Option::VALUE_SEP), type: BadArgument) { "Argument collected by @: does not include #{Option::VALUE_SEP}: #{argument} (end marker: #{end_marker})" }
|
|
475
493
|
path, value = argument.split(Option::VALUE_SEP, 2)
|
|
476
494
|
result = DotContainer.dotted_to_container(path.split(DotContainer::SEPARATOR), Parser.smart_convert(value), result)
|
|
477
495
|
end
|
|
@@ -525,11 +543,17 @@ module Aspera
|
|
|
525
543
|
" (#{types.map(&:name).join(', ')})"
|
|
526
544
|
end
|
|
527
545
|
|
|
528
|
-
# Consume positional arguments, and evaluate them
|
|
546
|
+
# Consume positional arguments, and evaluate them as told by `evaluate`
|
|
529
547
|
# @return [Object, Array] one value, or list if `multiple`
|
|
530
|
-
def read_arguments(descr, multiple:, validation:, accept_list:, aliases:,
|
|
548
|
+
def read_arguments(descr, multiple:, validation:, accept_list:, aliases:, evaluate:)
|
|
531
549
|
values = @command_line.shift_arguments(multiple)
|
|
532
|
-
|
|
550
|
+
context = "argument: #{descr}"
|
|
551
|
+
case evaluate
|
|
552
|
+
when :extended then values = values.map { |v| ExtendedValue.instance.evaluate(v, context: context, allowed: validation) }
|
|
553
|
+
when :smart then values = values.map { |v| Parser.smart_convert(v, context: context, allowed: validation) }
|
|
554
|
+
when :none then nil
|
|
555
|
+
else Aspera.error_unexpected_value(evaluate)
|
|
556
|
+
end
|
|
533
557
|
# If expecting list and only one arg of type array : it is the list
|
|
534
558
|
values = values.first if multiple && values.length.eql?(1) && values.first.is_a?(Array)
|
|
535
559
|
if accept_list
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../../assert'
|
|
7
|
+
require_relative '../../api/alee'
|
|
8
|
+
require_relative '../../nagios'
|
|
9
|
+
require_relative 'basic_auth'
|
|
7
10
|
|
|
8
11
|
module Aspera
|
|
9
12
|
module Cli
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
|
|
6
|
+
require_relative '../../schema/registry'
|
|
7
|
+
require_relative 'oauth'
|
|
8
|
+
require_relative 'node'
|
|
9
|
+
require_relative 'ats'
|
|
10
|
+
require_relative '../transfer_agent'
|
|
11
|
+
require_relative '../special_values'
|
|
12
|
+
require_relative '../../environment'
|
|
13
|
+
require_relative '../wizard'
|
|
14
|
+
require_relative '../../agent/node'
|
|
15
|
+
require_relative '../../transfer/result'
|
|
16
|
+
require_relative '../../transfer/spec'
|
|
17
|
+
require_relative '../../api/aoc'
|
|
18
|
+
require_relative '../../api/node'
|
|
19
|
+
require_relative '../../persistency_action_once'
|
|
20
|
+
require_relative '../../id_generator'
|
|
21
|
+
require_relative '../../assert'
|
|
22
|
+
require_relative '../../graphql'
|
|
23
|
+
require_relative '../../rainbow'
|
|
20
24
|
require 'securerandom'
|
|
21
25
|
require 'date'
|
|
22
|
-
require 'aspera/rainbow'
|
|
23
26
|
using Rainbow
|
|
24
27
|
|
|
25
28
|
module Aspera
|
|
@@ -104,17 +107,19 @@ module Aspera
|
|
|
104
107
|
# @param package_info [Hash] Package information
|
|
105
108
|
# @param destination_folder [String] Base folder
|
|
106
109
|
# @param fld [Array] List of fields of package
|
|
110
|
+
# @return [String] Folder path in destination folder
|
|
107
111
|
def unique_folder(package_info, destination_folder, fld: nil, seq: false, opt: false)
|
|
108
112
|
Aspera.assert_array_all(fld, String, type: BadArgument) { 'fld' }
|
|
109
113
|
Aspera.assert_values(fld.length, [1, 2]) { 'fld length' }
|
|
110
|
-
|
|
114
|
+
# Existence is checked in the destination folder
|
|
115
|
+
folder = File.join(destination_folder, Environment.instance.sanitized_filename(package_info[fld[0]].to_s))
|
|
111
116
|
if seq
|
|
112
117
|
folder = next_available_folder(folder, always: !opt)
|
|
113
118
|
elsif fld[1] && (Dir.exist?(folder) || !opt)
|
|
114
119
|
# NOTE: it might already exist
|
|
115
|
-
folder = "#{folder}.#{Environment.instance.sanitized_filename(fld[1])}"
|
|
120
|
+
folder = "#{folder}.#{Environment.instance.sanitized_filename(package_info[fld[1]].to_s)}"
|
|
116
121
|
end
|
|
117
|
-
|
|
122
|
+
folder
|
|
118
123
|
end
|
|
119
124
|
|
|
120
125
|
# @return [String] AoC REST path for an admin resource type
|
|
@@ -212,7 +217,7 @@ module Aspera
|
|
|
212
217
|
auto_set_jwt = false
|
|
213
218
|
# use browser authentication to bootstrap
|
|
214
219
|
use_browser_authentication = false
|
|
215
|
-
|
|
220
|
+
private_key = wizard.ask_private_key(
|
|
216
221
|
user: wiz_username,
|
|
217
222
|
url: app_url,
|
|
218
223
|
page: [Environment.char('👤'), 'Account Settings', 'Profile', 'Public Key']
|
|
@@ -236,8 +241,8 @@ module Aspera
|
|
|
236
241
|
formatter.display_status('- origin: localhost')
|
|
237
242
|
formatter.display_status('Use the generated client id and secret in the following prompts.'.red)
|
|
238
243
|
Environment.instance.open_uri("#{app_url}/admin/integrations/api-clients")
|
|
239
|
-
client_id = options.get_option(:client_id, mandatory:
|
|
240
|
-
client_secret = options.get_option(:client_secret, mandatory:
|
|
244
|
+
client_id = options.get_option(:client_id, mandatory: wizard.required)
|
|
245
|
+
client_secret = options.get_option(:client_secret, mandatory: wizard.required)
|
|
241
246
|
# use_browser_authentication = true
|
|
242
247
|
end
|
|
243
248
|
end
|
|
@@ -252,7 +257,7 @@ module Aspera
|
|
|
252
257
|
end
|
|
253
258
|
myself = aoc_api.read('self')
|
|
254
259
|
if auto_set_pub_key
|
|
255
|
-
Aspera.assert(myself['public_key'].empty?, 'Public key is already set in profile (use
|
|
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
261
|
formatter.display_status('Updating profile with the public key.')
|
|
257
262
|
aoc_api.update("users/#{myself['id']}", {'public_key' => pub_key_pem})
|
|
258
263
|
end
|
|
@@ -266,7 +271,7 @@ module Aspera
|
|
|
266
271
|
url: app_url,
|
|
267
272
|
username: myself['email'],
|
|
268
273
|
auth: :jwt.to_s,
|
|
269
|
-
private_key:
|
|
274
|
+
private_key: private_key,
|
|
270
275
|
client_id: client_id,
|
|
271
276
|
client_secret: client_secret
|
|
272
277
|
}.compact,
|
|
@@ -806,7 +811,7 @@ module Aspera
|
|
|
806
811
|
)
|
|
807
812
|
command :create, description: 'Create an app membership', arguments: [{name: :membership, type: Hash}]
|
|
808
813
|
end
|
|
809
|
-
command :automation, description: 'Manage automation
|
|
814
|
+
command :automation, description: 'Manage automation'
|
|
810
815
|
command :gateway, description: 'Start AoC Faspex4 gateway',
|
|
811
816
|
arguments: [{name: :parameters, type: Hash, mandatory: false, default: {}, schema: Schema::Registry::GATEWAY_OPTIONS}]
|
|
812
817
|
|
|
@@ -933,9 +938,41 @@ module Aspera
|
|
|
933
938
|
# Automation API: a workflow has ordered steps (step_order), a step has ordered actions (action_order)
|
|
934
939
|
AUTOMATION_CRUD = {api: :@automation_api, body_component: Schema::Registry::AUTOMATION}.freeze
|
|
935
940
|
private_constant :AUTOMATION_CRUD
|
|
941
|
+
AOC_AUTOMATION_GUIDE_URLS = [
|
|
942
|
+
'https://raw.githubusercontent.com/laurent-martin/aspera-orchestrator-plugins-doc/main/docs/aoc/aoc-automation-development-guide.md'
|
|
943
|
+
].freeze
|
|
936
944
|
commands_under :automation do
|
|
945
|
+
command :guide, description: 'AoC Automation Development Guide (from GitHub, no AoC connection needed)'
|
|
946
|
+
command :workflows, description: 'Manage workflows', setup: :setup_automation_api
|
|
947
|
+
command :instances, description: 'Manage workflow instances (jobs)', setup: :setup_automation_api
|
|
948
|
+
command :steps, description: 'Manage workflow steps', setup: :setup_automation_api
|
|
949
|
+
command :actions, description: 'Manage workflow actions', setup: :setup_automation_api
|
|
950
|
+
|
|
951
|
+
commands_under :guide do
|
|
952
|
+
command :toc, description: 'List sections of the AoC Automation Development Guide: level, title, anchor',
|
|
953
|
+
arguments: [{name: :level, type: Integer, mandatory: false, default: 3}],
|
|
954
|
+
action: ->(level: 3, **) { automation_guide_toc(level) }
|
|
955
|
+
command :full, description: 'Display the whole AoC Automation Development Guide',
|
|
956
|
+
action: ->(**) { Result::Text.new(automation_guide_document) }
|
|
957
|
+
command :section, description: 'Display one section of the guide (anchor given by `toc`)',
|
|
958
|
+
arguments: [{name: :anchor, type: String}],
|
|
959
|
+
action: ->(anchor:, **) { automation_guide_section(anchor) }
|
|
960
|
+
end
|
|
937
961
|
commands_under :workflows do
|
|
938
962
|
crud_commands(**AUTOMATION_CRUD, entity: 'workflows', items_key: 'workflows', query_component: Schema::Registry::AUTOMATION)
|
|
963
|
+
command :details, description: 'Get full workflow structure with all steps and actions',
|
|
964
|
+
arguments: [{name: :workflow_id, type: :identifier}],
|
|
965
|
+
action: ->(workflow_id:, **) { Result::SingleObject.new(workflow_details(workflow_id)) }
|
|
966
|
+
command :export, description: 'Export workflow definition to a portable structure',
|
|
967
|
+
arguments: [{name: :workflow_id, type: :identifier}],
|
|
968
|
+
action: ->(workflow_id:, **) { Result::SingleObject.new(workflow_export_data(workflow_id)) }
|
|
969
|
+
command :import, description: 'Import workflow definition and create steps and actions',
|
|
970
|
+
arguments: [{name: :workflow, type: Hash, description: 'Workflow structure with steps and actions'}],
|
|
971
|
+
action: ->(workflow:, **) { Result::SingleObject.new(workflow_import_data(workflow)) }
|
|
972
|
+
command :duplicate, description: 'Duplicate workflow and all its steps and actions',
|
|
973
|
+
arguments: [{name: :workflow_id, type: :identifier},
|
|
974
|
+
{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)) }
|
|
939
976
|
command :launch, description: 'Launch a workflow',
|
|
940
977
|
arguments: [{name: :workflow_id, type: :identifier}],
|
|
941
978
|
action: ->(workflow_id:, **) { Result::SingleObject.new(@automation_api.create("workflows/#{workflow_id}/launch", {})) }
|
|
@@ -994,9 +1031,12 @@ module Aspera
|
|
|
994
1031
|
end
|
|
995
1032
|
commands_under :instances do
|
|
996
1033
|
crud_commands(
|
|
997
|
-
**AUTOMATION_CRUD, entity: 'workflow_instances', name: 'workflow instance', operations: %i[list
|
|
1034
|
+
**AUTOMATION_CRUD, entity: 'workflow_instances', name: 'workflow instance', operations: %i[list delete],
|
|
998
1035
|
items_key: 'workflow_instances', query_component: Schema::Registry::AUTOMATION
|
|
999
1036
|
)
|
|
1037
|
+
command :show, description: 'Show a workflow instance (job), by identifier or by UUID',
|
|
1038
|
+
arguments: [{name: :workflow_instance_id, type: :identifier}],
|
|
1039
|
+
action: ->(workflow_instance_id:, **) { Result::SingleObject.new(workflow_instance_find(workflow_instance_id)) }
|
|
1000
1040
|
command :cancel, description: 'Cancel workflow instance',
|
|
1001
1041
|
arguments: [{name: :workflow_instance_id, type: :identifier}],
|
|
1002
1042
|
action: ->(workflow_instance_id:, **) { Result::SingleObject.new(@automation_api.update("workflow_instances/#{workflow_instance_id}", {'status' => 'canceled'})) }
|
|
@@ -1025,7 +1065,6 @@ module Aspera
|
|
|
1025
1065
|
# Build automation API and store in @automation_api ivar.
|
|
1026
1066
|
def setup_automation_api(**)
|
|
1027
1067
|
change_api_scope(Api::AoC::Scope::ADMIN_USER)
|
|
1028
|
-
Log.log.warn('BETA: work under progress')
|
|
1029
1068
|
@automation_api = Rest::Client.new(**aoc_api.params, base_url: aoc_api.base_url.gsub('/api/', '/automation/'))
|
|
1030
1069
|
{}
|
|
1031
1070
|
end
|
|
@@ -1053,7 +1092,7 @@ module Aspera
|
|
|
1053
1092
|
end
|
|
1054
1093
|
package_data['encryption_at_rest'] = true if transfer.user_transfer_spec['content_protection'].eql?('encrypt')
|
|
1055
1094
|
created_package = aoc_api.create_package_simple(package_data, option_validate, new_user_option)
|
|
1056
|
-
return Runner.result_object_transfer(created_package[:info], transfer.start(created_package[:spec],
|
|
1095
|
+
return Runner.result_object_transfer(created_package[:info], transfer.start(created_package[:spec], oauth_api: created_package[:node]))
|
|
1057
1096
|
end
|
|
1058
1097
|
|
|
1059
1098
|
# packages > receive — package_id: from arguments:(:identifier) (or overridden by public_link)
|
|
@@ -1079,7 +1118,8 @@ module Aspera
|
|
|
1079
1118
|
ids_to_download = all_packages[:items].map { |e| e['id'] }
|
|
1080
1119
|
formatter.display_status("Found #{ids_to_download.length} package(s).")
|
|
1081
1120
|
else
|
|
1082
|
-
ids_to_download =
|
|
1121
|
+
ids_to_download = Array(ids_to_download)
|
|
1122
|
+
Aspera.assert_array_all(ids_to_download, String) { 'Package id(s)' }
|
|
1083
1123
|
end
|
|
1084
1124
|
ts_paths = transfer.ts_source_paths(default: ['.'])
|
|
1085
1125
|
per_package_def = options.get_option(:package_folder).symbolize_keys
|
|
@@ -1101,7 +1141,7 @@ module Aspera
|
|
|
1101
1141
|
transfer.user_transfer_spec['destination_root'] = self.class.unique_folder(package_info, destination_folder, **per_package_def) unless per_package_def.empty?
|
|
1102
1142
|
dest_folder = transfer.user_transfer_spec['destination_root'] || destination_folder
|
|
1103
1143
|
formatter.display_status(%Q{Downloading package: [#{package_info['id']}] "#{package_info['name']}" to [#{dest_folder}]})
|
|
1104
|
-
statuses = transfer.start(transfer_spec,
|
|
1144
|
+
statuses = transfer.start(transfer_spec, oauth_api: package_node_api)
|
|
1105
1145
|
File.write(File.join(dest_folder, "#{package_id}.info.json"), package_info.to_json) if save_metadata
|
|
1106
1146
|
result_transfer.push({'package' => package_id, Runner::STATUS_FIELD => statuses})
|
|
1107
1147
|
if skip_ids_persistency && statuses.is_a?(Transfer::Result::Success)
|
|
@@ -1507,6 +1547,174 @@ module Aspera
|
|
|
1507
1547
|
Result::SingleObject.new(new_action)
|
|
1508
1548
|
end
|
|
1509
1549
|
|
|
1550
|
+
# automation helper methods
|
|
1551
|
+
|
|
1552
|
+
# Get one job. `GET workflow_instances/<id>` does not answer on the server (the job is searched without an index on `instance_id`),
|
|
1553
|
+
# so use the list, which does. The search string `q` matches the UUID (`instance_id`) but not the numeric identifier:
|
|
1554
|
+
# in this case, browse the list.
|
|
1555
|
+
# @param instance_id [String] Numeric identifier or UUID of the job
|
|
1556
|
+
# @return [Hash] The job
|
|
1557
|
+
def workflow_instance_find(instance_id)
|
|
1558
|
+
instance_id = instance_id.to_s
|
|
1559
|
+
is_uuid = instance_id.include?('-')
|
|
1560
|
+
limit = 1000
|
|
1561
|
+
offset = 0
|
|
1562
|
+
loop do
|
|
1563
|
+
query = {'limit' => limit, 'offset' => offset, 'sort' => '-state_change_time'}
|
|
1564
|
+
query['q'] = instance_id if is_uuid
|
|
1565
|
+
page = @automation_api.read('workflow_instances', query)
|
|
1566
|
+
found = page['workflow_instances'].find { |job| job[is_uuid ? 'instance_id' : 'id'].eql?(instance_id) }
|
|
1567
|
+
return found unless found.nil?
|
|
1568
|
+
offset += limit
|
|
1569
|
+
raise BadIdentifier.new('Workflow instance', instance_id) if is_uuid || offset >= page['total_count'].to_i
|
|
1570
|
+
end
|
|
1571
|
+
end
|
|
1572
|
+
|
|
1573
|
+
def workflow_details(workflow_id)
|
|
1574
|
+
workflow = @automation_api.read("workflows/#{workflow_id}")
|
|
1575
|
+
steps = Array(workflow['step_order']).map do |step_id|
|
|
1576
|
+
step = @automation_api.read("steps/#{step_id}")
|
|
1577
|
+
actions = Array(step['action_order']).map { |action_id| @automation_api.read("actions/#{action_id}") }
|
|
1578
|
+
step.merge('actions' => actions)
|
|
1579
|
+
end
|
|
1580
|
+
workflow.merge('steps' => steps)
|
|
1581
|
+
end
|
|
1582
|
+
|
|
1583
|
+
def workflow_export_data(workflow_id)
|
|
1584
|
+
wf = workflow_details(workflow_id)
|
|
1585
|
+
portable_steps = Array(wf['steps']).each_with_index.map do |step, step_idx|
|
|
1586
|
+
portable_actions = Array(step['actions']).each_with_index.map do |action, act_idx|
|
|
1587
|
+
action_data = action.dup
|
|
1588
|
+
orig_action_id = action_data.delete('id')
|
|
1589
|
+
action_data.delete('step_id')
|
|
1590
|
+
action_data.delete('created_at')
|
|
1591
|
+
action_data.delete('updated_at')
|
|
1592
|
+
action_data.delete('user_id')
|
|
1593
|
+
action_data.delete('organization_id')
|
|
1594
|
+
{
|
|
1595
|
+
'ref_id' => orig_action_id || "action_#{step_idx + 1}_#{act_idx + 1}",
|
|
1596
|
+
'name' => action_data['name'],
|
|
1597
|
+
'type' => action_data['type'],
|
|
1598
|
+
'data' => action_data['data']
|
|
1599
|
+
}.compact
|
|
1600
|
+
end
|
|
1601
|
+
orig_step_id = step['id']
|
|
1602
|
+
{
|
|
1603
|
+
'ref_id' => orig_step_id || "step_#{step_idx + 1}",
|
|
1604
|
+
'name' => step['name'],
|
|
1605
|
+
'actions' => portable_actions
|
|
1606
|
+
}.compact
|
|
1607
|
+
end
|
|
1608
|
+
{
|
|
1609
|
+
'name' => wf['name'],
|
|
1610
|
+
'trigger_type' => wf['trigger_type'] || 'manual',
|
|
1611
|
+
'allow_notifications' => wf['allow_notifications'] || false,
|
|
1612
|
+
'workflow_notifications' => wf['workflow_notifications'] || {},
|
|
1613
|
+
'steps' => portable_steps
|
|
1614
|
+
}
|
|
1615
|
+
end
|
|
1616
|
+
|
|
1617
|
+
def workflow_import_data(manifest)
|
|
1618
|
+
raise Cli::BadArgument, 'Manifest must be a Hash' unless manifest.is_a?(Hash)
|
|
1619
|
+
wf_params = {
|
|
1620
|
+
'name' => manifest['name'] || 'Imported Workflow',
|
|
1621
|
+
'trigger_type' => manifest['trigger_type'] || 'manual',
|
|
1622
|
+
'allow_notifications' => manifest['allow_notifications'] || false,
|
|
1623
|
+
'workflow_notifications' => manifest['workflow_notifications'] || {}
|
|
1624
|
+
}
|
|
1625
|
+
new_wf = @automation_api.create('workflows', wf_params)
|
|
1626
|
+
wf_id = new_wf['id']
|
|
1627
|
+
|
|
1628
|
+
step_id_map = {}
|
|
1629
|
+
action_id_map = {}
|
|
1630
|
+
created_step_ids = []
|
|
1631
|
+
|
|
1632
|
+
begin
|
|
1633
|
+
Array(manifest['steps']).each_with_index do |step_data, s_idx|
|
|
1634
|
+
step_name = step_data['name'] || "Step #{s_idx + 1}"
|
|
1635
|
+
old_step_ref = step_data['ref_id'] || step_data['id'] || "step_#{s_idx + 1}"
|
|
1636
|
+
new_step = @automation_api.create('steps', {'workflow_id' => wf_id, 'name' => step_name})
|
|
1637
|
+
new_step_id = new_step['id']
|
|
1638
|
+
step_id_map[old_step_ref] = new_step_id
|
|
1639
|
+
created_step_ids << new_step_id
|
|
1640
|
+
# The API refuses an action whose step is not yet in the workflow
|
|
1641
|
+
@automation_api.update("workflows/#{wf_id}", {'step_order' => created_step_ids})
|
|
1642
|
+
|
|
1643
|
+
created_action_ids = []
|
|
1644
|
+
Array(step_data['actions']).each_with_index do |action_data, a_idx|
|
|
1645
|
+
old_action_ref = action_data['ref_id'] || action_data['id'] || "action_#{s_idx + 1}_#{a_idx + 1}"
|
|
1646
|
+
action_payload = {
|
|
1647
|
+
'step_id' => new_step_id,
|
|
1648
|
+
'name' => action_data['name'] || (s_idx.zero? && a_idx.zero? ? 'Trigger' : "Action #{a_idx + 1}"),
|
|
1649
|
+
'type' => action_data['type'] || 'manual',
|
|
1650
|
+
'data' => remap_references(action_data['data'] || {}, step_id_map, action_id_map)
|
|
1651
|
+
}
|
|
1652
|
+
new_act = @automation_api.create('actions', action_payload)
|
|
1653
|
+
new_act_id = new_act['id']
|
|
1654
|
+
action_id_map[old_action_ref] = new_act_id
|
|
1655
|
+
created_action_ids << new_act_id
|
|
1656
|
+
end
|
|
1657
|
+
@automation_api.update("steps/#{new_step_id}", {'action_order' => created_action_ids})
|
|
1658
|
+
end
|
|
1659
|
+
rescue StandardError
|
|
1660
|
+
# do not leave a partial workflow behind
|
|
1661
|
+
begin
|
|
1662
|
+
@automation_api.delete("workflows/#{wf_id}")
|
|
1663
|
+
rescue StandardError => e
|
|
1664
|
+
Log.log.warn { "Could not delete partial workflow #{wf_id}: #{e.message}" }
|
|
1665
|
+
end
|
|
1666
|
+
raise
|
|
1667
|
+
end
|
|
1668
|
+
|
|
1669
|
+
workflow_details(wf_id)
|
|
1670
|
+
end
|
|
1671
|
+
|
|
1672
|
+
# The copy is made by the server: the API does not return secrets (tokens, passwords), so an export/import would lose them.
|
|
1673
|
+
def workflow_duplicate(workflow_id, new_name: nil)
|
|
1674
|
+
new_name ||= @automation_api.read("workflows/#{workflow_id}/default_copy_name")['default_copy_name']
|
|
1675
|
+
@automation_api.create("workflows/#{workflow_id}/copy", {'name' => new_name})
|
|
1676
|
+
end
|
|
1677
|
+
|
|
1678
|
+
# Reference to an action output in a string: step_id_<STEP>.action_id_<ACTION>
|
|
1679
|
+
ACTION_OUTPUT_REFERENCE = /step_id_((?>[^.\s{}"']{1,256}))\.action_id_((?>[^.\s{}"']{1,256}))/
|
|
1680
|
+
private_constant :ACTION_OUTPUT_REFERENCE
|
|
1681
|
+
|
|
1682
|
+
# Replace the step and action identifiers of the manifest by the new ones, in all strings of `data`
|
|
1683
|
+
# (action fields as well as `substitutions[].template`).
|
|
1684
|
+
# One pass only: an identifier that was just replaced must not be replaced again.
|
|
1685
|
+
# @param data [Object] Hash, Array, or scalar to copy
|
|
1686
|
+
# @param step_map [Hash] manifest step reference => new step id
|
|
1687
|
+
# @param action_map [Hash] manifest action reference => new action id
|
|
1688
|
+
# @return [Object] copy of `data`
|
|
1689
|
+
def remap_references(data, step_map, action_map)
|
|
1690
|
+
case data
|
|
1691
|
+
when Hash then data.transform_values { |v| remap_references(v, step_map, action_map) }
|
|
1692
|
+
when Array then data.map { |v| remap_references(v, step_map, action_map) }
|
|
1693
|
+
when String
|
|
1694
|
+
data.gsub(ACTION_OUTPUT_REFERENCE) { "step_id_#{step_map.fetch(Regexp.last_match(1), Regexp.last_match(1))}.action_id_#{action_map.fetch(Regexp.last_match(2), Regexp.last_match(2))}" }
|
|
1695
|
+
else data
|
|
1696
|
+
end
|
|
1697
|
+
end
|
|
1698
|
+
|
|
1699
|
+
# automation guide methods
|
|
1700
|
+
|
|
1701
|
+
def automation_guide_document
|
|
1702
|
+
require_relative '../../uri_reader'
|
|
1703
|
+
UriReader.read_first(AOC_AUTOMATION_GUIDE_URLS, what: 'AoC Automation Development Guide')
|
|
1704
|
+
end
|
|
1705
|
+
|
|
1706
|
+
def automation_guide_toc(level)
|
|
1707
|
+
require_relative '../../markdown'
|
|
1708
|
+
Result::ObjectList.new(Markdown.toc(automation_guide_document, max_level: level || 3), fields: %w[level title anchor])
|
|
1709
|
+
end
|
|
1710
|
+
|
|
1711
|
+
def automation_guide_section(anchor)
|
|
1712
|
+
require_relative '../../markdown'
|
|
1713
|
+
text = Markdown.extract_section(automation_guide_document, anchor)
|
|
1714
|
+
Aspera.assert(!text.nil?, type: Cli::Error) { "Section not found: #{anchor}, use `toc` to list anchors" }
|
|
1715
|
+
Result::Text.new(text)
|
|
1716
|
+
end
|
|
1717
|
+
|
|
1510
1718
|
# admin > client > set_pub_key
|
|
1511
1719
|
def action_admin_client_set_pub_key(private_key_pem:, client_id:, **)
|
|
1512
1720
|
c = aoc_res_cfg(:client)
|
|
@@ -1585,9 +1793,10 @@ module Aspera
|
|
|
1585
1793
|
if Api::AoC.workspace_access?(item)
|
|
1586
1794
|
{'name' => '[Internal permission]'}
|
|
1587
1795
|
else
|
|
1588
|
-
aoc_api.read("admin/#{item['access_type']}s/#{item['access_id']}")
|
|
1796
|
+
aoc_api.read("admin/#{item['access_type']}s/#{item['access_id']}")
|
|
1589
1797
|
end
|
|
1590
|
-
rescue => e
|
|
1798
|
+
rescue StandardError => e
|
|
1799
|
+
# e.g. member deleted: the error is shown instead of the name
|
|
1591
1800
|
{'name' => e.to_s}
|
|
1592
1801
|
end
|
|
1593
1802
|
end
|
|
@@ -1609,7 +1818,7 @@ module Aspera
|
|
|
1609
1818
|
end
|
|
1610
1819
|
|
|
1611
1820
|
def action_gateway(parameters: {}, **)
|
|
1612
|
-
|
|
1821
|
+
require_relative '../../faspex_gw'
|
|
1613
1822
|
Faspex4GWServlet.serve(parameters.symbolize_keys, type: Cli::BadArgument) { [aoc_api, aoc_api.workspace_info[:id]] }
|
|
1614
1823
|
return Result::Status.new('Gateway terminated')
|
|
1615
1824
|
end
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# SPDX-FileCopyrightText: IBM Corp.
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
require_relative 'base'
|
|
7
|
+
require_relative 'node'
|
|
8
|
+
require_relative '../../api/ats'
|
|
9
|
+
require_relative '../../api/aoc'
|
|
10
|
+
require_relative '../../api/alee'
|
|
11
|
+
require_relative '../../assert'
|
|
12
|
+
require_relative '../../rainbow'
|
|
12
13
|
using Rainbow
|
|
13
14
|
|
|
14
15
|
module Aspera
|