Class: Aspera::Cli::Plugins::Console
- Inherits:
-
BasicAuthPlugin
- Object
- Aspera::Cli::Plugin
- BasicAuthPlugin
- Aspera::Cli::Plugins::Console
- Defined in:
- lib/aspera/cli/plugins/console.rb
Constant Summary collapse
- ACTIONS =
%i[transfer health].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) ⇒ Console
constructor
A new instance of Console.
Methods inherited from BasicAuthPlugin
#basic_auth_api, #basic_auth_params, register_options
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) ⇒ Console
Returns a new instance of Console.
12 13 14 15 16 17 18 |
# File 'lib/aspera/cli/plugins/console.rb', line 12 def initialize(env) super(env) time_now = Time.now .declare(:filter_from, 'Only after date', values: :date, default: Manager.time_to_string(time_now - DEFAULT_FILTER_AGE_SECONDS)) .declare(:filter_to, 'Only before date', values: :date, default: Manager.time_to_string(time_now)) . end |
Instance Method Details
#execute_action ⇒ Object
22 23 24 25 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 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/aspera/cli/plugins/console.rb', line 22 def execute_action api_console = basic_auth_api('api') command = .get_next_command(ACTIONS) case command when :health nagios = Nagios.new begin api_console.read('ssh_keys') nagios.add_ok('console api', 'accessible') rescue StandardError => e nagios.add_critical('console api', e.to_s) end return nagios.result when :transfer command = .get_next_command(%i[current smart]) case command when :smart command = .get_next_command(%i[list submit]) case command when :list return {type: :object_list, data: api_console.read('smart_transfers')[:data]} when :submit smart_id = .get_next_argument('smart_id') params = .get_next_argument('transfer parameters') return {type: :object_list, data: api_console.create('smart_transfers/' + smart_id, params)[:data]} end when :current command = .get_next_command([:list]) case command when :list return { type: :object_list, data: api_console.read('transfers', { 'from' => .get_option(:filter_from, mandatory: true), 'to' => .get_option(:filter_to, mandatory: true) })[:data], fields: %w[id contact name status]} end end end end |