export type CredentialV2CreateRequest = {name: string, username: string, password: string}; export type CreateApiV2ContainerRegistryAuthsArgs = {body: CredentialV2CreateRequest}; export type CreateApiV2ContainerRegistryAuthsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Create credential * * POST /v2/container-registry-auths */ export const createApiV2ContainerRegistryAuths = async (args: CreateApiV2ContainerRegistryAuthsArgs, options: CreateApiV2ContainerRegistryAuthsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") const url = `${baseUrl.replace(/\/+$/, '')}/v2/container-registry-auths${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() };