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 =
[:@password].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.



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

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

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

Instance Attribute Details

#groupObject (readonly)

Returns the value of attribute group.



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

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)


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

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