Add groups support (#146)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #146
This commit is contained in:
@ -1,12 +1,15 @@
|
||||
import { APIClient } from "./ApiClient";
|
||||
|
||||
export interface VMInfo {
|
||||
uiid: string;
|
||||
uuid: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
architecture: string;
|
||||
memory: number;
|
||||
number_vcpu: number;
|
||||
}
|
||||
|
||||
export interface VMCaps {
|
||||
can_get_state: boolean;
|
||||
can_start: boolean;
|
||||
can_shutdown: boolean;
|
||||
@ -17,6 +20,8 @@ export interface VMInfo {
|
||||
can_screenshot: boolean;
|
||||
}
|
||||
|
||||
export type VMInfoAndCaps = VMInfo & VMCaps;
|
||||
|
||||
export type VMState =
|
||||
| "NoState"
|
||||
| "Running"
|
||||
@ -34,7 +39,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 +47,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 +91,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;
|
||||
|
Reference in New Issue
Block a user