MCPcopy Index your code
hub / github.com/coder/coder / DeleteAPIKey

Method DeleteAPIKey

codersdk/apikey.go:167–177  ·  view source on GitHub ↗

DeleteAPIKey deletes API key by id.

(ctx context.Context, userID string, id string)

Source from the content-addressed store, hash-verified

165
166// DeleteAPIKey deletes API key by id.
167func (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.

Callers 4

TestTokenCRUDFunction · 0.80
TestExpireAPIKeyFunction · 0.80
openVSCodeMethod · 0.80
removeTokenMethod · 0.80

Calls 3

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65

Tested by 2

TestTokenCRUDFunction · 0.64
TestExpireAPIKeyFunction · 0.64