Class: Aspera::Cli::Plugins::Cos
- Inherits:
-
Aspera::Cli::Plugin
- Object
- Aspera::Cli::Plugin
- Aspera::Cli::Plugins::Cos
- Defined in:
- lib/aspera/cli/plugins/cos.rb
Constant Summary collapse
- ACTIONS =
%i[node].freeze
Constants inherited from Aspera::Cli::Plugin
Aspera::Cli::Plugin::ALL_OPS, Aspera::Cli::Plugin::GLOBAL_OPS, Aspera::Cli::Plugin::INSTANCE_OPS, Aspera::Cli::Plugin::MAX_ITEMS, Aspera::Cli::Plugin::MAX_PAGES, Aspera::Cli::Plugin::REGEX_LOOKUP_ID_BY_FIELD, Aspera::Cli::Plugin::VAL_ALL
Instance Method Summary collapse
- #execute_action ⇒ Object
-
#initialize(env) ⇒ Cos
constructor
A new instance of Cos.
Methods inherited from Aspera::Cli::Plugin
#do_bulk_operation, #entity_action, #entity_command, #instance_identifier, #old_query_read_delete, #query_read_delete, #value_create_modify, #value_or_query
Constructor Details
#initialize(env) ⇒ Cos
Returns a new instance of Cos.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/aspera/cli/plugins/cos.rb', line 11 def initialize(env) super(env) @service_creds = nil .declare(:bucket, 'Bucket name') .declare(:endpoint, 'Storage endpoint url') .declare(:apikey, 'Storage API key') .declare(:crn, 'Resource instance id') .declare(:service_credentials, 'IBM Cloud service credentials', types: Hash) .declare(:region, 'Storage region') .declare(:identity, "Authentication url (#{CosNode::IBM_CLOUD_TOKEN_URL})", default: CosNode::IBM_CLOUD_TOKEN_URL) . end |
Instance Method Details
#execute_action ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/aspera/cli/plugins/cos.rb', line 26 def execute_action command = .get_next_command(ACTIONS) case command when :node bucket_name = .get_option(:bucket, mandatory: true) # get service credentials, Hash, e.g. @json:@file:... service_credentials = .get_option(:service_credentials) storage_endpoint = .get_option(:endpoint) raise CliBadArgument, 'one of: endpoint or service_credentials is required' if service_credentials.nil? && storage_endpoint.nil? raise CliBadArgument, 'endpoint and service_credentials are mutually exclusive' unless service_credentials.nil? || storage_endpoint.nil? if service_credentials.nil? service_api_key = .get_option(:apikey, mandatory: true) instance_id = .get_option(:crn, mandatory: true) else params = CosNode.parameters_from_svc_creds(service_credentials, .get_option(:region, mandatory: true)) storage_endpoint = params[:storage_endpoint] service_api_key = params[:service_api_key] instance_id = params[:instance_id] end api_node = CosNode.new(bucket_name, storage_endpoint, instance_id, service_api_key, .get_option(:identity, mandatory: true)) node_plugin = Node.new(@agents.merge(skip_basic_auth_options: true, node_api: api_node)) command = .get_next_command(Node::COMMANDS_COS) return node_plugin.execute_action(command) end end |