Skip to main content
Module

x/ptereno/lib/types/client.ts

An efficient and fully compliant Pterodactyl API wrapper.
Latest
File
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
export type PowerActionType = "start" | "stop" | "restart" | "kill";
export enum PowerAction { START = "start", STOP = "stop", RESTART = "restart", KILL = "kill",}
/* Generic */
export interface Host { address: string; port: number;}
export interface Cron { day_of_week: string; day_of_month: string; hour: string; minute: string;}
export interface SignedURL { object: "signed_url"; attributes: SignedURLAttributes;}
export interface SignedURLAttributes { url: string;}
export interface PaginationMeta { pagination: Pagination;}
export interface Pagination { total: number; count: number; per_page: number; current_page: number; total_pages: number; links: {};}
/* Account */
export interface Account { object: "user"; attributes: AccountAttributes;}
export interface AccountAttributes { id: number; admin: boolean; username: string; email: string; first_name: string; last_name: string; language: string;}
/* 2FA */
export interface TwoFactorQR { data: TwoFactorQRData;}
export interface TwoFactorQRData { image_url_data: string;}
export interface TwoFactorTokenList { object: "recovery_tokens"; attributes: TwoFactorTokenListAttributes;}
export interface TwoFactorTokenListAttributes { tokens: Array<string>;}
/* Keys */
export interface APIKeyList { object: "list"; data: Array<APIKey>;}
export interface APIKey { object: "api_key"; attributes: APIKeyAttributes;}
export interface APIKeyAttributes { identifier: string; description: string; allowed_ips: Array<string>; last_used_at: string; created_at: string;}
export interface NewAPIKey extends APIKey { meta: { secret_token: string; };}
/* Databases */
export interface DatabaseList { object: "list"; data: Array<Database>;}
export interface Database { object: "server_database"; attributes: DatabaseAttributes;}
export interface DatabaseAttributes { id: string; host: Host; name: string; username: string; connections_from: string; max_connections: number; relationships?: { password?: { // parameter option: password object: "database_password"; attributes: { password: string; }; }; };}
export interface NewDatabase extends Database { attributes: NewDatabaseAttributes;}
export interface NewDatabaseAttributes extends DatabaseAttributes { relationships: { password: { object: "database_password"; attributes: { password: string; }; }; };}
/* Files */
export interface FileList { object: "list"; data: Array<File>;}
export interface File { object: "file_object"; attributes: FileAttributes;}
export interface FileAttributes { name: string; mode: string; mode_bits: string; size: number; is_file: boolean; is_symlink: boolean; is_editable?: boolean; mimetype: string; created_at: string; modified_at: string;}
/* Schedules */
export interface ScheduleList { object: "list"; data: Array<Schedule>;}
export interface Schedule { object: "server_schedule"; attributes: ScheduleAttributes;}
export interface ScheduleAttributes { id: number; name: string; cron: Cron; is_active: boolean; is_processing: boolean; last_run_at: string; next_run_at: string; created_at: string; updated_at: string; relationships: { tasks: TaskList; };}
/* Schedule Tasks */
export interface TaskList { object: "list"; data: Array<Task>;}
export interface Task { object: "schedule_task"; attributes: TaskAttributes;}
export interface TaskAttributes { id: number; sequence_id: number; action: string; payload: string; time_offset: number; is_queued: boolean; created_at: string; updated_at: string;}
/* Allocations */
export interface AllocationList { object: "list"; data: Array<Allocation>;}
export interface Allocation { object: "allocation"; attributes: AllocationAttributes;}
export interface AllocationAttributes { id: number; ip: string; ip_alias: string | null; port: number; notes: string | null; is_default: boolean;}
/* Subusers */
export interface SubUserList { object: "list"; data: Array<SubUser>;}
export interface SubUser { object: "server_subuser"; attributes: SubUserAttributes;}
export interface SubUserAttributes { uuid: string; username: string; email: string; image: string; "2fa_enabled": boolean; created_at: string; permissions: Array<string>;}
/* Backups */
export interface BackupList { object: "list"; data: Array<Backup>; meta: PaginationMeta;}
export interface Backup { object: "backup"; attributes: BackupAttributes;}
export interface BackupAttributes { uuid: string; is_successful: boolean; name: string; ignored_files: Array<string>; checksum: string | null; bytes: number; created_at: string; completed_at: string | null;}
/* Variables */
export interface VariableList { object: "list"; data: Array<Variable>;}
export interface Variable { object: "egg_variable"; attributes: VariableAttributes;}
export interface VariableAttributes { name: string; description: string; env_variable: string; default_value: string; server_value: string; is_editable: boolean; rules: string;}
/* Servers */
export interface ServerList { object: "list"; data: Array<Server>; meta: PaginationMeta;}
export interface Server { object: "server"; attributes: ServerAttributes; meta: ServerMeta;}
export interface ServerAttributes { server_owner: boolean; identifier: string; internal_id: number; uuid: string; name: string; node: string; sftp_details: Host; description: string; limits: { memory: number; swap: number; disk: number; io: number; cpu: number; }; invocation: string; egg_features: Array<String>; feature_limits: { databases: number; allocations: number; backups: number; }; is_suspended: boolean; is_installing: boolean; relationships: { allocations: AllocationList; variables: VariableList; egg?: Egg; // parameter option: egg subuser?: SubUserList; // parameter option: subusers };}
export interface ServerMeta { is_server_owner: boolean; user_permissions: Array<string>;}
export interface SocketCredentials { data: SocketCredentialsData;}
export interface SocketCredentialsData { token: string; socket: string;}
export interface ServerResources { // returned from GET request object: "stats"; attributes: ServerResourceAttributes;}
export interface ServerResourceAttributes { current_state: string; is_suspended: boolean; resources: { memory_bytes: number; cpu_absolute: number; disk_bytes: number; network_rx_bytes: number; network_tx_bytes: number; };}
export interface ServerStats { // returned from websocket cpu_absolute: number; disk_bytes: number; memory_bytes: number; memory_limit_bytes: number; network: { rx_bytes: number; tx_bytes: number; }; state: string;}
/* Eggs */
export interface Egg { object: "egg"; attributes: EggAttributes;}
export interface EggAttributes { uuid: string; name: string;}
/* Permissions */
export interface AllPermissions { object: "system_permissions"; attributes: AllPermissionAttributes;}
export interface AllPermissionAttributes { permissions: { websocket: { description: string; keys: { connect: string; }; }; control: { description: string; keys: { console: string; start: string; stop: string; restart: string; }; }; user: { description: string; keys: { create: string; read: string; update: string; delete: string; }; }; file: { description: string; keys: { create: string; read: string; "read-content": string; update: string; delete: string; archive: string; sftp: string; }; }; backup: { description: string; keys: { create: string; read: string; update: string; delete: string; download: string; }; }; allocation: { description: string; keys: { read: string; create: string; update: string; delet: string; }; }; startup: { description: string; keys: { read: string; update: string; }; }; database: { description: string; keys: { create: string; read: string; update: string; delete: string; view_password: string; }; }; schedule: { description: string; keys: { create: string; read: string; update: string; delete: string; }; }; settings: { description: string; keys: { rename: string; reinstall: string; }; }; };}
/* Options */
export interface UpdateEmailOptions { /** * The new email address */ email: string; /** * The account password */ password: string;}
export interface UpdatePasswordOptions { /** * The current account password */ oldPassword: string; /** * The new account password */ newPassword: string;}
export interface NewAPIKeyOptions { /** * The API key description */ description: string; /** * A list of ip addresses that can use this key. */ allowedIPs?: Array<string>;}
export interface NewDatabaseOptions { /** * The database name */ name: string; /** * The ip address allowed to access this database. * * @default "%" */ remote?: string;}
export interface RenameFileOptions { /** * The target file name */ oldName: string; /** * The new file name */ newName: string; /** * The root directory * * @default "%" */ directory?: string;}
export interface UploadFileOptions { /** * The name of the uploaded file */ name: string; /** * The path to the local file */ filePath: string;}
export interface SingleFileOptions { /** * The target file */ file: string; /** * The root directory to access the files from. * * @default "/" */ directory?: string;}
export interface MultiFileOptions { /** * A list of target files */ files: string[]; /** * The root directory to access the files from. */ directory?: string;}
export interface FolderOptions { /** * The folder name */ name: string; /** * The root directory of the folder */ directory?: string;}
export interface UpdateFileCHMODOptions { /** * The file options. */ file: CHMODFile; /** * The root directory to access the files from. * * @default "/" */ directory?: string;}
export interface UpdateFilesCHMODOptions { /** * An array of file options. */ files: Array<CHMODFile>; /** * The root directory to access the files from. * * @default "/" */ directory?: string;}
export interface CHMODFile { /** * The name of the file. */ file: string; /** * The 3 digit access mode bits. */ mode: string;}
export interface NewScheduleOptions { /** * The schedule name */ name: string; /** * The cron minute */ minute: string; /** * The cron hour */ hour: string; /** * The cron day of week */ dayOfWeek: string; /** * The cron day of month */ dayOfMonth: string; /** * Whether or not the schedule is active * * @default true */ is_active?: boolean;}
export type UpdateScheduleOptions = Omit<NewScheduleOptions, "name">;
export interface TaskOptions { /** * The delay between the previous task and the new task. */ timeOffset: number; /** * The action the task executes */ action: string; /** * The payload included with the action */ payload?: string;}
export interface NewUserOptions { /** * The user email address */ email: string; /** * A list of user permissions */ perms: Array<string>;}
export type UpdateUserOptions = Omit<NewUserOptions, "email">;
export interface NewBackupOptions { /** * The backup name */ name?: string; /** * A list of files or directories to ignore. */ ignoredFiles?: Array<string>;}
export interface UpdateVariableOptions { key: string; value: string | null;}
/* Parameters */
export type DatabaseParameters = Array<DatabaseParameter>;export type DatabaseParameter = "password";
export type ServerParameters = Array<ServerParameter>;export type ServerParameter = "egg" | "subusers";