@@ -31,13 +31,18 @@ type Environment struct {
31
31
UpdatedAt time.Time `json:"updated_at" tab:"-"`
32
32
LastOpenedAt time.Time `json:"last_opened_at" tab:"-"`
33
33
LastConnectionAt time.Time `json:"last_connection_at" tab:"-"`
34
- AutoOffThreshold xjson.Duration `json:"auto_off_threshold" tab:"-"`
34
+ AutoOffThreshold xjson.MSDuration `json:"auto_off_threshold" tab:"-"`
35
35
}
36
36
37
37
// RebuildMessage defines the message shown when an Environment requires a rebuild for it can be accessed.
38
38
type RebuildMessage struct {
39
- Text string `json:"text"`
40
- Required bool `json:"required"`
39
+ Text string `json:"text"`
40
+ Required bool `json:"required"`
41
+ AutoOffThreshold xjson.MSDuration `json:"auto_off_threshold" tab:"-"`
42
+ RebuildMessages []struct {
43
+ Text string `json:"text"`
44
+ Required bool `json:"required"`
45
+ } `json:"rebuild_messages" tab:"-"`
41
46
}
42
47
43
48
// EnvironmentStat represents the state of an environment
@@ -53,9 +58,7 @@ type EnvironmentStat struct {
53
58
DiskUsed int64 `json:"disk_used"`
54
59
}
55
60
56
- func (e EnvironmentStat ) String () string {
57
- return string (e .ContainerStatus )
58
- }
61
+ func (e EnvironmentStat ) String () string { return string (e .ContainerStatus ) }
59
62
60
63
// EnvironmentStatus refers to the states of an environment.
61
64
type EnvironmentStatus string
@@ -69,7 +72,7 @@ const (
69
72
EnvironmentUnknown EnvironmentStatus = "UNKNOWN"
70
73
)
71
74
72
- // CreateEnvironmentRequest is used to configure a new environment
75
+ // CreateEnvironmentRequest is used to configure a new environment.
73
76
type CreateEnvironmentRequest struct {
74
77
Name string `json:"name"`
75
78
ImageID string `json:"image_id"`
@@ -84,61 +87,50 @@ type CreateEnvironmentRequest struct {
84
87
// CreateEnvironment sends a request to create an environment.
85
88
func (c Client ) CreateEnvironment (ctx context.Context , orgID string , req CreateEnvironmentRequest ) (* Environment , error ) {
86
89
var env Environment
87
- err := c .requestBody (
88
- ctx ,
89
- http .MethodPost , "/api/orgs/" + orgID + "/environments" ,
90
- req ,
91
- & env ,
92
- )
93
- return & env , err
90
+ if err := c .requestBody (ctx , http .MethodPost , "/api/orgs/" + orgID + "/environments" , req , & env ); err != nil {
91
+ return nil , err
92
+ }
93
+ return & env , nil
94
94
}
95
95
96
96
// EnvironmentsByOrganization gets the list of environments owned by the given user.
97
97
func (c Client ) EnvironmentsByOrganization (ctx context.Context , userID , orgID string ) ([]Environment , error ) {
98
98
var envs []Environment
99
- err := c .requestBody (
100
- ctx ,
101
- http .MethodGet , "/api/orgs/" + orgID + "/members/" + userID + "/environments" ,
102
- nil ,
103
- & envs ,
104
- )
105
- return envs , err
99
+ if err := c .requestBody (ctx , http .MethodGet , "/api/orgs/" + orgID + "/members/" + userID + "/environments" , nil , & envs ); err != nil {
100
+ return nil , err
101
+ }
102
+ return envs , nil
106
103
}
107
104
108
105
// DeleteEnvironment deletes the environment.
109
106
func (c Client ) DeleteEnvironment (ctx context.Context , envID string ) error {
110
- return c .requestBody (
111
- ctx ,
112
- http .MethodDelete , "/api/environments/" + envID ,
113
- nil ,
114
- nil ,
115
- )
107
+ return c .requestBody (ctx , http .MethodDelete , "/api/environments/" + envID , nil , nil )
116
108
}
117
109
118
110
// DialWsep dials an environments command execution interface
119
- // See github.com/cdr/wsep for details
111
+ // See https:// github.com/cdr/wsep for details.
120
112
func (c Client ) DialWsep (ctx context.Context , env * Environment ) (* websocket.Conn , error ) {
121
- return c .dialWs (ctx , "/proxy/environments/" + env .ID + "/wsep" )
113
+ return c .dialWebsocket (ctx , "/proxy/environments/" + env .ID + "/wsep" )
122
114
}
123
115
124
116
// DialIDEStatus opens a websocket connection for cpu load metrics on the environment
125
117
func (c Client ) DialIDEStatus (ctx context.Context , envID string ) (* websocket.Conn , error ) {
126
- return c .dialWs (ctx , "/proxy/environments/" + envID + "/ide/api/status" )
118
+ return c .dialWebsocket (ctx , "/proxy/environments/" + envID + "/ide/api/status" )
127
119
}
128
120
129
- // DialEnvironmentBuildLog opens a websocket connection for the environment build log messages
121
+ // DialEnvironmentBuildLog opens a websocket connection for the environment build log messages.
130
122
func (c Client ) DialEnvironmentBuildLog (ctx context.Context , envID string ) (* websocket.Conn , error ) {
131
- return c .dialWs (ctx , "/api/environments/" + envID + "/watch-update" )
123
+ return c .dialWebsocket (ctx , "/api/environments/" + envID + "/watch-update" )
132
124
}
133
125
134
- // DialEnvironmentStats opens a websocket connection for environment stats
126
+ // DialEnvironmentStats opens a websocket connection for environment stats.
135
127
func (c Client ) DialEnvironmentStats (ctx context.Context , envID string ) (* websocket.Conn , error ) {
136
- return c .dialWs (ctx , "/api/environments/" + envID + "/watch-stats" )
128
+ return c .dialWebsocket (ctx , "/api/environments/" + envID + "/watch-stats" )
137
129
}
138
130
139
131
// DialResourceLoad opens a websocket connection for cpu load metrics on the environment
140
132
func (c Client ) DialResourceLoad (ctx context.Context , envID string ) (* websocket.Conn , error ) {
141
- return c .dialWs (ctx , "/api/environments/" + envID + "/watch-resource-load" )
133
+ return c .dialWebsocket (ctx , "/api/environments/" + envID + "/watch-resource-load" )
142
134
}
143
135
144
136
// BuildLogType describes the type of an event.
0 commit comments