MCPcopy Index your code
hub / github.com/coder/coder / CreateUserWorkspace

Method CreateUserWorkspace

codersdk/organizations.go:656–669  ·  view source on GitHub ↗

CreateUserWorkspace creates a new workspace for the template specified.

(ctx context.Context, user string, request CreateWorkspaceRequest)

Source from the content-addressed store, hash-verified

654
655// CreateUserWorkspace creates a new workspace for the template specified.
656func (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}

Callers 1

CreateWorkspaceMethod · 0.95

Calls 3

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected