import {z} from 'zod' export type GetApiV1MeshControlPlanesCpIdApiMeshesMeshMeshretriesArgs = {offset?: number | undefined, size?: number | undefined, filter?: ({key?: string | undefined, value?: string | undefined}) | undefined, mesh: string}; export type GetApiV1MeshControlPlanesCpIdApiMeshesMeshMeshretriesOptions = {baseUrl?: string | undefined, personalAccessToken?: string | undefined, fetch?: typeof fetch | undefined}; export const meshRetryItem = z.object({type: z.literal("MeshRetry"), mesh: z.string().optional(), kri: z.string().optional(), name: z.string(), labels: z.record(z.string(), z.string()).optional(), spec: z.object({targetRef: z.object({kind: z.enum(["Mesh", "MeshSubset", "MeshGateway", "MeshService", "MeshExternalService", "MeshMultiZoneService", "MeshServiceSubset", "MeshHTTPRoute", "Dataplane"]), labels: z.record(z.string(), z.string()).optional(), mesh: z.string().optional(), name: z.string().optional(), namespace: z.string().optional(), proxyTypes: z.array(z.enum(["Sidecar", "Gateway"])).optional(), sectionName: z.string().optional(), tags: z.record(z.string(), z.string()).optional()}).optional(), to: z.array(z.object({default: z.object({grpc: z.object({backOff: z.object({baseInterval: z.string().optional(), maxInterval: z.string().optional()}).optional(), numRetries: z.number().int().optional(), perTryTimeout: z.string().optional(), rateLimitedBackOff: z.object({maxInterval: z.string().optional(), resetHeaders: z.array(z.object({format: z.enum(["Seconds", "UnixTimestamp"]), name: z.string().min(1).max(256)})).optional()}).optional(), retryOn: z.array(z.enum(["Canceled", "DeadlineExceeded", "Internal", "ResourceExhausted", "Unavailable"])).optional()}).optional(), http: z.object({backOff: z.object({baseInterval: z.string().optional(), maxInterval: z.string().optional()}).optional(), hostSelection: z.array(z.object({predicate: z.enum(["OmitPreviousHosts", "OmitHostsWithTags", "OmitPreviousPriorities"]), tags: z.record(z.string(), z.string()).optional(), updateFrequency: z.number().int().optional()})).optional(), hostSelectionMaxAttempts: z.number().int().optional(), numRetries: z.number().int().optional(), perTryTimeout: z.string().optional(), rateLimitedBackOff: z.object({maxInterval: z.string().optional(), resetHeaders: z.array(z.object({format: z.enum(["Seconds", "UnixTimestamp"]), name: z.string().min(1).max(256)})).optional()}).optional(), retriableRequestHeaders: z.array(z.object({name: z.string().min(1).max(256), type: z.enum(["Exact", "Present", "RegularExpression", "Absent", "Prefix"]).optional(), value: z.string().optional()})).optional(), retriableResponseHeaders: z.array(z.object({name: z.string().min(1).max(256), type: z.enum(["Exact", "Present", "RegularExpression", "Absent", "Prefix"]).optional(), value: z.string().optional()})).optional(), retryOn: z.array(z.string()).optional()}).optional(), tcp: z.object({maxConnectAttempt: z.number().int().optional()}).optional()}).optional(), targetRef: z.object({kind: z.enum(["Mesh", "MeshSubset", "MeshGateway", "MeshService", "MeshExternalService", "MeshMultiZoneService", "MeshServiceSubset", "MeshHTTPRoute", "Dataplane"]), labels: z.record(z.string(), z.string()).optional(), mesh: z.string().optional(), name: z.string().optional(), namespace: z.string().optional(), proxyTypes: z.array(z.enum(["Sidecar", "Gateway"])).optional(), sectionName: z.string().optional(), tags: z.record(z.string(), z.string()).optional()})})).optional()}), creationTime: z.string().optional(), modificationTime: z.string().optional()}); export const getApiV1MeshControlPlanesCpIdApiMeshesMeshMeshretriesResponse = z.object({items: z.array(meshRetryItem).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 MeshRetry in the mesh. * * GET /v1/mesh/control-planes/{cpId}/api/meshes/{mesh}/meshretries * * Also accepts auth: systemAccountAccessToken, konnectAccessToken, serviceAccessToken */ export const getApiV1MeshControlPlanesCpIdApiMeshesMeshMeshretries = async (args: GetApiV1MeshControlPlanesCpIdApiMeshesMeshMeshretriesArgs, options?: GetApiV1MeshControlPlanesCpIdApiMeshesMeshMeshretriesOptions) => { 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))}/meshretries${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(getApiV1MeshControlPlanesCpIdApiMeshesMeshMeshretriesResponse, await res.json()) };