diff --git a/fields/main.go b/fields/main.go index 87da6ac..f02d4be 100644 --- a/fields/main.go +++ b/fields/main.go @@ -260,14 +260,6 @@ func main() { f.OmitEmpty = true return nil } - case "NetworkConf": - resource.FieldProcessor = func(name string, f *FieldInfo) error { - switch name { - case "WANEgressQOS": - f.FieldType = "string" - } - return nil - } case "SettingUsg": resource.FieldProcessor = func(name string, f *FieldInfo) error { if strings.HasSuffix(name, "Timeout") && name != "ArpCacheTimeout" { diff --git a/unifi/network.go b/unifi/network.go index f89d83b..8c99dae 100644 --- a/unifi/network.go +++ b/unifi/network.go @@ -11,6 +11,7 @@ func (dst *Network) UnmarshalJSON(b []byte) error { aux := &struct { VLAN emptyStringInt `json:"vlan"` DHCPDLeaseTime emptyStringInt `json:"dhcpd_leasetime"` + WANEgressQOS emptyStringInt `json:"wan_egress_qos"` *Alias }{ @@ -24,6 +25,7 @@ func (dst *Network) UnmarshalJSON(b []byte) error { dst.VLAN = int(aux.VLAN) dst.DHCPDLeaseTime = int(aux.DHCPDLeaseTime) + dst.WANEgressQOS = int(aux.WANEgressQOS) return nil } diff --git a/unifi/network_test.go b/unifi/network_test.go index f2fe8ae..588d219 100644 --- a/unifi/network_test.go +++ b/unifi/network_test.go @@ -38,6 +38,19 @@ func TestNetworkUnmarshalJSON(t *testing.T) { expected: unifi.Network{DHCPDLeaseTime: 0}, json: `{ "dhcpd_leasetime": "" }`, }, + + "int wan_egress_qos": { + expected: unifi.Network{WANEgressQOS: 1}, + json: `{ "wan_egress_qos": 1 }`, + }, + "string wan_egress_qos": { + expected: unifi.Network{WANEgressQOS: 1}, + json: `{ "wan_egress_qos": "1" }`, + }, + "empty string wan_egress_qos": { + expected: unifi.Network{WANEgressQOS: 0}, + json: `{ "wan_egress_qos": "" }`, + }, } { t.Run(n, func(t *testing.T) { var actual unifi.Network