export type RegistryCredential = {type?: string | undefined, access_key?: string | undefined, access_secret?: string | undefined}; export type Registry = {id?: number | undefined, url?: string | undefined, name?: string | undefined, credential?: RegistryCredential | undefined, type?: string | undefined, insecure?: boolean | undefined, ca_certificate?: (string | null) | undefined, description?: string | undefined, status?: string | undefined, creation_time?: string | undefined, update_time?: string | undefined}; export type CreateApiRegistriesArgs = {'X-Request-Id'?: string | undefined, body: Registry}; export type CreateApiRegistriesOptions = {baseUrl?: string | undefined, basic?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Create a registry * * POST /registries */ export const createApiRegistries = async (args: CreateApiRegistriesArgs, options?: CreateApiRegistriesOptions) => { const {baseUrl = "http://localhost/api/v2.0", fetch: fetchFn = fetch, basic} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['X-Request-Id'] != null) headers.set("X-Request-Id", String(args['X-Request-Id'])) if (basic !== undefined) headers.set('authorization', `Basic ${btoa(`${basic.username}:${basic.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/registries${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 undefined };