@@ -11,18 +11,19 @@ import (
11
11
12
12
// Environment describes a Coder environment
13
13
type Environment struct {
14
- ID string `json:"id" tab:"-"`
15
- Name string `json:"name"`
16
- ImageID string `json:"image_id" tab:"-"`
17
- ImageTag string `json:"image_tag"`
18
- OrganizationID string `json:"organization_id" tab:"-"`
19
- UserID string `json:"user_id" tab:"-"`
20
- LastBuiltAt time.Time `json:"last_built_at" tab:"-"`
21
- CPUCores float32 `json:"cpu_cores"`
22
- MemoryGB int `json:"memory_gb"`
23
- DiskGB int `json:"disk_gb"`
24
- GPUs int `json:"gpus"`
25
- Updating bool `json:"updating"`
14
+ ID string `json:"id" tab:"-"`
15
+ Name string `json:"name"`
16
+ ImageID string `json:"image_id" tab:"-"`
17
+ ImageTag string `json:"image_tag"`
18
+ OrganizationID string `json:"organization_id" tab:"-"`
19
+ UserID string `json:"user_id" tab:"-"`
20
+ LastBuiltAt time.Time `json:"last_built_at" tab:"-"`
21
+ CPUCores float32 `json:"cpu_cores"`
22
+ MemoryGB int `json:"memory_gb"`
23
+ DiskGB int `json:"disk_gb"`
24
+ GPUs int `json:"gpus"`
25
+ Updating bool `json:"updating"`
26
+ LatestStat EnvironmentStat `json:"latest_stat" tab:"Status"`
26
27
RebuildMessages []struct {
27
28
Text string `json:"text"`
28
29
Required bool `json:"required"`
@@ -34,6 +35,35 @@ type Environment struct {
34
35
AutoOffThreshold xjson.Duration `json:"auto_off_threshold" tab:"-"`
35
36
}
36
37
38
+ // EnvironmentStat represents the state of an environment
39
+ type EnvironmentStat struct {
40
+ Time time.Time `json:"time"`
41
+ LastOnline time.Time `json:"last_online"`
42
+ ContainerStatus EnvironmentStatus `json:"container_status"`
43
+ StatError string `json:"stat_error"`
44
+ CPUUsage float32 `json:"cpu_usage"`
45
+ MemoryTotal int64 `json:"memory_total"`
46
+ MemoryUsage float32 `json:"memory_usage"`
47
+ DiskTotal int64 `json:"disk_total"`
48
+ DiskUsed int64 `json:"disk_used"`
49
+ }
50
+
51
+ func (e EnvironmentStat ) String () string {
52
+ return string (e .ContainerStatus )
53
+ }
54
+
55
+ // EnvironmentStatus refers to the states of an environment.
56
+ type EnvironmentStatus string
57
+
58
+ // The following represent the possible environment container states
59
+ const (
60
+ EnvironmentCreating EnvironmentStatus = "CREATING"
61
+ EnvironmentOff EnvironmentStatus = "OFF"
62
+ EnvironmentOn EnvironmentStatus = "ON"
63
+ EnvironmentFailed EnvironmentStatus = "FAILED"
64
+ EnvironmentUnknown EnvironmentStatus = "UNKNOWN"
65
+ )
66
+
37
67
// CreateEnvironmentRequest is used to configure a new environment
38
68
type CreateEnvironmentRequest struct {
39
69
Name string `json:"name"`
0 commit comments