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.



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

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

#loginObject



30
31
32
33
# File 'lib/hammer_cli_foreman/api/connection.rb', line 30

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

#login_statusObject



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

def 
  @authenticator.status
end

#logoutObject



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

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