export type UpgradeTime = {hours: number, minutes: number, seconds?: (number | null) | undefined}; export type DailySchedule = {time?: (UpgradeTime | null) | undefined}; export type WeeklySchedule = {day_of_week?: (number | null) | undefined, time?: (UpgradeTime | null) | undefined}; export type MonthlySchedule = {day_of_month?: (number | null) | undefined, time?: (UpgradeTime | null) | undefined}; export type ScheduleType = {daily: DailySchedule} | {weekly: WeeklySchedule} | {monthly: MonthlySchedule}; export type AutoUpgradeSchedule = {schedule_type?: (ScheduleType | null) | undefined}; export type UpdateAutoUpgradeConfigRequest = {enabled: boolean, schedule?: (AutoUpgradeSchedule | null) | undefined}; export type PatchApiApiV1UpgradeAutoUpgradeArgs = {body: UpdateAutoUpgradeConfigRequest}; export type PatchApiApiV1UpgradeAutoUpgradeOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Set auto-upgrade settings * * PATCH /api/v1/upgrade/auto-upgrade */ export const patchApiApiV1UpgradeAutoUpgrade = async (args: PatchApiApiV1UpgradeAutoUpgradeArgs, options?: PatchApiApiV1UpgradeAutoUpgradeOptions) => { const {baseUrl = "http://miner", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/upgrade/auto-upgrade${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };