WorkspaceAgentListContainers returns a list of containers that are currently running on a Docker daemon accessible to the workspace agent.
(ctx context.Context, agentID uuid.UUID, labels map[string]string)
| 571 | // WorkspaceAgentListContainers returns a list of containers that are currently |
| 572 | // running on a Docker daemon accessible to the workspace agent. |
| 573 | func (c *Client) WorkspaceAgentListContainers(ctx context.Context, agentID uuid.UUID, labels map[string]string) (WorkspaceAgentListContainersResponse, error) { |
| 574 | lf := workspaceAgentContainersLabelFilter(labels) |
| 575 | res, err := c.Request(ctx, http.MethodGet, fmt.Sprintf("/api/v2/workspaceagents/%s/containers", agentID), nil, lf) |
| 576 | if err != nil { |
| 577 | return WorkspaceAgentListContainersResponse{}, err |
| 578 | } |
| 579 | defer res.Body.Close() |
| 580 | if res.StatusCode != http.StatusOK { |
| 581 | return WorkspaceAgentListContainersResponse{}, ReadBodyAsError(res) |
| 582 | } |
| 583 | var cr WorkspaceAgentListContainersResponse |
| 584 | |
| 585 | return cr, json.NewDecoder(res.Body).Decode(&cr) |
| 586 | } |
| 587 | |
| 588 | func (c *Client) WatchWorkspaceAgentContainers(ctx context.Context, agentID uuid.UUID) (<-chan WorkspaceAgentListContainersResponse, io.Closer, error) { |
| 589 | reqURL, err := c.URL.Parse(fmt.Sprintf("/api/v2/workspaceagents/%s/containers/watch", agentID)) |