@@ -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,56 +87,55 @@ 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
90
+ << << << < HEAD
87
91
err := c .requestBody (
88
92
ctx ,
89
93
http .MethodPost , "/api/orgs/" + orgID + "/environments" ,
90
94
req ,
91
95
& env ,
92
96
)
93
97
return & env , err
98
+ == == == =
99
+ if err := c .requestBody (ctx , http .MethodPost , "/api/orgs/" + orgID + "/environments" , req , & env ); err != nil {
100
+ return nil , err
101
+ }
102
+ return & env , nil
103
+ >> >> >> > Cleanup:
94
104
}
95
105
96
106
// EnvironmentsByOrganization gets the list of environments owned by the given user.
97
107
func (c Client ) EnvironmentsByOrganization (ctx context.Context , userID , orgID string ) ([]Environment , error ) {
98
108
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
109
+ if err := c .requestBody (ctx , http .MethodGet , "/api/orgs/" + orgID + "/members/" + userID + "/environments" , nil , & envs ); err != nil {
110
+ return nil , err
111
+ }
112
+ return envs , nil
106
113
}
107
114
108
115
// DeleteEnvironment deletes the environment.
109
116
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
- )
117
+ return c .requestBody (ctx , http .MethodDelete , "/api/environments/" + envID , nil , nil )
116
118
}
117
119
118
120
// DialWsep dials an environments command execution interface
119
- // See github.com/cdr/wsep for details
121
+ // See https:// github.com/cdr/wsep for details.
120
122
func (c Client ) DialWsep (ctx context.Context , env * Environment ) (* websocket.Conn , error ) {
121
- return c .dialWs (ctx , "/proxy/environments/" + env .ID + "/wsep" )
123
+ return c .dialWebsocket (ctx , "/proxy/environments/" + env .ID + "/wsep" )
122
124
}
123
125
124
126
// DialIDEStatus opens a websocket connection for cpu load metrics on the environment
125
127
func (c Client ) DialIDEStatus (ctx context.Context , envID string ) (* websocket.Conn , error ) {
126
128
return c .dialWs (ctx , "/proxy/environments/" + envID + "/ide/api/status" )
127
129
}
128
130
129
- // DialEnvironmentBuildLog opens a websocket connection for the environment build log messages
131
+ // DialEnvironmentBuildLog opens a websocket connection for the environment build log messages.
130
132
func (c Client ) DialEnvironmentBuildLog (ctx context.Context , envID string ) (* websocket.Conn , error ) {
131
- return c .dialWs (ctx , "/api/environments/" + envID + "/watch-update" )
133
+ return c .dialWebsocket (ctx , "/api/environments/" + envID + "/watch-update" )
132
134
}
133
135
134
- // DialEnvironmentStats opens a websocket connection for environment stats
136
+ // DialEnvironmentStats opens a websocket connection for environment stats.
135
137
func (c Client ) DialEnvironmentStats (ctx context.Context , envID string ) (* websocket.Conn , error ) {
136
- return c .dialWs (ctx , "/api/environments/" + envID + "/watch-stats" )
138
+ return c .dialWebsocket (ctx , "/api/environments/" + envID + "/watch-stats" )
137
139
}
138
140
139
141
// DialResourceLoad opens a websocket connection for cpu load metrics on the environment
0 commit comments