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

Method Tokens

codersdk/apikey.go:125–136  ·  view source on GitHub ↗

Tokens list machine API keys.

(ctx context.Context, userID string, filter TokensFilter)

Source from the content-addressed store, hash-verified

123
124// Tokens list machine API keys.
125func (c *Client) Tokens(ctx context.Context, userID string, filter TokensFilter) ([]APIKeyWithOwner, error) {
126 res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/users/%s/keys/tokens", userID), nil, filter.asRequestOption())
127 if err != nil {
128 return nil, err
129 }
130 defer res.Body.Close()
131 if res.StatusCode > http.StatusOK {
132 return nil, ReadBodyAsError(res)
133 }
134 apiKey := []APIKeyWithOwner{}
135 return apiKey, json.NewDecoder(res.Body).Decode(&apiKey)
136}
137
138// APIKeyByID returns the api key by id.
139func (c *Client) APIKeyByID(ctx context.Context, userID string, id string) (*APIKey, error) {

Callers 9

TestTokenCRUDFunction · 0.80
TestTokensFilterExpiredFunction · 0.80
TestTokenScopedFunction · 0.80
TestUserSetTokenDurationFunction · 0.80
TestDefaultTokenDurationFunction · 0.80
listTokensMethod · 0.80

Calls 4

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65
asRequestOptionMethod · 0.45

Tested by 8

TestTokenCRUDFunction · 0.64
TestTokensFilterExpiredFunction · 0.64
TestTokenScopedFunction · 0.64
TestUserSetTokenDurationFunction · 0.64
TestDefaultTokenDurationFunction · 0.64