import {z} from 'zod' export type GetApiNetworkServicesV1AirmatchPartitionArgs = {'band-selected'?: ('2.4GHz' | '5GHz' | '6GHz') | undefined, type?: ('normal' | 'opmode' | 'dynamic') | undefined, summary?: boolean | undefined, id?: Array | undefined, offset?: number | undefined, limit?: number | undefined}; export type GetApiNetworkServicesV1AirmatchPartitionOptions = {baseUrl?: string | undefined, OAuth2?: string | undefined, fetch?: typeof fetch | undefined}; export const partition = z.object({id: z.string(), type: z.string(), apSerial: z.string().optional(), band: z.string().optional(), docCount: z.number().int().optional(), radioMac: z.string().optional(), rfDomainId: z.string().optional(), rfPartitionId: z.string().optional(), rfPartitionTimestamp: z.string().optional(), rfPartitionType: z.string().optional(), shardAttr: z.string().optional(), siteId: z.string().optional(), tenantId: z.string().optional(), updateTimestamp: z.number().int().optional(), requestId: z.string().optional(), apCoveragePlanTimestamp: 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 }; /** * Get RF partition information * * GET /network-services/v1/airmatch-partition */ export const getApiNetworkServicesV1AirmatchPartition = async (args: GetApiNetworkServicesV1AirmatchPartitionArgs, options?: GetApiNetworkServicesV1AirmatchPartitionOptions) => { 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['band-selected'] != null) query.append("band-selected", String(args['band-selected'])) if (args.type != null) query.append("type", String(args.type)) if (args.summary != null) query.append("summary", String(args.summary)) for (const item of args.id ?? []) query.append("id", String(item)) if (args.offset != null) query.append("offset", String(args.offset)) if (args.limit != null) query.append("limit", String(args.limit)) if (OAuth2 !== undefined) headers.set('authorization', `Bearer ${OAuth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/network-services/v1/airmatch-partition${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(partition, await res.json()) };