import {z} from 'zod' export type GetApiAgentsAgentIdRouterLanWanAccessRulesPublicIdArgs = {'Api-Version': 2, 'Api-Application': string, 'Api-Company': string, 'Api-Branding'?: string | undefined, fields?: Array | undefined, filters?: Array | undefined, agentId: string, publicId: string}; export type GetApiAgentsAgentIdRouterLanWanAccessRulesPublicIdOptions = {baseUrl?: string | undefined, bearerToken?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiAgentsAgentIdRouterLanWanAccessRulesPublicIdResponse = z.object({status: z.string(), type: z.string(), data: z.object({publicId: z.string().min(12).max(12).optional(), agent: z.object({publicId: z.string().optional()}).optional(), sourceIpAddress: z.string().max(255).nullable().optional(), sourceMacAddress: z.string().min(17).max(17).nullable().optional(), destinationPort: z.number().int().lte(65535).nullable().optional(), destinationIpAddress: z.string().max(255).nullable().optional(), protocol: z.enum(["all", "tcp", "udp", "icmp", "ah", "ax.25", "dccp", "ddp", "egp", "eigrp", "encap", "esp", "etherip", "fc", "ggp", "gre", "hmp", "idpr-cmtp", "idrp", "igmp", "igp", "ipcomp", "ipencap", "ipip", "ipv6", "ipv6-frag", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "ipv6-route", "isis", "iso-tp4", "l2tp", "ospf", "pim", "pup", "rdp", "rspf", "rsvp", "sctp", "skip", "st", "vmtp", "vrrp", "xns-idp", "xtp"]).optional(), description: z.string().max(255).nullable().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 }; /** * AgentRouterLanWanAccessRule * * GET /agents/{agentId}/router-lan-wan-access-rules/{publicId} */ export const getApiAgentsAgentIdRouterLanWanAccessRulesPublicId = async (args: GetApiAgentsAgentIdRouterLanWanAccessRulesPublicIdArgs, options?: GetApiAgentsAgentIdRouterLanWanAccessRulesPublicIdOptions) => { const {baseUrl = "https://portal.ixon.cloud:443/api", fetch: fetchFn = fetch, bearerToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['Api-Version'] != null) headers.set("Api-Version", String(args['Api-Version'])) if (args['Api-Application'] != null) headers.set("Api-Application", String(args['Api-Application'])) if (args['Api-Company'] != null) headers.set("Api-Company", String(args['Api-Company'])) if (args['Api-Branding'] != null) headers.set("Api-Branding", String(args['Api-Branding'])) for (const item of args.fields ?? []) query.append("fields", String(item)) for (const item of args.filters ?? []) query.append("filters", String(item)) if (bearerToken !== undefined) headers.set('authorization', `Bearer ${bearerToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/agents/${encodeURIComponent(String(args.agentId))}/router-lan-wan-access-rules/${encodeURIComponent(String(args.publicId))}${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(getApiAgentsAgentIdRouterLanWanAccessRulesPublicIdResponse, await res.json()) };