Workspaces returns all workspaces the authenticated user has access to.
(ctx context.Context, filter WorkspaceFilter)
| 575 | |
| 576 | // Workspaces returns all workspaces the authenticated user has access to. |
| 577 | func (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. |
| 597 | func (c *Client) WorkspaceByOwnerAndName(ctx context.Context, owner string, name string, params WorkspaceOptions) (Workspace, error) { |