import {z} from 'zod' export type HelmRepositoryKindEnum = 'HTTPS' | 'OCI_ECR' | 'OCI_SCALEWAY_CR' | 'OCI_DOCKER_HUB' | 'OCI_PUBLIC_ECR' | 'OCI_GENERIC_CR' | 'OCI_GITHUB_CR' | 'OCI_GITLAB_CR'; export type HelmRepositoryRequest = {name: string, kind: HelmRepositoryKindEnum, description?: string | undefined, url?: string | undefined, skip_tls_verification: boolean, config: {username?: string | undefined, password?: string | undefined, access_key_id?: string | undefined, secret_access_key?: string | undefined, region?: string | undefined, scaleway_access_key?: string | undefined, scaleway_secret_key?: string | undefined, scaleway_project_id?: string | undefined, azure_tenant_id?: string | undefined, azure_subscription_id?: string | undefined}}; export type UpdateApiOrganizationOrganizationIdHelmRepositoryHelmRepositoryIdArgs = {organizationId: string, helmRepositoryId: string, body: HelmRepositoryRequest}; export type UpdateApiOrganizationOrganizationIdHelmRepositoryHelmRepositoryIdOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const helmRepositoryKindEnum = z.enum(["HTTPS", "OCI_ECR", "OCI_SCALEWAY_CR", "OCI_DOCKER_HUB", "OCI_PUBLIC_ECR", "OCI_GENERIC_CR", "OCI_GITHUB_CR", "OCI_GITLAB_CR"]); export const helmRepositoryResponse = z.object({id: z.string(), created_at: z.string(), updated_at: z.string().optional(), name: z.string(), kind: helmRepositoryKindEnum.optional(), description: z.string().optional(), url: z.string().optional(), skip_tls_verification: z.boolean().optional(), associated_services_count: z.number().int().optional(), config: z.object({username: z.string().optional(), region: z.string().optional(), access_key_id: z.string().optional(), scaleway_access_key: z.string().optional(), scaleway_project_id: z.string().optional(), azure_tenant_id: z.string().optional(), azure_subscription_id: z.string().optional()}).optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Edit a helm repository * * PUT /organization/{organizationId}/helmRepository/{helmRepositoryId} * * Also accepts auth: bearerAuth */ export const updateApiOrganizationOrganizationIdHelmRepositoryHelmRepositoryId = async (args: UpdateApiOrganizationOrganizationIdHelmRepositoryHelmRepositoryIdArgs, options?: UpdateApiOrganizationOrganizationIdHelmRepositoryHelmRepositoryIdOptions) => { const {baseUrl = "https://api.qovery.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (ApiKeyAuth !== undefined) headers.set("Authorization", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/organization/${encodeURIComponent(String(args.organizationId))}/helmRepository/${encodeURIComponent(String(args.helmRepositoryId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 validateResponse(helmRepositoryResponse, await res.json()) };