Class: Aspera::Plugins::Cos::Commands

Inherits:
Cli::Plugins::Base show all
Defined in:
lib/aspera/plugins/cos/commands.rb

Constant Summary collapse

SERVICE_CREDENTIALS =

Schema of option service_credentials, in the schemas of the bundle (manifest schemas)

'cos_opts:components.schemas.CosServiceCredentials'

Constants inherited from Cli::Plugins::Base

Cli::Plugins::Base::FILTER_ARGS

Instance Attribute Summary

Attributes inherited from Cli::Plugins::Base

#context, #help_path

Instance Method Summary collapse

Methods inherited from Cli::Plugins::Base

#action_for, application_name, #bulk_result, #check_argument_access, command, command_registry, commands_under, #config, #crud_api, crud_commands, declare_options, define_action_method, #dispatch_child, #dispatch_from_registry, #dispatch_leaf, #dispatch_mount, #entity_create, #entity_delete, #entity_list, #entity_modify, entity_noun, #entity_res_path, #entity_show, #execute_action, #execute_leaf, file_matcher, #formatter, #generate_help, #http_config, include_mounts, #initialize, #invoke_action, operation_description, option_sources, option_specs, #options, #persistency, #poll_result, #presets, #progress_bar, #query_read_delete, register_option_spec, #resolve_argument, #resolve_arguments, #transfer, use_options, used_option_sources, #validate_registry

Methods included from Cli::Option::Declarator

#declare_options, #option, #option_specs, #register_option_spec

Constructor Details

This class inherits a constructor from Aspera::Cli::Plugins::Base

Instance Method Details

#cos_node_plugin ⇒ Node::Commands

node - mount target: build the COS Node API and plugin from CLI options.

Returns:



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/aspera/plugins/cos/commands.rb', line 36

def cos_node_plugin(**)
  # get service credentials, Hash, e.g. @json:@file:...
  service_credentials = options.get_option(:service_credentials, complete: true)
  cos_node_params = {
    auth_url: options.get_option(:identity, mandatory: true),
    bucket:   options.get_option(:bucket, mandatory: true),
    endpoint: options.get_option(:endpoint)
  }
  if service_credentials.nil?
    Aspera.assert(!cos_node_params[:endpoint].nil?, 'endpoint required when service credentials not provided', type: Cli::BadArgument)
    cos_node_params[:api_key] = options.get_option(:apikey, mandatory: true)
    cos_node_params[:instance_id] = options.get_option(:crn, mandatory: true)
  else
    Aspera.assert(cos_node_params[:endpoint].nil?, 'endpoint not allowed when service credentials provided', type: Cli::BadArgument)
    cos_node_params.merge!(Api.parameters_from_svc_credentials(service_credentials, options.get_option(:region, mandatory: true)))
  end
  api_node = Api.new(**cos_node_params)
  Node::Commands.new(context: context, api: api_node)
end