import { type ApiRequestable } from "./proxy.js"; import { RequestInit, Response } from 'undici'; import { URL } from "url"; /** * Common Proxmox authentification properties */ export interface ProxmoxEngineOptionsCommon { /** * Proxmox address * currently used as hostname, so it can not contains a port number. */ host: string; /** * Proxmox connexion port, default is 8006 */ port?: number; /** * http protocol, can be http or https, default is https */ schema?: 'https' | 'http'; /** * separated timeout for authentification call, default is 5 second */ authTimeout?: number; /** * timeout for proxmox request, default is 60 seconds */ queryTimeout?: number; /** * print the request in curl or fetch format */ debug?: 'curl' | 'fetch'; } /** * Proxmox authentification as user / password */ export interface ProxmoxEngineOptionsPass extends ProxmoxEngineOptionsCommon { /** * Your username, if not specified will use root@pam */ username?: string; /** * The password */ password: string; } /** * Proxmox authentification as tokenID / tokenSecret */ export interface ProxmoxEngineOptionsToken extends ProxmoxEngineOptionsCommon { tokenID: string; tokenSecret: string; } export type FetchInterface = (url: string | URL, options?: RequestInit) => Promise; /** * Type Union for proxmox Authentification options */ export type ProxmoxEngineOptions = (ProxmoxEngineOptionsToken | ProxmoxEngineOptionsPass) & { fetch?: FetchInterface; }; /** * Default Proxmox doRequest provider, this Class will be used if you provide Proxmox authentification options to the Proxy generator */ export declare class ProxmoxEngine implements ApiRequestable { CSRFPreventionToken?: string; ticket?: string; private readonly username; private readonly password; private hostname; private port?; private readonly schema; private authTimeout; private queryTimeout; private debug?; private fetch; constructor(options: ProxmoxEngineOptions); get host(): string; /** * * @param method http method GET POST PUT of DELETE * @param path http path * @param pathTemplate http path without var replacements * * @param params query params * @param retries retries id * @returns data from remote response */ doRequest(method: string, path: string, pathTemplate: string, params?: { [key: string]: any; }, retries?: number): Promise; /** * return the current ticket/token, or create new ones, is previous one had been discared, or missing. * @returns Proxmox API ticket and CSRFPreventionToken */ getTicket(): Promise<{ ticket: string; CSRFPreventionToken: string; }>; } export default ProxmoxEngine;