jspteroapi
Version:
A pterodactyl v1 api using undici
77 lines (76 loc) • 6.81 kB
TypeScript
import { JSPteroAPIError } from '../modules/Error';
declare class Client {
private host;
private key;
private errorHandler;
/**
* @param host - Panels address
* @param key - Api key to use
* @param errorHandler - A custom function to handle errors
* @param fast - Fast login (No credential check)
*/
constructor(host: string, key: string, errorHandler?: (error: JSPteroAPIError) => void, fast?: boolean);
/**
* @param throwError - Whether to throw an error or return bool
* @remarks Will not work if using custom error handler.
*/
testAPI: (throwError?: boolean) => Promise<boolean>;
/**
@internal
*/
request: (requestType: "GET" | "POST" | "PUT" | "DELETE" | "PATCH", data: unknown, dataObj: string, endpoint: string, text?: boolean) => Promise<any>;
getAllServers: (options?: import("./interfaces/Server").ServerIncludeInput | undefined, filter?: import("./interfaces/Server").ServerFilterInput | undefined, admin?: boolean) => Promise<import("./interfaces/Server").Server[]>;
getServerInfo: (serverId: string, options?: import("./interfaces/Server").ServerIncludeInput | undefined) => Promise<import("./interfaces/Server").ServerAttributes>;
getServerResources: (serverId: string) => Promise<import("./interfaces/ServerResources").ServerResources>;
getAllPermissions: () => Promise<import("./interfaces/Permissions").Permissions>;
getAllDatabases: (serverId: string, options?: import("./interfaces/Database").DatabaseIncludeInput | undefined) => Promise<import("./interfaces/Database").Database[]>;
getAllFiles: (serverId: string, dir?: string) => Promise<import("./interfaces/ServerFile").ServerFile[]>;
getFileContents: (serverId: string, file: string) => Promise<string>;
getFileDownloadLink: (serverId: string, file: string) => Promise<string>;
getFileUploadLink: (serverId: string) => Promise<string>;
getAccountInfo: () => Promise<import("./interfaces/User").UserAttributes>;
getAccount2FADetails: () => Promise<string>;
getAllApiKeys: () => Promise<import("./interfaces/ApiKey").ApiKey[]>;
getAllSchedules: (serverId: string) => Promise<import("./interfaces/Schedule").Schedule[]>;
getScheduleInfo: (serverId: string, scheduleId: number) => Promise<import("./interfaces/Schedule").ScheduleAttributes>;
getAllAlocations: (serverId: string) => Promise<import("./interfaces/Allocation").Allocation[]>;
getAllSubUsers: (serverId: string) => Promise<import("./interfaces/SubUser").SubUser[]>;
getSubUserInfo: (serverId: string, subUserId: string) => Promise<import("./interfaces/SubUser").SubUserAttributes>;
getAllBackups: (serverId: string) => Promise<import("./interfaces/Backups").Backup[]>;
getBackupInfo: (serverId: string, backupId: string) => Promise<import("./interfaces/Backups").BackupAttributes>;
getBackupDownloadLink: (serverId: string, backupId: string) => Promise<string>;
sendCommand: (serverId: string, command: string) => Promise<string>;
setPowerState: (serverId: string, action: "stop" | "start" | "restart" | "kill") => Promise<string>;
createDatabase: (serverId: string, databaseName: string, connectionsAllowedFrom?: string, options?: import("./interfaces/Database").DatabaseIncludeInput | undefined) => Promise<import("./interfaces/Database").DatabaseAttributes>;
rotateDatabasePass: (serverId: string, databaseId: string) => Promise<import("./interfaces/Database").DatabaseAttributes>;
copyFile: (serverId: string, location: string) => Promise<string>;
writeFile: (serverId: string, file: string, contents: string) => Promise<string>;
compressFile: (serverId: string, data: import("./interfaces/ServerFile").ServerFileCompress) => Promise<import("./interfaces/ServerFile").ServerFileAttributes>;
decompressFile: (serverId: string, data: import("./interfaces/ServerFile").ServerFileDecompress) => Promise<string>;
deleteFile: (serverId: string, data: import("./interfaces/ServerFile").ServerFileCompress) => Promise<string>;
createFolder: (serverId: string, data: import("./interfaces/ServerFile").ServerFileCreateFolder) => Promise<string>;
enable2FA: (code: string) => Promise<string[]>;
createApiKey: (description: string, allowedIps?: string[]) => Promise<import("./interfaces/ApiKey").ApiKey>;
createSchedule: (serverId: string, name: string, minute: string, hour: string, dayOfMonth: string, month: string, dayOfWeek: string, isActive?: boolean, onlyWhenOnline?: boolean) => Promise<import("./interfaces/Schedule").ScheduleAttributes>;
editSchedule: (serverId: string, scheduleId: number, options: import("./interfaces/Schedule").SheduleEditOptions) => Promise<import("./interfaces/Schedule").ScheduleAttributes>;
assignAllocation: (serverId: string) => Promise<import("./interfaces/Allocation").Allocation>;
setAllocationNote: (serverId: string, allocationId: number, note: string) => Promise<import("./interfaces/Allocation").Allocation>;
setAllocationPrimary: (serverId: string, allocationId: number) => Promise<import("./interfaces/Allocation").Allocation>;
createSubUser: (serverId: string, email: string, permissions: import("./interfaces/SubUser").SubuserPermission[]) => Promise<import("./interfaces/SubUser").SubUserAttributes>;
updateSubUserPermissions: (serverId: string, subUserId: string, permissions: import("./interfaces/SubUser").SubuserPermission[]) => Promise<import("./interfaces/SubUser").SubUserAttributes>;
createBackup: (serverId: string, name?: string, ignored?: string[], isLocked?: boolean) => Promise<import("./interfaces/Backups").BackupAttributes>;
renameServer: (serverId: string, name: string) => Promise<string>;
reinstallServer: (serverId: string) => Promise<string>;
toggleLockBackup: (serverId: string, backupId: string) => Promise<import("./interfaces/Backups").BackupAttributes>;
restoreBackup: (serverId: string, backupId: string, truncate?: boolean) => Promise<import("./interfaces/Backups").BackupAttributes>;
deleteDatabase: (serverId: string, databaseId: string) => Promise<string>;
deleteApiKey: (apiKeyIden: string) => Promise<string>;
deleteAllocation: (serverId: string, allocationId: number) => Promise<string>;
deleteSubUser: (serverId: string, subUserId: string) => Promise<string>;
deleteBackup: (serverId: string, backupId: string) => Promise<string>;
renameFile: (serverId: string, data: import("./interfaces/ServerFile").SeverFileRename) => Promise<string>;
updateEmail: (email: string, password: string) => Promise<string>;
updatePassword: (currentPassword: string, password: string) => Promise<string>;
startConsoleConnection: (serverId: string) => Promise<import("./Websocket").WebsocketClient>;
}
export { Client };