From b6512ab7938f4ef168aaf66ffe255adc8409e5bd Mon Sep 17 00:00:00 2001 From: Mateusz Filipowicz Date: Thu, 20 Mar 2025 20:42:16 +0100 Subject: [PATCH] fix: perform client-side filtering on GET firewall zone, because API for getting single zone by ID does not exist (#58) --- unifi/firewall_zone.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/unifi/firewall_zone.go b/unifi/firewall_zone.go index b3972f6..64bdcb3 100644 --- a/unifi/firewall_zone.go +++ b/unifi/firewall_zone.go @@ -7,7 +7,18 @@ func (c *client) ListFirewallZone(ctx context.Context, site string) ([]FirewallZ } func (c *client) GetFirewallZone(ctx context.Context, site, id string) (*FirewallZone, error) { - return c.getFirewallZone(ctx, site, id) + // client-side filtering is needed, because of lack of endpoint + zones, err := c.listFirewallZone(ctx, site) + if err != nil { + return nil, err + } + + for _, zone := range zones { + if zone.ID == id { + return &zone, nil + } + } + return nil, ErrNotFound } func (c *client) DeleteFirewallZone(ctx context.Context, site, id string) error {