Class: HammerCLIForeman::Api::Connection

Inherits:
HammerCLI::Apipie::ApiConnection
  • Object
show all
Defined in:
lib/hammer_cli_foreman/api/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings, logger = nil, locale = nil, auth_type = nil) ⇒ Connection

Returns a new instance of Connection.



23
24
25
26
27
28
29
30
# File 'lib/hammer_cli_foreman/api/connection.rb', line 23

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

#authenticatorObject (readonly)

Returns the value of attribute authenticator.



21
22
23
# File 'lib/hammer_cli_foreman/api/connection.rb', line 21

def authenticator
  @authenticator
end

Instance Method Details

#loginObject



32
33
34
35
# File 'lib/hammer_cli_foreman/api/connection.rb', line 32

def 
  # Call some api entry point to trigger the successful connection
  @api.resource(:home).action(:status).call
end

#login_statusObject



41
42
43
# File 'lib/hammer_cli_foreman/api/connection.rb', line 41

def 
  @authenticator.status
end

#logoutObject



37
38
39
# File 'lib/hammer_cli_foreman/api/connection.rb', line 37

def logout
  @authenticator.clear if @authenticator.respond_to?(:clear)
end