@@ -11,20 +11,34 @@ export class VmResource extends APIResource {
1111 return this . _client . get ( '/vms' , options ) ;
1212 }
1313
14- delete ( vmID : string , options ?: RequestOptions ) : APIPromise < VmDeleteResponse > {
15- return this . _client . delete ( path `/vm/${ vmID } ` , options ) ;
14+ delete (
15+ vmID : string ,
16+ params : VmDeleteParams | null | undefined = { } ,
17+ options ?: RequestOptions ,
18+ ) : APIPromise < VmDeleteResponse > {
19+ const { skip_wait_boot } = params ?? { } ;
20+ return this . _client . delete ( path `/vm/${ vmID } ` , { query : { skip_wait_boot } , ...options } ) ;
1621 }
1722
1823 branch ( vmID : string , options ?: RequestOptions ) : APIPromise < NewVmResponse > {
1924 return this . _client . post ( path `/vm/${ vmID } /branch` , options ) ;
2025 }
2126
22- commit ( vmID : string , options ?: RequestOptions ) : APIPromise < VmCommitResponse > {
23- return this . _client . post ( path `/vm/${ vmID } /commit` , options ) ;
27+ commit (
28+ vmID : string ,
29+ params : VmCommitParams | null | undefined = { } ,
30+ options ?: RequestOptions ,
31+ ) : APIPromise < VmCommitResponse > {
32+ const { keep_paused, skip_wait_boot } = params ?? { } ;
33+ return this . _client . post ( path `/vm/${ vmID } /commit` , {
34+ query : { keep_paused, skip_wait_boot } ,
35+ ...options ,
36+ } ) ;
2437 }
2538
26- createRoot ( body : VmCreateRootParams , options ?: RequestOptions ) : APIPromise < NewVmResponse > {
27- return this . _client . post ( '/vm/new_root' , { body, ...options } ) ;
39+ createRoot ( params : VmCreateRootParams , options ?: RequestOptions ) : APIPromise < NewVmResponse > {
40+ const { wait_boot, ...body } = params ;
41+ return this . _client . post ( '/vm/new_root' , { query : { wait_boot } , body, ...options } ) ;
2842 }
2943
3044 getSSHKey ( vmID : string , options ?: RequestOptions ) : APIPromise < VmSSHKeyResponse > {
@@ -35,8 +49,10 @@ export class VmResource extends APIResource {
3549 return this . _client . post ( '/vm/from_commit' , { body, ...options } ) ;
3650 }
3751
38- updateState ( vmID : string , body : VmUpdateStateParams , options ?: RequestOptions ) : APIPromise < void > {
52+ updateState ( vmID : string , params : VmUpdateStateParams , options ?: RequestOptions ) : APIPromise < void > {
53+ const { skip_wait_boot, ...body } = params ;
3954 return this . _client . patch ( path `/vm/${ vmID } /state` , {
55+ query : { skip_wait_boot } ,
4056 body,
4157 ...options ,
4258 headers : buildHeaders ( [ { Accept : '*/*' } , options ?. headers ] ) ,
@@ -107,31 +123,19 @@ export interface Vm {
107123
108124 owner_id : string ;
109125
110- vm_id : string ;
111-
112- parent ?: string | null ;
113- }
114-
115- /**
116- * The response body for POST /api/vm/{vm_id}/commit
117- */
118- export interface VmCommitResponse {
119126 /**
120- * The commit ID, a (v4) UUID
127+ * The state of a VM
121128 */
122- commit_id : string ;
129+ state : 'booting' | 'running' | 'paused' ;
123130
124- /**
125- * The host architecture, eg: "x86_64" (currently implemented with `uname -m``)
126- */
127- host_architecture : string ;
131+ vm_id : string ;
128132}
129133
130134/**
131135 * Response body for DELETE /api/vm/{vm_id}
132136 */
133137export interface VmDeleteResponse {
134- deleted_ids : Array < string > ;
138+ vm_id : string ;
135139}
136140
137141/**
@@ -169,11 +173,43 @@ export interface VmUpdateStateRequest {
169173
170174export type VmListResponse = Array < Vm > ;
171175
176+ /**
177+ * A summary of a commit, appropriate for displaying on the frontend
178+ */
179+ export interface VmCommitResponse {
180+ commit_id : string ;
181+ }
182+
183+ export interface VmDeleteParams {
184+ /**
185+ * If true, return an error immediately if the VM is still booting. Default: false
186+ */
187+ skip_wait_boot ?: boolean ;
188+ }
189+
190+ export interface VmCommitParams {
191+ /**
192+ * If true, keep VM paused after commit
193+ */
194+ keep_paused ?: boolean ;
195+
196+ /**
197+ * If true, return an error immediately if the VM is still booting. Default: false
198+ */
199+ skip_wait_boot ?: boolean ;
200+ }
201+
172202export interface VmCreateRootParams {
173203 /**
174- * Struct representing configuration options common to all VMs
204+ * Body param: Struct representing configuration options common to all VMs
175205 */
176206 vm_config : VmCreateRootParams . VmConfig ;
207+
208+ /**
209+ * Query param: If true, wait for the newly-created VM to finish booting before
210+ * returning. Default: false.
211+ */
212+ wait_boot ?: boolean ;
177213}
178214
179215export namespace VmCreateRootParams {
@@ -214,9 +250,15 @@ export interface VmRestoreFromCommitParams {
214250
215251export interface VmUpdateStateParams {
216252 /**
217- * The requested state for the VM
253+ * Body param: The requested state for the VM
218254 */
219255 state : 'Paused' | 'Running' ;
256+
257+ /**
258+ * Query param: If true, error immediately if the VM is not finished booting.
259+ * Defaults to false
260+ */
261+ skip_wait_boot ?: boolean ;
220262}
221263
222264export declare namespace VmResource {
@@ -225,12 +267,14 @@ export declare namespace VmResource {
225267 type NewRootRequest as NewRootRequest ,
226268 type NewVmResponse as NewVmResponse ,
227269 type Vm as Vm ,
228- type VmCommitResponse as VmCommitResponse ,
229270 type VmDeleteResponse as VmDeleteResponse ,
230271 type VmFromCommitRequest as VmFromCommitRequest ,
231272 type VmSSHKeyResponse as VmSSHKeyResponse ,
232273 type VmUpdateStateRequest as VmUpdateStateRequest ,
233274 type VmListResponse as VmListResponse ,
275+ type VmCommitResponse as VmCommitResponse ,
276+ type VmDeleteParams as VmDeleteParams ,
277+ type VmCommitParams as VmCommitParams ,
234278 type VmCreateRootParams as VmCreateRootParams ,
235279 type VmRestoreFromCommitParams as VmRestoreFromCommitParams ,
236280 type VmUpdateStateParams as VmUpdateStateParams ,
0 commit comments