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.
25 26 27 28 29 30 31 32 |
# File 'lib/hammer_cli_foreman/api/connection.rb', line 25 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.
23 24 25 |
# File 'lib/hammer_cli_foreman/api/connection.rb', line 23 def authenticator @authenticator end |
Instance Method Details
#login ⇒ Object
34 35 36 37 |
# File 'lib/hammer_cli_foreman/api/connection.rb', line 34 def login # Call some api entry point to trigger the successful connection @api.resource(:home).action(:status).call end |
#login_status ⇒ Object
43 44 45 |
# File 'lib/hammer_cli_foreman/api/connection.rb', line 43 def login_status @authenticator.status end |
#logout ⇒ Object
39 40 41 |
# File 'lib/hammer_cli_foreman/api/connection.rb', line 39 def logout @authenticator.clear if @authenticator.respond_to?(:clear) end |