import {z} from 'zod' export type GetApiApiopsProjectsProjectNameLimitAssignmentRunsRunIdIssuesArgs = {projectName: string, runId: string, page?: number | undefined, size?: number | undefined}; export type GetApiApiopsProjectsProjectNameLimitAssignmentRunsRunIdIssuesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const apiOpsResponseLimitAssignmentIssue = z.object({seq: z.number().int().optional(), subjectType: z.enum(["PLATFORM", "PROJECT", "ORGANIZATION", "CONSUMER", "APPLICATION", "API_CLIENT", "API_PROXY", "AUDIENCE_RULE"]).optional(), subjectName: z.string().optional(), outcome: z.string().optional(), bindingKey: z.string().optional(), messageKey: z.string().optional(), messageParams: z.record(z.string(), z.string()).optional(), occurredAt: z.string().optional()}); export const apiOpsPagedResponseApiOpsResponseLimitAssignmentIssue = z.object({status: z.enum(["SUCCESS", "FAILURE"]).optional(), items: z.array(apiOpsResponseLimitAssignmentIssue).optional(), page: z.number().int().optional(), size: z.number().int().optional(), totalElements: z.number().int().optional(), totalPages: z.number().int().optional(), sort: z.array(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 }; /** * List the issues of one run * * GET /apiops/projects/{projectName}/limit-assignment-runs/{runId}/issues */ export const getApiApiopsProjectsProjectNameLimitAssignmentRunsRunIdIssues = async (args: GetApiApiopsProjectsProjectNameLimitAssignmentRunsRunIdIssuesArgs, options?: GetApiApiopsProjectsProjectNameLimitAssignmentRunsRunIdIssuesOptions) => { const {baseUrl = "http://167.86.118.166:32080", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.page != null) query.append("page", String(args.page)) if (args.size != null) query.append("size", String(args.size)) const url = `${baseUrl.replace(/\/+$/, '')}/apiops/projects/${encodeURIComponent(String(args.projectName))}/limit-assignment-runs/${encodeURIComponent(String(args.runId))}/issues${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(apiOpsPagedResponseApiOpsResponseLimitAssignmentIssue, await res.json()) };