Class: Aspera::Cli::Plugins::Faspio
- Defined in:
- lib/aspera/cli/plugins/faspio.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
- #action_health ⇒ Object
-
#build_api ⇒ Rest
Build the REST API object based on the configured auth type.
-
#initialize(**_) ⇒ Faspio
constructor
A new instance of Faspio.
-
#wizard(wizard, app_url) ⇒ Hash
:preset_value, :test_args.
Methods inherited from BasicAuth
#basic_auth_api, #basic_auth_params
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(**_) ⇒ Faspio
53 54 55 56 |
# File 'lib/aspera/cli/plugins/faspio.rb', line 53 def initialize(**_) super . end |
Class Method Details
.detect(base_url) ⇒ Hash, NilClass
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/aspera/cli/plugins/faspio.rb', line 15 def detect(base_url) api = Rest.new(base_url: base_url) data, http = api.read('ping', ret: :both) server_type = http['Server'] return unless data.is_a?(Hash) && data.empty? return unless server_type.is_a?(String) && server_type.include?('faspio') return { version: server_type.gsub(%r{^.*/}, ''), url: base_url } end |
Instance Method Details
#action_health ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/aspera/cli/plugins/faspio.rb', line 88 def action_health nagios = Nagios.new begin result = build_api.read('ping') if result.is_a?(Hash) && result.empty? nagios.add_ok('api', 'answered ok') else nagios.add_critical('api', 'not expected answer') end rescue StandardError => e nagios.add_critical('api', e.to_s) end Result::ObjectList.new(nagios.status_list) end |
#build_api ⇒ Rest
Build the REST API object based on the configured auth type.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/aspera/cli/plugins/faspio.rb', line 60 def build_api base_url = .get_option(:url, mandatory: true) case .get_option(:auth, mandatory: true) when :basic basic_auth_api when :jwt app_client_id = .get_option(:client_id, mandatory: true) Rest.new( base_url: base_url, auth: { type: :oauth2, grant_method: :jwt, base_url: "#{base_url}/auth", params: { client_id: app_client_id }, use_query: true, payload: { iss: app_client_id, # issuer sub: app_client_id # subject }, private_key_obj: OpenSSL::PKey::RSA.new(.get_option(:private_key, mandatory: true), .get_option(:passphrase)), headers: {typ: 'JWT'} } ) end end |
#wizard(wizard, app_url) ⇒ Hash
31 32 33 34 35 36 37 38 |
# File 'lib/aspera/cli/plugins/faspio.rb', line 31 def wizard(wizard, app_url) return { preset_value: { url: app_url }, test_args: 'info' } end |