Class: Aspera::Cli::Plugins::Alee
- Inherits:
-
BasicAuthPlugin
- Object
- Aspera::Cli::Plugin
- BasicAuthPlugin
- Aspera::Cli::Plugins::Alee
- Defined in:
- lib/aspera/cli/plugins/alee.rb
Constant Summary collapse
- ACTIONS =
%i[health entitlement].freeze
Constants inherited from Aspera::Cli::Plugin
Aspera::Cli::Plugin::ALL_OPS, Aspera::Cli::Plugin::GLOBAL_OPS, Aspera::Cli::Plugin::INIT_PARAMS, Aspera::Cli::Plugin::INSTANCE_OPS, Aspera::Cli::Plugin::MAX_ITEMS, Aspera::Cli::Plugin::MAX_PAGES, Aspera::Cli::Plugin::REGEX_LOOKUP_ID_BY_FIELD
Instance Method Summary collapse
Methods inherited from BasicAuthPlugin
#basic_auth_api, #basic_auth_params, declare_options, #initialize
Methods inherited from Aspera::Cli::Plugin
declare_generic_options, #do_bulk_operation, #entity_action, #entity_command, #init_params, #initialize, #instance_identifier, #query_option, #query_read_delete, #value_create_modify
Constructor Details
This class inherits a constructor from Aspera::Cli::BasicAuthPlugin
Instance Method Details
#execute_action ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/aspera/cli/plugins/alee.rb', line 12 def execute_action command = .get_next_command(ACTIONS) case command when :health nagios = Nagios.new begin api = Api::Alee.new(nil, nil, version: 'ping') result = api.call(operation: 'GET', subpath: '') raise "unexpected response: #{result[:http].body}" unless result[:http].body.eql?('pong') nagios.add_ok('api', 'answered ok') rescue StandardError => e nagios.add_critical('api', e.to_s) end return nagios.result when :entitlement entitlement_id = .get_option(:username, mandatory: true) customer_id = .get_option(:password, mandatory: true) api_metering = Api::Alee.new(entitlement_id, customer_id) return {type: :single_object, data: api_metering.read('entitlement')[:data]} end end |