export type ControlTaskAction = {'action-type': 'stop'} | {'action-type': 'cancel'} | {'action-type': 'run-now'} | {'action-type': 'run-at', 'scheduled-for': string}; export type ControlTasksRequest = {action: ControlTaskAction, 'task-ids': Array}; export type CreateApiManagementV1ProjectTaskControlArgs = {'x-project-id'?: (string | null) | undefined, body: ControlTasksRequest}; export type CreateApiManagementV1ProjectTaskControlOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Control a set of Project-level tasks by their IDs (e.g., cancel, request stop, run now) * * POST /management/v1/project/task/control */ export const createApiManagementV1ProjectTaskControl = async (args: CreateApiManagementV1ProjectTaskControlArgs, options?: CreateApiManagementV1ProjectTaskControlOptions) => { const {baseUrl = "https://localhost", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['x-project-id'] != null) headers.set("x-project-id", String(args['x-project-id'])) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/management/v1/project/task/control${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 undefined };