Refactorize VM information management
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
2024-11-30 10:59:38 +01:00
parent 184a106542
commit 09f54bf3c1
3 changed files with 30 additions and 23 deletions

View File

@ -1,7 +1,7 @@
import { APIClient } from "./ApiClient";
export interface VMInfo {
uiid: string;
uuid: string;
name: string;
description?: string;
architecture: string;
@ -34,7 +34,7 @@ export class VMApi {
*/
static async State(vm: VMInfo): Promise<VMState> {
return (
await APIClient.exec({ method: "GET", uri: `/vm/${vm.uiid}/state` })
await APIClient.exec({ method: "GET", uri: `/vm/${vm.uuid}/state` })
).data.state;
}
@ -42,42 +42,42 @@ export class VMApi {
* Request to start VM
*/
static async StartVM(vm: VMInfo): Promise<void> {
await APIClient.exec({ method: "GET", uri: `/vm/${vm.uiid}/start` });
await APIClient.exec({ method: "GET", uri: `/vm/${vm.uuid}/start` });
}
/**
* Request to suspend VM
*/
static async SuspendVM(vm: VMInfo): Promise<void> {
await APIClient.exec({ method: "GET", uri: `/vm/${vm.uiid}/suspend` });
await APIClient.exec({ method: "GET", uri: `/vm/${vm.uuid}/suspend` });
}
/**
* Request to resume VM
*/
static async ResumeVM(vm: VMInfo): Promise<void> {
await APIClient.exec({ method: "GET", uri: `/vm/${vm.uiid}/resume` });
await APIClient.exec({ method: "GET", uri: `/vm/${vm.uuid}/resume` });
}
/**
* Request to shutdown VM
*/
static async ShutdownVM(vm: VMInfo): Promise<void> {
await APIClient.exec({ method: "GET", uri: `/vm/${vm.uiid}/shutdown` });
await APIClient.exec({ method: "GET", uri: `/vm/${vm.uuid}/shutdown` });
}
/**
* Request to kill VM
*/
static async KillVM(vm: VMInfo): Promise<void> {
await APIClient.exec({ method: "GET", uri: `/vm/${vm.uiid}/kill` });
await APIClient.exec({ method: "GET", uri: `/vm/${vm.uuid}/kill` });
}
/**
* Request to reset VM
*/
static async ResetVM(vm: VMInfo): Promise<void> {
await APIClient.exec({ method: "GET", uri: `/vm/${vm.uiid}/reset` });
await APIClient.exec({ method: "GET", uri: `/vm/${vm.uuid}/reset` });
}
/**
@ -86,7 +86,7 @@ export class VMApi {
static async Screenshot(vm: VMInfo): Promise<Blob> {
return (
await APIClient.exec({
uri: `/vm/${vm.uiid}/screenshot`,
uri: `/vm/${vm.uuid}/screenshot`,
method: "GET",
})
).data;