Support firewall reorder command (#127)
This commit is contained in:
@@ -2,8 +2,14 @@ package unifi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type FirewallRuleIndexUpdate struct {
|
||||
ID string `json:"_id"`
|
||||
RuleIndex int `json:"rule_index,string"`
|
||||
}
|
||||
|
||||
func (c *Client) ListFirewallRule(ctx context.Context, site string) ([]FirewallRule, error) {
|
||||
return c.listFirewallRule(ctx, site)
|
||||
}
|
||||
@@ -23,3 +29,21 @@ func (c *Client) CreateFirewallRule(ctx context.Context, site string, d *Firewal
|
||||
func (c *Client) UpdateFirewallRule(ctx context.Context, site string, d *FirewallRule) (*FirewallRule, error) {
|
||||
return c.updateFirewallRule(ctx, site, d)
|
||||
}
|
||||
|
||||
func (c *Client) ReorderFirewallRules(ctx context.Context, site, ruleset string, reorder []FirewallRuleIndexUpdate) error {
|
||||
reqBody := struct {
|
||||
Cmd string `json:"cmd"`
|
||||
Ruleset string `json:"ruleset"`
|
||||
Rules []FirewallRuleIndexUpdate `json:"rules"`
|
||||
}{
|
||||
Cmd: "reorder",
|
||||
Ruleset: ruleset,
|
||||
Rules: reorder,
|
||||
}
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/cmd/firewall", site), reqBody, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user