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

Method WorkspaceByOwnerAndName

codersdk/workspaces.go:597–614  ·  view source on GitHub ↗

WorkspaceByOwnerAndName returns a workspace by the owner's UUID and the workspace's name.

(ctx context.Context, owner string, name string, params WorkspaceOptions)

Source from the content-addressed store, hash-verified

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) {
598 res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/users/%s/workspace/%s", owner, name), nil, func(r *http.Request) {
599 q := r.URL.Query()
600 q.Set("include_deleted", fmt.Sprintf("%t", params.IncludeDeleted))
601 r.URL.RawQuery = q.Encode()
602 })
603 if err != nil {
604 return Workspace{}, err
605 }
606 defer res.Body.Close()
607
608 if res.StatusCode != http.StatusOK {
609 return Workspace{}, ReadBodyAsError(res)
610 }
611
612 var workspace Workspace
613 return workspace, json.NewDecoder(res.Body).Decode(&workspace)
614}
615
616// SplitWorkspaceIdentifier splits an identifier into owner and
617// workspace name. A bare name defaults the owner to Me ("me"). An

Callers 1

ResolveWorkspaceMethod · 0.95

Calls 5

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
EncodeMethod · 0.80
SetMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected