Enhance API with OIDC support, including login and callback endpoints. Update environment variables for OIDC configuration in .env.example. Add new features to the catalog service for listing software families, Minecraft versions, and deployment regions. Implement server management actions such as kill, delete, and update in the servers module. Integrate feature flags for maintenance mode in server operations. Update pnpm-lock.yaml with new dependencies and versions.
This commit is contained in:
78
apps/web/src/lib/api/schedules.ts
Normal file
78
apps/web/src/lib/api/schedules.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
import { apiFetch } from "./auth";
|
||||
|
||||
export type ScheduleTaskType =
|
||||
| "START"
|
||||
| "STOP"
|
||||
| "RESTART"
|
||||
| "BACKUP"
|
||||
| "CONSOLE_COMMAND"
|
||||
| "UPDATE_CHECK"
|
||||
| "MAINTENANCE";
|
||||
|
||||
export interface ScheduledTask {
|
||||
id: string;
|
||||
taskType: ScheduleTaskType;
|
||||
payload: Record<string, unknown> | null;
|
||||
}
|
||||
|
||||
export interface Schedule {
|
||||
id: string;
|
||||
name: string;
|
||||
timezone: string;
|
||||
cronExpr: string;
|
||||
enabled: boolean;
|
||||
nextRunAt: string | null;
|
||||
lastRunAt: string | null;
|
||||
tasks: ScheduledTask[];
|
||||
}
|
||||
|
||||
export interface ScheduleListResponse {
|
||||
schedules: Schedule[];
|
||||
}
|
||||
|
||||
export interface CreateSchedulePayload {
|
||||
name: string;
|
||||
timezone?: string;
|
||||
cronExpr: string;
|
||||
enabled?: boolean;
|
||||
tasks: Array<{
|
||||
taskType: ScheduleTaskType;
|
||||
payload?: Record<string, unknown>;
|
||||
}>;
|
||||
}
|
||||
|
||||
export type UpdateSchedulePayload = Partial<CreateSchedulePayload>;
|
||||
|
||||
export async function listSchedules(serverId: string): Promise<ScheduleListResponse> {
|
||||
return apiFetch<ScheduleListResponse>(`/servers/${serverId}/schedules`);
|
||||
}
|
||||
|
||||
export async function createSchedule(
|
||||
serverId: string,
|
||||
payload: CreateSchedulePayload,
|
||||
): Promise<Schedule> {
|
||||
return apiFetch<Schedule>(`/servers/${serverId}/schedules`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export async function updateSchedule(
|
||||
serverId: string,
|
||||
scheduleId: string,
|
||||
payload: UpdateSchedulePayload,
|
||||
): Promise<Schedule> {
|
||||
return apiFetch<Schedule>(`/servers/${serverId}/schedules/${scheduleId}`, {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
}
|
||||
|
||||
export async function deleteSchedule(
|
||||
serverId: string,
|
||||
scheduleId: string,
|
||||
): Promise<void> {
|
||||
await apiFetch<void>(`/servers/${serverId}/schedules/${scheduleId}`, {
|
||||
method: "DELETE",
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user