export type CreateApiV1AutomationsAutomationIdRunsArgs = {'App-ID': string, 'Auth-Token': string, automation_id: string}; export type CreateApiV1AutomationsAutomationIdRunsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Run an automation for existing objects * * POST /v1/automations/{automation_id}/runs/ */ export const createApiV1AutomationsAutomationIdRuns = async (args: CreateApiV1AutomationsAutomationIdRunsArgs, options: CreateApiV1AutomationsAutomationIdRunsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['App-ID'] != null) headers.set("App-ID", String(args['App-ID'])) if (args['Auth-Token'] != null) headers.set("Auth-Token", String(args['Auth-Token'])) const url = `${baseUrl.replace(/\/+$/, '')}/v1/automations/${encodeURIComponent(String(args.automation_id))}/runs/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };