Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit ba5d4b8

Browse files
committed
Add ws dials for resource load and ide status
1 parent 90dfe59 commit ba5d4b8

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

coder-sdk/env.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ type CreateEnvironmentRequest struct {
7878

7979
// CreateEnvironment sends a request to create an environment.
8080
func (c Client) CreateEnvironment(ctx context.Context, orgID string, req CreateEnvironmentRequest) (*Environment, error) {
81-
var env *Environment
81+
var env Environment
8282
err := c.requestBody(
8383
ctx,
8484
http.MethodPost, "/api/orgs/"+orgID+"/environments",
8585
req,
86-
env,
86+
&env,
8787
)
88-
return env, err
88+
return &env, err
8989
}
9090

9191
// EnvironmentsByOrganization gets the list of environments owned by the given user.
@@ -116,6 +116,11 @@ func (c Client) DialWsep(ctx context.Context, env *Environment) (*websocket.Conn
116116
return c.dialWs(ctx, "/proxy/environments/"+env.ID+"/wsep")
117117
}
118118

119+
// DialIDEStatus opens a websocket connection for cpu load metrics on the environment
120+
func (c Client) DialIDEStatus(ctx context.Context, envID string) (*websocket.Conn, error) {
121+
return c.dialWs(ctx, "/proxy/environments/"+envID+"/ide/api/status")
122+
}
123+
119124
// DialEnvironmentBuildLog opens a websocket connection for the environment build log messages
120125
func (c Client) DialEnvironmentBuildLog(ctx context.Context, envID string) (*websocket.Conn, error) {
121126
return c.dialWs(ctx, "/api/environments/"+envID+"/watch-update")
@@ -125,3 +130,8 @@ func (c Client) DialEnvironmentBuildLog(ctx context.Context, envID string) (*web
125130
func (c Client) DialEnvironmentStats(ctx context.Context, envID string) (*websocket.Conn, error) {
126131
return c.dialWs(ctx, "/api/environments/"+envID+"/watch-stats")
127132
}
133+
134+
// DialResourceLoad opens a websocket connection for cpu load metrics on the environment
135+
func (c Client) DialResourceLoad(ctx context.Context, envID string) (*websocket.Conn, error) {
136+
return c.dialWs(ctx, "/api/environments/"+envID+"/watch-resource-load")
137+
}

0 commit comments

Comments
 (0)