export type ProjectMetadata = {public?: string | undefined, enable_content_trust?: (string | null) | undefined, enable_content_trust_cosign?: (string | null) | undefined, prevent_vul?: (string | null) | undefined, severity?: (string | null) | undefined, auto_scan?: (string | null) | undefined, auto_sbom_generation?: (string | null) | undefined, reuse_sys_cve_allowlist?: (string | null) | undefined, retention_id?: (string | null) | undefined, proxy_speed_kb?: (string | null) | undefined, max_upstream_conn?: (string | null) | undefined, proxy_cache_local_on_not_found?: (string | null) | undefined}; export type CVEAllowlistItem = {cve_id?: string | undefined}; export type CVEAllowlist = {id?: number | undefined, project_id?: number | undefined, expires_at?: (number | null) | undefined, items?: Array | undefined, creation_time?: string | undefined, update_time?: string | undefined}; export type ProjectReq = {project_name?: string | undefined, public?: (boolean | null) | undefined, metadata?: ProjectMetadata | undefined, cve_allowlist?: CVEAllowlist | undefined, storage_limit?: (number | null) | undefined, registry_id?: (number | null) | undefined}; export type CreateApiProjectsArgs = {'X-Request-Id'?: string | undefined, 'X-Resource-Name-In-Location'?: boolean | undefined, body: ProjectReq}; export type CreateApiProjectsOptions = {baseUrl?: string | undefined, basic?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Create a new project. * * POST /projects */ export const createApiProjects = async (args: CreateApiProjectsArgs, options?: CreateApiProjectsOptions) => { 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 (args['X-Resource-Name-In-Location'] != null) headers.set("X-Resource-Name-In-Location", String(args['X-Resource-Name-In-Location'])) if (basic !== undefined) headers.set('authorization', `Basic ${btoa(`${basic.username}:${basic.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/projects${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 };