export type ClipDownloadInput = {job_id: string, mosaic_type: string, user_agent?: (string | null) | undefined, requester_ip?: (string | null) | undefined}; export type CreateApiV1OpClipJobDownloadArgs = {'x-api-key'?: (string | null) | undefined, body: ClipDownloadInput}; export type CreateApiV1OpClipJobDownloadOptions = {baseUrl: string, HTTPBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Stream a clip file from GCS (egress-enforced). * * POST /v1/op/clip.job.download */ export const createApiV1OpClipJobDownload = async (args: CreateApiV1OpClipJobDownloadArgs, options: CreateApiV1OpClipJobDownloadOptions) => { const {baseUrl, fetch: fetchFn = fetch, HTTPBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "image/tiff") if (args['x-api-key'] != null) headers.set("x-api-key", String(args['x-api-key'])) if (HTTPBearer !== undefined) headers.set('authorization', `Bearer ${HTTPBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/op/clip.job.download${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 res.blob() };