Class: SoftLayer::Messaging::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/softlayer/messaging/auth.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(auth_endpoint, username, api_key, options = {}) ⇒ Auth

Returns a new instance of Auth.



7
8
9
10
11
12
# File 'lib/softlayer/messaging/auth.rb', line 7

def initialize(auth_endpoint, username, api_key, options={})
  @username = username
  @api_key = api_key
  @auth_token = options[:auth_token]
  @endpoint = auth_endpoint
end

Instance Attribute Details

#auth_tokenObject

Returns the value of attribute auth_token.



6
7
8
# File 'lib/softlayer/messaging/auth.rb', line 6

def auth_token
  @auth_token
end

Instance Method Details

#authorizeObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/softlayer/messaging/auth.rb', line 18

def authorize
  headers = {
              :accept => :json, 
              'X-Auth-User' => @username,
              'X-Auth-Key' => @api_key,
            }
  
  resource = RestClient::Resource.new(@endpoint, :headers => headers)
  result = resource.post nil
  @auth_token = result.headers[:x_auth_token]
end