import {z} from 'zod' export type PatchApiApiV1PkiSyncsNutanixPrismCentralPkiSyncIdArgs = {pkiSyncId: string, body: {name?: string | undefined, description?: string | undefined, isAutoSyncEnabled?: boolean | undefined, destinationConfig?: {clusterId: string, clusterName: string} | undefined, syncOptions?: ({canImportCertificates?: false | undefined, canRemoveCertificates?: false | undefined, healthCheckCommand?: (string | null) | undefined, postSyncCommand?: (string | null) | undefined}) | undefined, subscriberId?: (string | null) | undefined, connectionId?: string | undefined, filters?: ({profileIds?: Array | undefined, certificateOrderIds?: Array | undefined, metadata?: (Array<{key: string, value?: string | undefined}>) | undefined} | null) | undefined}}; export type PatchApiApiV1PkiSyncsNutanixPrismCentralPkiSyncIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const patchApiApiV1PkiSyncsNutanixPrismCentralPkiSyncIdResponse = z.object({id: z.string(), name: z.string().max(256), description: z.string().nullable().optional(), destination: z.literal("nutanix-prism-central"), isAutoSyncEnabled: z.boolean(), destinationConfig: z.object({clusterId: z.string().min(1), clusterName: z.string().min(1)}), syncOptions: z.object({canImportCertificates: z.literal(false).optional(), canRemoveCertificates: z.literal(false).optional(), healthCheckCommand: z.string().max(8192).nullable().optional(), postSyncCommand: z.string().max(8192).nullable().optional()}), projectId: z.string(), subscriberId: z.string().nullable().optional(), connectionId: z.string(), createdAt: z.string(), updatedAt: z.string(), syncStatus: z.string().nullable().optional(), lastSyncedAt: z.string().nullable().optional(), lastHealthCheckRanAt: z.string().nullable().optional(), lastHealthCheckStatus: z.enum(["pending", "running", "succeeded", "failed"]).nullable().optional(), lastHealthCheckMessage: z.string().nullable().optional(), filters: z.object({profileIds: z.array(z.string()).optional(), certificateOrderIds: z.array(z.string()).optional(), metadata: z.array(z.object({key: z.string(), value: z.string().optional()})).optional()}).nullable().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 Nutanix Prism Central PKI Sync. * * PATCH /api/v1/pki/syncs/nutanix-prism-central/{pkiSyncId} */ export const patchApiApiV1PkiSyncsNutanixPrismCentralPkiSyncId = async (args: PatchApiApiV1PkiSyncsNutanixPrismCentralPkiSyncIdArgs, options?: PatchApiApiV1PkiSyncsNutanixPrismCentralPkiSyncIdOptions) => { 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/pki/syncs/nutanix-prism-central/${encodeURIComponent(String(args.pkiSyncId))}${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(patchApiApiV1PkiSyncsNutanixPrismCentralPkiSyncIdResponse, await res.json()) };