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

Method Workspaces

codersdk/workspaces.go:577–594  ·  view source on GitHub ↗

Workspaces returns all workspaces the authenticated user has access to.

(ctx context.Context, filter WorkspaceFilter)

Source from the content-addressed store, hash-verified

575
576// Workspaces returns all workspaces the authenticated user has access to.
577func (c *Client) Workspaces(ctx context.Context, filter WorkspaceFilter) (WorkspacesResponse, error) {
578 page := Pagination{
579 Offset: filter.Offset,
580 Limit: filter.Limit,
581 }
582 res, err := c.Request(ctx, http.MethodGet, "/api/v2/workspaces", nil, filter.asRequestOption(), page.asRequestOption())
583 if err != nil {
584 return WorkspacesResponse{}, err
585 }
586 defer res.Body.Close()
587
588 if res.StatusCode != http.StatusOK {
589 return WorkspacesResponse{}, ReadBodyAsError(res)
590 }
591
592 var wres WorkspacesResponse
593 return wres, json.NewDecoder(res.Body).Decode(&wres)
594}
595
596// WorkspaceByOwnerAndName returns a workspace by the owner's UUID and the workspace's name.
597func (c *Client) WorkspaceByOwnerAndName(ctx context.Context, owner string, name string, params WorkspaceOptions) (Workspace, error) {

Callers 15

TestWorkspacesSortOrderFunction · 0.80
TestWorkspaceFilterFunction · 0.80
TestOffsetLimitFunction · 0.80
TestWorkspaceListTasksFunction · 0.80
TestPostWorkspaceBuildFunction · 0.80
TestTemplateMetricsFunction · 0.80
TestDeleteUserFunction · 0.80
TestWorkspacesByUserFunction · 0.80

Calls 5

RequestMethod · 0.95
asRequestOptionMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65
asRequestOptionMethod · 0.45

Tested by 15

TestWorkspacesSortOrderFunction · 0.64
TestWorkspaceFilterFunction · 0.64
TestOffsetLimitFunction · 0.64
TestWorkspaceListTasksFunction · 0.64
TestPostWorkspaceBuildFunction · 0.64
TestTemplateMetricsFunction · 0.64
TestDeleteUserFunction · 0.64
TestWorkspacesByUserFunction · 0.64