Class: HammerCLIForeman::Api::Connection
- Inherits:
-
HammerCLI::Apipie::ApiConnection
- Object
- HammerCLI::Apipie::ApiConnection
- HammerCLIForeman::Api::Connection
- Defined in:
- lib/hammer_cli_foreman/api/connection.rb
Instance Attribute Summary collapse
-
#authenticator ⇒ Object
readonly
Returns the value of attribute authenticator.
Instance Method Summary collapse
-
#initialize(settings, logger = nil, locale = nil, auth_type = nil) ⇒ Connection
constructor
A new instance of Connection.
- #login ⇒ Object
- #login_status ⇒ Object
- #logout ⇒ Object
Constructor Details
#initialize(settings, logger = nil, locale = nil, auth_type = nil) ⇒ Connection
Returns a new instance of Connection.
21 22 23 24 25 26 27 28 |
# File 'lib/hammer_cli_foreman/api/connection.rb', line 21 def initialize(settings, logger = nil, locale = nil, auth_type = nil) auth_type ||= default_auth_type(settings) default_params = build_default_params(settings, logger, locale, auth_type) super(default_params, :logger => logger, :reload_cache => settings.get(:_params, :reload_cache) || settings.get(:reload_cache) ) end |
Instance Attribute Details
#authenticator ⇒ Object (readonly)
Returns the value of attribute authenticator.
19 20 21 |
# File 'lib/hammer_cli_foreman/api/connection.rb', line 19 def authenticator @authenticator end |
Instance Method Details
#login ⇒ Object
30 31 32 33 |
# File 'lib/hammer_cli_foreman/api/connection.rb', line 30 def login # Call some api entry point to trigger the successful connection @api.resource(:home).action(:status).call end |
#login_status ⇒ Object
39 40 41 |
# File 'lib/hammer_cli_foreman/api/connection.rb', line 39 def login_status @authenticator.status end |
#logout ⇒ Object
35 36 37 |
# File 'lib/hammer_cli_foreman/api/connection.rb', line 35 def logout @authenticator.clear if @authenticator.respond_to?(:clear) end |