CreateUserWorkspace creates a new workspace for the template specified.
(ctx context.Context, user string, request CreateWorkspaceRequest)
| 654 | |
| 655 | // CreateUserWorkspace creates a new workspace for the template specified. |
| 656 | func (c *Client) CreateUserWorkspace(ctx context.Context, user string, request CreateWorkspaceRequest) (Workspace, error) { |
| 657 | res, err := c.Request(ctx, http.MethodPost, fmt.Sprintf("/api/v2/users/%s/workspaces", user), request) |
| 658 | if err != nil { |
| 659 | return Workspace{}, err |
| 660 | } |
| 661 | defer res.Body.Close() |
| 662 | |
| 663 | if res.StatusCode != http.StatusCreated { |
| 664 | return Workspace{}, ReadBodyAsError(res) |
| 665 | } |
| 666 | |
| 667 | var workspace Workspace |
| 668 | return workspace, json.NewDecoder(res.Body).Decode(&workspace) |
| 669 | } |
no test coverage detected