import {z} from 'zod' export type CreateApiApiV1CertManagerSyncsWindowsServerTestHealthCheckArgs = {body: {connectionId: string, applicationId?: string | undefined, syncId?: string | undefined, certificateIds?: Array | undefined, filters?: ({profileIds?: Array | undefined, certificateOrderIds?: Array | undefined, metadata?: (Array<{key: string, value?: string | undefined}>) | undefined} | null) | undefined, destinationConfig: {destinationPath: string, host?: string | undefined, port?: number | undefined, sslEnabled?: boolean | undefined, sslRejectUnauthorized?: boolean | undefined, sslCertificate?: string | undefined}, syncOptions: {canRemoveCertificates?: boolean | undefined, includeRootCa?: boolean | undefined, includePrivateKey?: boolean | undefined, exportFormat?: ('pem' | 'pkcs12' | 'jks') | undefined, pemCertificateExtension?: ('pem' | 'crt') | undefined, combineCertificateChain?: boolean | undefined, keystoreAlias?: string | undefined, includeTruststore?: boolean | undefined, fileAccessRules?: (Array<{identity: string, access: 'read' | 'modify' | 'full-control'}>) | undefined, healthCheckCommand?: (string | null) | undefined, postSyncCommand?: (string | null) | undefined, certificateNameSchema?: string | undefined}}}; export type CreateApiApiV1CertManagerSyncsWindowsServerTestHealthCheckOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiApiV1CertManagerSyncsWindowsServerTestHealthCheckResponse = z.object({healthCheck: z.object({status: z.enum(["pending", "running", "succeeded", "failed"]), exitCode: z.number().optional(), timedOut: z.boolean().optional(), durationMs: z.number(), output: z.string().optional(), failureDetail: z.string().optional(), message: z.string().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 }; /** * Run a health check command against a Windows Server host without saving it to a sync. * * POST /api/v1/cert-manager/syncs/windows-server/test-health-check */ export const createApiApiV1CertManagerSyncsWindowsServerTestHealthCheck = async (args: CreateApiApiV1CertManagerSyncsWindowsServerTestHealthCheckArgs, options?: CreateApiApiV1CertManagerSyncsWindowsServerTestHealthCheckOptions) => { 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/windows-server/test-health-check${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(createApiApiV1CertManagerSyncsWindowsServerTestHealthCheckResponse, await res.json()) };