DeleteAPIKey deletes API key by id.
(ctx context.Context, userID string, id string)
| 165 | |
| 166 | // DeleteAPIKey deletes API key by id. |
| 167 | func (c *Client) DeleteAPIKey(ctx context.Context, userID string, id string) error { |
| 168 | res, err := c.Request(ctx, http.MethodDelete, fmt.Sprintf("/api/v2/users/%s/keys/%s", userID, id), nil) |
| 169 | if err != nil { |
| 170 | return err |
| 171 | } |
| 172 | defer res.Body.Close() |
| 173 | if res.StatusCode > http.StatusNoContent { |
| 174 | return ReadBodyAsError(res) |
| 175 | } |
| 176 | return nil |
| 177 | } |
| 178 | |
| 179 | // ExpireAPIKey expires an API key by id, setting its expiry to now. |
| 180 | // This preserves the API key record for audit purposes rather than deleting it. |