blob: aaea184a5347b0c5bd47781b4533814cc1730f19 [file] [log] [blame]
Samuel A. Falvo II8a549ef2014-01-24 15:20:54 -08001package identity
2
3import (
4 "github.com/mitchellh/mapstructure"
5)
6
7type TenantDesc struct {
8 Id string
9 Name string
10}
11
12type TokenDesc struct {
13 Id_ string `mapstructure:"Id"`
14 Expires_ string `mapstructure:"Expires"`
15 Tenant TenantDesc
16}
17
18func Token(m AuthResults) (*TokenDesc, error) {
19 accessMap := m["access"].(map[string]interface{})
20 tokenMap := accessMap["token"].(map[string]interface{})
21 td := &TokenDesc{}
22 err := mapstructure.Decode(tokenMap, td)
23 if err != nil {
24 return nil, err
25 }
26 return td, nil
27}
28
29func (td *TokenDesc) Id() string {
30 return td.Id_
31}
32
33func (td *TokenDesc) Expires() string {
34 return td.Expires_
35}
36
37func (td *TokenDesc) TenantId() string {
38 return td.Tenant.Id
39}
40
41func (td *TokenDesc) TenantName() string {
42 return td.Tenant.Name
43}