export type CreateApiImagesLoadArgs = {quiet?: boolean | undefined, platform?: Array | undefined, body: BodyInit}; export type CreateApiImagesLoadOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Import images * * POST /images/load */ export const createApiImagesLoad = async (args: CreateApiImagesLoadArgs, options: CreateApiImagesLoadOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/x-tar") if (args.quiet != null) query.append("quiet", String(args.quiet)) for (const item of args.platform ?? []) query.append("platform", String(item)) const url = `${baseUrl.replace(/\/+$/, '')}/images/load${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };