export type CreateApiImagesNameTagArgs = {name: string, repo?: string | undefined, tag?: string | undefined}; export type CreateApiImagesNameTagOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Tag an image * * POST /images/{name}/tag */ export const createApiImagesNameTag = async (args: CreateApiImagesNameTagArgs, options: CreateApiImagesNameTagOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.repo != null) query.append("repo", String(args.repo)) if (args.tag != null) query.append("tag", String(args.tag)) const url = `${baseUrl.replace(/\/+$/, '')}/images/${encodeURIComponent(String(args.name))}/tag${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 };