WatchAllWorkspaceBuilds watches for workspace build updates across all workspaces. This requires the workspace-build-updates experiment to be enabled. The returned decoder should be closed by calling Close() when done to properly clean up the WebSocket connection.
(ctx context.Context)
| 859 | // The returned decoder should be closed by calling Close() when done to properly |
| 860 | // clean up the WebSocket connection. |
| 861 | func (c *Client) WatchAllWorkspaceBuilds(ctx context.Context) (*wsjson.Decoder[WorkspaceBuildUpdate], error) { |
| 862 | ctx, span := tracing.StartSpan(ctx) |
| 863 | defer span.End() |
| 864 | |
| 865 | serverURL, err := c.URL.Parse("/api/experimental/watch-all-workspacebuilds") |
| 866 | if err != nil { |
| 867 | return nil, xerrors.Errorf("parse url: %w", err) |
| 868 | } |
| 869 | |
| 870 | jar, err := cookiejar.New(nil) |
| 871 | if err != nil { |
| 872 | return nil, xerrors.Errorf("create cookie jar: %w", err) |
| 873 | } |
| 874 | jar.SetCookies(serverURL, []*http.Cookie{{ |
| 875 | Name: SessionTokenCookie, |
| 876 | Value: c.SessionToken(), |
| 877 | }}) |
| 878 | httpClient := &http.Client{ |
| 879 | Jar: jar, |
| 880 | Transport: c.HTTPClient.Transport, |
| 881 | } |
| 882 | |
| 883 | conn, res, err := websocket.Dial(ctx, serverURL.String(), &websocket.DialOptions{ |
| 884 | HTTPClient: httpClient, |
| 885 | CompressionMode: websocket.CompressionDisabled, |
| 886 | }) |
| 887 | if err != nil { |
| 888 | if res == nil { |
| 889 | return nil, err |
| 890 | } |
| 891 | return nil, ReadBodyAsError(res) |
| 892 | } |
| 893 | |
| 894 | d := wsjson.NewDecoder[WorkspaceBuildUpdate](conn, websocket.MessageText, c.logger) |
| 895 | return d, nil |
| 896 | } |
| 897 | |
| 898 | // WorkspaceAvailableUsers returns users available for workspace creation. |
| 899 | // This is used to populate the owner dropdown when creating workspaces for |