Class: ManageIQ::API::Client::Authentication

Inherits:
Object
  • Object
show all
Includes:
CustomInspectMixin
Defined in:
lib/manageiq/api/client/authentication.rb

Constant Summary collapse

DEFAULTS =
{
  :user     => "admin",
  :password => "smartvm"
}.freeze
CUSTOM_INSPECT_EXCLUSIONS =
%i[@password @token @miqtoken @bearer_token].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CustomInspectMixin

#inspect, #pretty_print, #pretty_print_instance_variables

Constructor Details

#initialize(options = {}) ⇒ Authentication

Returns a new instance of Authentication.



20
21
22
23
24
25
26
27
# File 'lib/manageiq/api/client/authentication.rb', line 20

def initialize(options = {})
  @user, @password = fetch_credentials(options)
  @token, @miqtoken, @bearer_token, @group = options.values_at(:token, :miqtoken, :bearer_token, :group)

  unless token || miqtoken || bearer_token
    raise "Must specify both a user and a password" if user.blank? || password.blank?
  end
end

Instance Attribute Details

#bearer_tokenObject (readonly)

Returns the value of attribute bearer_token.



9
10
11
# File 'lib/manageiq/api/client/authentication.rb', line 9

def bearer_token
  @bearer_token
end

#groupObject (readonly)

Returns the value of attribute group.



10
11
12
# File 'lib/manageiq/api/client/authentication.rb', line 10

def group
  @group
end

#miqtokenObject (readonly)

Returns the value of attribute miqtoken.



8
9
10
# File 'lib/manageiq/api/client/authentication.rb', line 8

def miqtoken
  @miqtoken
end

#passwordObject (readonly)

Returns the value of attribute password.



6
7
8
# File 'lib/manageiq/api/client/authentication.rb', line 6

def password
  @password
end

#tokenObject (readonly)

Returns the value of attribute token.



7
8
9
# File 'lib/manageiq/api/client/authentication.rb', line 7

def token
  @token
end

#userObject (readonly)

Returns the value of attribute user.



5
6
7
# File 'lib/manageiq/api/client/authentication.rb', line 5

def user
  @user
end

Class Method Details

.auth_options_specified?(options) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/manageiq/api/client/authentication.rb', line 29

def self.auth_options_specified?(options)
  options.slice(:user, :password, :token, :miqtoken, :bearer_token, :group).present?
end