49 lines
887 B
TypeScript
Raw Normal View History

import { APIClient } from "./ApiClient";
2024-11-30 10:26:14 +01:00
import { VMInfo } from "./VMApi";
export interface ServerConfig {
authenticated: boolean;
disable_auth: boolean;
}
2024-11-30 10:26:14 +01:00
export interface Rights {
vms: VMInfo[];
sys_info: boolean;
}
let config: ServerConfig | null = null;
export class ServerApi {
/**
* Get server configuration
*/
static async LoadConfig(): Promise<void> {
config = (
await APIClient.exec({
uri: "/server/config",
method: "GET",
})
).data;
}
/**
* Get cached configuration
*/
static get Config(): ServerConfig {
if (config === null) throw new Error("Missing configuration!");
return config;
}
2024-11-30 10:26:14 +01:00
/**
* Get application rights
*/
static async GetRights(): Promise<Rights> {
return (
await APIClient.exec({
uri: "/server/rights",
method: "GET",
})
).data;
}
}