-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathfirewall_zones.go
More file actions
36 lines (26 loc) · 878 Bytes
/
firewall_zones.go
File metadata and controls
36 lines (26 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package unifi
import "fmt"
// GetFirewallZones returns firewall zones for a site. Zone IDs appear in firewall policies.
func (u *Unifi) GetFirewallZones(site *IntegrationSite) ([]*FirewallZone, error) {
if u == nil {
return nil, ErrNilUnifi
}
if site == nil {
return nil, ErrNoSiteProvided
}
if site.ID == "" {
return nil, fmt.Errorf("site %q has an empty ID; cannot construct Integration/v1 API path", site.Name)
}
u.DebugLog("Polling Integration/v1 for firewall zones, site %s", site.Name)
path := fmt.Sprintf(APIFirewallZonesPath, site.ID)
items, err := getIntegrationList[FirewallZone](u, path)
if err != nil {
return nil, fmt.Errorf("fetching firewall zones for site %s: %w", site.Name, err)
}
result := make([]*FirewallZone, len(items))
for i := range items {
items[i].SiteName = site.Name
result[i] = &items[i]
}
return result, nil
}