import {z} from 'zod' export type GetApiHelmHelmIdAdvancedSettingsArgs = {helmId: string}; export type GetApiHelmHelmIdAdvancedSettingsOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const helmAdvancedSettings = z.object({"deployment.custom_domain_check_enabled": z.boolean().optional(), "network.ingress.proxy_body_size_mb": z.number().int().optional(), "network.ingress.force_ssl_redirect": z.boolean().optional(), "network.ingress.enable_cors": z.boolean().optional(), "network.ingress.cors_allow_origin": z.string().optional(), "network.ingress.cors_allow_methods": z.string().optional(), "network.ingress.cors_allow_headers": z.string().optional(), "network.ingress.proxy_buffer_size_kb": z.number().int().optional(), "network.ingress.keepalive_time_seconds": z.number().int().optional(), "network.ingress.keepalive_timeout_seconds": z.number().int().optional(), "network.ingress.send_timeout_seconds": z.number().int().optional(), "network.ingress.proxy_connect_timeout_seconds": z.number().int().optional(), "network.ingress.proxy_send_timeout_seconds": z.number().int().optional(), "network.ingress.proxy_read_timeout_seconds": z.number().int().optional(), "network.ingress.proxy_buffering": z.string().optional(), "network.ingress.proxy_request_buffering": z.string().optional(), "network.ingress.grpc_send_timeout_seconds": z.number().int().optional(), "network.ingress.grpc_read_timeout_seconds": z.number().int().optional(), "network.ingress.whitelist_source_range": z.string().optional(), "network.ingress.denylist_source_range": z.string().optional(), "network.ingress.extra_headers": z.string().optional(), "network.ingress.basic_auth_env_var": z.string().optional(), "network.ingress.enable_sticky_session": z.boolean().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 }; /** * Get advanced settings * * GET /helm/{helmId}/advancedSettings * * Also accepts auth: bearerAuth */ export const getApiHelmHelmIdAdvancedSettings = async (args: GetApiHelmHelmIdAdvancedSettingsArgs, options?: GetApiHelmHelmIdAdvancedSettingsOptions) => { const {baseUrl = "https://api.qovery.com", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (ApiKeyAuth !== undefined) headers.set("Authorization", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/helm/${encodeURIComponent(String(args.helmId))}/advancedSettings${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(helmAdvancedSettings, await res.json()) };