Get VM state
This commit is contained in:
@ -17,6 +17,17 @@ export interface VMInfo {
|
||||
can_screenshot: boolean;
|
||||
}
|
||||
|
||||
export type VMState =
|
||||
| "NoState"
|
||||
| "Running"
|
||||
| "Blocked"
|
||||
| "Paused"
|
||||
| "Shutdown"
|
||||
| "Shutoff"
|
||||
| "Crashed"
|
||||
| "PowerManagementSuspended"
|
||||
| "Other";
|
||||
|
||||
export class VMApi {
|
||||
/**
|
||||
* Get the list of VM that can be managed by this console
|
||||
@ -24,4 +35,13 @@ export class VMApi {
|
||||
static async GetList(): Promise<VMInfo[]> {
|
||||
return (await APIClient.exec({ method: "GET", uri: "/vm/list" })).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the state of a VM
|
||||
*/
|
||||
static async State(vm: VMInfo): Promise<VMState> {
|
||||
return (
|
||||
await APIClient.exec({ method: "GET", uri: `/vm/${vm.uiid}/state` })
|
||||
).data.state;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user