Class: Aspera::Cli::Plugins::Httpgw
- Inherits:
-
Aspera::Cli::Plugin
- Object
- Aspera::Cli::Plugin
- Aspera::Cli::Plugins::Httpgw
- Defined in:
- lib/aspera/cli/plugins/httpgw.rb
Constant Summary collapse
- ACTIONS =
%i[health info].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
Instance Attribute Summary
Attributes inherited from Aspera::Cli::Plugin
Class Method Summary collapse
- .application_name ⇒ Object
- .detect(base_url) ⇒ Object
-
.wizard(object:) ⇒ Hash
:preset_value, :test_args.
Instance Method Summary collapse
- #execute_action ⇒ Object
-
#initialize(**_) ⇒ Httpgw
constructor
A new instance of Httpgw.
Methods inherited from Aspera::Cli::Plugin
#add_manual_header, #config, declare_generic_options, #do_bulk_operation, #entity_execute, #formatter, #instance_identifier, #list_entities_limit_offset_total_count, #lookup_entity_by_field, #options, #persistency, #query_read_delete, #transfer, #value_create_modify
Constructor Details
#initialize(**_) ⇒ Httpgw
Returns a new instance of Httpgw.
40 41 42 43 44 |
# File 'lib/aspera/cli/plugins/httpgw.rb', line 40 def initialize(**_) super .declare(:url, 'URL of application, e.g. https://app.example.com/aspera/app') . end |
Class Method Details
.application_name ⇒ Object
12 13 14 |
# File 'lib/aspera/cli/plugins/httpgw.rb', line 12 def application_name 'HTTP Gateway' end |
.detect(base_url) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/aspera/cli/plugins/httpgw.rb', line 16 def detect(base_url) api = Api::Httpgw.new(url: base_url) api_info = api.info return { url: api.base_url, version: api_info['version'] } if api_info.is_a?(Hash) && api_info.key?('download_endpoint') return end |
.wizard(object:) ⇒ Hash
Returns :preset_value, :test_args.
28 29 30 31 32 33 34 35 36 |
# File 'lib/aspera/cli/plugins/httpgw.rb', line 28 def wizard(object:) = object. return { preset_value: { url: .get_option(:url, mandatory: true) }, test_args: 'info' } end |
Instance Method Details
#execute_action ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/aspera/cli/plugins/httpgw.rb', line 46 def execute_action base_url = .get_option(:url, mandatory: true) command = .get_next_command(ACTIONS) case command when :health nagios = Nagios.new begin Api::Httpgw.new(url: base_url) nagios.add_ok('api', 'answered ok') rescue StandardError => e nagios.add_critical('api', e.to_s) end return nagios.result when :info api_v1 = Api::Httpgw.new(url: base_url) return Main.result_single_object(api_v1.info) end end |