GitSSHKey returns the user's git SSH public key.
(ctx context.Context, user string)
| 23 | |
| 24 | // GitSSHKey returns the user's git SSH public key. |
| 25 | func (c *Client) GitSSHKey(ctx context.Context, user string) (GitSSHKey, error) { |
| 26 | res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/users/%s/gitsshkey", user), nil) |
| 27 | if err != nil { |
| 28 | return GitSSHKey{}, xerrors.Errorf("execute request: %w", err) |
| 29 | } |
| 30 | defer res.Body.Close() |
| 31 | |
| 32 | if res.StatusCode != http.StatusOK { |
| 33 | return GitSSHKey{}, ReadBodyAsError(res) |
| 34 | } |
| 35 | |
| 36 | var gitsshkey GitSSHKey |
| 37 | return gitsshkey, json.NewDecoder(res.Body).Decode(&gitsshkey) |
| 38 | } |
| 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) { |