Jon Perritt | db0ae14 | 2016-03-13 00:33:41 -0600 | [diff] [blame] | 1 | package gophercloud |
| 2 | |
| 3 | type PasswordCredentialsV2 struct { |
| 4 | Username string `json:"username" required:"true"` |
| 5 | Password string `json:"password" required:"true"` |
| 6 | } |
| 7 | |
| 8 | type TokenCredentialsV2 struct { |
| 9 | ID string `json:"id,omitempty" required:"true"` |
| 10 | } |
| 11 | |
| 12 | // AuthOptions wraps a gophercloud AuthOptions in order to adhere to the AuthOptionsBuilder |
| 13 | // interface. |
| 14 | type AuthOptionsV2 struct { |
| 15 | PasswordCredentials *PasswordCredentialsV2 `json:"passwordCredentials,omitempty" xor:"TokenCredentials"` |
| 16 | |
| 17 | // The TenantID and TenantName fields are optional for the Identity V2 API. |
| 18 | // Some providers allow you to specify a TenantName instead of the TenantId. |
| 19 | // Some require both. Your provider's authentication policies will determine |
| 20 | // how these fields influence authentication. |
| 21 | TenantID string `json:"tenantId,omitempty"` |
| 22 | TenantName string `json:"tenantName,omitempty"` |
| 23 | |
| 24 | // TokenCredentials allows users to authenticate (possibly as another user) with an |
| 25 | // authentication token ID. |
| 26 | TokenCredentials *TokenCredentialsV2 `json:"token,omitempty" xor:"PasswordCredentials"` |
| 27 | } |
| 28 | |
| 29 | // ToTokenV2CreateMap allows AuthOptionsV2 to satisfy the AuthOptionsBuilder |
| 30 | // interface in the v2 tokens package |
| 31 | func (opts AuthOptionsV2) ToTokenV2CreateMap() (map[string]interface{}, error) { |
| 32 | return BuildRequestBody(opts, "auth") |
| 33 | } |