APIKeyByID returns the api key by id.
(ctx context.Context, userID string, id string)
| 137 | |
| 138 | // APIKeyByID returns the api key by id. |
| 139 | func (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. |
| 153 | func (c *Client) APIKeyByName(ctx context.Context, userID string, name string) (*APIKey, error) { |