| 71 | } |
| 72 | |
| 73 | func (c *Client) UserSecretByName(ctx context.Context, user string, name string) (UserSecret, error) { |
| 74 | res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/users/%s/secrets/%s", user, name), nil) |
| 75 | if err != nil { |
| 76 | return UserSecret{}, err |
| 77 | } |
| 78 | defer res.Body.Close() |
| 79 | if res.StatusCode != http.StatusOK { |
| 80 | return UserSecret{}, ReadBodyAsError(res) |
| 81 | } |
| 82 | var secret UserSecret |
| 83 | return secret, json.NewDecoder(res.Body).Decode(&secret) |
| 84 | } |
| 85 | |
| 86 | func (c *Client) UpdateUserSecret(ctx context.Context, user string, name string, req UpdateUserSecretRequest) (UserSecret, error) { |
| 87 | res, err := c.Request(ctx, http.MethodPatch, fmt.Sprintf("/api/v2/users/%s/secrets/%s", user, name), req) |