add ID as an output for token API and Delete token (#110)
* add ID as an output for token API * add ability to delete token via SDK
This commit is contained in:
parent
b2308e3f70
commit
ec80752c95
1 changed files with 7 additions and 0 deletions
|
@ -20,6 +20,7 @@ func BasicAuthEncode(user, pass string) string {
|
||||||
// AccessToken represents a API access token.
|
// AccessToken represents a API access token.
|
||||||
// swagger:response AccessToken
|
// swagger:response AccessToken
|
||||||
type AccessToken struct {
|
type AccessToken struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Sha1 string `json:"sha1"`
|
Sha1 string `json:"sha1"`
|
||||||
}
|
}
|
||||||
|
@ -54,3 +55,9 @@ func (c *Client) CreateAccessToken(user, pass string, opt CreateAccessTokenOptio
|
||||||
"Authorization": []string{"Basic " + BasicAuthEncode(user, pass)}},
|
"Authorization": []string{"Basic " + BasicAuthEncode(user, pass)}},
|
||||||
bytes.NewReader(body), t)
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue