Class: Aspera::Cli::Plugins::Cos

Inherits:
Base
  • Object
show all
Defined in:
lib/aspera/cli/plugins/cos.rb

Constant Summary

Constants inherited from Base

Base::FILTER_ARGS

Instance Attribute Summary

Attributes inherited from Base

#context, #help_path

Instance Method Summary collapse

Methods inherited from Base

#action_for, #add_manual_header, application_name, #bulk_result, command, command_registry, commands_under, #config, crud_commands, declare_options, define_action_method, #dispatch_child, #dispatch_from_registry, #dispatch_leaf, #entity_create, #entity_delete, entity_display_name, #entity_list, #entity_modify, #entity_res_path, #entity_show, #execute_action, #execute_leaf, file_matcher, #formatter, #generate_help, #http_config, #invoke_action, option, #options, #persistency, #presets, #progress_bar, #query_read_delete, #resolve_argument, root_setup, #transfer, use_options, used_option_sources

Constructor Details

#initialize(**_) ⇒ Cos

Returns a new instance of Cos.



32
33
34
35
# File 'lib/aspera/cli/plugins/cos.rb', line 32

def initialize(**_)
  super
  options.parse_options!
end

Instance Method Details

#setup_cos_nodeHash

Build the COS Node API and plugin from CLI options.

Returns:

  • (Hash)

    context hash containing :node_plugin



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/aspera/cli/plugins/cos.rb', line 39

def setup_cos_node(**)
  # get service credentials, Hash, e.g. @json:@file:...
  service_credentials = options.get_option(:service_credentials)
  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::CosNode.parameters_from_svc_credentials(service_credentials, options.get_option(:region, mandatory: true)))
  end
  api_node = Api::CosNode.new(**cos_node_params)
  {node_plugin: Node.new(context: context, api: api_node)}
end