import {z} from 'zod' export type CreateApiApiV1CertManagerSyncsCertificatesSearchArgs = {body: {pkiSyncId?: string | undefined, applicationId?: string | undefined, filters?: ({profileIds?: Array | undefined, certificateOrderIds?: Array | undefined, metadata?: (Array<{key: string, value?: string | undefined}>) | undefined} | null) | undefined, offset?: number | undefined, limit?: number | undefined}}; export type CreateApiApiV1CertManagerSyncsCertificatesSearchOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiApiV1CertManagerSyncsCertificatesSearchResponse = z.object({matchedCount: z.number(), certificates: z.array(z.object({id: z.string(), commonName: z.string(), altNames: z.string().nullable().optional(), serialNumber: z.string().optional(), notAfter: z.string().optional(), orderId: z.string().optional(), profileName: z.string().nullable().optional()})), toUnlink: z.array(z.object({id: z.string(), commonName: z.string(), altNames: z.string().nullable().optional(), serialNumber: z.string().optional(), notAfter: z.string().optional(), orderId: z.string().optional(), profileName: z.string().nullable().optional()})), toUnlinkAtDestinationCount: z.number(), willRemoveFromDestination: z.boolean()}); 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 }; /** * List the certificates a set of filters matches, for an existing PKI Sync or an Application. * * POST /api/v1/cert-manager/syncs/certificates/search */ export const createApiApiV1CertManagerSyncsCertificatesSearch = async (args: CreateApiApiV1CertManagerSyncsCertificatesSearchArgs, options?: CreateApiApiV1CertManagerSyncsCertificatesSearchOptions) => { 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/cert-manager/syncs/certificates/search${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 validateResponse(createApiApiV1CertManagerSyncsCertificatesSearchResponse, await res.json()) };