//native
import * as wmill from "windmill-client"
// windmill-client errors only carry the status text: throw the response body, which says why
wmill.OpenAPI.interceptors.response.use(async (response) => {
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return response
})
export type DynSelect_path = string
export async function path() {
const schedules = await wmill.ScheduleService.listSchedules({
workspace: wmill.getWorkspace(),
perPage: 1000,
})
return schedules.map((s) => ({
value: s.path,
label: `${s.path} (${s.schedule})`,
}))
}
/**
* Enable or Disable Schedule
* Turn a schedule on or off without changing anything else.
*/
export async function main(path: DynSelect_path, enabled: boolean) {
return await wmill.ScheduleService.setScheduleEnabled({
workspace: wmill.getWorkspace(),
path,
requestBody: { enabled: enabled ?? false },
})
}
Submitted by hugo989 5 hours ago
//native
import * as wmill from "windmill-client@1";
export async function main(schedule_path: string, enabled: boolean) {
const conf = wmill.createConf();
const schedule_api = new wmill.ScheduleApi(conf);
return await schedule_api.setScheduleEnabled(
conf.workspace_id,
schedule_path,
{
enabled,
}
);
}
Submitted by hugo989 134 days ago