Class: Stacktor::Identity::V2::Token

Inherits:
Core::Resource show all
Defined in:
lib/stacktor/identity/v2/token.rb

Instance Attribute Summary

Attributes inherited from Core::Resource

#client, #data

Instance Method Summary collapse

Methods inherited from Core::Resource

#[], #[]=, #handle_data, #headers, #initialize, #method_missing

Constructor Details

This class inherits a constructor from Stacktor::Core::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stacktor::Core::Resource

Instance Method Details

#endpoint_url_for_service_type(type, level = :public) ⇒ Object



24
25
26
27
28
# File 'lib/stacktor/identity/v2/token.rb', line 24

def endpoint_url_for_service_type(type, level=:public)
  svc = self.data['access']['serviceCatalog'].select{|s| s['type'] == type}.first
  return nil if svc.nil?
  return svc['endpoints'][0]["#{level.to_s}URL"]
end

#expired?Boolean

Returns:



16
17
18
# File 'lib/stacktor/identity/v2/token.rb', line 16

def expired?
  self.expires_at < Time.now
end

#expires_atObject



12
13
14
15
# File 'lib/stacktor/identity/v2/token.rb', line 12

def expires_at
  str = self.data["access"]["token"]["expires"]
  Time.parse(str)
end

#idObject



9
10
11
# File 'lib/stacktor/identity/v2/token.rb', line 9

def id
  self.data["access"]["token"]["id"]
end

#valid?Boolean

Returns:



20
21
22
# File 'lib/stacktor/identity/v2/token.rb', line 20

def valid?
  !self.expired?
end