import {z} from 'zod' export type PatchApiApiV1AppConnectionsImpervaConnectionIdArgs = {connectionId: string, body: {credentials?: ({apiId: string, apiKey: string, accountId?: string | undefined}) | undefined, name?: string | undefined, description?: (string | null) | undefined, isPlatformManagedCredentials?: false | undefined, gatewayId?: (string | null) | undefined, gatewayPoolId?: (string | null) | undefined, isAutoRotationEnabled?: false | undefined, rotation?: ('null' | null) | undefined}}; export type PatchApiApiV1AppConnectionsImpervaConnectionIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const patchApiApiV1AppConnectionsImpervaConnectionIdResponse = z.object({appConnection: z.object({id: z.string(), name: z.string(), description: z.string().nullable().optional(), version: z.number().optional(), orgId: z.string(), createdAt: z.string(), updatedAt: z.string(), isPlatformManagedCredentials: z.boolean().nullable().optional(), gatewayId: z.string().nullable().optional(), projectId: z.string().nullable().optional(), isAutoRotationEnabled: z.boolean().optional(), gatewayPoolId: z.string().nullable().optional(), rotation: z.object({lastRotationMessage: z.string().nullable().optional(), rotationInterval: z.number(), nextRotationAt: z.string().nullable().optional(), rotationStatus: z.enum(["success", "failed"]), rotateAtUtc: z.object({hours: z.number(), minutes: z.number()})}).optional(), credentialsHash: z.string().optional(), project: z.object({name: z.string(), id: z.string(), type: z.string(), slug: z.string()}).nullable().optional(), app: z.literal("imperva"), method: z.literal("api-key"), credentials: z.object({apiId: z.string().min(1).max(256), accountId: z.string().min(1).max(32).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 }; /** * Update the specified Imperva Connection. * * PATCH /api/v1/app-connections/imperva/{connectionId} */ export const patchApiApiV1AppConnectionsImpervaConnectionId = async (args: PatchApiApiV1AppConnectionsImpervaConnectionIdArgs, options?: PatchApiApiV1AppConnectionsImpervaConnectionIdOptions) => { const {baseUrl = "https://us.infisical.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/app-connections/imperva/${encodeURIComponent(String(args.connectionId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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(patchApiApiV1AppConnectionsImpervaConnectionIdResponse, await res.json()) };