{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "design_network_segment",
  "type": "object",
  "properties": {
    "vlan_id": {
      "type": "integer",
      "minimum": 1,
      "maximum": 4094
    },
    "name": {
      "type": "string",
      "pattern": "^\\S+$",
      "description": "Name for the VLAN interface, e.g. 'guest'"
    },
    "subnet": {
      "type": "string",
      "format": "cidrv4",
      "pattern": "^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\/([0-9]|[1-2][0-9]|3[0-2])$",
      "description": "Canonical IPv4 network CIDR, e.g. '192.168.30.0/24'"
    },
    "gateway": {
      "type": "string",
      "format": "ipv4",
      "pattern": "^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$",
      "description": "Usable router address inside the subnet, excluded from the DHCP pool"
    },
    "bridge": {
      "default": "bridge",
      "description": "Bridge to put the VLAN on",
      "type": "string"
    },
    "tagged_ports": {
      "description": "Comma-separated verified tagged ports; the bridge/CPU is included once automatically",
      "type": "string"
    },
    "untagged_ports": {
      "description": "Comma-separated access/untagged ports",
      "type": "string"
    },
    "dhcp": {
      "default": true,
      "description": "Create a DHCP server + pool for the segment",
      "type": "boolean"
    },
    "dhcp_range": {
      "description": "Single start-end IPv4 range excluding gateway/network/broadcast. Required outside /24; /24 defaults to .10–.254",
      "type": "string"
    },
    "internet": {
      "default": true,
      "description": "Add egress-scoped IPv4 masquerade (requires wan_interface); not a firewall allow. Set false to reuse existing NAT",
      "type": "boolean"
    },
    "wan_interface": {
      "description": "Verified egress interface for new masquerade. Required when internet=true; never inferred",
      "type": "string",
      "minLength": 1
    },
    "isolate_from": {
      "description": "Subnets this segment must NOT reach, e.g. ['192.168.1.0/24']",
      "type": "array",
      "items": {
        "type": "string",
        "format": "cidrv4",
        "pattern": "^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\/([0-9]|[1-2][0-9]|3[0-2])$"
      }
    },
    "isolation_before": {
      "description": "Current enabled forward rule .id from a fresh read; insert drops before this reviewed rule, not after broad accepts. Required with isolate_from",
      "type": "string",
      "pattern": "^\\*[0-9a-f]+$"
    },
    "apply": {
      "default": false,
      "description": "false = preview (default); true = build",
      "type": "boolean"
    }
  },
  "required": ["vlan_id", "name", "subnet", "gateway", "bridge", "dhcp", "internet", "apply"],
  "additionalProperties": false
}
