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

Add ws dials for resource load and ide status #111

Merged
merged 3 commits into from
Sep 4, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add ws dials for resource load and ide status
  • Loading branch information
f0ssel committed Sep 4, 2020
commit ba5d4b8cac0b852c1aa1b925034613cb9ce0e55e
16 changes: 13 additions & 3 deletions coder-sdk/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ type CreateEnvironmentRequest struct {

// CreateEnvironment sends a request to create an environment.
func (c Client) CreateEnvironment(ctx context.Context, orgID string, req CreateEnvironmentRequest) (*Environment, error) {
var env *Environment
var env Environment
err := c.requestBody(
ctx,
http.MethodPost, "/api/orgs/"+orgID+"/environments",
req,
env,
&env,
)
return env, err
return &env, err
}

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

// DialIDEStatus opens a websocket connection for cpu load metrics on the environment
func (c Client) DialIDEStatus(ctx context.Context, envID string) (*websocket.Conn, error) {
return c.dialWs(ctx, "/proxy/environments/"+envID+"/ide/api/status")
}

// DialEnvironmentBuildLog opens a websocket connection for the environment build log messages
func (c Client) DialEnvironmentBuildLog(ctx context.Context, envID string) (*websocket.Conn, error) {
return c.dialWs(ctx, "/api/environments/"+envID+"/watch-update")
Expand All @@ -125,3 +130,8 @@ func (c Client) DialEnvironmentBuildLog(ctx context.Context, envID string) (*web
func (c Client) DialEnvironmentStats(ctx context.Context, envID string) (*websocket.Conn, error) {
return c.dialWs(ctx, "/api/environments/"+envID+"/watch-stats")
}

// DialResourceLoad opens a websocket connection for cpu load metrics on the environment
func (c Client) DialResourceLoad(ctx context.Context, envID string) (*websocket.Conn, error) {
return c.dialWs(ctx, "/api/environments/"+envID+"/watch-resource-load")
}