import { APIClient } from "./ApiClient"; import { VMCaps, VMInfo, VMInfoAndCaps } from "./VMApi"; export interface ServerConfig { authenticated: boolean; disable_auth: boolean; } export interface Rights { groups: VMGroup[]; vms: VMInfoAndCaps[]; sys_info: boolean; } export type VMGroup = VMGroupInfo & VMCaps; export interface VMGroupInfo { id: string; vms: VMInfo[]; } let config: ServerConfig | null = null; export class ServerApi { /** * Get server configuration */ static async LoadConfig(): Promise { 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; } /** * Get application rights */ static async GetRights(): Promise { return ( await APIClient.exec({ uri: "/server/rights", method: "GET", }) ).data; } }