toggle_traffic_rule
toggle_traffic_rule
Section titled “toggle_traffic_rule”Enable or disable a traffic rule without editing its other fields.
Side effects:
- Flips the rule’s
enabledflag. Reads the current rule first and PUTs the full object back with onlyenabledchanged (read-modify-write), so the rest of the rule is preserved. - Takes effect immediately: a disabled BLOCK rule stops blocking; a disabled ALLOW rule stops allowing.
- Mutates controller state. Use dry_run=True to preview the change without applying.
Example
Section titled “Example”toggle_traffic_rule(rule_id="65f...", enabled=False)Parameters
Section titled “Parameters”| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
rule_id | string | yes | — | The _id from list_traffic_rules. |
enabled | boolean | yes | — | True to enable the rule, False to disable it. |
controller | string | no | ”default” | Name of the UniFi controller to target. Defaults to "default". |
dry_run | boolean | no | false | Preview the change without applying it. Returns the predicted change set. |