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
|
@@ -27,12 +27,14 @@ module Aspera
|
|
|
27
27
|
client
|
|
28
28
|
client_access_key
|
|
29
29
|
client_registration_token
|
|
30
|
+
configuration_policy
|
|
30
31
|
contact
|
|
31
32
|
dropbox
|
|
32
33
|
dropbox_membership
|
|
33
34
|
group
|
|
34
35
|
group_membership
|
|
35
36
|
kms_profile
|
|
37
|
+
network_policy
|
|
36
38
|
node
|
|
37
39
|
operation
|
|
38
40
|
organization
|
|
@@ -100,7 +102,7 @@ module Aspera
|
|
|
100
102
|
# @param fld. [Array] List of fields of package
|
|
101
103
|
def unique_folder(package_info, destination_folder, fld: nil, seq: false, opt: false)
|
|
102
104
|
Aspera.assert_array_all(fld, String, type: BadArgument){'fld'}
|
|
103
|
-
Aspera.
|
|
105
|
+
Aspera.assert_values(fld.length, [1, 2]){'fld length'}
|
|
104
106
|
folder = Environment.instance.sanitized_filename(package_info[fld[0]])
|
|
105
107
|
if seq
|
|
106
108
|
folder = next_available_folder(folder, always: !opt)
|
|
@@ -178,7 +180,7 @@ module Aspera
|
|
|
178
180
|
end
|
|
179
181
|
myself = aoc_api.read('self')
|
|
180
182
|
if auto_set_pub_key
|
|
181
|
-
Aspera.assert(myself['public_key'].empty?,
|
|
183
|
+
Aspera.assert(myself['public_key'].empty?, 'Public key is already set in profile (use --override=yes)', type: Error) unless option_override
|
|
182
184
|
formatter.display_status('Updating profile with the public key.')
|
|
183
185
|
aoc_api.update("users/#{myself['id']}", {'public_key' => pub_key_pem})
|
|
184
186
|
end
|
|
@@ -289,7 +291,7 @@ module Aspera
|
|
|
289
291
|
# @return identifier
|
|
290
292
|
def get_resource_id_from_args(resource_class_path)
|
|
291
293
|
return options.instance_identifier do |field, value|
|
|
292
|
-
Aspera.
|
|
294
|
+
Aspera.assert_values(field, ['name'], type: BadArgument){'selector field'}
|
|
293
295
|
aoc_api.lookup_with_q(resource_class_path, value: value)['id']
|
|
294
296
|
end
|
|
295
297
|
end
|
|
@@ -312,7 +314,7 @@ module Aspera
|
|
|
312
314
|
# caller may add specific modifications or checks to query
|
|
313
315
|
yield(query) if block_given?
|
|
314
316
|
result = aoc_api.read_with_paging(resource_class_path, base_query.merge(query).compact)
|
|
315
|
-
return
|
|
317
|
+
return Result::ObjectList.new(result[:items], fields: fields, total: result[:total])
|
|
316
318
|
end
|
|
317
319
|
|
|
318
320
|
# Translates `dropbox_name` to `dropbox_id` and fills current workspace_id
|
|
@@ -389,7 +391,7 @@ module Aspera
|
|
|
389
391
|
'destination_root_id' => server_apifid.file_id,
|
|
390
392
|
'source_root_id' => client_apifid.file_id
|
|
391
393
|
}
|
|
392
|
-
return
|
|
394
|
+
return Runner.result_transfer(transfer.start(server_apifid.node_api.transfer_spec_gen4(
|
|
393
395
|
server_apifid.file_id,
|
|
394
396
|
client_direction,
|
|
395
397
|
add_ts
|
|
@@ -413,6 +415,7 @@ module Aspera
|
|
|
413
415
|
supported_operations = Operations::ALL
|
|
414
416
|
# API path
|
|
415
417
|
resource_class_path = "#{resource_type}s"
|
|
418
|
+
resource_class_path = resource_class_path.gsub(/ys$/, 'ies')
|
|
416
419
|
# path in openapi where post is located to get creation schema
|
|
417
420
|
create_schema_path = resource_class_path
|
|
418
421
|
case resource_type
|
|
@@ -428,6 +431,8 @@ module Aspera
|
|
|
428
431
|
when :contact
|
|
429
432
|
list_default_fields = %w[source_type source_id name email]
|
|
430
433
|
# list_default_query = {'include_only_user_personal_contacts' => true} if @scope == Api::AoC::Scope::USER
|
|
434
|
+
when :configuration_policy, :network_policy
|
|
435
|
+
list_default_fields = nil
|
|
431
436
|
when :dropbox
|
|
432
437
|
require_workspace_id = true
|
|
433
438
|
resource_class_path = "#{resource_type}es"
|
|
@@ -480,7 +485,7 @@ module Aspera
|
|
|
480
485
|
return result_list(resource_class_path, fields: list_default_fields, default_query: list_default_query)
|
|
481
486
|
when :show
|
|
482
487
|
object = aoc_api.read(resource_instance_path, query_read_delete)
|
|
483
|
-
return
|
|
488
|
+
return Result::SingleObject.new(object, fields: Formatter.all_but('certificate'))
|
|
484
489
|
when :modify
|
|
485
490
|
changes = options.get_next_argument('properties', validation: Hash, schema: schema_create_modify)
|
|
486
491
|
return do_bulk_operation(command: command, values: res_id) do |one_id|
|
|
@@ -497,7 +502,7 @@ module Aspera
|
|
|
497
502
|
the_private_key = options.get_next_argument('private_key PEM value', validation: String)
|
|
498
503
|
the_public_key = OpenSSL::PKey::RSA.new(the_private_key).public_key.to_s
|
|
499
504
|
aoc_api.update(resource_instance_path, {jwt_grant_enabled: true, public_key: the_public_key})
|
|
500
|
-
return
|
|
505
|
+
return Result::Success.new
|
|
501
506
|
when :do
|
|
502
507
|
command_repo = options.get_next_command(FILES_COMMANDS)
|
|
503
508
|
return execute_nodegen4_command(command_repo, res_id, scope: Api::Node::Scope::ADMIN)
|
|
@@ -506,14 +511,14 @@ module Aspera
|
|
|
506
511
|
node_id: res_id,
|
|
507
512
|
scope: options.get_next_argument('scope', default: Api::Node::Scope::ADMIN)
|
|
508
513
|
)
|
|
509
|
-
return
|
|
514
|
+
return Result::Text.new(node_api.oauth.authorization)
|
|
510
515
|
when :dropbox
|
|
511
516
|
command_shared = options.get_next_command(%i[list])
|
|
512
517
|
case command_shared
|
|
513
518
|
when :list
|
|
514
519
|
query = options.get_option(:query) || {}
|
|
515
520
|
res_data = aoc_api.read('dropboxes', query.merge({'workspace_id'=>res_id}))
|
|
516
|
-
return
|
|
521
|
+
return Result::ObjectList.new(res_data, fields: %w[id name description])
|
|
517
522
|
end
|
|
518
523
|
when :shared_folder
|
|
519
524
|
query = options.get_option(:query) || Api::AoC.workspace_access(res_id).merge({'admin' => true})
|
|
@@ -522,17 +527,17 @@ module Aspera
|
|
|
522
527
|
command_shared = options.get_next_command(%i[list node member])
|
|
523
528
|
case command_shared
|
|
524
529
|
when :list
|
|
525
|
-
return
|
|
530
|
+
return Result::ObjectList.new(shared_folders, fields: %w[id node_name node_id file_id file.path tags.aspera.files.workspace.share_as])
|
|
526
531
|
when :node
|
|
527
532
|
shared_folder_id = options.instance_identifier(description: 'Shared folder ID')
|
|
528
533
|
shared_folder = shared_folders.find{ |i| i['id'].eql?(shared_folder_id)}
|
|
529
|
-
Aspera.assert(shared_folder)
|
|
534
|
+
Aspera.assert(shared_folder, 'shared folder not found')
|
|
530
535
|
command_repo = options.get_next_command(FILES_COMMANDS)
|
|
531
536
|
return execute_nodegen4_command(command_repo, shared_folder['node_id'], file_id: shared_folder['file_id'], scope: Api::Node::Scope::ADMIN)
|
|
532
537
|
when :member
|
|
533
538
|
shared_folder_id = options.instance_identifier(description: 'Shared folder ID')
|
|
534
539
|
shared_folder = shared_folders.find{ |i| i['id'].eql?(shared_folder_id)}
|
|
535
|
-
Aspera.assert(shared_folder)
|
|
540
|
+
Aspera.assert(shared_folder, 'shared folder not found')
|
|
536
541
|
command_shared_member = options.get_next_command(%i[list])
|
|
537
542
|
case command_shared_member
|
|
538
543
|
when :list
|
|
@@ -558,17 +563,17 @@ module Aspera
|
|
|
558
563
|
end
|
|
559
564
|
end
|
|
560
565
|
# TODO : read users and group name and add, if query "include_members"
|
|
561
|
-
return
|
|
566
|
+
return Result::ObjectList.new(result, fields: %w[access_type access_id access_level last_updated_at member.name member.email member.system_group_type member.system_group])
|
|
562
567
|
end
|
|
563
568
|
end
|
|
564
569
|
when :preferences, :notifications
|
|
565
570
|
user_preferences_res = "#{resource_instance_path}/#{command.eql?(:preferences) ? 'user_interaction_preferences' : 'notification_preferences'}"
|
|
566
571
|
case options.get_next_command(%i[show modify])
|
|
567
572
|
when :show
|
|
568
|
-
return
|
|
573
|
+
return Result::SingleObject.new(aoc_api.read(user_preferences_res))
|
|
569
574
|
when :modify
|
|
570
575
|
aoc_api.update(user_preferences_res, options.get_next_argument('properties', validation: Hash))
|
|
571
|
-
return
|
|
576
|
+
return Result::Status.new('modified')
|
|
572
577
|
end
|
|
573
578
|
else Aspera.error_unexpected_value(command)
|
|
574
579
|
end
|
|
@@ -576,21 +581,22 @@ module Aspera
|
|
|
576
581
|
|
|
577
582
|
def execute_application_action
|
|
578
583
|
apps_info = aoc_api.read('admin/apps')
|
|
579
|
-
|
|
584
|
+
# List of allowed symbols for app type
|
|
585
|
+
all_app_syms = apps_info.map{ |i| i['app_type'].to_sym}
|
|
580
586
|
command_apps = options.get_next_command(%i[types settings instance membership])
|
|
581
587
|
case command_apps
|
|
582
588
|
when :types
|
|
583
|
-
return
|
|
589
|
+
return Result::ObjectList.new(apps_info)
|
|
584
590
|
when :settings
|
|
585
|
-
app_type = options.get_next_command(
|
|
591
|
+
app_type = options.get_next_command(all_app_syms)
|
|
586
592
|
cmd_path = "/apps/#{app_type}/settings"
|
|
587
593
|
command_app_settings = options.get_next_command(Operations::SINGLETON)
|
|
588
594
|
case command_app_settings
|
|
589
595
|
when :show
|
|
590
|
-
return
|
|
596
|
+
return Result::SingleObject.new(aoc_api.read(cmd_path))
|
|
591
597
|
when :modify
|
|
592
598
|
aoc_api.update(cmd_path, options.get_next_argument('properties', validation: Hash))
|
|
593
|
-
return
|
|
599
|
+
return Result::Status.new('modified')
|
|
594
600
|
end
|
|
595
601
|
when :instance
|
|
596
602
|
list_default_query = {workspace_id: aoc_api.workspace_info[:id]}
|
|
@@ -598,17 +604,17 @@ module Aspera
|
|
|
598
604
|
command_app_instances = options.get_next_command(%i[list] + Operations::SINGLETON)
|
|
599
605
|
resource_path = 'admin/apps_new'
|
|
600
606
|
if Operations::SINGLETON.include?(command_app_instances)
|
|
601
|
-
app_type = options.get_next_command(
|
|
607
|
+
app_type = options.get_next_command(all_app_syms)
|
|
602
608
|
resource_path = "#{resource_path}/#{app_type}/#{options.instance_identifier(description: "#{app_type} identifier")}"
|
|
603
609
|
end
|
|
604
610
|
case command_app_instances
|
|
605
611
|
when :list
|
|
606
612
|
return result_list(resource_path, fields: list_default_fields, default_query: list_default_query)
|
|
607
613
|
when :show
|
|
608
|
-
return
|
|
614
|
+
return Result::SingleObject.new(aoc_api.read(resource_path, query_read_delete))
|
|
609
615
|
when :modify
|
|
610
616
|
aoc_api.update(resource_path, options.get_next_argument('properties', validation: Hash))
|
|
611
|
-
return
|
|
617
|
+
return Result::Status.new('modified')
|
|
612
618
|
end
|
|
613
619
|
when :membership
|
|
614
620
|
resource_path = 'apps/app_memberships'
|
|
@@ -618,13 +624,16 @@ module Aspera
|
|
|
618
624
|
when :list
|
|
619
625
|
return result_list(resource_path)
|
|
620
626
|
when :delete
|
|
621
|
-
aoc_api.delete(
|
|
622
|
-
return
|
|
627
|
+
aoc_api.delete(resource_path)
|
|
628
|
+
return Result::Status.new('deleted')
|
|
623
629
|
when :show
|
|
624
|
-
return
|
|
630
|
+
return Result::SingleObject.new(aoc_api.read(resource_path, query_read_delete))
|
|
625
631
|
when :create
|
|
626
|
-
|
|
627
|
-
|
|
632
|
+
data = options.get_next_argument('membership properties', validation: Hash)
|
|
633
|
+
app_type = data.delete('app_type')
|
|
634
|
+
Aspera.assert_type(app_type, String){'app_type'}
|
|
635
|
+
Aspera.assert_values(app_type.to_sym, all_app_syms){'app_type'}
|
|
636
|
+
return Result::SingleObject.new(aoc_api.create("apps/#{app_type}/app_memberships", data))
|
|
628
637
|
end
|
|
629
638
|
end
|
|
630
639
|
end
|
|
@@ -637,7 +646,7 @@ module Aspera
|
|
|
637
646
|
command_admin = options.get_next_command(ADMIN_ACTIONS)
|
|
638
647
|
case command_admin
|
|
639
648
|
when :bearer_token
|
|
640
|
-
return
|
|
649
|
+
return Result::Text.new(aoc_api.oauth.authorization)
|
|
641
650
|
when *ADMIN_OBJECTS
|
|
642
651
|
return execute_resource_action(command_admin)
|
|
643
652
|
when :application
|
|
@@ -709,7 +718,7 @@ module Aspera
|
|
|
709
718
|
GRAPHQL
|
|
710
719
|
# cspell:enable
|
|
711
720
|
result = bss_graphql.create(nil, {query: graphql_query, variables: {organization_id: org['id']}})['data']
|
|
712
|
-
return
|
|
721
|
+
return Result::SingleObject.new(result['aoc']['bssSubscription'])
|
|
713
722
|
when :usage
|
|
714
723
|
# cspell:disable
|
|
715
724
|
graphql_query = <<-GRAPHQL
|
|
@@ -760,7 +769,7 @@ module Aspera
|
|
|
760
769
|
}
|
|
761
770
|
}
|
|
762
771
|
)['data']
|
|
763
|
-
return
|
|
772
|
+
return Result::SingleObject.new(result['aoc'])
|
|
764
773
|
end
|
|
765
774
|
when :ats
|
|
766
775
|
ats_api = Rest.new(**aoc_api.params.deep_merge({
|
|
@@ -778,7 +787,7 @@ module Aspera
|
|
|
778
787
|
when :application_events
|
|
779
788
|
event_type = command_analytics.to_s
|
|
780
789
|
events = analytics_api.read("organizations/#{aoc_api.current_user_info['organization_id']}/#{event_type}")[event_type]
|
|
781
|
-
return
|
|
790
|
+
return Result::ObjectList.new(events)
|
|
782
791
|
when :transfers
|
|
783
792
|
event_type = command_analytics.to_s
|
|
784
793
|
event_resource_type = options.get_next_argument('resource', accept_list: %i[organizations users nodes])
|
|
@@ -817,7 +826,7 @@ module Aspera
|
|
|
817
826
|
config.send_email_template(values: {ev: tr_event})
|
|
818
827
|
end
|
|
819
828
|
end
|
|
820
|
-
return
|
|
829
|
+
return Result::ObjectList.new(events)
|
|
821
830
|
when :files
|
|
822
831
|
event_type = command_analytics.to_s
|
|
823
832
|
event_resource_type = options.get_next_argument('resource', accept_list: %i[organizations users nodes])
|
|
@@ -833,7 +842,7 @@ module Aspera
|
|
|
833
842
|
filter = query_read_delete(default: {})
|
|
834
843
|
filter['limit'] ||= 100
|
|
835
844
|
events = analytics_api.read("#{event_resource_type}/#{event_resource_id}/transfers/#{event_uuid}/#{event_type}", filter)[event_type]
|
|
836
|
-
return
|
|
845
|
+
return Result::ObjectList.new(events)
|
|
837
846
|
end
|
|
838
847
|
when :usage_reports
|
|
839
848
|
return result_list('usage_reports', base_query: workspace_id_hash)
|
|
@@ -898,7 +907,7 @@ module Aspera
|
|
|
898
907
|
result_create_short_link = aoc_api.create('short_links', create_payload)
|
|
899
908
|
# Creation: perm_block: permission on node
|
|
900
909
|
yield(:create, result_create_short_link['resource_id'], access_levels) if block_given? && link_type.eql?(:public)
|
|
901
|
-
return
|
|
910
|
+
return Result::SingleObject.new(result_create_short_link)
|
|
902
911
|
when :delete, :list, :show, :modify
|
|
903
912
|
workspace_id_hash(shared_data)
|
|
904
913
|
query = if link_type.eql?(:private)
|
|
@@ -931,14 +940,14 @@ module Aspera
|
|
|
931
940
|
edit_access: true,
|
|
932
941
|
json_query: shared_data.to_json
|
|
933
942
|
})
|
|
934
|
-
return
|
|
943
|
+
return Result::Status.new('deleted')
|
|
935
944
|
when :list
|
|
936
|
-
return
|
|
945
|
+
return Result::ObjectList.new(short_list[:items], fields: Formatter.all_but('data'), total: short_list[:total])
|
|
937
946
|
when :show
|
|
938
947
|
one_id = options.instance_identifier(description: 'short link id')
|
|
939
948
|
found = short_list[:items].find{ |item| item['id'].eql?(one_id)}
|
|
940
949
|
raise BadIdentifier.new('Short link', one_id) if found.nil?
|
|
941
|
-
return
|
|
950
|
+
return Result::SingleObject.new(found, fields: Formatter.all_but('data'))
|
|
942
951
|
when :modify
|
|
943
952
|
one_id = options.instance_identifier(description: 'short link id')
|
|
944
953
|
node_file = shared_data.slice(:node_id, :file_id)
|
|
@@ -966,7 +975,7 @@ module Aspera
|
|
|
966
975
|
end
|
|
967
976
|
modify_payload.deep_merge!(custom_data)
|
|
968
977
|
aoc_api.update("short_links/#{one_id}", modify_payload)
|
|
969
|
-
return
|
|
978
|
+
return Result::Status.new('modified')
|
|
970
979
|
end
|
|
971
980
|
else Aspera.error_unexpected_value(command)
|
|
972
981
|
end
|
|
@@ -1010,46 +1019,48 @@ module Aspera
|
|
|
1010
1019
|
when :reminder
|
|
1011
1020
|
# send an email reminder with list of orgs
|
|
1012
1021
|
user_email = options.get_option(:username, mandatory: true)
|
|
1013
|
-
|
|
1014
|
-
|
|
1022
|
+
no_auth_api = Api::AoC.new(url: options.get_option(:url), auth: :none)
|
|
1023
|
+
no_auth_api.create('organization_reminders', {email: user_email})
|
|
1024
|
+
return Result::Status.new("List of organizations user is member of, has been sent by e-mail to #{user_email}")
|
|
1015
1025
|
when :servers
|
|
1016
|
-
|
|
1026
|
+
no_auth_api = Api::AoC.new(url: options.get_option(:url), auth: :none)
|
|
1027
|
+
return Result::ObjectList.new(no_auth_api.read('servers'))
|
|
1017
1028
|
when :bearer_token
|
|
1018
|
-
return
|
|
1029
|
+
return Result::Text.new(aoc_api.oauth.authorization)
|
|
1019
1030
|
when :organization
|
|
1020
|
-
return
|
|
1031
|
+
return Result::SingleObject.new(aoc_api.read('organization'))
|
|
1021
1032
|
when :tier_restrictions
|
|
1022
|
-
return
|
|
1033
|
+
return Result::SingleObject.new(aoc_api.read('tier_restrictions'))
|
|
1023
1034
|
when :user
|
|
1024
|
-
user_cmd = options.get_next_command(%i[workspaces profile preferences notifications contacts])
|
|
1035
|
+
user_cmd = options.get_next_command(%i[workspaces profile preferences notifications contacts settings])
|
|
1025
1036
|
case user_cmd
|
|
1026
1037
|
when :contacts
|
|
1027
1038
|
return execute_resource_action(:contact)
|
|
1028
|
-
|
|
1029
|
-
|
|
1039
|
+
when :settings
|
|
1040
|
+
return entity_execute(api: aoc_api, entity: 'client_settings')
|
|
1030
1041
|
when :workspaces
|
|
1031
1042
|
case options.get_next_command(%i[list current])
|
|
1032
1043
|
when :list
|
|
1033
1044
|
return result_list('workspaces', fields: %w[id name])
|
|
1034
1045
|
when :current
|
|
1035
|
-
return
|
|
1046
|
+
return Result::SingleObject.new(aoc_api.workspace_info)
|
|
1036
1047
|
end
|
|
1037
1048
|
when :profile
|
|
1038
1049
|
case options.get_next_command(%i[show modify])
|
|
1039
1050
|
when :show
|
|
1040
|
-
return
|
|
1051
|
+
return Result::SingleObject.new(aoc_api.current_user_info(exception: true))
|
|
1041
1052
|
when :modify
|
|
1042
1053
|
aoc_api.update("users/#{aoc_api.current_user_info(exception: true)['id']}", options.get_next_argument('properties', validation: Hash))
|
|
1043
|
-
return
|
|
1054
|
+
return Result::Status.new('modified')
|
|
1044
1055
|
end
|
|
1045
1056
|
when :preferences, :notifications
|
|
1046
1057
|
user_preferences_res = "users/#{aoc_api.current_user_info(exception: true)['id']}/#{user_cmd.eql?(:preferences) ? 'user_interaction_preferences' : 'notification_preferences'}"
|
|
1047
1058
|
case options.get_next_command(%i[show modify])
|
|
1048
1059
|
when :show
|
|
1049
|
-
return
|
|
1060
|
+
return Result::SingleObject.new(aoc_api.read(user_preferences_res))
|
|
1050
1061
|
when :modify
|
|
1051
1062
|
aoc_api.update(user_preferences_res, options.get_next_argument('properties', validation: Hash))
|
|
1052
|
-
return
|
|
1063
|
+
return Result::Status.new('modified')
|
|
1053
1064
|
end
|
|
1054
1065
|
end
|
|
1055
1066
|
when :packages
|
|
@@ -1062,7 +1073,7 @@ module Aspera
|
|
|
1062
1073
|
workspace_id_hash(default_query, string: true)
|
|
1063
1074
|
return result_list('dropbox_memberships', fields: %w[dropbox_id dropbox.name], default_query: default_query)
|
|
1064
1075
|
when :show
|
|
1065
|
-
return
|
|
1076
|
+
return Result::SingleObject.new(aoc_api.read(get_resource_path_from_args('dropboxes')))
|
|
1066
1077
|
when :short_link
|
|
1067
1078
|
# TODO: check name
|
|
1068
1079
|
return short_link_command(dropbox_id: get_resource_id_from_args('dropboxes'), name: '')
|
|
@@ -1083,9 +1094,9 @@ module Aspera
|
|
|
1083
1094
|
package_data['encryption_at_rest'] = true if transfer.user_transfer_spec['content_protection'].eql?('encrypt')
|
|
1084
1095
|
# transfer may raise an error
|
|
1085
1096
|
created_package = aoc_api.create_package_simple(package_data, option_validate, new_user_option)
|
|
1086
|
-
|
|
1097
|
+
Runner.result_transfer(transfer.start(created_package[:spec], rest_token: created_package[:node]))
|
|
1087
1098
|
# return all info on package (especially package id)
|
|
1088
|
-
return
|
|
1099
|
+
return Result::SingleObject.new(created_package[:info])
|
|
1089
1100
|
when :receive
|
|
1090
1101
|
ids_to_download = nil
|
|
1091
1102
|
if !aoc_api.public_link.nil?
|
|
@@ -1099,10 +1110,10 @@ module Aspera
|
|
|
1099
1110
|
case ids_to_download
|
|
1100
1111
|
when SpecialValues::INIT
|
|
1101
1112
|
all_packages = list_all_packages_with_query[:items]
|
|
1102
|
-
Aspera.assert(skip_ids_persistency
|
|
1113
|
+
Aspera.assert(skip_ids_persistency, 'INIT requires option once_only')
|
|
1103
1114
|
skip_ids_persistency.data.clear.concat(all_packages.map{ |e| e['id']})
|
|
1104
1115
|
skip_ids_persistency.save
|
|
1105
|
-
return
|
|
1116
|
+
return Result::Status.new("Initialized skip for #{skip_ids_persistency.data.count} package(s)")
|
|
1106
1117
|
when SpecialValues::ALL
|
|
1107
1118
|
all_packages = list_all_packages_with_query[:items]
|
|
1108
1119
|
# remove from list the ones already downloaded
|
|
@@ -1140,25 +1151,25 @@ module Aspera
|
|
|
1140
1151
|
rest_token: package_node_api
|
|
1141
1152
|
)
|
|
1142
1153
|
File.write(File.join(dest_folder, "#{package_id}.info.json"), package_info.to_json) if save_metadata
|
|
1143
|
-
result_transfer.push({'package' => package_id,
|
|
1154
|
+
result_transfer.push({'package' => package_id, Runner::STATUS_FIELD => statuses})
|
|
1144
1155
|
# update skip list only if all transfer sessions completed
|
|
1145
1156
|
if skip_ids_persistency && TransferAgent.session_status(statuses).eql?(:success)
|
|
1146
1157
|
skip_ids_persistency.data.push(package_id)
|
|
1147
1158
|
skip_ids_persistency.save
|
|
1148
1159
|
end
|
|
1149
1160
|
end
|
|
1150
|
-
return
|
|
1161
|
+
return Runner.result_transfer_multiple(result_transfer)
|
|
1151
1162
|
when :show
|
|
1152
1163
|
package_id = options.instance_identifier
|
|
1153
1164
|
package_info = aoc_api.read("packages/#{package_id}")
|
|
1154
|
-
return
|
|
1165
|
+
return Result::SingleObject.new(package_info)
|
|
1155
1166
|
when :list
|
|
1156
1167
|
result = list_all_packages_with_query
|
|
1157
1168
|
skip_ids_persistency = package_persistency
|
|
1158
1169
|
reject_packages_from_persistency(result[:items], skip_ids_persistency)
|
|
1159
1170
|
display_fields = PACKAGE_LIST_DEFAULT_FIELDS
|
|
1160
1171
|
display_fields += ['workspace_id'] if aoc_api.workspace_info[:id].nil?
|
|
1161
|
-
return
|
|
1172
|
+
return Result::ObjectList.new(result[:items], fields: display_fields, total: result[:total])
|
|
1162
1173
|
when :delete
|
|
1163
1174
|
return do_bulk_operation(command: package_command, values: options.instance_identifier) do |package_id|
|
|
1164
1175
|
Aspera.assert_type(package_id, String, Integer){'identifier'}
|
|
@@ -1168,7 +1179,7 @@ module Aspera
|
|
|
1168
1179
|
package_id = options.instance_identifier
|
|
1169
1180
|
package_data = value_create_modify(command: package_command)
|
|
1170
1181
|
aoc_api.update("packages/#{package_id}", package_data)
|
|
1171
|
-
return
|
|
1182
|
+
return Result::Status.new('modified')
|
|
1172
1183
|
when *Node::NODE4_READ_ACTIONS
|
|
1173
1184
|
package_id = options.instance_identifier
|
|
1174
1185
|
package_info = aoc_api.read("packages/#{package_id}")
|
|
@@ -1245,7 +1256,7 @@ module Aspera
|
|
|
1245
1256
|
when :launch
|
|
1246
1257
|
wf_id = options.instance_identifier
|
|
1247
1258
|
data = automation_api.create("workflows/#{wf_id}/launch", {})
|
|
1248
|
-
return
|
|
1259
|
+
return Result::SingleObject.new(data)
|
|
1249
1260
|
when :action
|
|
1250
1261
|
# TODO: not complete
|
|
1251
1262
|
wf_id = options.instance_identifier
|
|
@@ -1256,7 +1267,7 @@ module Aspera
|
|
|
1256
1267
|
action = automation_api.create('actions', {'step_id' => step['id'], 'type' => 'manual'})
|
|
1257
1268
|
automation_api.update("steps/#{step['id']}", {'action_order' => [action['id']]})
|
|
1258
1269
|
wf = automation_api.read("workflows/#{wf_id}")
|
|
1259
|
-
return
|
|
1270
|
+
return Result::SingleObject.new(wf)
|
|
1260
1271
|
end
|
|
1261
1272
|
end
|
|
1262
1273
|
when :admin
|
|
@@ -1266,10 +1277,10 @@ module Aspera
|
|
|
1266
1277
|
parameters = value_create_modify(command: command, default: {}).symbolize_keys
|
|
1267
1278
|
uri = URI.parse(parameters.delete(:url){WebServerSimple::DEFAULT_URL})
|
|
1268
1279
|
server = WebServerSimple.new(uri, **parameters.slice(*WebServerSimple::PARAMS))
|
|
1269
|
-
Aspera.assert(parameters.except(*WebServerSimple::PARAMS).empty?)
|
|
1280
|
+
Aspera.assert(parameters.except(*WebServerSimple::PARAMS).empty?){"unexpected parameters: #{parameters.except(*WebServerSimple::PARAMS).keys}"}
|
|
1270
1281
|
server.mount(uri.path, Faspex4GWServlet, aoc_api, aoc_api.workspace_info[:id])
|
|
1271
1282
|
server.start
|
|
1272
|
-
return
|
|
1283
|
+
return Result::Status.new('Gateway terminated')
|
|
1273
1284
|
else Aspera.error_unreachable_line
|
|
1274
1285
|
end
|
|
1275
1286
|
Aspera.error_unreachable_line
|
|
@@ -89,27 +89,27 @@ module Aspera
|
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
res = ats_api.create('access_keys', params)
|
|
92
|
-
return
|
|
92
|
+
return Result::SingleObject.new(res)
|
|
93
93
|
# TODO : action : modify, with "PUT"
|
|
94
94
|
when :list
|
|
95
95
|
params = query_read_delete(default: {'offset' => 0, 'max_results' => 1000})
|
|
96
96
|
res = ats_api.read('access_keys', params)
|
|
97
|
-
return
|
|
97
|
+
return Result::ObjectList.new(res['data'], fields: ['name', 'id', 'created.at', 'modified.at'])
|
|
98
98
|
when :show
|
|
99
99
|
res = ats_api.read("access_keys/#{access_key_id}")
|
|
100
|
-
return
|
|
100
|
+
return Result::SingleObject.new(res)
|
|
101
101
|
when :modify
|
|
102
102
|
params = value_create_modify(command: command)
|
|
103
103
|
params['id'] = access_key_id
|
|
104
104
|
ats_api.update("access_keys/#{access_key_id}", params)
|
|
105
|
-
return
|
|
105
|
+
return Result::Status.new('modified')
|
|
106
106
|
when :entitlement
|
|
107
107
|
ak = ats_api.read("access_keys/#{access_key_id}")
|
|
108
108
|
api_bss = Api::Alee.new(ak['license']['entitlement_id'], ak['license']['customer_id'])
|
|
109
|
-
return
|
|
109
|
+
return Result::SingleObject.new(api_bss.read('entitlement'))
|
|
110
110
|
when :delete
|
|
111
111
|
ats_api.delete("access_keys/#{access_key_id}")
|
|
112
|
-
return
|
|
112
|
+
return Result::Status.new("deleted #{access_key_id}")
|
|
113
113
|
when :node
|
|
114
114
|
ak_data = ats_api.read("access_keys/#{access_key_id}")
|
|
115
115
|
server_data = @ats_api_open.all_servers.find{ |i| i['id'].start_with?(ak_data['transfer_server_id'])}
|
|
@@ -135,7 +135,7 @@ module Aspera
|
|
|
135
135
|
password: config.lookup_secret(url: ats_url, username: access_key_id)
|
|
136
136
|
}
|
|
137
137
|
)
|
|
138
|
-
return
|
|
138
|
+
return Result::SingleObject.new(api_ak_auth.read('servers'))
|
|
139
139
|
else Aspera.error_unexpected_value(command)
|
|
140
140
|
end
|
|
141
141
|
end
|
|
@@ -144,9 +144,9 @@ module Aspera
|
|
|
144
144
|
command = options.get_next_command(%i[clouds list show])
|
|
145
145
|
case command
|
|
146
146
|
when :clouds
|
|
147
|
-
return
|
|
147
|
+
return Result::ObjectList.new(@ats_api_open.cloud_names.map{ |k, v| CLOUD_TABLE.zip([k, v]).to_h})
|
|
148
148
|
when :list
|
|
149
|
-
return
|
|
149
|
+
return Result::ObjectList.new(@ats_api_open.all_servers, fields: %w[id cloud region])
|
|
150
150
|
when :show
|
|
151
151
|
if options.get_option(:cloud) || options.get_option(:region)
|
|
152
152
|
server_data = server_by_cloud_region
|
|
@@ -155,7 +155,7 @@ module Aspera
|
|
|
155
155
|
server_data = @ats_api_open.all_servers.find{ |i| i['id'].eql?(server_id)}
|
|
156
156
|
raise BadIdentifier.new('server', server_id) if server_data.nil?
|
|
157
157
|
end
|
|
158
|
-
return
|
|
158
|
+
return Result::SingleObject.new(server_data)
|
|
159
159
|
end
|
|
160
160
|
end
|
|
161
161
|
|
|
@@ -195,19 +195,19 @@ module Aspera
|
|
|
195
195
|
when :instances
|
|
196
196
|
instances = ats_ibm_api.read('instances')
|
|
197
197
|
Log.log.warn{"more instances remaining: #{instances['remaining']}"} unless instances['remaining'].to_i.eql?(0)
|
|
198
|
-
return
|
|
198
|
+
return Result::ValueList.new(instances['data'], name: 'instance')
|
|
199
199
|
when :create
|
|
200
200
|
created_key = ats_ibm_api.create('api_keys', value_create_modify(command: command, default: {}))
|
|
201
|
-
return
|
|
201
|
+
return Result::SingleObject.new(created_key)
|
|
202
202
|
when :list # list known api keys in ATS (this require an api_key ...)
|
|
203
203
|
res = ats_ibm_api.read('api_keys', {'offset' => 0, 'max_results' => 1000})
|
|
204
|
-
return
|
|
204
|
+
return Result::ValueList.new(res['data'], name: 'ats_id')
|
|
205
205
|
when :show # show one of api_key in ATS
|
|
206
206
|
res = ats_ibm_api.read("api_keys/#{concerned_id}")
|
|
207
|
-
return
|
|
207
|
+
return Result::SingleObject.new(res)
|
|
208
208
|
when :delete
|
|
209
209
|
ats_ibm_api.delete("api_keys/#{concerned_id}")
|
|
210
|
-
return
|
|
210
|
+
return Result::Status.new("deleted #{concerned_id}")
|
|
211
211
|
else Aspera.error_unexpected_value(command)
|
|
212
212
|
end
|
|
213
213
|
end
|
|
@@ -228,7 +228,7 @@ module Aspera
|
|
|
228
228
|
return execute_action_api_key
|
|
229
229
|
when :aws_trust_policy
|
|
230
230
|
res = ats_api.read('aws/trustpolicy', {region: options.get_option(:region, mandatory: true)})
|
|
231
|
-
return
|
|
231
|
+
return Result::SingleObject.new(res)
|
|
232
232
|
else Aspera.error_unexpected_value(command)
|
|
233
233
|
end
|
|
234
234
|
end
|