aspera-cli 4.26.1 → 4.26.2
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/CHANGELOG.md +19 -1
- data/CONTRIBUTING.md +2 -5
- data/bin/ascli +2 -2
- data/lib/aspera/agent/direct.rb +1 -1
- data/lib/aspera/agent/factory.rb +4 -0
- data/lib/aspera/agent/httpgw.rb +1 -1
- data/lib/aspera/agent/node.rb +2 -2
- data/lib/aspera/api/aoc.rb +43 -36
- data/lib/aspera/api/cos_node.rb +1 -1
- data/lib/aspera/api/faspex.rb +7 -6
- data/lib/aspera/api/node.rb +7 -7
- data/lib/aspera/ascmd.rb +4 -4
- data/lib/aspera/ascp/installation.rb +6 -2
- data/lib/aspera/cli/context.rb +58 -0
- data/lib/aspera/cli/extended_value.rb +3 -2
- data/lib/aspera/cli/formatter.rb +83 -184
- data/lib/aspera/cli/http.rb +167 -0
- data/lib/aspera/cli/manager.rb +3 -2
- data/lib/aspera/cli/plugins/alee.rb +2 -2
- data/lib/aspera/cli/plugins/aoc.rb +78 -67
- data/lib/aspera/cli/plugins/ats.rb +16 -16
- data/lib/aspera/cli/plugins/base.rb +18 -12
- data/lib/aspera/cli/plugins/config.rb +166 -438
- data/lib/aspera/cli/plugins/console.rb +7 -7
- data/lib/aspera/cli/plugins/cos.rb +2 -2
- data/lib/aspera/cli/plugins/factory.rb +3 -0
- data/lib/aspera/cli/plugins/faspex.rb +21 -21
- data/lib/aspera/cli/plugins/faspex5.rb +64 -44
- data/lib/aspera/cli/plugins/faspio.rb +1 -1
- data/lib/aspera/cli/plugins/httpgw.rb +2 -2
- data/lib/aspera/cli/plugins/node.rb +79 -79
- data/lib/aspera/cli/plugins/orchestrator.rb +21 -26
- data/lib/aspera/cli/plugins/preview.rb +9 -9
- data/lib/aspera/cli/plugins/server.rb +7 -7
- data/lib/aspera/cli/plugins/shares.rb +2 -2
- data/lib/aspera/cli/preset_manager.rb +235 -0
- data/lib/aspera/cli/result.rb +310 -0
- data/lib/aspera/cli/{main.rb → runner.rb} +14 -155
- data/lib/aspera/cli/sync_actions.rb +14 -10
- data/lib/aspera/cli/terminal_formatter.rb +65 -0
- data/lib/aspera/cli/transfer_progress.rb +6 -6
- data/lib/aspera/cli/version.rb +1 -1
- data/lib/aspera/cli/wizard.rb +5 -6
- data/lib/aspera/command_line_builder.rb +1 -1
- data/lib/aspera/data_repository.rb +4 -0
- data/lib/aspera/dot_container.rb +1 -1
- data/lib/aspera/environment.rb +22 -3
- data/lib/aspera/faspex_gw.rb +1 -1
- data/lib/aspera/json_rpc.rb +6 -5
- data/lib/aspera/keychain/base.rb +1 -1
- data/lib/aspera/keychain/encrypted_hash.rb +1 -1
- data/lib/aspera/keychain/factory.rb +1 -1
- data/lib/aspera/keychain/macos_security.rb +1 -1
- data/lib/aspera/log.rb +6 -2
- data/lib/aspera/nagios.rb +2 -2
- data/lib/aspera/oauth/base.rb +5 -5
- data/lib/aspera/oauth/boot.rb +43 -0
- data/lib/aspera/oauth/factory.rb +37 -13
- data/lib/aspera/oauth/web.rb +2 -2
- data/lib/aspera/oauth.rb +1 -0
- data/lib/aspera/persistency_action_once.rb +2 -2
- data/lib/aspera/preview/file_types.rb +4 -0
- data/lib/aspera/products/connect.rb +3 -0
- data/lib/aspera/products/transferd.rb +2 -2
- data/lib/aspera/proxy_auto_config.rb +3 -3
- data/lib/aspera/rest.rb +8 -4
- data/lib/aspera/rest_error_analyzer.rb +4 -0
- data/lib/aspera/rest_list.rb +10 -3
- data/lib/aspera/schema/IBM Aspera Faspex API-5.0-enhanced.yaml +14 -4
- data/lib/aspera/schema/IBM Aspera on Cloud API-0.2.6-enhanced.yaml +827 -88
- data/lib/aspera/schema/async_tables.yaml +361 -0
- data/lib/aspera/schema/reader.rb +1 -1
- data/lib/aspera/schema/registry.rb +13 -6
- data/lib/aspera/secret_hider.rb +4 -0
- data/lib/aspera/sync/database.rb +14 -10
- data/lib/aspera/sync/operations.rb +5 -5
- data/lib/aspera/temp_file_manager.rb +4 -0
- data/lib/aspera/transfer/parameters.rb +4 -4
- data/lib/aspera/transfer/resumer.rb +1 -1
- data/lib/aspera/transfer/spec.schema.yaml +17 -8
- data/lib/aspera/transfer/uri.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +21 -14
- metadata.gz.sig +0 -0
|
@@ -97,7 +97,7 @@ module Aspera
|
|
|
97
97
|
rescue StandardError => e
|
|
98
98
|
nagios.add_critical('console api', e.to_s)
|
|
99
99
|
end
|
|
100
|
-
|
|
100
|
+
Result::ObjectList.new(nagios.status_list)
|
|
101
101
|
when :transfer
|
|
102
102
|
command = options.get_next_command(%i[current smart])
|
|
103
103
|
case command
|
|
@@ -105,11 +105,11 @@ module Aspera
|
|
|
105
105
|
command = options.get_next_command(%i[list submit])
|
|
106
106
|
case command
|
|
107
107
|
when :list
|
|
108
|
-
return
|
|
108
|
+
return Result::ObjectList.new(api_console.read('smart_transfers'))
|
|
109
109
|
when :submit
|
|
110
110
|
smart_id = options.get_next_argument('smart_id')
|
|
111
111
|
params = options.get_next_argument('transfer parameters', validation: Hash)
|
|
112
|
-
return
|
|
112
|
+
return Result::ObjectList.new(api_console.create("smart_transfers/#{smart_id}", params))
|
|
113
113
|
end
|
|
114
114
|
when :current
|
|
115
115
|
command = options.get_next_command(%i[list show files start pause cancel resume rerun change_rate change_policy move_forwards move_back])
|
|
@@ -125,21 +125,21 @@ module Aspera
|
|
|
125
125
|
if (filter = query.delete('filter'))
|
|
126
126
|
parse_extended_filter(filter, query)
|
|
127
127
|
end
|
|
128
|
-
return
|
|
128
|
+
return Result::ObjectList.new(
|
|
129
129
|
api_console.read('transfers', query),
|
|
130
130
|
fields: %w[id contact name status]
|
|
131
131
|
)
|
|
132
132
|
when :show
|
|
133
133
|
transfer_id = options.instance_identifier(description: 'transfer ID')
|
|
134
|
-
return
|
|
134
|
+
return Result::SingleObject.new(api_console.read("transfers/#{transfer_id}"))
|
|
135
135
|
when :files
|
|
136
136
|
transfer_id = options.instance_identifier(description: 'transfer ID')
|
|
137
137
|
query = query_read_delete(default: {})
|
|
138
138
|
query['limit'] ||= 100
|
|
139
|
-
return
|
|
139
|
+
return Result::ObjectList.new(api_console.read("transfers/#{transfer_id}/files", query))
|
|
140
140
|
when :start, :pause, :cancel, :resume, :rerun, :change_rate, :change_policy, :move_forwards, :move_back
|
|
141
141
|
transfer_id = options.instance_identifier(description: 'transfer ID')
|
|
142
|
-
return
|
|
142
|
+
return Result::SingleObject.new(api_console.update("transfers/#{transfer_id}/#{command}", query_read_delete))
|
|
143
143
|
end
|
|
144
144
|
end
|
|
145
145
|
end
|
|
@@ -36,11 +36,11 @@ module Aspera
|
|
|
36
36
|
endpoint: options.get_option(:endpoint)
|
|
37
37
|
}
|
|
38
38
|
if service_credentials.nil?
|
|
39
|
-
Aspera.assert(!cos_node_params[:endpoint].nil?,
|
|
39
|
+
Aspera.assert(!cos_node_params[:endpoint].nil?, 'endpoint required when service credentials not provided', type: Cli::BadArgument)
|
|
40
40
|
cos_node_params[:api_key] = options.get_option(:apikey, mandatory: true)
|
|
41
41
|
cos_node_params[:instance_id] = options.get_option(:crn, mandatory: true)
|
|
42
42
|
else
|
|
43
|
-
Aspera.assert(cos_node_params[:endpoint].nil?,
|
|
43
|
+
Aspera.assert(cos_node_params[:endpoint].nil?, 'endpoint not allowed when service credentials provided', type: Cli::BadArgument)
|
|
44
44
|
cos_node_params.merge!(Api::CosNode.parameters_from_svc_credentials(service_credentials, options.get_option(:region, mandatory: true)))
|
|
45
45
|
end
|
|
46
46
|
api_node = Api::CosNode.new(**cos_node_params)
|
|
@@ -78,7 +78,7 @@ module Aspera
|
|
|
78
78
|
# extract elements from faspex public link
|
|
79
79
|
def get_link_data(public_url)
|
|
80
80
|
public_uri = URI.parse(public_url)
|
|
81
|
-
Aspera.assert(m = public_uri.path.match(%r{^(.*)/(external.*)$}),
|
|
81
|
+
Aspera.assert(m = public_uri.path.match(%r{^(.*)/(external.*)$}), 'Public link does not match Faspex format', type: Cli::BadArgument)
|
|
82
82
|
base = m[1]
|
|
83
83
|
subpath = m[2]
|
|
84
84
|
port_add = public_uri.port.eql?(public_uri.default_port) ? '' : ":#{public_uri.port}"
|
|
@@ -176,7 +176,7 @@ module Aspera
|
|
|
176
176
|
if !mailbox_query.nil?
|
|
177
177
|
Aspera.assert_type(mailbox_query, Hash){'query'}
|
|
178
178
|
Aspera.assert((mailbox_query.keys - ATOM_EXT_PARAMS).empty?){"query: supported params: #{ATOM_EXT_PARAMS}"}
|
|
179
|
-
Aspera.assert(!(mailbox_query.key?('startIndex') && mailbox_query.key?('page'))
|
|
179
|
+
Aspera.assert(!(mailbox_query.key?('startIndex') && mailbox_query.key?('page')), 'query: startIndex and page are exclusive')
|
|
180
180
|
# Extract pagination control parameters (not part of API query)
|
|
181
181
|
max_items = mailbox_query.delete(RestList::MAX_ITEMS)
|
|
182
182
|
max_pages = mailbox_query.delete(RestList::MAX_PAGES)
|
|
@@ -286,15 +286,15 @@ module Aspera
|
|
|
286
286
|
rescue StandardError => e
|
|
287
287
|
nagios.add_critical('faspex api', e.to_s)
|
|
288
288
|
end
|
|
289
|
-
|
|
289
|
+
Result::ObjectList.new(nagios.status_list)
|
|
290
290
|
when :package
|
|
291
291
|
command_pkg = options.get_next_command(%i[send receive list show], aliases: {recv: :receive})
|
|
292
292
|
case command_pkg
|
|
293
293
|
when :show
|
|
294
294
|
delivery_id = options.instance_identifier
|
|
295
|
-
return
|
|
295
|
+
return Result::SingleObject.new(mailbox_filtered_entries(stop_at_id: delivery_id).find{ |p| p[PACKAGE_MATCH_FIELD].eql?(delivery_id)})
|
|
296
296
|
when :list
|
|
297
|
-
return
|
|
297
|
+
return Result::ObjectList.new(mailbox_filtered_entries, fields: [PACKAGE_MATCH_FIELD, 'title', 'items'])
|
|
298
298
|
when :send
|
|
299
299
|
delivery_info = options.get_option(:delivery_info, mandatory: true)
|
|
300
300
|
Aspera.assert_type(delivery_info, Hash, type: Cli::BadArgument){'delivery_info'}
|
|
@@ -308,7 +308,7 @@ module Aspera
|
|
|
308
308
|
first_source['paths'].concat(transfer.source_list)
|
|
309
309
|
source_id = options.get_option(:remote_source)
|
|
310
310
|
if source_id && (m = Manager.percent_selector(source_id))
|
|
311
|
-
Aspera.
|
|
311
|
+
Aspera.assert_values(m[:field], ['name'], type: Cli::BadArgument){'selector field'}
|
|
312
312
|
source_list = api_v3.read('source_shares')['items']
|
|
313
313
|
source_id = self.class.get_source_id_by_name(m[:value], source_list)
|
|
314
314
|
end
|
|
@@ -316,7 +316,7 @@ module Aspera
|
|
|
316
316
|
pkg_created = api_v3.create('send', package_create_params)
|
|
317
317
|
if first_source.key?('id')
|
|
318
318
|
# no transfer spec if remote source: handled by faspex
|
|
319
|
-
return
|
|
319
|
+
return Result::ValueList.new([pkg_created['links']['status']], name: 'link')
|
|
320
320
|
end
|
|
321
321
|
raise Cli::BadArgument, 'expecting one session exactly' if pkg_created['xfer_sessions'].length != 1
|
|
322
322
|
transfer_spec = pkg_created['xfer_sessions'].first
|
|
@@ -326,7 +326,7 @@ module Aspera
|
|
|
326
326
|
transfer_spec = send_public_link_to_ts(public_link_url, package_create_params)
|
|
327
327
|
end
|
|
328
328
|
# Log.dump(:transfer_spec,transfer_spec)
|
|
329
|
-
return
|
|
329
|
+
return Runner.result_transfer(transfer.start(transfer_spec))
|
|
330
330
|
when :receive
|
|
331
331
|
link_url = options.get_option(:link)
|
|
332
332
|
# list of faspex ID/URI to download
|
|
@@ -349,15 +349,15 @@ module Aspera
|
|
|
349
349
|
end
|
|
350
350
|
# get command line parameters
|
|
351
351
|
delivery_id = options.instance_identifier
|
|
352
|
-
Aspera.assert(!delivery_id.empty
|
|
352
|
+
Aspera.assert(!delivery_id.empty?, 'empty id')
|
|
353
353
|
recipient = options.get_option(:recipient)
|
|
354
354
|
if delivery_id.eql?(SpecialValues::ALL)
|
|
355
355
|
pkg_id_uri = mailbox_filtered_entries.map{ |i| {id: i[PACKAGE_MATCH_FIELD], uri: self.class.get_fasp_uri_from_entry(i, raise_no_link: false)}}
|
|
356
356
|
elsif delivery_id.eql?(SpecialValues::INIT)
|
|
357
|
-
Aspera.assert(skip_ids_persistency
|
|
357
|
+
Aspera.assert(skip_ids_persistency, 'Only with option once_only')
|
|
358
358
|
skip_ids_persistency.data.clear.concat(mailbox_filtered_entries.map{ |i| {id: i[PACKAGE_MATCH_FIELD]}})
|
|
359
359
|
skip_ids_persistency.save
|
|
360
|
-
return
|
|
360
|
+
return Result::Status.new("Initialized skip for #{skip_ids_persistency.data.count} package(s)")
|
|
361
361
|
elsif !recipient.nil? && recipient.start_with?('*')
|
|
362
362
|
found_package_link = mailbox_filtered_entries(stop_at_id: delivery_id).find{ |p| p[PACKAGE_MATCH_FIELD].eql?(delivery_id)}['link'].first['href']
|
|
363
363
|
raise "Not Found. Dropbox and Workgroup packages can use the link option with #{Transfer::Uri::SCHEME}" if found_package_link.nil?
|
|
@@ -401,7 +401,7 @@ module Aspera
|
|
|
401
401
|
# skip_ids_data.select!{|id|pkg_id_uri.select{|p|p[:id].eql?(id)}}
|
|
402
402
|
pkg_id_uri.reject!{ |i| skip_ids_data.include?(i[:id])}
|
|
403
403
|
Log.dump(:pkg_id_uri, pkg_id_uri)
|
|
404
|
-
return
|
|
404
|
+
return Result::Status.new('no new package') if pkg_id_uri.empty?
|
|
405
405
|
result_transfer = []
|
|
406
406
|
pkg_id_uri.each do |id_uri|
|
|
407
407
|
if id_uri[:uri].nil?
|
|
@@ -427,22 +427,22 @@ module Aspera
|
|
|
427
427
|
transfer_spec['direction'] = Transfer::Spec::DIRECTION_RECEIVE
|
|
428
428
|
statuses = transfer.start(transfer_spec)
|
|
429
429
|
end
|
|
430
|
-
result_transfer.push({'package' => id_uri[:id],
|
|
430
|
+
result_transfer.push({'package' => id_uri[:id], Runner::STATUS_FIELD => statuses})
|
|
431
431
|
# skip only if all sessions completed
|
|
432
432
|
skip_ids_data.push(id_uri[:id]) if TransferAgent.session_status(statuses).eql?(:success)
|
|
433
433
|
end
|
|
434
434
|
skip_ids_persistency&.save
|
|
435
|
-
return
|
|
435
|
+
return Runner.result_transfer_multiple(result_transfer)
|
|
436
436
|
end
|
|
437
437
|
when :source
|
|
438
438
|
command_source = options.get_next_command(%i[list info node])
|
|
439
439
|
source_list = api_v3.read('source_shares')['items']
|
|
440
440
|
case command_source
|
|
441
441
|
when :list
|
|
442
|
-
return
|
|
442
|
+
return Result::ObjectList.new(source_list)
|
|
443
443
|
else # :info :node
|
|
444
444
|
source_id = options.instance_identifier do |field, value|
|
|
445
|
-
Aspera.
|
|
445
|
+
Aspera.assert_values(field, ['name'], type: Cli::BadArgument){'selector field'}
|
|
446
446
|
self.class.get_source_id_by_name(value, source_list)
|
|
447
447
|
end.to_i
|
|
448
448
|
selected_source = source_list.find{ |i| i['id'].eql?(source_id)}
|
|
@@ -462,7 +462,7 @@ module Aspera
|
|
|
462
462
|
Log.dump(:source_info, source_info)
|
|
463
463
|
case command_source
|
|
464
464
|
when :info
|
|
465
|
-
return
|
|
465
|
+
return Result::SingleObject.new(source_info)
|
|
466
466
|
when :node
|
|
467
467
|
node_config = ExtendedValue.instance.evaluate(source_info[KEY_NODE], context: 'faspex node')
|
|
468
468
|
Log.log.debug{"node=#{node_config}"}
|
|
@@ -481,13 +481,13 @@ module Aspera
|
|
|
481
481
|
end
|
|
482
482
|
when :me
|
|
483
483
|
my_info = api_v3.read('me')
|
|
484
|
-
return
|
|
484
|
+
return Result::SingleObject.new(my_info)
|
|
485
485
|
when :dropbox
|
|
486
486
|
command_pkg = options.get_next_command([:list])
|
|
487
487
|
case command_pkg
|
|
488
488
|
when :list
|
|
489
489
|
dropbox_list = api_v3.read('dropboxes')
|
|
490
|
-
return
|
|
490
|
+
return Result::ObjectList.new(dropbox_list['items'], fields: %w[name id description can_read can_write])
|
|
491
491
|
end
|
|
492
492
|
when :v4
|
|
493
493
|
command = options.get_next_command(%i[package dropbox dmembership workgroup wmembership user metadata_profile])
|
|
@@ -526,11 +526,11 @@ module Aspera
|
|
|
526
526
|
u['first_name'], u['last_name'] = u['displayName'].split(' ', 2)
|
|
527
527
|
u['x'] = true
|
|
528
528
|
end
|
|
529
|
-
return
|
|
529
|
+
return Result::ObjectList.new(users)
|
|
530
530
|
when :login_methods
|
|
531
531
|
login_meths = api_v3.call(operation: 'GET', subpath: 'login/new', headers: {'Accept' => 'application/xrds+xml'}, ret: :resp).body
|
|
532
532
|
login_methods = XmlSimple.xml_in(login_meths, {'ForceArray' => false})
|
|
533
|
-
return
|
|
533
|
+
return Result::ObjectList.new(login_methods['XRD']['Service'])
|
|
534
534
|
end
|
|
535
535
|
end
|
|
536
536
|
end
|
|
@@ -213,10 +213,10 @@ module Aspera
|
|
|
213
213
|
packages = []
|
|
214
214
|
case package_ids
|
|
215
215
|
when SpecialValues::INIT
|
|
216
|
-
Aspera.assert(skip_ids_persistency
|
|
216
|
+
Aspera.assert(skip_ids_persistency, 'Only with option once_only')
|
|
217
217
|
skip_ids_persistency.data.clear.concat(list_packages_with_filter.first.map{ |p| p['id']})
|
|
218
218
|
skip_ids_persistency.save
|
|
219
|
-
return
|
|
219
|
+
return Result::Status.new("Initialized skip for #{skip_ids_persistency.data.count} package(s)")
|
|
220
220
|
when SpecialValues::ALL
|
|
221
221
|
# TODO: if packages have same name, they will overwrite ?
|
|
222
222
|
packages = list_packages_with_filter(query: {'status' => 'completed'}).first
|
|
@@ -259,14 +259,14 @@ module Aspera
|
|
|
259
259
|
# delete flag for Connect Client
|
|
260
260
|
transfer_spec.delete('authentication')
|
|
261
261
|
statuses = transfer.start(transfer_spec)
|
|
262
|
-
result_transfer.push({'package' => pkg_id,
|
|
262
|
+
result_transfer.push({'package' => pkg_id, Runner::STATUS_FIELD => statuses})
|
|
263
263
|
# skip only if all sessions completed
|
|
264
264
|
if TransferAgent.session_status(statuses).eql?(:success) && skip_ids_persistency
|
|
265
265
|
skip_ids_persistency.data.push(pkg_id)
|
|
266
266
|
skip_ids_persistency.save
|
|
267
267
|
end
|
|
268
268
|
end
|
|
269
|
-
return
|
|
269
|
+
return Runner.result_transfer_multiple(result_transfer)
|
|
270
270
|
end
|
|
271
271
|
|
|
272
272
|
def package_send
|
|
@@ -296,7 +296,7 @@ module Aspera
|
|
|
296
296
|
)
|
|
297
297
|
# well, we asked a TS for connect, but we actually want a generic one
|
|
298
298
|
transfer_spec.delete('authentication')
|
|
299
|
-
return
|
|
299
|
+
return Runner.result_transfer(transfer.start(transfer_spec))
|
|
300
300
|
else
|
|
301
301
|
# send from remote shared folder
|
|
302
302
|
if (m = Manager.percent_selector(shared_folder))
|
|
@@ -314,7 +314,7 @@ module Aspera
|
|
|
314
314
|
formatter.display_status("Package #{package['id']}")
|
|
315
315
|
result = wait_package_status(package['id'])
|
|
316
316
|
end
|
|
317
|
-
return
|
|
317
|
+
return Result::SingleObject.new(result)
|
|
318
318
|
end
|
|
319
319
|
end
|
|
320
320
|
|
|
@@ -371,24 +371,25 @@ module Aspera
|
|
|
371
371
|
query.delete('iteration_token')
|
|
372
372
|
end
|
|
373
373
|
RestParameters.instance.spinner_cb.call(action: :success)
|
|
374
|
-
return
|
|
374
|
+
return Result::ObjectList.new(all_items, total: total_count)
|
|
375
375
|
end
|
|
376
376
|
|
|
377
377
|
def package_action
|
|
378
|
-
command = options.get_next_command(%i[show browse status delete receive send list])
|
|
378
|
+
command = options.get_next_command(%i[show browse status delete receive send list file_processing])
|
|
379
379
|
package_id =
|
|
380
|
-
|
|
380
|
+
unless %i[send list].include?(command)
|
|
381
381
|
@api_v5.pub_link_context&.key?('package_id') ? @api_v5.pub_link_context['package_id'] : options.instance_identifier
|
|
382
382
|
end
|
|
383
|
+
package_instance = "packages/#{package_id}"
|
|
383
384
|
case command
|
|
384
385
|
when :show
|
|
385
|
-
return
|
|
386
|
+
return Result::SingleObject.new(@api_v5.read(package_instance))
|
|
386
387
|
when :browse
|
|
387
|
-
return browse_folder("
|
|
388
|
+
return browse_folder("#{package_instance}/files/#{Api::Faspex.box_type(options.get_option(:box))}", recipient_query(package_id))
|
|
388
389
|
when :status
|
|
389
390
|
status_list = options.get_next_argument('list of states, or nothing', mandatory: false, validation: Array)
|
|
390
391
|
status = wait_package_status(package_id, status_list: status_list)
|
|
391
|
-
return
|
|
392
|
+
return Result::SingleObject.new(status)
|
|
392
393
|
when :delete
|
|
393
394
|
ids = package_id
|
|
394
395
|
ids = [ids] unless ids.is_a?(Array)
|
|
@@ -401,7 +402,7 @@ module Aspera
|
|
|
401
402
|
body: {ids: ids},
|
|
402
403
|
headers: {'Accept' => Mime::JSON}
|
|
403
404
|
)
|
|
404
|
-
return
|
|
405
|
+
return Result::Status.new('Package(s) deleted')
|
|
405
406
|
when :receive
|
|
406
407
|
return package_receive(package_id)
|
|
407
408
|
when :send
|
|
@@ -411,11 +412,18 @@ module Aspera
|
|
|
411
412
|
fields = %w[id title status sender.name recipients.0.name release_date total_bytes total_files]
|
|
412
413
|
fields.delete('recipients.0.name') if %w[inbox inbox_history].include?(options.get_option(:box))
|
|
413
414
|
fields.delete('sender.name') if %w[outbox outbox_history].include?(options.get_option(:box))
|
|
414
|
-
return
|
|
415
|
+
return Result::ObjectList.new(list, total: total, fields: fields)
|
|
416
|
+
when :file_processing
|
|
417
|
+
result, count = @api_v5.list_entities_limit_offset_total_count(
|
|
418
|
+
entity: "#{package_instance}/file_statuses",
|
|
419
|
+
items_key: 'files'
|
|
420
|
+
)
|
|
421
|
+
return Result::ObjectList.new(result, total: count)
|
|
415
422
|
end
|
|
416
423
|
end
|
|
417
424
|
|
|
418
425
|
def execute_resource(res_sym)
|
|
426
|
+
# Arguments for Plugin::Base::entity_execute
|
|
419
427
|
exec_args = {
|
|
420
428
|
api: @api_v5,
|
|
421
429
|
entity: res_sym.to_s
|
|
@@ -448,9 +456,14 @@ module Aspera
|
|
|
448
456
|
available_commands += %i[shared_folders browse]
|
|
449
457
|
when :jobs
|
|
450
458
|
exec_args[:display_fields] = %w[id job_name job_type status]
|
|
459
|
+
when :file_processing
|
|
460
|
+
available_commands = %i[next modify]
|
|
461
|
+
# schema for modify
|
|
462
|
+
exec_args[:schema] = Schema::Registry.req_body(Schema::Registry::FASPEX, 'file_processing.put')
|
|
463
|
+
exec_args[:is_singleton] = true
|
|
451
464
|
end
|
|
452
465
|
res_command = options.get_next_command(available_commands)
|
|
453
|
-
return
|
|
466
|
+
return Result::ValueList.new(Api::Faspex::EMAIL_NOTIF_LIST, name: 'email_id') if res_command.eql?(:list) && res_sym.eql?(:email_notifications)
|
|
454
467
|
case res_command
|
|
455
468
|
when :create, :modify, :delete, :show
|
|
456
469
|
return entity_execute(command: res_command, **exec_args) do |field, value|
|
|
@@ -458,28 +471,28 @@ module Aspera
|
|
|
458
471
|
end
|
|
459
472
|
when :list
|
|
460
473
|
data, total = exec_args[:api].list_entities_limit_offset_total_count(entity: exec_args[:entity], items_key: exec_args[:items_key], query: query_read_delete(default: exec_args[:list_query]))
|
|
461
|
-
return
|
|
474
|
+
return Result::ObjectList.new(data, total: total, fields: exec_args[:display_fields])
|
|
462
475
|
when :shared_folders
|
|
463
476
|
# nodes
|
|
464
477
|
node_id = options.instance_identifier do |field, value|
|
|
465
478
|
@api_v5.lookup_entity_by_field(entity: 'nodes', field: field, value: value)['id']
|
|
466
479
|
end
|
|
467
|
-
|
|
480
|
+
shared_folder_entity = "nodes/#{node_id}/shared_folders"
|
|
468
481
|
sh_command = options.get_next_command(Operations::ALL + [:user])
|
|
469
482
|
case sh_command
|
|
470
483
|
when *Operations::ALL
|
|
471
484
|
return entity_execute(
|
|
472
485
|
api: @api_v5,
|
|
473
|
-
entity:
|
|
486
|
+
entity: shared_folder_entity,
|
|
474
487
|
command: sh_command
|
|
475
488
|
) do |field, value|
|
|
476
|
-
@api_v5.lookup_entity_by_field(entity:
|
|
489
|
+
@api_v5.lookup_entity_by_field(entity: shared_folder_entity, field: field, value: value)['id']
|
|
477
490
|
end
|
|
478
491
|
when :user
|
|
479
492
|
sh_id = options.instance_identifier do |field, value|
|
|
480
|
-
@api_v5.lookup_entity_by_field(entity:
|
|
493
|
+
@api_v5.lookup_entity_by_field(entity: shared_folder_entity, field: field, value: value)['id']
|
|
481
494
|
end
|
|
482
|
-
user_path = "#{
|
|
495
|
+
user_path = "#{shared_folder_entity}/#{sh_id}/custom_access_users"
|
|
483
496
|
return entity_execute(api: @api_v5, entity: user_path, items_key: 'users') do |field, value|
|
|
484
497
|
@api_v5.lookup_entity_by_field(entity: user_path, items_key: 'users', field: field, value: value)['id']
|
|
485
498
|
end
|
|
@@ -503,7 +516,7 @@ module Aspera
|
|
|
503
516
|
value: creation_payload['email_address'],
|
|
504
517
|
query: {}
|
|
505
518
|
)
|
|
506
|
-
return
|
|
519
|
+
return Result::SingleObject.new(result)
|
|
507
520
|
when :members, :saml_groups
|
|
508
521
|
# res_command := :shared_inboxes, :workgroups
|
|
509
522
|
res_id = options.instance_identifier{ |field, value| @api_v5.lookup_entity_by_field(entity: res_sym.to_s, field: field, value: value, query: res_id_query)['id']}
|
|
@@ -549,7 +562,14 @@ module Aspera
|
|
|
549
562
|
# :accounts
|
|
550
563
|
contact_id = options.instance_identifier{ |field, value| @api_v5.lookup_entity_by_field(entity: 'accounts', field: field, value: value, query: res_id_query)['id']}
|
|
551
564
|
@api_v5.create("accounts/#{contact_id}/reset_password", {})
|
|
552
|
-
return
|
|
565
|
+
return Result::Status.new('password reset, user shall check email')
|
|
566
|
+
when :next
|
|
567
|
+
result, count = @api_v5.list_entities_limit_offset_total_count(
|
|
568
|
+
entity: exec_args[:entity],
|
|
569
|
+
operation: 'POST',
|
|
570
|
+
items_key: 'files'
|
|
571
|
+
)
|
|
572
|
+
return Result::ObjectList.new(result, total: count)
|
|
553
573
|
end
|
|
554
574
|
Aspera.error_unreachable_line
|
|
555
575
|
end
|
|
@@ -563,29 +583,29 @@ module Aspera
|
|
|
563
583
|
delete_data = value_create_modify(command: command, default: {})
|
|
564
584
|
delete_data = @api_v5.read('configuration').slice('days_before_deleting_package_records') if delete_data.empty?
|
|
565
585
|
res = @api_v5.create('internal/packages/clean_deleted', delete_data)
|
|
566
|
-
return
|
|
586
|
+
return Result::SingleObject.new(res)
|
|
567
587
|
when :events
|
|
568
588
|
event_type = options.get_next_command(%i[application webhook])
|
|
569
589
|
case event_type
|
|
570
590
|
when :application
|
|
571
591
|
list, total = @api_v5.list_entities_limit_offset_total_count(entity: 'application_events', query: query_read_delete)
|
|
572
|
-
return
|
|
592
|
+
return Result::ObjectList.new(list, total: total, fields: %w[event_type created_at application user.name])
|
|
573
593
|
when :webhook
|
|
574
594
|
list, total = @api_v5.list_entities_limit_offset_total_count(
|
|
575
595
|
entity: 'all_webhooks_events',
|
|
576
596
|
query: query_read_delete,
|
|
577
597
|
items_key: 'events'
|
|
578
598
|
)
|
|
579
|
-
return
|
|
599
|
+
return Result::ObjectList.new(list, total: total)
|
|
580
600
|
end
|
|
581
601
|
when :configuration
|
|
582
602
|
conf_path = 'configuration'
|
|
583
603
|
conf_cmd = options.get_next_command(%i[show modify])
|
|
584
604
|
case conf_cmd
|
|
585
605
|
when :show
|
|
586
|
-
return
|
|
606
|
+
return Result::SingleObject.new(@api_v5.read(conf_path))
|
|
587
607
|
when :modify
|
|
588
|
-
return
|
|
608
|
+
return Result::SingleObject.new(@api_v5.update(conf_path, value_create_modify(command: conf_cmd)))
|
|
589
609
|
end
|
|
590
610
|
when :smtp
|
|
591
611
|
# only one SMTP config
|
|
@@ -593,21 +613,21 @@ module Aspera
|
|
|
593
613
|
smtp_cmd = options.get_next_command(%i[show create modify delete test])
|
|
594
614
|
case smtp_cmd
|
|
595
615
|
when :show
|
|
596
|
-
return
|
|
616
|
+
return Result::SingleObject.new(@api_v5.read(smtp_path))
|
|
597
617
|
when :create
|
|
598
|
-
return
|
|
618
|
+
return Result::SingleObject.new(@api_v5.create(smtp_path, value_create_modify(command: smtp_cmd)))
|
|
599
619
|
when :modify
|
|
600
|
-
return
|
|
620
|
+
return Result::SingleObject.new(@api_v5.update(smtp_path, value_create_modify(command: smtp_cmd)))
|
|
601
621
|
when :delete
|
|
602
622
|
@api_v5.delete(smtp_path)
|
|
603
|
-
return
|
|
623
|
+
return Result::Status.new('SMTP configuration deleted')
|
|
604
624
|
when :test
|
|
605
625
|
test_data = options.get_next_argument('Email or test data, see API')
|
|
606
626
|
test_data = {test_email_recipient: test_data} if test_data.is_a?(String)
|
|
607
627
|
creation = @api_v5.create(File.join(smtp_path, 'test'), test_data)
|
|
608
628
|
result = wait_for_job(creation['job_id'])
|
|
609
629
|
result['serialized_args'] = JSON.parse(result['serialized_args']) rescue result['serialized_args']
|
|
610
|
-
return
|
|
630
|
+
return Result::SingleObject.new(result)
|
|
611
631
|
end
|
|
612
632
|
end
|
|
613
633
|
end
|
|
@@ -624,7 +644,7 @@ module Aspera
|
|
|
624
644
|
end
|
|
625
645
|
case command
|
|
626
646
|
when :version
|
|
627
|
-
return
|
|
647
|
+
return Result::SingleObject.new(@api_v5.read('version'))
|
|
628
648
|
when :health
|
|
629
649
|
nagios = Nagios.new
|
|
630
650
|
begin
|
|
@@ -637,29 +657,29 @@ module Aspera
|
|
|
637
657
|
rescue StandardError => e
|
|
638
658
|
nagios.add_critical('core', e.to_s)
|
|
639
659
|
end
|
|
640
|
-
|
|
660
|
+
Result::ObjectList.new(nagios.status_list)
|
|
641
661
|
when :user
|
|
642
662
|
case options.get_next_command(%i[account profile])
|
|
643
663
|
when :account
|
|
644
|
-
return
|
|
664
|
+
return Result::SingleObject.new(@api_v5.read('account', query_read_delete))
|
|
645
665
|
when :profile
|
|
646
666
|
case options.get_next_command(%i[show modify])
|
|
647
667
|
when :show
|
|
648
|
-
return
|
|
668
|
+
return Result::SingleObject.new(@api_v5.read('account/preferences'))
|
|
649
669
|
when :modify
|
|
650
670
|
@api_v5.update('account/preferences', options.get_next_argument('modified parameters', validation: Hash))
|
|
651
|
-
return
|
|
671
|
+
return Result::Status.new('modified')
|
|
652
672
|
end
|
|
653
673
|
end
|
|
654
674
|
when :bearer_token
|
|
655
|
-
return
|
|
675
|
+
return Result::Text.new(@api_v5.oauth.authorization)
|
|
656
676
|
when :packages
|
|
657
677
|
return package_action
|
|
658
678
|
when :shared_folders
|
|
659
679
|
all_shared_folders = @api_v5.read('shared_folders')['shared_folders']
|
|
660
680
|
case options.get_next_command(%i[list browse])
|
|
661
681
|
when :list
|
|
662
|
-
return
|
|
682
|
+
return Result::ObjectList.new(all_shared_folders)
|
|
663
683
|
when :browse
|
|
664
684
|
shared_folder_id = options.instance_identifier do |field, value|
|
|
665
685
|
matches = all_shared_folders.select{ |i| i[field].eql?(value)}
|
|
@@ -684,7 +704,7 @@ module Aspera
|
|
|
684
704
|
end
|
|
685
705
|
when :resend
|
|
686
706
|
@api_v5.create("#{invitation_endpoint}/#{options.instance_identifier}/resend", nil)
|
|
687
|
-
return
|
|
707
|
+
return Result::Status.new('Invitation resent')
|
|
688
708
|
else
|
|
689
709
|
return entity_execute(
|
|
690
710
|
api: @api_v5,
|
|
@@ -701,10 +721,10 @@ module Aspera
|
|
|
701
721
|
parameters = value_create_modify(command: command, default: {}).symbolize_keys
|
|
702
722
|
uri = URI.parse(parameters.delete(:url){WebServerSimple::DEFAULT_URL})
|
|
703
723
|
server = WebServerSimple.new(uri, **parameters.slice(*WebServerSimple::PARAMS))
|
|
704
|
-
Aspera.assert(parameters.except(*WebServerSimple::PARAMS).empty?)
|
|
724
|
+
Aspera.assert(parameters.except(*WebServerSimple::PARAMS).empty?){"unexpected parameters: #{parameters.except(*WebServerSimple::PARAMS).keys}"}
|
|
705
725
|
server.mount(uri.path, Faspex4GWServlet, @api_v5, nil)
|
|
706
726
|
server.start
|
|
707
|
-
return
|
|
727
|
+
return Result::Status.new('Gateway terminated')
|
|
708
728
|
when :postprocessing
|
|
709
729
|
require 'aspera/faspex_postproc' # cspell:disable-line
|
|
710
730
|
parameters = value_create_modify(command: command, default: {}).symbolize_keys
|
|
@@ -713,7 +733,7 @@ module Aspera
|
|
|
713
733
|
server = WebServerSimple.new(uri, **parameters.slice(*WebServerSimple::PARAMS))
|
|
714
734
|
server.mount(uri.path, Faspex4PostProcServlet, parameters.except(*WebServerSimple::PARAMS))
|
|
715
735
|
server.start
|
|
716
|
-
return
|
|
736
|
+
return Result::Status.new('Gateway terminated')
|
|
717
737
|
end
|
|
718
738
|
end
|
|
719
739
|
SHARED_INBOX_MEMBER_LEVELS = %i[submit_only standard shared_inbox_admin].freeze
|
|
@@ -57,10 +57,10 @@ module Aspera
|
|
|
57
57
|
rescue StandardError => e
|
|
58
58
|
nagios.add_critical('api', e.to_s)
|
|
59
59
|
end
|
|
60
|
-
|
|
60
|
+
Result::ObjectList.new(nagios.status_list)
|
|
61
61
|
when :info
|
|
62
62
|
api_v1 = Api::Httpgw.new(url: base_url)
|
|
63
|
-
return
|
|
63
|
+
return Result::SingleObject.new(api_v1.info)
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
end
|