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

Method ExpireAPIKey

codersdk/apikey.go:181–191  ·  view source on GitHub ↗

ExpireAPIKey expires an API key by id, setting its expiry to now. This preserves the API key record for audit purposes rather than deleting it.

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

Source from the content-addressed store, hash-verified

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.
181func (c *Client) ExpireAPIKey(ctx context.Context, userID string, id string) error {
182 res, err := c.Request(ctx, http.MethodPut, fmt.Sprintf("/api/v2/users/%s/keys/%s/expire", userID, id), nil)
183 if err != nil {
184 return err
185 }
186 defer res.Body.Close()
187 if res.StatusCode > http.StatusNoContent {
188 return ReadBodyAsError(res)
189 }
190 return nil
191}
192
193// GetTokenConfig returns deployment options related to token management
194func (c *Client) GetTokenConfig(ctx context.Context, userID string) (TokenConfig, error) {

Callers 3

TestTokensFilterExpiredFunction · 0.80
TestExpireAPIKeyFunction · 0.80
removeTokenMethod · 0.80

Calls 3

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65

Tested by 2

TestTokensFilterExpiredFunction · 0.64
TestExpireAPIKeyFunction · 0.64