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

Method APIKeyByID

codersdk/apikey.go:139–150  ·  view source on GitHub ↗

APIKeyByID returns the api key by id.

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

Source from the content-addressed store, hash-verified

137
138// APIKeyByID returns the api key by id.
139func (c *Client) APIKeyByID(ctx context.Context, userID string, id string) (*APIKey, error) {
140 res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/users/%s/keys/%s", userID, id), nil)
141 if err != nil {
142 return nil, err
143 }
144 defer res.Body.Close()
145 if res.StatusCode > http.StatusCreated {
146 return nil, ReadBodyAsError(res)
147 }
148 apiKey := &APIKey{}
149 return apiKey, json.NewDecoder(res.Body).Decode(apiKey)
150}
151
152// APIKeyByName returns the api key by name.
153func (c *Client) APIKeyByName(ctx context.Context, userID string, name string) (*APIKey, error) {

Callers 7

TestExpireAPIKeyFunction · 0.80
TestPostLoginFunction · 0.80
TestPostLogoutFunction · 0.80
TestUpdateUserPasswordFunction · 0.80
RunFunction · 0.80
viewTokenMethod · 0.80
removeTokenMethod · 0.80

Calls 3

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65

Tested by 4

TestExpireAPIKeyFunction · 0.64
TestPostLoginFunction · 0.64
TestPostLogoutFunction · 0.64
TestUpdateUserPasswordFunction · 0.64