export type CreateApiImagesCreateArgs = {fromImage?: string | undefined, fromSrc?: string | undefined, repo?: string | undefined, tag?: string | undefined, message?: string | undefined, 'X-Registry-Auth'?: string | undefined, changes?: Array | undefined, platform?: string | undefined, body: BodyInit}; export type CreateApiImagesCreateOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Create an image * * POST /images/create */ export const createApiImagesCreate = async (args: CreateApiImagesCreateArgs, options: CreateApiImagesCreateOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "text/plain") if (args.fromImage != null) query.append("fromImage", String(args.fromImage)) if (args.fromSrc != null) query.append("fromSrc", String(args.fromSrc)) if (args.repo != null) query.append("repo", String(args.repo)) if (args.tag != null) query.append("tag", String(args.tag)) if (args.message != null) query.append("message", String(args.message)) if (args['X-Registry-Auth'] != null) headers.set("X-Registry-Auth", String(args['X-Registry-Auth'])) for (const item of args.changes ?? []) query.append("changes", String(item)) if (args.platform != null) query.append("platform", String(args.platform)) const url = `${baseUrl.replace(/\/+$/, '')}/images/create${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 };