@@ -170,6 +170,7 @@ type Codespace struct {
170170 State string `json:"state"`
171171 GitStatus CodespaceGitStatus `json:"git_status"`
172172 Connection CodespaceConnection `json:"connection"`
173+ Machine CodespaceMachine `json:"machine"`
173174}
174175
175176type CodespaceGitStatus struct {
@@ -180,6 +181,15 @@ type CodespaceGitStatus struct {
180181 HasUncommitedChanges bool `json:"has_uncommited_changes"`
181182}
182183
184+ type CodespaceMachine struct {
185+ Name string `json:"name"`
186+ DisplayName string `json:"display_name"`
187+ OperatingSystem string `json:"operating_system"`
188+ StorageInBytes int `json:"storage_in_bytes"`
189+ MemoryInBytes int `json:"memory_in_bytes"`
190+ CPUCount int `json:"cpus"`
191+ }
192+
183193const (
184194 // CodespaceStateAvailable is the state for a running codespace environment.
185195 CodespaceStateAvailable = "Available"
@@ -207,6 +217,7 @@ var CodespaceFields = []string{
207217 "gitStatus" ,
208218 "createdAt" ,
209219 "lastUsedAt" ,
220+ "machineName" ,
210221}
211222
212223func (c * Codespace ) ExportData (fields []string ) map [string ]interface {} {
@@ -219,6 +230,8 @@ func (c *Codespace) ExportData(fields []string) map[string]interface{} {
219230 data [f ] = c .Owner .Login
220231 case "repository" :
221232 data [f ] = c .Repository .FullName
233+ case "machineName" :
234+ data [f ] = c .Machine .Name
222235 case "gitStatus" :
223236 data [f ] = map [string ]interface {}{
224237 "ref" : c .GitStatus .Ref ,
@@ -265,6 +278,7 @@ func (a *API) ListCodespaces(ctx context.Context, limit int) (codespaces []*Code
265278 var response struct {
266279 Codespaces []* Codespace `json:"codespaces"`
267280 }
281+
268282 dec := json .NewDecoder (resp .Body )
269283 if err := dec .Decode (& response ); err != nil {
270284 return nil , fmt .Errorf ("error unmarshaling response: %w" , err )
@@ -704,7 +718,7 @@ func (a *API) EditCodespace(ctx context.Context, codespaceName string, params *E
704718 IdleTimeoutMinutes : params .IdleTimeoutMinutes ,
705719 Machine : params .Machine ,
706720 })
707- fmt . Printf ( "requestBody: %s \n " , requestBody )
721+
708722 if err != nil {
709723 return nil , fmt .Errorf ("error marshaling request: %w" , err )
710724 }
@@ -721,9 +735,7 @@ func (a *API) EditCodespace(ctx context.Context, codespaceName string, params *E
721735 }
722736 defer resp .Body .Close ()
723737
724- if resp .StatusCode == http .StatusAccepted {
725- return nil , errProvisioningInProgress // RPC finished before result of creation known
726- } else if resp .StatusCode != http .StatusOK && resp .StatusCode != http .StatusCreated {
738+ if resp .StatusCode != http .StatusOK && resp .StatusCode != http .StatusCreated {
727739 return nil , api .HandleHTTPError (resp )
728740 }
729741
0 commit comments