Documentation
¶
Index ¶
- Constants
- Variables
- type BuildLogType
- type Client
- func (c Client) CreateEnvironment(ctx context.Context, orgID string, req CreateEnvironmentRequest) (*Environment, error)
- func (c Client) DelDevURL(ctx context.Context, envID, urlID string) error
- func (c Client) DeleteEnvironment(ctx context.Context, envID string) error
- func (c *Client) DeleteSecretByName(ctx context.Context, name, userID string) error
- func (c Client) DialEnvironmentBuildLog(ctx context.Context, envID string) (*websocket.Conn, error)
- func (c Client) DialEnvironmentStats(ctx context.Context, envID string) (*websocket.Conn, error)
- func (c Client) DialIDEStatus(ctx context.Context, envID string) (*websocket.Conn, error)
- func (c Client) DialResourceLoad(ctx context.Context, envID string) (*websocket.Conn, error)
- func (c Client) DialWsep(ctx context.Context, env *Environment) (*websocket.Conn, error)
- func (c Client) EnvironmentsByOrganization(ctx context.Context, userID, orgID string) ([]Environment, error)
- func (c Client) ImportImage(ctx context.Context, orgID string, req ImportImageRequest) (*Image, error)
- func (c Client) InsertDevURL(ctx context.Context, envID string, port int, name, access string) error
- func (c *Client) InsertSecret(ctx context.Context, user *User, req InsertSecretReq) error
- func (c Client) Me(ctx context.Context) (*User, error)
- func (c Client) Orgs(ctx context.Context) ([]Org, error)
- func (c Client) PushActivity(ctx context.Context, source, envID string) error
- func (c Client) SSHKey(ctx context.Context) (*SSHKey, error)
- func (c *Client) SecretByName(ctx context.Context, name, userID string) (*Secret, error)
- func (c *Client) SecretWithValueByID(ctx context.Context, id, userID string) (*Secret, error)
- func (c *Client) SecretWithValueByName(ctx context.Context, name, userID string) (*Secret, error)
- func (c *Client) Secrets(ctx context.Context, userID string) ([]Secret, error)
- func (c Client) UpdateDevURL(ctx context.Context, envID, urlID string, port int, name, access string) error
- func (c Client) UserByEmail(ctx context.Context, email string) (*User, error)
- func (c Client) UserByID(ctx context.Context, id string) (*User, error)
- func (c Client) Users(ctx context.Context) ([]User, error)
- func (c Client) WaitForEnvironmentReady(ctx context.Context, env *Environment) error
- type CreateEnvironmentRequest
- type DevURL
- type Environment
- type EnvironmentStat
- type EnvironmentStatus
- type Image
- type ImportImageRequest
- type InsertSecretReq
- type NewRegistryRequest
- type Org
- type RebuildMessage
- type SSHKey
- type Secret
- type User
Constants ¶
const Me = "me"
Me is the route param to access resources of the authenticated user
Variables ¶
var ErrNotFound = xerrors.Errorf("resource not found")
ErrNotFound describes an error case in which the requested resource could not be found
Functions ¶
This section is empty.
Types ¶
type BuildLogType ¶ added in v1.11.0
type BuildLogType string
BuildLogType describes the type of an event.
const ( // BuildLogTypeStart signals that a new build log has begun. BuildLogTypeStart BuildLogType = "start" // BuildLogTypeStage is a stage-level event for an environment. // It can be thought of as a major step in the environment's // lifecycle. BuildLogTypeStage BuildLogType = "stage" // BuildLogTypeError describes an error that has occurred. BuildLogTypeError BuildLogType = "error" // BuildLogTypeSubstage describes a subevent that occurs as // part of a stage. This can be the output from a user's // personalization script, or a long running command. BuildLogTypeSubstage BuildLogType = "substage" // BuildLogTypeDone signals that the build has completed. BuildLogTypeDone BuildLogType = "done" )
type Client ¶
Client wraps the Coder HTTP API
func (Client) CreateEnvironment ¶ added in v1.11.0
func (c Client) CreateEnvironment(ctx context.Context, orgID string, req CreateEnvironmentRequest) (*Environment, error)
CreateEnvironment sends a request to create an environment.
func (Client) DeleteEnvironment ¶ added in v1.11.0
DeleteEnvironment deletes the environment.
func (*Client) DeleteSecretByName ¶
DeleteSecretByName deletes the authenticated users secret with the given name
func (Client) DialEnvironmentBuildLog ¶ added in v1.11.0
DialEnvironmentBuildLog opens a websocket connection for the environment build log messages.
func (Client) DialEnvironmentStats ¶ added in v1.11.0
DialEnvironmentStats opens a websocket connection for environment stats.
func (Client) DialIDEStatus ¶ added in v1.11.0
DialIDEStatus opens a websocket connection for cpu load metrics on the environment
func (Client) DialResourceLoad ¶ added in v1.11.0
DialResourceLoad opens a websocket connection for cpu load metrics on the environment
func (Client) DialWsep ¶
DialWsep dials an environments command execution interface See https://github.com/cdr/wsep for details.
func (Client) EnvironmentsByOrganization ¶
func (c Client) EnvironmentsByOrganization(ctx context.Context, userID, orgID string) ([]Environment, error)
EnvironmentsByOrganization gets the list of environments owned by the given user.
func (Client) ImportImage ¶ added in v1.11.0
func (c Client) ImportImage(ctx context.Context, orgID string, req ImportImageRequest) (*Image, error)
ImportImage creates a new image and optionally a new registry
func (Client) InsertDevURL ¶
func (c Client) InsertDevURL(ctx context.Context, envID string, port int, name, access string) error
InsertDevURL inserts a new devurl for the authenticated user.
func (*Client) InsertSecret ¶
InsertSecret adds a new secret for the authed user
func (Client) PushActivity ¶
PushActivity pushes CLI activity to Coder.
func (*Client) SecretByName ¶
SecretByName gets a secret object by name
func (*Client) SecretWithValueByID ¶
SecretWithValueByID gets the Coder secret with its value by the secret_id.
func (*Client) SecretWithValueByName ¶
SecretWithValueByName gets the Coder secret with its value by its name.
func (Client) UpdateDevURL ¶
func (c Client) UpdateDevURL(ctx context.Context, envID, urlID string, port int, name, access string) error
UpdateDevURL updates an existing devurl for the authenticated user.
func (Client) UserByEmail ¶
UserByEmail gets a user by email.
func (Client) WaitForEnvironmentReady ¶ added in v1.11.0
func (c Client) WaitForEnvironmentReady(ctx context.Context, env *Environment) error
WaitForEnvironmentReady will watch the build log and return when done
type CreateEnvironmentRequest ¶ added in v1.11.0
type CreateEnvironmentRequest struct {
Name string `json:"name"`
ImageID string `json:"image_id"`
ImageTag string `json:"image_tag"`
CPUCores float32 `json:"cpu_cores"`
MemoryGB int `json:"memory_gb"`
DiskGB int `json:"disk_gb"`
GPUs int `json:"gpus"`
Services []string `json:"services"`
}
CreateEnvironmentRequest is used to configure a new environment.
type DevURL ¶
type DevURL struct {
ID string `json:"id" tab:"ID"`
URL string `json:"url" tab:"URL"`
Port int `json:"port" tab:"Port"`
Access string `json:"access" tab:"Access"`
Name string `json:"name" tab:"Name"`
}
DevURL is the parsed json response record for a devURL from cemanager.
type Environment ¶
type Environment struct {
ID string `json:"id" tab:"-"`
Name string `json:"name" tab:"Name"`
ImageID string `json:"image_id" tab:"-"`
ImageTag string `json:"image_tag" tab:"ImageTag"`
OrganizationID string `json:"organization_id" tab:"-"`
UserID string `json:"user_id" tab:"-"`
LastBuiltAt time.Time `json:"last_built_at" tab:"-"`
CPUCores float32 `json:"cpu_cores" tab:"CPUCores"`
MemoryGB int `json:"memory_gb" tab:"MemoryGB"`
DiskGB int `json:"disk_gb" tab:"DiskGB"`
GPUs int `json:"gpus" tab:"GPUs"`
Updating bool `json:"updating" tab:"Updating"`
LatestStat EnvironmentStat `json:"latest_stat" tab:"Status"`
RebuildMessages []RebuildMessage `json:"rebuild_messages" tab:"-"`
CreatedAt time.Time `json:"created_at" tab:"-"`
UpdatedAt time.Time `json:"updated_at" tab:"-"`
LastOpenedAt time.Time `json:"last_opened_at" tab:"-"`
LastConnectionAt time.Time `json:"last_connection_at" tab:"-"`
AutoOffThreshold xjson.MSDuration `json:"auto_off_threshold" tab:"-"`
}
Environment describes a Coder environment
type EnvironmentStat ¶ added in v1.11.0
type EnvironmentStat struct {
Time time.Time `json:"time"`
LastOnline time.Time `json:"last_online"`
ContainerStatus EnvironmentStatus `json:"container_status"`
StatError string `json:"stat_error"`
CPUUsage float32 `json:"cpu_usage"`
MemoryTotal int64 `json:"memory_total"`
MemoryUsage float32 `json:"memory_usage"`
DiskTotal int64 `json:"disk_total"`
DiskUsed int64 `json:"disk_used"`
}
EnvironmentStat represents the state of an environment
func (EnvironmentStat) String ¶ added in v1.11.0
func (e EnvironmentStat) String() string
type EnvironmentStatus ¶ added in v1.11.0
type EnvironmentStatus string
EnvironmentStatus refers to the states of an environment.
const ( EnvironmentCreating EnvironmentStatus = "CREATING" EnvironmentOff EnvironmentStatus = "OFF" EnvironmentOn EnvironmentStatus = "ON" EnvironmentFailed EnvironmentStatus = "FAILED" EnvironmentUnknown EnvironmentStatus = "UNKNOWN" )
The following represent the possible environment container states
type Image ¶ added in v1.11.0
type Image struct {
ID string `json:"id"`
OrganizationID string `json:"organization_id"`
Repository string `json:"repository"`
Description string `json:"description"`
URL string `json:"url"` // User-supplied URL for image.
DefaultCPUCores float32 `json:"default_cpu_cores"`
DefaultMemoryGB int `json:"default_memory_gb"`
DefaultDiskGB int `json:"default_disk_gb"`
Deprecated bool `json:"deprecated"`
}
Image describes a Coder Image
type ImportImageRequest ¶ added in v1.11.0
type ImportImageRequest struct {
RegistryID *string `json:"registry_id"` // Used to import images to existing registries.
NewRegistry *NewRegistryRequest `json:"new_registry"` // Used when adding a new registry.
Repository string `json:"repository"` // Refers to the image. Ex: "codercom/ubuntu".
Tag string `json:"tag"`
DefaultCPUCores float32 `json:"default_cpu_cores"`
DefaultMemoryGB int `json:"default_memory_gb"`
DefaultDiskGB int `json:"default_disk_gb"`
Description string `json:"description"`
URL string `json:"url"`
}
ImportImageRequest is used to import new images and registries into Coder
type InsertSecretReq ¶
type InsertSecretReq struct {
Name string `json:"name"`
Value string `json:"value"`
Description string `json:"description"`
}
InsertSecretReq describes the request body for creating a new secret.
type NewRegistryRequest ¶ added in v1.11.0
type NewRegistryRequest struct {
FriendlyName string `json:"friendly_name"`
Registry string `json:"registry"`
Username string `json:"username"`
Password string `json:"password"`
}
NewRegistryRequest describes a docker registry used in importing an image
type RebuildMessage ¶ added in v1.11.0
type RebuildMessage struct {
Text string `json:"text"`
Required bool `json:"required"`
AutoOffThreshold xjson.MSDuration `json:"auto_off_threshold" tab:"-"`
RebuildMessages []struct {
Text string `json:"text"`
Required bool `json:"required"`
} `json:"rebuild_messages" tab:"-"`
}
RebuildMessage defines the message shown when an Environment requires a rebuild for it can be accessed.
type Secret ¶
type Secret struct {
ID string `json:"id" tab:"-"`
Name string `json:"name" tab:"Name"`
Value string `json:"value,omitempty" tab:"Value"`
Description string `json:"description" tab:"Description"`
CreatedAt time.Time `json:"created_at" tab:"CreatedAt"`
UpdatedAt time.Time `json:"updated_at" tab:"-"`
}
Secret describes a Coder secret
type User ¶
type User struct {
ID string `json:"id" tab:"-"`
Email string `json:"email" tab:"Email"`
Username string `json:"username" tab:"Username"`
Name string `json:"name" tab:"Name"`
CreatedAt time.Time `json:"created_at" tab:"CreatedAt"`
UpdatedAt time.Time `json:"updated_at" tab:"-"`
}
User describes a Coder user account.