Class: SoftLayer::Messaging::Auth
- Inherits:
-
Object
- Object
- SoftLayer::Messaging::Auth
- Defined in:
- lib/softlayer/messaging/auth.rb
Instance Attribute Summary collapse
-
#auth_token ⇒ Object
Returns the value of attribute auth_token.
Instance Method Summary collapse
- #authorize ⇒ Object
-
#initialize(auth_endpoint, username, api_key, options = {}) ⇒ Auth
constructor
A new instance of Auth.
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, ={}) @username = username @api_key = api_key @auth_token = [:auth_token] @endpoint = auth_endpoint end |
Instance Attribute Details
#auth_token ⇒ Object
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
#authorize ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/softlayer/messaging/auth.rb', line 18 def 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 |