APIKeyByName returns the api key by name.
(ctx context.Context, userID string, name string)
| 151 | |
| 152 | // APIKeyByName returns the api key by name. |
| 153 | func (c *Client) APIKeyByName(ctx context.Context, userID string, name string) (*APIKey, error) { |
| 154 | res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/users/%s/keys/tokens/%s", userID, name), nil) |
| 155 | if err != nil { |
| 156 | return nil, err |
| 157 | } |
| 158 | defer res.Body.Close() |
| 159 | if res.StatusCode > http.StatusCreated { |
| 160 | return nil, ReadBodyAsError(res) |
| 161 | } |
| 162 | apiKey := &APIKey{} |
| 163 | return apiKey, json.NewDecoder(res.Body).Decode(apiKey) |
| 164 | } |
| 165 | |
| 166 | // DeleteAPIKey deletes API key by id. |
| 167 | func (c *Client) DeleteAPIKey(ctx context.Context, userID string, id string) error { |