jspteroapi
Version:
A pterodactyl v1 api using undici
132 lines (131 loc) • 6.15 kB
TypeScript
import { Client } from '../index';
import { Schedule, ScheduleAttributes, ScheduleTaskAttributes, SheduleEditOptions, TaskEditOptions } from '../interfaces/Schedule';
export declare class scheduleMethods {
private readonly client;
constructor(client: Client);
/**
* @param serverId - ID of the server to get (In the settings tab of server/in link)
* @returns An Array of servers schedules
* @example
* ```ts
* const res = await client.getAllSchedules() // res = Schedule[]
* ```
* @example
* ```ts
* client.getAllSchedules().then((res) => console.log(res)) // res = Schedule[]
* ```
*/
getAllSchedules: (serverId: string) => Promise<Schedule[]>;
/**
* @param serverId - ID of the server to get (In the settings tab of server/in link)
* @param name - Name of the schedule
* @param minute - Cron minute syntax
* @param hour - Cron hour syntax
* @param dayOfMonth - Cron day of month syntax
* @param month - Cron month syntax
* @param dayOfWeek - Cron day of week syntax
* @param isActive - Whether the schedule should be activated on creation (default true)
* @param onlyWhenOnline - Whether the schedule should only run when server is on (default true)
* @returns The schedule information
* @example
* ```ts
* const res = await client.createSchedule('TESTING', '*', '*', '*', '*') // res = ScheduleAttributes
* ```
* @example
* ```ts
* client.createSchedule('TESTING', '*', '*', '*', '*').then((res) => console.log(res)) // res = ScheduleAttributes
* ```
*/
createSchedule: (serverId: string, name: string, minute: string, hour: string, dayOfMonth: string, month: string, dayOfWeek: string, isActive?: boolean, onlyWhenOnline?: boolean) => Promise<ScheduleAttributes>;
/**
* @param serverId - ID of the server to get (In the settings tab of server/in link)
* @param scheduleId - Id of the schedule to get info
* @returns Schedule information
* @example
* ```ts
* const res = await client.getScheduleInfo('7e74354d', 7) // res = ScheduleAttributes
* ```
* @example
* ```ts
* client.getScheduleInfo('7e74354d', 8).then((res) => console.log(res)) // res = ScheduleAttributes
* ```
*/
getScheduleInfo: (serverId: string, scheduleId: number) => Promise<ScheduleAttributes>;
/**
* @param serverId - ID of the server to get (In the settings tab of server/in link)
* @param scheduleId - Id of the schedule to edit
* @param options - Edit schedule options
* @returns The schedule information
* @example
* ```ts
* const res = await client.editSchedule('7e74354d', 5, { name: 'EditedName' }) // res = ScheduleAttributes
* ```
* @example
* ```ts
* client.editSchedule('7e74354d', 5, { name: 'EditedName' }).then((res) => console.log(res)) // res = ScheduleAttributes
* ```
*/
editSchedule: (serverId: string, scheduleId: number, options: SheduleEditOptions) => Promise<ScheduleAttributes>;
/**
* @param serverId - ID of the server to get (In the settings tab of server/in link)
* @param scheduleId - Id of the schedule to delete
* @returns Successfuly deleted schedule!
* @example
* ```ts
* const res = await client.deleteSchedule('7e74354d', 5) // res = Successfuly deleted schedule!
* ```
* @example
* ```ts
* client.deleteSchedule('7e74354d', 5).then((res) => console.log(res)) // res = Successfuly deleted schedule!
* ```
*/
deleteSchedule: (serverId: string, scheduleId: number) => Promise<string>;
/**
* @param serverId - ID of the server to get (In the settings tab of server/in link)
* @param scheduleId - Id of the schedule to create task for
* @param action - Action that the schedule should perform (command/power/backup)
* @param payload - What that action should do. Command or power (start/stop/restart/kill). Backup payload is ignored file list.
* @param timeOffset - The time offset that the task should run after the schdule is triggered. (default 0)
* @param continueOnFailure - Should the task continue to work on failure. (default false)
* @returns The task information
* @example
* ```ts
* const res = await client.createTask('7e74354d', 5, 'power', 'start') // res = ScheduleTaskAttributes
* ```
* @example
* ```ts
* client.createTask('7e74354d', 5, 'power', 'start').then((res) => console.log(res)) // res = ScheduleTaskAttributes
* ```
*/
createTask: (serverId: string, scheduleId: number, action: 'command' | 'power' | 'backup', payload: string, timeOffset?: number, continueOnFailure?: boolean) => Promise<ScheduleTaskAttributes>;
/**
* @param serverId - ID of the server to get (In the settings tab of server/in link)
* @param scheduleId - ID of the schedule to edit task for
* @param taskId - ID of the task to edit
* @returns The task information
* @example
* ```ts
* const res = await client.editTask('7e74354d', 5, 1, { payload: 'restart' }) // res = ScheduleTaskAttributes
* ```
* @example
* ```ts
* client.editTask('7e74354d', 5, 1, { payload: 'restart' }).then((res) => console.log(res)) // res = ScheduleTaskAttributes
* ```
*/
editTask: (serverId: string, scheduleId: number, taskId: number, options: TaskEditOptions) => Promise<ScheduleTaskAttributes>;
/**
* @param serverId - ID of the server to get (In the settings tab of server/in link)
* @param scheduleId - ID of the schedule
* @param taskId - ID of the task to delete
* @returns Successfuly deleted schedule!
* @example
* ```ts
* const res = await client.deleteTask('7e74354d', 5) // res = Successfuly deleted schedule!
* ```
* @example
* ```ts
* client.deleteTask('7e74354d', 5).then((res) => console.log(res)) // res = Successfuly deleted schedule!
* ```
*/
deleteTask: (serverId: string, scheduleId: number, taskId: number) => Promise<string>;
}