RegenerateGitSSHKey will create a new SSH key pair for the user and return it.
(ctx context.Context, user string)
| 39 | |
| 40 | // RegenerateGitSSHKey will create a new SSH key pair for the user and return it. |
| 41 | func (c *Client) RegenerateGitSSHKey(ctx context.Context, user string) (GitSSHKey, error) { |
| 42 | res, err := c.Request(ctx, http.MethodPut, fmt.Sprintf("/api/v2/users/%s/gitsshkey", user), nil) |
| 43 | if err != nil { |
| 44 | return GitSSHKey{}, xerrors.Errorf("execute request: %w", err) |
| 45 | } |
| 46 | defer res.Body.Close() |
| 47 | |
| 48 | if res.StatusCode != http.StatusOK { |
| 49 | return GitSSHKey{}, ReadBodyAsError(res) |
| 50 | } |
| 51 | |
| 52 | var gitsshkey GitSSHKey |
| 53 | return gitsshkey, json.NewDecoder(res.Body).Decode(&gitsshkey) |
| 54 | } |