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.



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

#authenticatorObject (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

#loginObject



34
35
36
37
# File 'lib/hammer_cli_foreman/api/connection.rb', line 34

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

#login_statusObject



43
44
45
# File 'lib/hammer_cli_foreman/api/connection.rb', line 43

def 
  @authenticator.status
end

#logoutObject



39
40
41
# File 'lib/hammer_cli_foreman/api/connection.rb', line 39

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