import {z} from 'zod' export type GetApiNetworkServicesV1AirmatchSolutionArgs = {count?: number | undefined, 'start-at'?: string | undefined, 'end-at'?: string | undefined, runmode?: ('SCHEDULED' | 'ON-DEMAND' | 'INCREMENTAL' | 'EIRP' | 'OPMODE') | undefined, 'rf-domain-id'?: number | undefined, 'rf-partition-id'?: number | undefined, 'band-selected'?: ('2.4GHz' | '5GHz' | '6GHz') | undefined, id?: Array | undefined, status?: ('COMPUTED' | 'SENT' | 'RETRIED' | 'DEPLOY_UNSUCCESSFUL' | 'CONFIRMED') | undefined, limit?: number | undefined, offset?: number | undefined}; export type GetApiNetworkServicesV1AirmatchSolutionOptions = {baseUrl?: string | undefined, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; export const solution = z.object({id: z.string(), type: z.string(), apEthMac: z.string().optional(), apOpmodeComputed: z.string().optional(), apSerial: z.string().optional(), band: z.string().optional(), bandwidth: z.string().optional(), cbwFrozen: z.boolean().optional(), chanFrozen: z.boolean().optional(), currentApOpmode: z.string().optional(), computedApOpmode: z.string().optional(), dbTimestamp: z.number().int().optional(), deployEnd: z.number().int().optional(), deployStart: z.number().int().optional(), deployStatus: z.string().optional(), deployedChannelReason: z.string().optional(), deployedEirpReason: z.string().optional(), deployedOpmodeReason: z.string().optional(), eirpFrozen: z.boolean().optional(), eirpTruncated: z.boolean().optional(), estimateDuration: z.number().optional(), eventChannels: z.string().optional(), optimizationEnd: z.number().int().optional(), optimizationStart: z.number().int().optional(), optimizationInfo: z.string().optional(), radioMac: z.string().optional(), rfDomainId: z.number().int().optional(), rfPartitionId: z.number().int().optional(), runnowType: z.number().int().optional(), siteId: z.string().optional(), solverChannel: z.number().int().optional(), solverEirp: z.number().int().optional(), solverEirpDbm: z.number().int().optional(), solverFeasList: z.object({bwList: z.array(z.string()).optional(), chanList: z.record(z.string(), z.array(z.number().int())).optional()}).optional(), tenantId: z.string().optional(), requestId: z.string().optional()}); export const solutionAll = z.object({id: z.string(), type: z.string(), count: z.number().int(), items: z.array(solution)}); 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 solver optimizations for a given tenant * * GET /network-services/v1/airmatch-solution */ export const getApiNetworkServicesV1AirmatchSolution = async (args: GetApiNetworkServicesV1AirmatchSolutionArgs, options?: GetApiNetworkServicesV1AirmatchSolutionOptions) => { const {baseUrl = "https://sso.common.cloud.hpe.com", fetch: fetchFn = fetch, OAuth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.count != null) query.append("count", String(args.count)) if (args['start-at'] != null) query.append("start-at", String(args['start-at'])) if (args['end-at'] != null) query.append("end-at", String(args['end-at'])) if (args.runmode != null) query.append("runmode", String(args.runmode)) if (args['rf-domain-id'] != null) query.append("rf-domain-id", String(args['rf-domain-id'])) if (args['rf-partition-id'] != null) query.append("rf-partition-id", String(args['rf-partition-id'])) if (args['band-selected'] != null) query.append("band-selected", String(args['band-selected'])) for (const item of args.id ?? []) query.append("id", String(item)) if (args.status != null) query.append("status", String(args.status)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/network-services/v1/airmatch-solution${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(solutionAll, await res.json()) };