import {z} from 'zod' export type GetApiApiV1CertManagerApplicationsApplicationIdProfilesProfileIdEnrollmentArgs = {applicationId: string, profileId: string}; export type GetApiApiV1CertManagerApplicationsApplicationIdProfilesProfileIdEnrollmentOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiApiV1CertManagerApplicationsApplicationIdProfilesProfileIdEnrollmentResponse = z.object({applicationId: z.string(), profileId: z.string(), api: z.object({id: z.string(), autoRenew: z.boolean(), renewBeforeDays: z.number().int().nullable()}).nullable(), est: z.object({id: z.string(), disableBootstrapCaValidation: z.boolean(), estEndpointUrl: z.string()}).nullable(), acme: z.object({id: z.string(), skipDnsOwnershipVerification: z.boolean(), skipEabBinding: z.boolean(), directoryUrl: z.string()}).nullable(), scep: z.object({id: z.string(), challengeType: z.enum(["static", "dynamic", "microsoft-intune"]), includeCaCertInResponse: z.boolean(), allowCertBasedRenewal: z.boolean(), dynamicChallengeExpiryMinutes: z.number().int().nullable(), dynamicChallengeMaxPending: z.number().int().nullable(), scepEndpointUrl: z.string(), challengeEndpointUrl: z.string().nullable(), raCertificatePem: z.string(), raCertExpiresAt: z.string(), validationConnectionId: z.string().nullable(), signRaWithCa: z.boolean()}).nullable(), caType: z.enum(["internal", "acme", "azure-ad-cs", "adcs", "aws-pca", "digicert", "aws-acm-public-ca", "venafi-tpp", "godaddy"]), estConfigured: z.boolean(), acmeConfigured: z.boolean(), scepConfigured: 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 }; /** * Get the enrollment state for a profile on an application. * * GET /api/v1/cert-manager/applications/{applicationId}/profiles/{profileId}/enrollment */ export const getApiApiV1CertManagerApplicationsApplicationIdProfilesProfileIdEnrollment = async (args: GetApiApiV1CertManagerApplicationsApplicationIdProfilesProfileIdEnrollmentArgs, options?: GetApiApiV1CertManagerApplicationsApplicationIdProfilesProfileIdEnrollmentOptions) => { const {baseUrl = "https://us.infisical.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/cert-manager/applications/${encodeURIComponent(String(args.applicationId))}/profiles/${encodeURIComponent(String(args.profileId))}/enrollment${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(getApiApiV1CertManagerApplicationsApplicationIdProfilesProfileIdEnrollmentResponse, await res.json()) };