import {z} from 'zod' export type GetApiCopilotAnomaliesWifiCapacityClientListArgs = {deviceId: number, channel: number, timestamp: number}; export type GetApiCopilotAnomaliesWifiCapacityClientListOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const xiqAnomalyHealthType = z.enum(["NONE", "GOOD", "MEDIUM", "POOR"]); export const xiqClientStatsEntity = z.object({client_mac: z.string().optional(), client_name: z.string().optional(), client_host_os: z.string().optional(), avg_snr: z.number().int().optional(), avg_tx_rate: z.number().int().optional(), avg_rx_rate: z.number().int().optional(), client_id: z.number().int().optional(), avg_rssi: z.number().int().optional(), health_score: xiqAnomalyHealthType.optional()}); export const xiqWifiCapacityClientListResponse = z.object({client_wifi_stats: z.array(xiqClientStatsEntity).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 }; /** * GET /copilot/anomalies/wifi-capacity/client-list */ export const getApiCopilotAnomaliesWifiCapacityClientList = async (args: GetApiCopilotAnomaliesWifiCapacityClientListArgs, options?: GetApiCopilotAnomaliesWifiCapacityClientListOptions) => { const {baseUrl = "https://api.extremecloudiq.com", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.deviceId != null) query.append("deviceId", String(args.deviceId)) if (args.channel != null) query.append("channel", String(args.channel)) if (args.timestamp != null) query.append("timestamp", String(args.timestamp)) if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/copilot/anomalies/wifi-capacity/client-list${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(xiqWifiCapacityClientListResponse, await res.json()) };