Class: Keystone::V2_0::TokenManager

Inherits:
Openstack::Client::Manager show all
Defined in:
lib/keystone/v2_0/tokens.rb

Constant Summary collapse

RESOURCE_CLASS =
Token

Instance Attribute Summary

Attributes inherited from Openstack::Client::Manager

#api, #resource_class

Instance Method Summary collapse

Methods inherited from Openstack::Client::Manager

#_create, #_delete, #_get, #_list, #_update, #get_id, #url_with_params

Constructor Details

#initialize(api) ⇒ TokenManager

Returns a new instance of TokenManager.



15
16
17
# File 'lib/keystone/v2_0/tokens.rb', line 15

def initialize api
  super
end

Instance Method Details

#authenticate(options) ⇒ Object

options:

:username
:tenant_id
:tenant_name
:password
:token
:return_raw


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/keystone/v2_0/tokens.rb', line 26

def authenticate options
  if options[:token]
    params = { 'auth' => { 'token' => { 'id' => options[:token] } } }
  elsif options[:username] and options[:password]
    params = { 
      'auth' => { 
        'passwordCredentials' => {
          'username' => options[:username],
          'password' => options[:password]
    }}}
  else
    raise 'A username and password or token is required.'
  end

  if options[:tenant_id]
    params['auth']['tenantId'] = options[:tenant_id]
  elsif options[:tenant_name]
    params['auth']['tenantName'] = options[:tenant_name]
  end

  return self._create('/tokens', params, 'access', options[:return_raw])
end

#delete(token) ⇒ Object



49
50
51
# File 'lib/keystone/v2_0/tokens.rb', line 49

def delete token
  self._delete("/tokens/#{token.id}")
end

#endpoints(token) ⇒ Object



53
54
55
# File 'lib/keystone/v2_0/tokens.rb', line 53

def endpoints token
  self._get("/tokens/#{token.id}/endpoints", 'token')
end