WorkspaceByOwnerAndName returns a workspace by the owner's UUID and the workspace's name.
(ctx context.Context, owner string, name string, params WorkspaceOptions)
| 595 | |
| 596 | // WorkspaceByOwnerAndName returns a workspace by the owner's UUID and the workspace's name. |
| 597 | func (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 |
no test coverage detected