REST API client for the lab's Mikrotik RouterOS switch.
Per progress#188433: pick a VLAN id below 10, and any subnet within 192.168.0.0/16 - both are only locally significant to this switch, not coordinated with any wider address plan, since the switch's uplink to the managed network stays untagged/access-only (see that ticket for why).
add_vlan() and set_port_pvid() enforce the VLAN id rule and die for any id outside 1..MAX_VLAN_ID.
get_all_vlans();
Fetches every entry of the bridge VLAN table (/interface/bridge/vlan), each containing 'bridge', 'vlan-ids', 'tagged' and 'untagged' member lists.
Dies on any non-2xx response.
get_vlan($vlan_id);
Fetches the bridge VLAN table entry for a given VLAN id, e.g. get_vlan(5). Dies if no entry with that VLAN id exists.
Dies on any non-2xx response.
add_vlan(bridge => 'bridge1', vlan_id => 5, untagged => 'ether5', tagged => 'ether1');
Adds a new entry to the bridge VLAN table. 'bridge' and 'vlan_id' are required. 'tagged' and 'untagged' are optional comma-separated interface lists (as accepted by RouterOS) naming the bridge member ports to attach to the VLAN. Returns the created entry.
Dies if vlan_id is outside 1..MAX_VLAN_ID (see "VLAN AND NETWORK CONVENTIONS").
Dies if an entry already exists for that bridge/vlan_id - use update_vlan() (not yet implemented) to change an existing VLAN's port membership.
Dies on any non-2xx response.
remove_vlan($vlan_id);
Removes the bridge VLAN table entry for a given VLAN id, e.g. remove_vlan(5). Dies if no entry with that VLAN id exists.
Dies on any non-2xx response.
get_port_pvid($port_name);
Fetches the PVID (untagged/native VLAN id) currently configured for a bridge port, e.g. get_port_pvid('ether5'). Dies if the port is not a member of any bridge.
Dies on any non-2xx response.
set_port_pvid($port_name, $vlan_id);
Sets the PVID (untagged/native VLAN id) of a bridge port, e.g. set_port_pvid('ether5', 5). This is what makes a port an untagged member of a VLAN. Dies if the port is not a member of any bridge, or if vlan_id is outside 1..MAX_VLAN_ID (see "VLAN AND NETWORK CONVENTIONS").
Dies on any non-2xx response.