export type PipelineWarmup = {minimum_nodes: number, duration?: number | undefined}; export type CreateApiV4PipelinesPipelineIdWarmupArgs = {pipeline_id: string, body: PipelineWarmup}; export type CreateApiV4PipelinesPipelineIdWarmupOptions = {baseUrl?: string | undefined, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Pipeline Warmup * * POST /v4/pipelines/{pipeline_id}/warmup * * Also accepts auth: APIKeyCookie */ export const createApiV4PipelinesPipelineIdWarmup = async (args: CreateApiV4PipelinesPipelineIdWarmupArgs, options?: CreateApiV4PipelinesPipelineIdWarmupOptions) => { const {baseUrl = "https://www.mystic.ai", fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v4/pipelines/${encodeURIComponent(String(args.pipeline_id))}/warmup${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 };