Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 1 | package tokens |
| 2 | |
| 3 | import ( |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 4 | "fmt" |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 5 | |
| 6 | "github.com/gophercloud/gophercloud" |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 7 | ) |
| 8 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 9 | func unacceptedAttributeErr(attribute string) string { |
| 10 | return fmt.Sprintf("The base Identity V3 API does not accept authentication by %s", attribute) |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 11 | } |
| 12 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 13 | func redundantWithTokenErr(attribute string) string { |
| 14 | return fmt.Sprintf("%s may not be provided when authenticating with a TokenID", attribute) |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 15 | } |
| 16 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 17 | func redundantWithUserID(attribute string) string { |
| 18 | return fmt.Sprintf("%s may not be provided when authenticating with a UserID", attribute) |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 19 | } |
| 20 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 21 | // ErrAPIKeyProvided indicates that an APIKey was provided but can't be used. |
| 22 | type ErrAPIKeyProvided struct{ gophercloud.BaseError } |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 23 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 24 | func (e ErrAPIKeyProvided) Error() string { |
| 25 | return unacceptedAttributeErr("APIKey") |
| 26 | } |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 27 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 28 | // ErrTenantIDProvided indicates that a TenantID was provided but can't be used. |
| 29 | type ErrTenantIDProvided struct{ gophercloud.BaseError } |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 30 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 31 | func (e ErrTenantIDProvided) Error() string { |
| 32 | return unacceptedAttributeErr("TenantID") |
| 33 | } |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 34 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 35 | // ErrTenantNameProvided indicates that a TenantName was provided but can't be used. |
| 36 | type ErrTenantNameProvided struct{ gophercloud.BaseError } |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 37 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 38 | func (e ErrTenantNameProvided) Error() string { |
| 39 | return unacceptedAttributeErr("TenantName") |
| 40 | } |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 41 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 42 | // ErrUsernameWithToken indicates that a Username was provided, but token authentication is being used instead. |
| 43 | type ErrUsernameWithToken struct{ gophercloud.BaseError } |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 44 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 45 | func (e ErrUsernameWithToken) Error() string { |
| 46 | return redundantWithTokenErr("Username") |
| 47 | } |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 48 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 49 | // ErrUserIDWithToken indicates that a UserID was provided, but token authentication is being used instead. |
| 50 | type ErrUserIDWithToken struct{ gophercloud.BaseError } |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 51 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 52 | func (e ErrUserIDWithToken) Error() string { |
| 53 | return redundantWithTokenErr("UserID") |
| 54 | } |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 55 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 56 | // ErrDomainIDWithToken indicates that a DomainID was provided, but token authentication is being used instead. |
| 57 | type ErrDomainIDWithToken struct{ gophercloud.BaseError } |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 58 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 59 | func (e ErrDomainIDWithToken) Error() string { |
| 60 | return redundantWithTokenErr("DomainID") |
| 61 | } |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 62 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 63 | // ErrDomainNameWithToken indicates that a DomainName was provided, but token authentication is being used instead.s |
| 64 | type ErrDomainNameWithToken struct{ gophercloud.BaseError } |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 65 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 66 | func (e ErrDomainNameWithToken) Error() string { |
| 67 | return redundantWithTokenErr("DomainName") |
| 68 | } |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 69 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 70 | // ErrUsernameOrUserID indicates that neither username nor userID are specified, or both are at once. |
| 71 | type ErrUsernameOrUserID struct{ gophercloud.BaseError } |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 72 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 73 | func (e ErrUsernameOrUserID) Error() string { |
| 74 | return "Exactly one of Username and UserID must be provided for password authentication" |
| 75 | } |
Ash Wilson | 2a32580 | 2014-08-28 14:23:00 -0400 | [diff] [blame] | 76 | |
jrperritt | 29ae6b3 | 2016-04-13 12:59:37 -0500 | [diff] [blame] | 77 | // ErrDomainIDWithUserID indicates that a DomainID was provided, but unnecessary because a UserID is being used. |
| 78 | type ErrDomainIDWithUserID struct{ gophercloud.BaseError } |
| 79 | |
| 80 | func (e ErrDomainIDWithUserID) Error() string { |
| 81 | return redundantWithUserID("DomainID") |
| 82 | } |
| 83 | |
| 84 | // ErrDomainNameWithUserID indicates that a DomainName was provided, but unnecessary because a UserID is being used. |
| 85 | type ErrDomainNameWithUserID struct{ gophercloud.BaseError } |
| 86 | |
| 87 | func (e ErrDomainNameWithUserID) Error() string { |
| 88 | return redundantWithUserID("DomainName") |
| 89 | } |
| 90 | |
| 91 | // ErrDomainIDOrDomainName indicates that a username was provided, but no domain to scope it. |
| 92 | // It may also indicate that both a DomainID and a DomainName were provided at once. |
| 93 | type ErrDomainIDOrDomainName struct{ gophercloud.BaseError } |
| 94 | |
| 95 | func (e ErrDomainIDOrDomainName) Error() string { |
| 96 | return "You must provide exactly one of DomainID or DomainName to authenticate by Username" |
| 97 | } |
| 98 | |
| 99 | // ErrMissingPassword indicates that no password was provided and no token is available. |
| 100 | type ErrMissingPassword struct{ gophercloud.BaseError } |
| 101 | |
| 102 | func (e ErrMissingPassword) Error() string { |
| 103 | return "You must provide a password to authenticate" |
| 104 | } |
| 105 | |
| 106 | // ErrScopeDomainIDOrDomainName indicates that a domain ID or Name was required in a Scope, but not present. |
| 107 | type ErrScopeDomainIDOrDomainName struct{ gophercloud.BaseError } |
| 108 | |
| 109 | func (e ErrScopeDomainIDOrDomainName) Error() string { |
| 110 | return "You must provide exactly one of DomainID or DomainName in a Scope with ProjectName" |
| 111 | } |
| 112 | |
| 113 | // ErrScopeProjectIDOrProjectName indicates that both a ProjectID and a ProjectName were provided in a Scope. |
| 114 | type ErrScopeProjectIDOrProjectName struct{ gophercloud.BaseError } |
| 115 | |
| 116 | func (e ErrScopeProjectIDOrProjectName) Error() string { |
| 117 | return "You must provide at most one of ProjectID or ProjectName in a Scope" |
| 118 | } |
| 119 | |
| 120 | // ErrScopeProjectIDAlone indicates that a ProjectID was provided with other constraints in a Scope. |
| 121 | type ErrScopeProjectIDAlone struct{ gophercloud.BaseError } |
| 122 | |
| 123 | func (e ErrScopeProjectIDAlone) Error() string { |
| 124 | return "ProjectID must be supplied alone in a Scope" |
| 125 | } |
| 126 | |
| 127 | // ErrScopeDomainName indicates that a DomainName was provided alone in a Scope. |
| 128 | type ErrScopeDomainName struct{ gophercloud.BaseError } |
| 129 | |
| 130 | func (e ErrScopeDomainName) Error() string { |
| 131 | return "DomainName must be supplied with a ProjectName or ProjectID in a Scope" |
| 132 | } |
| 133 | |
| 134 | // ErrScopeEmpty indicates that no credentials were provided in a Scope. |
| 135 | type ErrScopeEmpty struct{ gophercloud.BaseError } |
| 136 | |
| 137 | func (e ErrScopeEmpty) Error() string { |
| 138 | return "You must provide either a Project or Domain in a Scope" |
| 139 | } |