Add ability to delete a token (#4235)

Fix #4234
This commit is contained in:
techknowlogick 2018-07-06 21:54:30 -04:00 committed by GitHub
parent 1675fc4301
commit ab55ca7ebd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 138 additions and 1 deletions

View file

@ -20,6 +20,7 @@ func BasicAuthEncode(user, pass string) string {
// AccessToken represents a API access token.
// swagger:response AccessToken
type AccessToken struct {
ID int64 `json:"id"`
Name string `json:"name"`
Sha1 string `json:"sha1"`
}
@ -54,3 +55,9 @@ func (c *Client) CreateAccessToken(user, pass string, opt CreateAccessTokenOptio
"Authorization": []string{"Basic " + BasicAuthEncode(user, pass)}},
bytes.NewReader(body), t)
}
// DeleteAccessToken delete token with key id
func (c *Client) DeleteAccessToken(user string, keyID int64) error {
_, err := c.getResponse("DELETE", fmt.Sprintf("/user/%s/tokens/%d", user, keyID), nil, nil)
return err
}