import {z} from 'zod' export type Limitfco = number; export type Offsetfco = number; export type GetApiNetworkServicesV1FcoRespInfoAllArgs = {limit?: Limitfco | undefined, offset?: Offsetfco | undefined}; export type GetApiNetworkServicesV1FcoRespInfoAllOptions = {baseUrl?: string | undefined, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; export const fcoRespInfo = z.object({id: z.string(), type: z.string(), tenantId: z.string().optional(), serialNumber: z.string().optional(), afcReqTimestamp: z.number().int().optional(), afcRespTimestamp: z.number().int().optional(), afcExpiryTimestamp: z.number().int().optional(), chanList20MHz: z.array(z.number().int()).optional(), chanList40MHz: z.array(z.number().int()).optional(), chanList80MHz: z.array(z.number().int()).optional(), chanList160MHz: z.array(z.number().int()).optional(), chanList320MHz1: z.array(z.number().int()).optional(), chanList320MHz2: z.array(z.number().int()).optional(), chanListPsd: z.array(z.number().int()).optional(), eirpList20MHz: z.array(z.number()).optional(), eirpList40MHz: z.array(z.number()).optional(), eirpList80MHz: z.array(z.number()).optional(), eirpList160MHz: z.array(z.number()).optional(), eirpList320MHz1: z.array(z.number()).optional(), eirpList320MHz2: z.array(z.number()).optional(), eirpListPsd: z.array(z.number()).optional()}); export const fcoRespInfoAll = z.object({items: z.array(fcoRespInfo), count: z.number().int().gte(1).lte(2147483647), offset: z.number().int().optional(), total: z.number().int().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 AFC channel data for all access points belonging to the tenant. * * GET /network-services/v1/fco-resp-info-all */ export const getApiNetworkServicesV1FcoRespInfoAll = async (args: GetApiNetworkServicesV1FcoRespInfoAllArgs, options?: GetApiNetworkServicesV1FcoRespInfoAllOptions) => { 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.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/fco-resp-info-all${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(fcoRespInfoAll, await res.json()) };