import {z} from 'zod' export type GetApiV1MeshControlPlanesCpIdApiMeshesMeshMeshidentitiesArgs = {offset?: number | undefined, size?: number | undefined, filter?: ({key?: string | undefined, value?: string | undefined}) | undefined, mesh: string}; export type GetApiV1MeshControlPlanesCpIdApiMeshesMeshMeshidentitiesOptions = {baseUrl?: string | undefined, personalAccessToken?: string | undefined, fetch?: typeof fetch | undefined}; export const meshIdentityItem = z.object({type: z.literal("MeshIdentity"), mesh: z.string().optional(), kri: z.string().optional(), name: z.string(), labels: z.record(z.string(), z.string()).optional(), spec: z.object({provider: z.object({bundled: z.object({autogenerate: z.object({enabled: z.boolean().optional()}).optional(), ca: z.object({certificate: z.object({envVar: z.object({name: z.string()}).optional(), file: z.object({path: z.string()}).optional(), insecureInline: z.object({value: z.string()}).optional(), secretRef: z.object({kind: z.literal("Secret"), name: z.string()}).optional(), type: z.enum(["File", "Secret", "EnvVar", "InsecureInline"])}).optional(), privateKey: z.object({envVar: z.object({name: z.string()}).optional(), file: z.object({path: z.string()}).optional(), insecureInline: z.object({value: z.string()}).optional(), secretRef: z.object({kind: z.literal("Secret"), name: z.string()}).optional(), type: z.enum(["File", "Secret", "EnvVar", "InsecureInline"])}).optional()}).optional(), certificateParameters: z.object({expiry: z.string().optional()}).optional(), insecureAllowSelfSigned: z.boolean().optional(), meshTrustCreation: z.enum(["Enabled", "Disabled"]).optional()}).optional(), extension: z.object({config: z.unknown(), name: z.string()}).optional(), spire: z.object({agent: z.object({timeout: z.string().optional()}).optional()}).optional(), type: z.enum(["Bundled", "Spire", "Extension"])}).optional(), selector: z.object({dataplane: z.object({matchLabels: z.record(z.string(), z.string()).optional()}).optional()}).optional(), spiffeID: z.object({path: z.string().optional(), trustDomain: z.string().optional()}).optional()}), creationTime: z.string().optional(), modificationTime: z.string().optional(), status: z.object({conditions: z.array(z.object({message: z.string().max(32768), reason: z.string().min(1).max(1024), status: z.enum(["True", "False", "Unknown"]), type: z.string().max(316)})).optional()}).optional()}); export const getApiV1MeshControlPlanesCpIdApiMeshesMeshMeshidentitiesResponse = z.object({items: z.array(meshIdentityItem).optional(), total: z.number().optional(), next: 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 }; /** * Returns a list of MeshIdentity in the mesh. * * GET /v1/mesh/control-planes/{cpId}/api/meshes/{mesh}/meshidentities * * Also accepts auth: systemAccountAccessToken, konnectAccessToken, serviceAccessToken */ export const getApiV1MeshControlPlanesCpIdApiMeshesMeshMeshidentities = async (args: GetApiV1MeshControlPlanesCpIdApiMeshesMeshMeshidentitiesArgs, options?: GetApiV1MeshControlPlanesCpIdApiMeshesMeshMeshidentitiesOptions) => { const {baseUrl = "https://global.api.konghq.com", fetch: fetchFn = fetch, personalAccessToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.offset != null) query.append("offset", String(args.offset)) if (args.size != null) query.append("size", String(args.size)) if (args.filter != null) query.append("filter", JSON.stringify(args.filter)) if (personalAccessToken !== undefined) headers.set('authorization', `Bearer ${personalAccessToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/mesh/control-planes/${encodeURIComponent(String(args.cpId))}/api/meshes/${encodeURIComponent(String(args.mesh))}/meshidentities${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(getApiV1MeshControlPlanesCpIdApiMeshesMeshMeshidentitiesResponse, await res.json()) };