aspera-cli 4.26.0 → 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 +36 -4
- 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 +45 -37
- data/lib/aspera/api/cos_node.rb +1 -1
- data/lib/aspera/api/faspex.rb +7 -6
- data/lib/aspera/api/node.rb +9 -9
- data/lib/aspera/ascmd.rb +4 -4
- data/lib/aspera/ascp/installation.rb +13 -6
- data/lib/aspera/assert.rb +17 -13
- data/lib/aspera/cli/context.rb +58 -0
- data/lib/aspera/cli/extended_value.rb +9 -4
- data/lib/aspera/cli/formatter.rb +91 -187
- data/lib/aspera/cli/http.rb +167 -0
- data/lib/aspera/cli/manager.rb +132 -77
- data/lib/aspera/cli/options.schema.yaml +82 -0
- data/lib/aspera/cli/plugins/alee.rb +2 -2
- data/lib/aspera/cli/plugins/aoc.rb +113 -77
- data/lib/aspera/cli/plugins/ats.rb +16 -16
- data/lib/aspera/cli/plugins/base.rb +64 -49
- data/lib/aspera/cli/plugins/config.rb +172 -444
- 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 +22 -22
- data/lib/aspera/cli/plugins/faspex5.rb +68 -49
- 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 +80 -80
- 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} +48 -130
- data/lib/aspera/cli/sync_actions.rb +15 -11
- data/lib/aspera/cli/terminal_formatter.rb +65 -0
- data/lib/aspera/cli/transfer_agent.rb +17 -15
- 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 +22 -18
- data/lib/aspera/data_repository.rb +4 -0
- data/lib/aspera/dot_container.rb +1 -1
- data/lib/aspera/environment.rb +25 -6
- data/lib/aspera/faspex_gw.rb +1 -1
- data/lib/aspera/formatter_interface.rb +14 -0
- data/lib/aspera/hash_ext.rb +6 -0
- 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 +10 -5
- data/lib/aspera/markdown.rb +4 -1
- 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 +38 -14
- 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 +6 -3
- data/lib/aspera/rest.rb +9 -5
- 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 +62811 -0
- data/lib/aspera/schema/IBM Aspera on Cloud API-0.2.6-enhanced.yaml +9637 -0
- data/lib/aspera/schema/async_tables.yaml +361 -0
- data/lib/aspera/schema/documentation.rb +107 -0
- data/lib/aspera/schema/reader.rb +75 -0
- data/lib/aspera/schema/registry.rb +70 -0
- data/lib/aspera/secret_hider.rb +4 -0
- data/lib/aspera/sync/conf.schema.yaml +0 -26
- data/lib/aspera/sync/database.rb +14 -10
- data/lib/aspera/sync/operations.rb +14 -10
- data/lib/aspera/temp_file_manager.rb +4 -0
- data/lib/aspera/transfer/faux_file.rb +1 -1
- data/lib/aspera/transfer/parameters.rb +4 -4
- data/lib/aspera/transfer/resumer.rb +2 -2
- data/lib/aspera/transfer/spec.rb +3 -3
- data/lib/aspera/transfer/spec.schema.yaml +18 -9
- data/lib/aspera/transfer/uri.rb +1 -1
- data/lib/aspera/uri_reader.rb +1 -1
- data/lib/aspera/yaml.rb +4 -2
- data.tar.gz.sig +0 -0
- metadata +28 -15
- metadata.gz.sig +1 -1
- data/lib/aspera/transfer/spec_doc.rb +0 -76
|
@@ -41,7 +41,7 @@ module Aspera
|
|
|
41
41
|
|
|
42
42
|
def remove_in_object_list!(obj_list)
|
|
43
43
|
obj_list.each do |item|
|
|
44
|
-
item['path'] = item['path']
|
|
44
|
+
item['path'] = item['path'].delete_prefix(@root) if item['path'].start_with?(@root)
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
end
|
|
@@ -224,7 +224,7 @@ module Aspera
|
|
|
224
224
|
# 'file','symbolic_link'
|
|
225
225
|
if !Node.gen3_entry_folder?(response['self']) || only_path
|
|
226
226
|
@node_path_prefix&.remove_in_object_list!([response['self']])
|
|
227
|
-
return
|
|
227
|
+
return Result::SingleObject.new(response['self'])
|
|
228
228
|
end
|
|
229
229
|
items = response['items']
|
|
230
230
|
total_count ||= response['total_count']
|
|
@@ -246,7 +246,7 @@ module Aspera
|
|
|
246
246
|
query.delete('skip')
|
|
247
247
|
end
|
|
248
248
|
@node_path_prefix&.remove_in_object_list!(all_items)
|
|
249
|
-
return
|
|
249
|
+
return Result::ObjectList.new(all_items)
|
|
250
250
|
ensure
|
|
251
251
|
RestParameters.instance.spinner_cb.call(action: :success)
|
|
252
252
|
end
|
|
@@ -298,18 +298,18 @@ module Aspera
|
|
|
298
298
|
other_options = options.get_option(:query)
|
|
299
299
|
parameters.merge!(other_options) unless other_options.nil?
|
|
300
300
|
resp = @api_node.create('files/search', parameters)
|
|
301
|
-
return
|
|
301
|
+
return Result::Empty.new if resp['items'].empty?
|
|
302
302
|
fields = resp['items'].first.keys.reject{ |i| SEARCH_REMOVE_FIELDS.include?(i)}
|
|
303
303
|
formatter.display_item_count(resp['item_count'], resp['total_count'])
|
|
304
304
|
formatter.display_status("params: #{resp['parameters'].keys.map{ |k| "#{k}:#{resp['parameters'][k]}"}.join(',')}")
|
|
305
305
|
@node_path_prefix&.remove_in_object_list!(resp['items'])
|
|
306
|
-
return
|
|
306
|
+
return Result::ObjectList.new(resp['items'], fields: fields)
|
|
307
307
|
when :space
|
|
308
308
|
path_list = options.get_next_argument('folder path or ext.val. list', multiple: true)
|
|
309
309
|
@node_path_prefix&.add_to_paths!(path_list)
|
|
310
310
|
resp = @api_node.create('space', {'paths' => path_list.map{ |i| {path: i}}})
|
|
311
311
|
@node_path_prefix&.remove_in_object_list!(resp['paths'])
|
|
312
|
-
return
|
|
312
|
+
return Result::ObjectList.new(resp['paths'])
|
|
313
313
|
when :mkdir
|
|
314
314
|
path_list = options.get_next_argument('folder path or ext.val. list', multiple: true)
|
|
315
315
|
@node_path_prefix&.add_to_paths!(path_list)
|
|
@@ -377,17 +377,17 @@ module Aspera
|
|
|
377
377
|
Api::Node.add_private_key(transfer_spec)
|
|
378
378
|
# delete this part, as the returned value contains only destination, and not sources
|
|
379
379
|
transfer_spec.delete('paths') if command.eql?(:upload)
|
|
380
|
-
return
|
|
380
|
+
return Runner.result_transfer(transfer.start(transfer_spec))
|
|
381
381
|
when :cat
|
|
382
382
|
remote_path = options.get_next_argument('remote path', validation: String)
|
|
383
383
|
remote_path = @node_path_prefix.add_to_path(remote_path) unless @node_path_prefix.nil?
|
|
384
384
|
File.basename(remote_path)
|
|
385
385
|
http = @api_node.read("files/#{URI.encode_www_form_component(remote_path)}/contents", ret: :resp)
|
|
386
|
-
return
|
|
386
|
+
return Result::Text.new(http.body)
|
|
387
387
|
when :transport
|
|
388
|
-
return
|
|
388
|
+
return Result::SingleObject.new(@api_node.transport_params)
|
|
389
389
|
when :spec
|
|
390
|
-
return
|
|
390
|
+
return Result::SingleObject.new(@api_node.base_spec, fields: Formatter.all_but(Transfer::Spec::SPECIFIC))
|
|
391
391
|
end
|
|
392
392
|
Aspera.error_unreachable_line
|
|
393
393
|
end
|
|
@@ -433,7 +433,7 @@ module Aspera
|
|
|
433
433
|
key = key.public_key if key.private?
|
|
434
434
|
bearer_key_pem = key.to_pem
|
|
435
435
|
@api_node.update("access_keys/#{access_key_id}", {token_verification_key: bearer_key_pem})
|
|
436
|
-
return
|
|
436
|
+
return Result::Status.new('public key updated')
|
|
437
437
|
end
|
|
438
438
|
when :health
|
|
439
439
|
nagios = Nagios.new
|
|
@@ -458,21 +458,21 @@ module Aspera
|
|
|
458
458
|
rescue StandardError => e
|
|
459
459
|
nagios.add_critical('central', e.to_s)
|
|
460
460
|
end
|
|
461
|
-
|
|
461
|
+
Result::ObjectList.new(nagios.status_list)
|
|
462
462
|
when :events
|
|
463
463
|
events = @api_node.read('events', query_read_delete)
|
|
464
|
-
return
|
|
464
|
+
return Result::ObjectList.new(events, fields: ->(f){!f.start_with?('data')})
|
|
465
465
|
when :info
|
|
466
466
|
nd_info = @api_node.read('info')
|
|
467
|
-
return
|
|
467
|
+
return Result::SingleObject.new(nd_info)
|
|
468
468
|
when :slash
|
|
469
469
|
nd_info = @api_node.read('')
|
|
470
|
-
return
|
|
470
|
+
return Result::SingleObject.new(nd_info)
|
|
471
471
|
when :license
|
|
472
472
|
# requires: asnodeadmin -mu <node user> --acl-add=internal --internal
|
|
473
|
-
return
|
|
473
|
+
return Result::SingleObject.new(@api_node.read('license'))
|
|
474
474
|
when :api_details
|
|
475
|
-
return
|
|
475
|
+
return Result::SingleObject.new({base_url: @api_node.base_url}.merge(@api_node.params))
|
|
476
476
|
end
|
|
477
477
|
end
|
|
478
478
|
|
|
@@ -514,21 +514,21 @@ module Aspera
|
|
|
514
514
|
result[:password] = apifid.node_api.oauth.authorization
|
|
515
515
|
else Aspera.error_unexpected_value(apifid.node_api.auth_params[:type]){'Node API Auth type'}
|
|
516
516
|
end
|
|
517
|
-
return
|
|
517
|
+
return Result::SingleObject.new(result) if command_repo.eql?(:node_info)
|
|
518
518
|
Log.dump(:result, result)
|
|
519
519
|
raise BadArgument, "Cannot get bearer token if authenticating with secret (#{apifid.node_api.auth_params[:type]})" unless apifid.node_api.auth_params[:type].eql?(:oauth2)
|
|
520
|
-
Aspera.assert(OAuth::Factory.bearer_auth?(result[:password])
|
|
521
|
-
return
|
|
520
|
+
Aspera.assert(OAuth::Factory.bearer_auth?(result[:password]), 'Not using bearer token auth')
|
|
521
|
+
return Result::Text.new(result[:password])
|
|
522
522
|
when :browse
|
|
523
523
|
apifid = apifid_from_next_arg(top_file_id)
|
|
524
524
|
file_info = apifid.node_api.read("files/#{apifid.file_id}", headers: Api::Node.add_cache_control)
|
|
525
525
|
# a single file
|
|
526
|
-
return
|
|
527
|
-
return
|
|
526
|
+
return Result::ObjectList.new([file_info], fields: GEN4_LS_FIELDS) unless file_info['type'].eql?('folder')
|
|
527
|
+
return Result::ObjectList.new(apifid.node_api.list_files(apifid.file_id, query: query_read_delete), fields: GEN4_LS_FIELDS)
|
|
528
528
|
when :find
|
|
529
529
|
apifid = apifid_from_next_arg(top_file_id)
|
|
530
530
|
find_lambda = Api::Node.file_matcher_from_argument(options)
|
|
531
|
-
return
|
|
531
|
+
return Result::ObjectList.new(@api_node.find_files(apifid.file_id, find_lambda), fields: ['path'])
|
|
532
532
|
when :mkdir, :mklink, :mkfile
|
|
533
533
|
containing_folder_path, new_item = Api::Node.split_folder(options.get_next_argument('path'))
|
|
534
534
|
apifid = @api_node.resolve_api_fid(top_file_id, containing_folder_path, true)
|
|
@@ -555,20 +555,20 @@ module Aspera
|
|
|
555
555
|
payload[:type] = :folder
|
|
556
556
|
when :mklink
|
|
557
557
|
payload[:type] = :link
|
|
558
|
-
Aspera.assert(payload[:target_id]
|
|
559
|
-
Aspera.assert(payload[:target_node_id]
|
|
558
|
+
Aspera.assert(payload[:target_id], 'Missing target_id')
|
|
559
|
+
Aspera.assert(payload[:target_node_id], 'Missing target_node_id')
|
|
560
560
|
when :mkfile
|
|
561
561
|
payload[:type] = :file
|
|
562
562
|
payload[:contents] = Base64.strict_encode64(options.get_next_argument('contents'))
|
|
563
563
|
end
|
|
564
564
|
result = apifid.node_api.create("files/#{apifid.file_id}/files", payload)
|
|
565
|
-
return
|
|
565
|
+
return Result::SingleObject.new(result)
|
|
566
566
|
when :rename
|
|
567
567
|
file_path = options.get_next_argument('source path')
|
|
568
568
|
apifid = @api_node.resolve_api_fid(top_file_id, file_path)
|
|
569
569
|
newname = options.get_next_argument('new name')
|
|
570
570
|
result = apifid.node_api.update("files/#{apifid.file_id}", {name: newname})
|
|
571
|
-
return
|
|
571
|
+
return Result::Status.new("renamed to #{newname}")
|
|
572
572
|
when :delete
|
|
573
573
|
return do_bulk_operation(command: command_repo, descr: 'path', values: String, id_result: 'path') do |l_path|
|
|
574
574
|
apifid = if (m = Manager.percent_selector(l_path))
|
|
@@ -595,43 +595,43 @@ module Aspera
|
|
|
595
595
|
end
|
|
596
596
|
when :upload
|
|
597
597
|
apifid = @api_node.resolve_api_fid(top_file_id, transfer.destination_folder(Transfer::Spec::DIRECTION_SEND), true)
|
|
598
|
-
return
|
|
598
|
+
return Runner.result_transfer(transfer.start(apifid.node_api.transfer_spec_gen4(apifid.file_id, Transfer::Spec::DIRECTION_SEND)))
|
|
599
599
|
when :download
|
|
600
600
|
apifid, source_paths = @api_node.resolve_api_fid_paths(top_file_id, transfer.ts_source_paths)
|
|
601
|
-
return
|
|
601
|
+
return Runner.result_transfer(transfer.start(apifid.node_api.transfer_spec_gen4(apifid.file_id, Transfer::Spec::DIRECTION_RECEIVE, {'paths'=>source_paths})))
|
|
602
602
|
when :cat
|
|
603
603
|
apifid = apifid_from_next_arg(top_file_id)
|
|
604
604
|
http = apifid.node_api.read("files/#{apifid.file_id}/content", ret: :resp)
|
|
605
|
-
return
|
|
605
|
+
return Result::Text.new(http.body)
|
|
606
606
|
when :show
|
|
607
607
|
apifid = apifid_from_next_arg(top_file_id)
|
|
608
608
|
items = apifid.node_api.read("files/#{apifid.file_id}")
|
|
609
|
-
return
|
|
609
|
+
return Result::SingleObject.new(items)
|
|
610
610
|
when :modify
|
|
611
611
|
apifid = apifid_from_next_arg(top_file_id)
|
|
612
612
|
update_param = options.get_next_argument('update data', validation: Hash)
|
|
613
613
|
apifid.node_api.update("files/#{apifid.file_id}", update_param)
|
|
614
|
-
return
|
|
614
|
+
return Result::Status.new('Done')
|
|
615
615
|
when :thumbnail
|
|
616
616
|
apifid = apifid_from_next_arg(top_file_id)
|
|
617
617
|
http = apifid.node_api.read("files/#{apifid.file_id}/preview", headers: {'Accept' => 'image/png'}, ret: :resp)
|
|
618
|
-
return
|
|
618
|
+
return Result::Image.new(http.body)
|
|
619
619
|
when :permission
|
|
620
620
|
apifid = apifid_from_next_arg(top_file_id)
|
|
621
621
|
command_perm = options.get_next_command(%i[list show create delete modify])
|
|
622
622
|
case command_perm
|
|
623
623
|
when :modify
|
|
624
624
|
apifid.node_api.update("permissions/#{options.instance_identifier}", value_create_modify(command: 'permission modify'))
|
|
625
|
-
return
|
|
625
|
+
return Result::Status.new('Updated')
|
|
626
626
|
when :list
|
|
627
627
|
list_query = query_read_delete(default: Rest.php_style({'include' => %w[access_level permission_count]}))
|
|
628
628
|
# Specify file to get permissions for unless not specified (then, get all permissions)
|
|
629
629
|
list_query['file_id'] = apifid.file_id unless apifid.file_id.to_s.empty?
|
|
630
630
|
list_query['inherited'] = false if list_query.key?('file_id') && !list_query.key?('inherited')
|
|
631
631
|
items = apifid.node_api.read_with_pages('permissions', list_query)
|
|
632
|
-
return
|
|
632
|
+
return Result::ObjectList.new(items)
|
|
633
633
|
when :show
|
|
634
|
-
return
|
|
634
|
+
return Result::SingleObject.new(apifid.node_api.read("permissions/#{options.instance_identifier}"))
|
|
635
635
|
when :delete
|
|
636
636
|
return do_bulk_operation(command: command_perm, values: :identifier) do |one_id|
|
|
637
637
|
apifid.node_api.delete("permissions/#{one_id}")
|
|
@@ -652,7 +652,7 @@ module Aspera
|
|
|
652
652
|
created_data = apifid.node_api.create('permissions', create_param)
|
|
653
653
|
# notify application of creation
|
|
654
654
|
the_app&.api&.permissions_send_event(event_data: created_data, app_info: the_app)
|
|
655
|
-
return
|
|
655
|
+
return Result::SingleObject.new(created_data)
|
|
656
656
|
else Aspera.error_unreachable_line
|
|
657
657
|
end
|
|
658
658
|
else Aspera.error_unreachable_line
|
|
@@ -691,22 +691,22 @@ module Aspera
|
|
|
691
691
|
case command
|
|
692
692
|
when :list
|
|
693
693
|
resp = @api_node.read('async/list')['sync_ids']
|
|
694
|
-
return
|
|
694
|
+
return Result::ValueList.new(resp)
|
|
695
695
|
when :show
|
|
696
696
|
resp = @api_node.create('async/summary', post_data)['sync_summaries']
|
|
697
|
-
return
|
|
698
|
-
return
|
|
699
|
-
return
|
|
697
|
+
return Result::Empty.new if resp.empty?
|
|
698
|
+
return Result::ObjectList.new(resp, fields: %w[snid name local_dir remote_dir]) if async_id.eql?(SpecialValues::ALL)
|
|
699
|
+
return Result::SingleObject.new(resp.first)
|
|
700
700
|
when :delete
|
|
701
701
|
resp = @api_node.create('async/delete', post_data)
|
|
702
|
-
return
|
|
702
|
+
return Result::SingleObject.new(resp)
|
|
703
703
|
when :bandwidth
|
|
704
704
|
post_data['seconds'] = 100 # TODO: as parameter with --query
|
|
705
705
|
resp = @api_node.create('async/bandwidth', post_data)
|
|
706
706
|
data = resp['bandwidth_data']
|
|
707
|
-
return
|
|
707
|
+
return Result::Empty.new if data.empty?
|
|
708
708
|
data = data.first[async_id]['data']
|
|
709
|
-
return
|
|
709
|
+
return Result::ObjectList.new(data)
|
|
710
710
|
when :files
|
|
711
711
|
# count int
|
|
712
712
|
# filename str
|
|
@@ -733,13 +733,13 @@ module Aspera
|
|
|
733
733
|
data.select!{ |l| l['fnid'].to_i > iteration_data.first} unless iteration_data.first.nil?
|
|
734
734
|
iteration_data[0] = data.last['fnid'].to_i unless data.empty?
|
|
735
735
|
end
|
|
736
|
-
return
|
|
736
|
+
return Result::Empty.new if data.empty?
|
|
737
737
|
skip_ids_persistency&.save
|
|
738
|
-
return
|
|
738
|
+
return Result::ObjectList.new(data)
|
|
739
739
|
when :counters
|
|
740
740
|
resp = @api_node.create('async/counters', post_data)['sync_counters'].first[async_id].last
|
|
741
|
-
return
|
|
742
|
-
return
|
|
741
|
+
return Result::Empty.new if resp.nil?
|
|
742
|
+
return Result::SingleObject.new(resp)
|
|
743
743
|
end
|
|
744
744
|
end
|
|
745
745
|
|
|
@@ -775,20 +775,20 @@ module Aspera
|
|
|
775
775
|
case command
|
|
776
776
|
when :create
|
|
777
777
|
resp = @api_node.create(res_class_path, value_create_modify(command: command))
|
|
778
|
-
return
|
|
778
|
+
return Result::Status.new("#{resp['id']} created")
|
|
779
779
|
when :list
|
|
780
780
|
resp = @api_node.read(res_class_path, query_read_delete)
|
|
781
|
-
return
|
|
781
|
+
return Result::ValueList.new(resp['ids'])
|
|
782
782
|
when :show
|
|
783
|
-
return
|
|
783
|
+
return Result::SingleObject.new(@api_node.read(one_res_path))
|
|
784
784
|
when :modify
|
|
785
785
|
@api_node.update(one_res_path, value_create_modify(command: 'watch_folder'))
|
|
786
|
-
return
|
|
786
|
+
return Result::Status.new("#{one_res_id} updated")
|
|
787
787
|
when :delete
|
|
788
788
|
@api_node.delete(one_res_path)
|
|
789
|
-
return
|
|
789
|
+
return Result::Status.new("#{one_res_id} deleted")
|
|
790
790
|
when :state
|
|
791
|
-
return
|
|
791
|
+
return Result::SingleObject.new(@api_node.read("#{one_res_path}/state"))
|
|
792
792
|
end
|
|
793
793
|
end
|
|
794
794
|
|
|
@@ -833,29 +833,29 @@ module Aspera
|
|
|
833
833
|
body: '',
|
|
834
834
|
ret: :resp
|
|
835
835
|
).body
|
|
836
|
-
return
|
|
836
|
+
return Result::Status.new('Done')
|
|
837
837
|
end
|
|
838
838
|
parameters = options.get_option(:query) || {} if %i[bandwidth counters files].include?(sync_command)
|
|
839
|
-
return
|
|
839
|
+
return Result::SingleObject.new(@api_node.read("asyncs/#{asyncs_id}/#{sync_command}", parameters))
|
|
840
840
|
end
|
|
841
841
|
when :stream
|
|
842
842
|
command = options.get_next_command(%i[list create show modify cancel])
|
|
843
843
|
case command
|
|
844
844
|
when :list
|
|
845
845
|
resp = @api_node.read('ops/transfers', query_read_delete)
|
|
846
|
-
return
|
|
846
|
+
return Result::ObjectList.new(resp, fields: %w[id status]) # TODO: useful?
|
|
847
847
|
when :create
|
|
848
848
|
resp = @api_node.create('streams', value_create_modify(command: command))
|
|
849
|
-
return
|
|
849
|
+
return Result::SingleObject.new(resp)
|
|
850
850
|
when :show
|
|
851
851
|
resp = @api_node.read("ops/transfers/#{options.get_next_argument('transfer id')}")
|
|
852
|
-
return
|
|
852
|
+
return Result::SingleObject.new(resp)
|
|
853
853
|
when :modify
|
|
854
854
|
resp = @api_node.update("streams/#{options.get_next_argument('transfer id')}", value_create_modify(command: command))
|
|
855
|
-
return
|
|
855
|
+
return Result::SingleObject.new(resp)
|
|
856
856
|
when :cancel
|
|
857
857
|
resp = @api_node.cancel("streams/#{options.get_next_argument('transfer id')}")
|
|
858
|
-
return
|
|
858
|
+
return Result::SingleObject.new(resp)
|
|
859
859
|
else Aspera.error_unexpected_value(command)
|
|
860
860
|
end
|
|
861
861
|
when :transfer
|
|
@@ -877,14 +877,14 @@ module Aspera
|
|
|
877
877
|
if transfer_filter.delete('reset')
|
|
878
878
|
iteration_persistency.data.clear
|
|
879
879
|
iteration_persistency.save
|
|
880
|
-
return
|
|
880
|
+
return Result::Status.new('Persistency reset')
|
|
881
881
|
end
|
|
882
882
|
else
|
|
883
|
-
Aspera.assert(!transfer_filter.key?('reset'),
|
|
883
|
+
Aspera.assert(!transfer_filter.key?('reset'), 'reset only with once_only', type: Cli::BadArgument)
|
|
884
884
|
end
|
|
885
885
|
transfers_data = @api_node.read_with_paging('ops/transfers', transfer_filter, iteration: iteration_persistency&.data)
|
|
886
886
|
iteration_persistency&.save
|
|
887
|
-
return
|
|
887
|
+
return Result::ObjectList.new(transfers_data, fields: %w[id status start_spec.direction start_spec.remote_user start_spec.remote_host start_spec.destination_path])
|
|
888
888
|
when :sessions
|
|
889
889
|
transfers_data = @api_node.read('ops/transfers', query_read_delete)
|
|
890
890
|
sessions = transfers_data.flat_map{ |t| t['sessions']}
|
|
@@ -894,16 +894,16 @@ module Aspera
|
|
|
894
894
|
session["#{what}_time"] = session["#{what}_time_usec"] ? Time.at(session["#{what}_time_usec"] / 1_000_000.0).utc.iso8601(0) : nil
|
|
895
895
|
end
|
|
896
896
|
end
|
|
897
|
-
return
|
|
897
|
+
return Result::ObjectList.new(sessions, fields: %w[id status start_time end_time target_rate_kbps])
|
|
898
898
|
when :cancel
|
|
899
899
|
@api_node.cancel("ops/transfers/#{options.instance_identifier}")
|
|
900
|
-
return
|
|
900
|
+
return Result::Status.new('Cancelled')
|
|
901
901
|
when :show
|
|
902
902
|
resp = @api_node.read("ops/transfers/#{options.instance_identifier}")
|
|
903
|
-
return
|
|
903
|
+
return Result::SingleObject.new(resp)
|
|
904
904
|
when :modify
|
|
905
905
|
@api_node.update("ops/transfers/#{options.instance_identifier}", options.get_next_argument('update value', validation: Hash))
|
|
906
|
-
return
|
|
906
|
+
return Result::Status.new('Modified')
|
|
907
907
|
when :bandwidth_average
|
|
908
908
|
transfers_data = @api_node.read('ops/transfers', query_read_delete)
|
|
909
909
|
# collect all key dates
|
|
@@ -946,7 +946,7 @@ module Aspera
|
|
|
946
946
|
end
|
|
947
947
|
result.push({start: Time.at(start_date / 1_000_000), end: Time.at(end_date / 1_000_000)}.merge(period_bandwidth))
|
|
948
948
|
end
|
|
949
|
-
return
|
|
949
|
+
return Result::ObjectList.new(result)
|
|
950
950
|
else Aspera.error_unexpected_value(command)
|
|
951
951
|
end
|
|
952
952
|
when :service
|
|
@@ -955,15 +955,15 @@ module Aspera
|
|
|
955
955
|
case command
|
|
956
956
|
when :list
|
|
957
957
|
resp = @api_node.read('rund/services')
|
|
958
|
-
return
|
|
958
|
+
return Result::ObjectList.new(resp['services'])
|
|
959
959
|
when :create
|
|
960
960
|
# @json:'{"type":"WATCHFOLDERD","run_as":{"user":"user1"}}'
|
|
961
961
|
params = options.get_next_argument('creation data', validation: Hash)
|
|
962
962
|
resp = @api_node.create('rund/services', params)
|
|
963
|
-
return
|
|
963
|
+
return Result::Status.new("#{resp['id']} created")
|
|
964
964
|
when :delete
|
|
965
965
|
@api_node.delete("rund/services/#{service_id}")
|
|
966
|
-
return
|
|
966
|
+
return Result::Status.new("#{service_id} deleted")
|
|
967
967
|
end
|
|
968
968
|
when :watch_folder
|
|
969
969
|
return watch_folder_action
|
|
@@ -980,7 +980,7 @@ module Aspera
|
|
|
980
980
|
request_data = options.get_next_argument('request data', mandatory: false, validation: Hash, default: {})
|
|
981
981
|
request_data.deep_merge!({'validation' => validation}) unless validation.nil?
|
|
982
982
|
resp = @api_node.create('services/rest/transfers/v1/sessions', request_data)
|
|
983
|
-
return
|
|
983
|
+
return Result::ObjectList.new(resp['session_info_result']['session_info'], fields: %w[session_uuid status transport direction bytes_transferred])
|
|
984
984
|
end
|
|
985
985
|
when :file
|
|
986
986
|
command = options.get_next_command(%i[list modify])
|
|
@@ -991,12 +991,12 @@ module Aspera
|
|
|
991
991
|
resp = @api_node.create('services/rest/transfers/v1/files', request_data)
|
|
992
992
|
resp = JSON.parse(resp) if resp.is_a?(String)
|
|
993
993
|
Log.dump(:resp, resp)
|
|
994
|
-
return
|
|
994
|
+
return Result::ObjectList.new(resp['file_transfer_info_result']['file_transfer_info'], fields: %w[session_uuid file_id status path])
|
|
995
995
|
when :modify
|
|
996
996
|
request_data = options.get_next_argument('request data', mandatory: false, validation: Hash, default: {})
|
|
997
997
|
request_data.deep_merge!(validation) unless validation.nil?
|
|
998
998
|
@api_node.update('services/rest/transfers/v1/files', request_data)
|
|
999
|
-
return
|
|
999
|
+
return Result::Status.new('updated')
|
|
1000
1000
|
end
|
|
1001
1001
|
end
|
|
1002
1002
|
when :asperabrowser
|
|
@@ -1008,14 +1008,14 @@ module Aspera
|
|
|
1008
1008
|
# encode parameters so that it looks good in url
|
|
1009
1009
|
encoded_params = Base64.strict_encode64(Zlib::Deflate.deflate(JSON.generate(browse_params))).gsub(/=+$/, '').tr('+/', '-_').reverse
|
|
1010
1010
|
Environment.instance.open_uri("#{options.get_option(:asperabrowserurl)}?goto=#{encoded_params}")
|
|
1011
|
-
return
|
|
1011
|
+
return Result::Status.new('done')
|
|
1012
1012
|
when :basic_token
|
|
1013
|
-
return
|
|
1013
|
+
return Result::Text.new(Rest.basic_authorization(options.get_option(:username, mandatory: true), options.get_option(:password, mandatory: true)))
|
|
1014
1014
|
when :bearer_token
|
|
1015
1015
|
private_key = OpenSSL::PKey::RSA.new(options.get_next_argument('private RSA key PEM value', validation: String))
|
|
1016
1016
|
token_info = options.get_next_argument('user and group identification', validation: Hash)
|
|
1017
1017
|
access_key = options.get_option(:username, mandatory: true)
|
|
1018
|
-
return
|
|
1018
|
+
return Result::Text.new(Api::Node.bearer_token(payload: token_info, access_key: access_key, private_key: private_key))
|
|
1019
1019
|
when :simulator
|
|
1020
1020
|
require 'aspera/node_simulator'
|
|
1021
1021
|
parameters = value_create_modify(command: command, default: {}).symbolize_keys
|
|
@@ -1023,7 +1023,7 @@ module Aspera
|
|
|
1023
1023
|
server = WebServerSimple.new(uri, **parameters.slice(*WebServerSimple::PARAMS))
|
|
1024
1024
|
server.mount(uri.path, NodeSimulatorServlet, parameters.except(*WebServerSimple::PARAMS), NodeSimulator.new)
|
|
1025
1025
|
server.start
|
|
1026
|
-
return
|
|
1026
|
+
return Result::Status.new('Simulator terminated')
|
|
1027
1027
|
when :telemetry
|
|
1028
1028
|
parameters = value_create_modify(command: command, default: {}).symbolize_keys
|
|
1029
1029
|
%i[url key].each do |psym|
|
|
@@ -1128,7 +1128,7 @@ module Aspera
|
|
|
1128
1128
|
def cli_result_from_paths_response(response, success_msg)
|
|
1129
1129
|
obj_list = response_to_result(response, success_msg)
|
|
1130
1130
|
@node_path_prefix&.remove_in_object_list!(obj_list)
|
|
1131
|
-
return
|
|
1131
|
+
return Result::ObjectList.new(obj_list, fields: %w[path result])
|
|
1132
1132
|
end
|
|
1133
1133
|
end
|
|
1134
1134
|
end
|
|
@@ -136,38 +136,34 @@ module Aspera
|
|
|
136
136
|
rescue StandardError => e
|
|
137
137
|
nagios.add_critical('node api', e.to_s)
|
|
138
138
|
end
|
|
139
|
-
|
|
139
|
+
Result::ObjectList.new(nagios.status_list)
|
|
140
140
|
# 14. Ping the remote Instance
|
|
141
141
|
when :info
|
|
142
142
|
result = call_ao('remote_node_ping', format: 'xml', xml_arrays: false)
|
|
143
|
-
return
|
|
143
|
+
return Result::SingleObject.new(result)
|
|
144
144
|
# 12. Orchestrator Background Process status
|
|
145
145
|
when :processes
|
|
146
146
|
# TODO: Bug ? API has only XML format
|
|
147
147
|
result = call_ao('processes_status', format: 'xml')
|
|
148
|
-
return
|
|
148
|
+
return Result::ObjectList.new(result['process'])
|
|
149
149
|
# 13. Orchestrator Monitor
|
|
150
150
|
when :monitors
|
|
151
151
|
result = call_ao('monitor_snapshot')
|
|
152
|
-
return
|
|
152
|
+
return Result::SingleObject.new(result['monitor'])
|
|
153
153
|
when :plugins
|
|
154
154
|
# TODO: Bug ? only json format on url
|
|
155
155
|
result = call_ao('plugin_version')
|
|
156
|
-
return
|
|
156
|
+
return Result::ObjectList.new(result['Plugin'])
|
|
157
157
|
when :workflows
|
|
158
158
|
command = options.get_next_command(%i[list status inputs details start export workorders outputs])
|
|
159
159
|
case command
|
|
160
160
|
# 1. List all available workflows on the system
|
|
161
161
|
when :list
|
|
162
162
|
result = call_ao('workflows_list')
|
|
163
|
-
return
|
|
163
|
+
return Result::ObjectList.new(result['workflows']['workflow'], fields: %w[id portable_id name published_status published_revision_id latest_revision_id last_modification])
|
|
164
164
|
# 2.1 Initiate a workorder - Asynchronous
|
|
165
165
|
# 2.2 Initiate a workorder - Synchronous
|
|
166
166
|
when :start
|
|
167
|
-
result = {
|
|
168
|
-
type: :single_object,
|
|
169
|
-
data: nil
|
|
170
|
-
}
|
|
171
167
|
call_params = {format: :json}
|
|
172
168
|
wf_id = options.instance_identifier
|
|
173
169
|
# get external parameters if any
|
|
@@ -179,7 +175,6 @@ module Aspera
|
|
|
179
175
|
# expected result for synchro call ?
|
|
180
176
|
result_location = options.get_option(:result)
|
|
181
177
|
unless result_location.nil?
|
|
182
|
-
result[:type] = :status
|
|
183
178
|
fields = result_location.split(':')
|
|
184
179
|
raise Cli::BadArgument, "Expects: work_step:result_name : #{result_location}" if fields.length != 2
|
|
185
180
|
call_params['explicit_output_step'] = fields[0]
|
|
@@ -187,34 +182,34 @@ module Aspera
|
|
|
187
182
|
# implicitly, call is synchronous
|
|
188
183
|
call_params['synchronous'] = true
|
|
189
184
|
end
|
|
190
|
-
|
|
191
|
-
result
|
|
192
|
-
return
|
|
185
|
+
result_data = call_ao("initiate/#{wf_id}", args: call_params)
|
|
186
|
+
# Return appropriate result type based on call mode
|
|
187
|
+
return call_params['synchronous'] ? Result::Text.new(result_data) : Result::SingleObject.new(result_data)
|
|
193
188
|
# 3. Fetch input specification for a workflow
|
|
194
189
|
when :inputs
|
|
195
190
|
result = call_ao("workflow_inputs_spec/#{options.instance_identifier}")
|
|
196
|
-
return
|
|
191
|
+
return Result::SingleObject.new(result['workflow_inputs_spec'])
|
|
197
192
|
# 4. Check the running status for all workflows
|
|
198
193
|
# 5. Check the running status for a particular workflow
|
|
199
194
|
when :status
|
|
200
195
|
wf_id = options.instance_identifier
|
|
201
196
|
result = call_ao(wf_id.eql?(SpecialValues::ALL) ? 'workflows_status' : "workflows_status/#{wf_id}")
|
|
202
|
-
return
|
|
197
|
+
return Result::ObjectList.new(result['workflows']['workflow'])
|
|
203
198
|
# 6. Check the detailed running status for a particular workflow
|
|
204
199
|
when :details
|
|
205
200
|
result = call_ao("workflow_details/#{options.instance_identifier}")
|
|
206
|
-
return
|
|
201
|
+
return Result::ObjectList.new(result['workflows']['workflow']['statuses'])
|
|
207
202
|
# 15. Fetch output specification for a particular work flow
|
|
208
203
|
when :outputs
|
|
209
204
|
result = call_ao("workflow_outputs_spec/#{options.instance_identifier}")
|
|
210
|
-
return
|
|
205
|
+
return Result::ObjectList.new(result['workflow_outputs_spec']['output'])
|
|
211
206
|
# 19.Fetch all workorders from a workflow
|
|
212
207
|
when :workorders
|
|
213
208
|
result = call_ao("work_orders_list/#{options.instance_identifier}")
|
|
214
|
-
return
|
|
209
|
+
return Result::ObjectList.new(result['work_orders'])
|
|
215
210
|
when :export
|
|
216
211
|
result = call_ao("export_workflow/#{options.instance_identifier}", format: nil, http: true)
|
|
217
|
-
return
|
|
212
|
+
return Result::Text.new(result.body)
|
|
218
213
|
end
|
|
219
214
|
when :workorders
|
|
220
215
|
command = options.get_next_command(%i[status cancel reset output])
|
|
@@ -223,22 +218,22 @@ module Aspera
|
|
|
223
218
|
when :status
|
|
224
219
|
wo_id = options.instance_identifier
|
|
225
220
|
result = call_ao("work_order_status/#{wo_id}")
|
|
226
|
-
return
|
|
221
|
+
return Result::SingleObject.new(result['work_order'])
|
|
227
222
|
# 9. Cancel a Work Order
|
|
228
223
|
when :cancel
|
|
229
224
|
wo_id = options.instance_identifier
|
|
230
225
|
result = call_ao("work_order_cancel/#{wo_id}")
|
|
231
|
-
return
|
|
226
|
+
return Result::SingleObject.new(result['work_order'])
|
|
232
227
|
# 11. Reset a Work order
|
|
233
228
|
when :reset
|
|
234
229
|
wo_id = options.instance_identifier
|
|
235
230
|
result = call_ao("work_order_reset/#{wo_id}")
|
|
236
|
-
return
|
|
231
|
+
return Result::SingleObject.new(result['work_order'])
|
|
237
232
|
# 16. Fetch output of a work order
|
|
238
233
|
when :output
|
|
239
234
|
wo_id = options.instance_identifier
|
|
240
235
|
result = call_ao("work_order_output/#{wo_id}", format: 'xml')
|
|
241
|
-
return
|
|
236
|
+
return Result::ObjectList.new(result['variable'])
|
|
242
237
|
end
|
|
243
238
|
when :workstep
|
|
244
239
|
command = options.get_next_command(%i[status cancel])
|
|
@@ -247,12 +242,12 @@ module Aspera
|
|
|
247
242
|
when :status
|
|
248
243
|
ws_id = options.instance_identifier
|
|
249
244
|
result = call_ao("work_step_status/#{ws_id}")
|
|
250
|
-
return
|
|
245
|
+
return Result::SingleObject.new(result)
|
|
251
246
|
# 10. Cancel a Work Step
|
|
252
247
|
when :cancel
|
|
253
248
|
ws_id = options.instance_identifier
|
|
254
249
|
result = call_ao("work_step_cancel/#{ws_id}")
|
|
255
|
-
return
|
|
250
|
+
return Result::SingleObject.new(result)
|
|
256
251
|
end
|
|
257
252
|
else Aspera.error_unexpected_value(command)
|
|
258
253
|
end
|