24 lines
2.2 KiB
TypeScript
24 lines
2.2 KiB
TypeScript
import { z } from "zod"
|
|
|
|
export const bridgeVlanRowIdSchema = z.string().regex(/^\*[0-9a-f]+$/i)
|
|
export const bridgeVlanInterfaceReferenceSchema = z.object({ resource: z.string().min(1).max(64), id: bridgeVlanRowIdSchema }).strict()
|
|
export const bridgeVlanIdSchema = z.number().int().min(1).max(4094)
|
|
export const bridgeVlanFrameTypesSchema = z.enum(["admit-all", "admit-only-vlan-tagged", "admit-only-untagged-and-priority-tagged"])
|
|
/** Complete desired static state. Omissions never authorize deletion. */
|
|
export const bridgeVlanDesiredSchema = z.object({
|
|
filtering: z.boolean(), pvid: bridgeVlanIdSchema,
|
|
frameTypes: bridgeVlanFrameTypesSchema.optional(), ingressFiltering: z.boolean().optional(),
|
|
ports: z.array(z.object({ id: bridgeVlanRowIdSchema.optional(), interface: bridgeVlanInterfaceReferenceSchema, pvid: bridgeVlanIdSchema, ingressFiltering: z.boolean(), frameTypes: bridgeVlanFrameTypesSchema, disabled: z.boolean(), comment: z.string().max(1000).optional() }).strict()).max(1024),
|
|
vlans: z.array(z.object({ id: bridgeVlanRowIdSchema.optional(), vlanIds: z.string().min(1).max(16384), tagged: z.array(bridgeVlanInterfaceReferenceSchema).max(1024), untagged: z.array(bridgeVlanInterfaceReferenceSchema).max(1024), disabled: z.boolean(), comment: z.string().max(1000).optional() }).strict()).max(4094),
|
|
removePortIds: z.array(bridgeVlanRowIdSchema).max(1024), removeVlanIds: z.array(bridgeVlanRowIdSchema).max(4094),
|
|
}).strict()
|
|
export const bridgeVlanConfigurationRequestSchema = z.object({ serverId: z.number().int().positive(), bridgeId: bridgeVlanRowIdSchema, desired: bridgeVlanDesiredSchema }).strict()
|
|
export type BridgeVlanDesired = z.infer<typeof bridgeVlanDesiredSchema>
|
|
export type BridgeVlanConfigurationRequest = z.infer<typeof bridgeVlanConfigurationRequestSchema>
|
|
const rows = z.array(z.record(z.string(), z.unknown()))
|
|
export const bridgeVlanStateSchema = z.object({
|
|
bridges: rows, ports: rows, vlans: rows, vlanInterfaces: rows, ipv4Addresses: rows, ipv6Addresses: rows,
|
|
interfaces: z.array(z.object({ resource: z.string(), id: z.string(), name: z.string(), disabled: z.unknown().optional() }).strict()),
|
|
}).strict()
|
|
export type BridgeVlanState = z.infer<typeof bridgeVlanStateSchema>
|