Compare commits
25 Commits
0.0.1-alph
...
16-create-
| Author | SHA1 | Date | |
|---|---|---|---|
| deed8eb64d | |||
| 32e66e46da | |||
| 9a6bf18774 | |||
| c4acd30bfb | |||
| 3a991266a1 | |||
| ad412ef42b | |||
| e72621290e | |||
| 42434bf718 | |||
| abe6ce09b2 | |||
| d008cac359 | |||
| 96cf5ac987 | |||
| d83c354874 | |||
| 861a985dd0 | |||
| e5b81b217f | |||
| 0e9e9cb8a3 | |||
| 42d7f4131b | |||
| be515d2e6f | |||
| ec43083868 | |||
| babe9757a6 | |||
| 225c79703f | |||
| b0d58766fc | |||
| 8721daf90a | |||
| 14f0897119 | |||
| bce4a5bdfd | |||
|
|
73d68d5ac1 |
@@ -139,7 +139,7 @@ func extractJSON(jarFile, fieldsDir string) error {
|
|||||||
return fmt.Errorf("unable to open settings file: %w", err)
|
return fmt.Errorf("unable to open settings file: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var settings map[string]interface{}
|
var settings map[string]any
|
||||||
err = json.Unmarshal(settingsData, &settings)
|
err = json.Unmarshal(settingsData, &settings)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to unmarshal settings: %w", err)
|
return fmt.Errorf("unable to unmarshal settings: %w", err)
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ func (l firmwareUpdateApiResponseEmbeddedFirmwareDataLink) MarshalJSON() ([]byte
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *firmwareUpdateApiResponseEmbeddedFirmwareDataLink) UnmarshalJSON(j []byte) error {
|
func (l *firmwareUpdateApiResponseEmbeddedFirmwareDataLink) UnmarshalJSON(j []byte) error {
|
||||||
var m map[string]interface{}
|
var m map[string]any
|
||||||
|
|
||||||
err := json.Unmarshal(j, &m)
|
err := json.Unmarshal(j, &m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -482,7 +482,7 @@ func (r *Resource) IsSetting() bool {
|
|||||||
return strings.HasPrefix(r.StructName, "Setting")
|
return strings.HasPrefix(r.StructName, "Setting")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Resource) processFields(fields map[string]interface{}) {
|
func (r *Resource) processFields(fields map[string]any) {
|
||||||
t := r.Types[r.StructName]
|
t := r.Types[r.StructName]
|
||||||
for name, validation := range fields {
|
for name, validation := range fields {
|
||||||
fieldInfo, err := r.fieldInfoFromValidation(name, validation)
|
fieldInfo, err := r.fieldInfoFromValidation(name, validation)
|
||||||
@@ -494,7 +494,7 @@ func (r *Resource) processFields(fields map[string]interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Resource) fieldInfoFromValidation(name string, validation interface{}) (*FieldInfo, error) {
|
func (r *Resource) fieldInfoFromValidation(name string, validation any) (*FieldInfo, error) {
|
||||||
fieldName := strcase.ToCamel(name)
|
fieldName := strcase.ToCamel(name)
|
||||||
fieldName = cleanName(fieldName, fieldReps)
|
fieldName = cleanName(fieldName, fieldReps)
|
||||||
|
|
||||||
@@ -502,7 +502,7 @@ func (r *Resource) fieldInfoFromValidation(name string, validation interface{})
|
|||||||
var fieldInfo *FieldInfo
|
var fieldInfo *FieldInfo
|
||||||
|
|
||||||
switch validation := validation.(type) {
|
switch validation := validation.(type) {
|
||||||
case []interface{}:
|
case []any:
|
||||||
if len(validation) == 0 {
|
if len(validation) == 0 {
|
||||||
fieldInfo = NewFieldInfo(fieldName, name, "string", "", false, true, "")
|
fieldInfo = NewFieldInfo(fieldName, name, "string", "", false, true, "")
|
||||||
err := r.FieldProcessor(fieldName, fieldInfo)
|
err := r.FieldProcessor(fieldName, fieldInfo)
|
||||||
@@ -523,7 +523,7 @@ func (r *Resource) fieldInfoFromValidation(name string, validation interface{})
|
|||||||
err = r.FieldProcessor(fieldName, fieldInfo)
|
err = r.FieldProcessor(fieldName, fieldInfo)
|
||||||
return fieldInfo, err
|
return fieldInfo, err
|
||||||
|
|
||||||
case map[string]interface{}:
|
case map[string]any:
|
||||||
typeName := r.StructName + fieldName
|
typeName := r.StructName + fieldName
|
||||||
|
|
||||||
result := NewFieldInfo(fieldName, name, typeName, "", true, false, "")
|
result := NewFieldInfo(fieldName, name, typeName, "", true, false, "")
|
||||||
@@ -587,7 +587,7 @@ func (r *Resource) fieldInfoFromValidation(name string, validation interface{})
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Resource) processJSON(b []byte) error {
|
func (r *Resource) processJSON(b []byte) error {
|
||||||
var fields map[string]interface{}
|
var fields map[string]any
|
||||||
err := json.Unmarshal(b, &fields)
|
err := json.Unmarshal(b, &fields)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ func TestFieldInfoFromValidation(t *testing.T) {
|
|||||||
expectedType string
|
expectedType string
|
||||||
expectedComment string
|
expectedComment string
|
||||||
expectedOmitEmpty bool
|
expectedOmitEmpty bool
|
||||||
validation interface{}
|
validation any
|
||||||
}{
|
}{
|
||||||
{"string", "", true, ""},
|
{"string", "", true, ""},
|
||||||
{"string", "default|custom", true, "default|custom"},
|
{"string", "default|custom", true, "default|custom"},
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -1,4 +1,4 @@
|
|||||||
module github.com/ubiquiti-community/go-unifi
|
module github.com/vegardengen/go-unifi
|
||||||
|
|
||||||
go 1.21
|
go 1.21
|
||||||
|
|
||||||
|
|||||||
2
unifi/account.generated.go
generated
2
unifi/account.generated.go
generated
@@ -25,12 +25,14 @@ type Account struct {
|
|||||||
NoDelete bool `json:"attr_no_delete,omitempty"`
|
NoDelete bool `json:"attr_no_delete,omitempty"`
|
||||||
NoEdit bool `json:"attr_no_edit,omitempty"`
|
NoEdit bool `json:"attr_no_edit,omitempty"`
|
||||||
|
|
||||||
|
FilterIDs []string `json:"filter_ids,omitempty"`
|
||||||
IP string `json:"ip,omitempty"` // ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^$
|
IP string `json:"ip,omitempty"` // ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^$
|
||||||
Name string `json:"name,omitempty"` // ^[^"' ]+$
|
Name string `json:"name,omitempty"` // ^[^"' ]+$
|
||||||
NetworkID string `json:"networkconf_id,omitempty"`
|
NetworkID string `json:"networkconf_id,omitempty"`
|
||||||
TunnelConfigType string `json:"tunnel_config_type,omitempty"` // vpn|802.1x|custom
|
TunnelConfigType string `json:"tunnel_config_type,omitempty"` // vpn|802.1x|custom
|
||||||
TunnelMediumType int `json:"tunnel_medium_type,omitempty"` // [1-9]|1[0-5]|^$
|
TunnelMediumType int `json:"tunnel_medium_type,omitempty"` // [1-9]|1[0-5]|^$
|
||||||
TunnelType int `json:"tunnel_type,omitempty"` // [1-9]|1[0-3]|^$
|
TunnelType int `json:"tunnel_type,omitempty"` // [1-9]|1[0-3]|^$
|
||||||
|
UlpUserID string `json:"ulp_user_id"`
|
||||||
VLAN int `json:"vlan,omitempty"` // [2-9]|[1-9][0-9]{1,2}|[1-3][0-9]{3}|400[0-9]|^$
|
VLAN int `json:"vlan,omitempty"` // [2-9]|[1-9][0-9]{1,2}|[1-3][0-9]{3}|400[0-9]|^$
|
||||||
XPassword string `json:"x_password,omitempty"`
|
XPassword string `json:"x_password,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/tj/assert"
|
"github.com/tj/assert"
|
||||||
"github.com/ubiquiti-community/go-unifi/unifi"
|
"github.com/vegardengen/go-unifi/unifi"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccountMarshalJSON(t *testing.T) {
|
func TestAccountMarshalJSON(t *testing.T) {
|
||||||
|
|||||||
39
unifi/device.generated.go
generated
39
unifi/device.generated.go
generated
@@ -28,13 +28,13 @@ type Device struct {
|
|||||||
MAC string `json:"mac,omitempty"`
|
MAC string `json:"mac,omitempty"`
|
||||||
|
|
||||||
Adopted bool `json:"adopted"`
|
Adopted bool `json:"adopted"`
|
||||||
|
AfcEnabled bool `json:"afc_enabled,omitempty"`
|
||||||
AtfEnabled bool `json:"atf_enabled,omitempty"`
|
AtfEnabled bool `json:"atf_enabled,omitempty"`
|
||||||
BandsteeringMode string `json:"bandsteering_mode,omitempty"` // off|equal|prefer_5g
|
BandsteeringMode string `json:"bandsteering_mode,omitempty"` // off|equal|prefer_5g
|
||||||
BaresipAuthUser string `json:"baresip_auth_user,omitempty"` // ^\+?[a-zA-Z0-9_.\-!~*'()]*
|
BaresipAuthUser string `json:"baresip_auth_user,omitempty"` // ^\+?[a-zA-Z0-9_.\-!~*'()]*
|
||||||
BaresipEnabled bool `json:"baresip_enabled,omitempty"`
|
BaresipEnabled bool `json:"baresip_enabled,omitempty"`
|
||||||
BaresipExtension string `json:"baresip_extension,omitempty"` // ^\+?[a-zA-Z0-9_.\-!~*'()]*
|
BaresipExtension string `json:"baresip_extension,omitempty"` // ^\+?[a-zA-Z0-9_.\-!~*'()]*
|
||||||
ConfigNetwork DeviceConfigNetwork `json:"config_network,omitempty"`
|
ConfigNetwork DeviceConfigNetwork `json:"config_network,omitempty"`
|
||||||
ConnectedBatteryOverrides []DeviceConnectedBatteryOverrides `json:"connected_battery_overrides,omitempty"`
|
|
||||||
DPIEnabled bool `json:"dpi_enabled,omitempty"`
|
DPIEnabled bool `json:"dpi_enabled,omitempty"`
|
||||||
Disabled bool `json:"disabled,omitempty"`
|
Disabled bool `json:"disabled,omitempty"`
|
||||||
Dot1XFallbackNetworkID string `json:"dot1x_fallback_networkconf_id,omitempty"` // [\d\w]+|
|
Dot1XFallbackNetworkID string `json:"dot1x_fallback_networkconf_id,omitempty"` // [\d\w]+|
|
||||||
@@ -44,6 +44,7 @@ type Device struct {
|
|||||||
FlowctrlEnabled bool `json:"flowctrl_enabled,omitempty"`
|
FlowctrlEnabled bool `json:"flowctrl_enabled,omitempty"`
|
||||||
GatewayVrrpMode string `json:"gateway_vrrp_mode,omitempty"` // primary|secondary
|
GatewayVrrpMode string `json:"gateway_vrrp_mode,omitempty"` // primary|secondary
|
||||||
GatewayVrrpPriority int `json:"gateway_vrrp_priority,omitempty"` // [1-9][0-9]|[1-9][0-9][0-9]
|
GatewayVrrpPriority int `json:"gateway_vrrp_priority,omitempty"` // [1-9][0-9]|[1-9][0-9][0-9]
|
||||||
|
GreenApEnabled bool `json:"green_ap_enabled,omitempty"`
|
||||||
HeightInMeters float64 `json:"heightInMeters,omitempty"`
|
HeightInMeters float64 `json:"heightInMeters,omitempty"`
|
||||||
Hostname string `json:"hostname,omitempty"` // .{1,128}
|
Hostname string `json:"hostname,omitempty"` // .{1,128}
|
||||||
JumboframeEnabled bool `json:"jumboframe_enabled,omitempty"`
|
JumboframeEnabled bool `json:"jumboframe_enabled,omitempty"`
|
||||||
@@ -53,6 +54,7 @@ type Device struct {
|
|||||||
LcmIDleTimeoutOverride bool `json:"lcm_idle_timeout_override,omitempty"`
|
LcmIDleTimeoutOverride bool `json:"lcm_idle_timeout_override,omitempty"`
|
||||||
LcmNightModeBegins string `json:"lcm_night_mode_begins,omitempty"` // (^$)|(^(0[1-9])|(1[0-9])|(2[0-3])):([0-5][0-9]$)
|
LcmNightModeBegins string `json:"lcm_night_mode_begins,omitempty"` // (^$)|(^(0[1-9])|(1[0-9])|(2[0-3])):([0-5][0-9]$)
|
||||||
LcmNightModeEnds string `json:"lcm_night_mode_ends,omitempty"` // (^$)|(^(0[1-9])|(1[0-9])|(2[0-3])):([0-5][0-9]$)
|
LcmNightModeEnds string `json:"lcm_night_mode_ends,omitempty"` // (^$)|(^(0[1-9])|(1[0-9])|(2[0-3])):([0-5][0-9]$)
|
||||||
|
LcmOrientationOverride int `json:"lcm_orientation_override,omitempty"` // 0|90|180|270
|
||||||
LcmSettingsRestrictedAccess bool `json:"lcm_settings_restricted_access,omitempty"`
|
LcmSettingsRestrictedAccess bool `json:"lcm_settings_restricted_access,omitempty"`
|
||||||
LcmTrackerEnabled bool `json:"lcm_tracker_enabled,omitempty"`
|
LcmTrackerEnabled bool `json:"lcm_tracker_enabled,omitempty"`
|
||||||
LcmTrackerSeed string `json:"lcm_tracker_seed,omitempty"` // .{0,50}
|
LcmTrackerSeed string `json:"lcm_tracker_seed,omitempty"` // .{0,50}
|
||||||
@@ -88,6 +90,8 @@ type Device struct {
|
|||||||
PowerSourceCtrl string `json:"power_source_ctrl,omitempty"` // auto|8023af|8023at|8023bt-type3|8023bt-type4|pasv24|poe-injector|ac|adapter|dc|rps
|
PowerSourceCtrl string `json:"power_source_ctrl,omitempty"` // auto|8023af|8023at|8023bt-type3|8023bt-type4|pasv24|poe-injector|ac|adapter|dc|rps
|
||||||
PowerSourceCtrlBudget int `json:"power_source_ctrl_budget,omitempty"` // [0-9]|[1-9][0-9]|[1-9][0-9][0-9]
|
PowerSourceCtrlBudget int `json:"power_source_ctrl_budget,omitempty"` // [0-9]|[1-9][0-9]|[1-9][0-9][0-9]
|
||||||
PowerSourceCtrlEnabled bool `json:"power_source_ctrl_enabled,omitempty"`
|
PowerSourceCtrlEnabled bool `json:"power_source_ctrl_enabled,omitempty"`
|
||||||
|
PtmpApMAC string `json:"ptmp_ap_mac,omitempty"` // ^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$
|
||||||
|
PtpApMAC string `json:"ptp_ap_mac,omitempty"` // ^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$
|
||||||
RADIUSProfileID string `json:"radiusprofile_id,omitempty"`
|
RADIUSProfileID string `json:"radiusprofile_id,omitempty"`
|
||||||
RadioTable []DeviceRadioTable `json:"radio_table,omitempty"`
|
RadioTable []DeviceRadioTable `json:"radio_table,omitempty"`
|
||||||
ResetbtnEnabled string `json:"resetbtn_enabled,omitempty"` // on|off
|
ResetbtnEnabled string `json:"resetbtn_enabled,omitempty"` // on|off
|
||||||
@@ -95,6 +99,7 @@ type Device struct {
|
|||||||
SnmpContact string `json:"snmp_contact,omitempty"` // .{0,255}
|
SnmpContact string `json:"snmp_contact,omitempty"` // .{0,255}
|
||||||
SnmpLocation string `json:"snmp_location,omitempty"` // .{0,255}
|
SnmpLocation string `json:"snmp_location,omitempty"` // .{0,255}
|
||||||
State DeviceState `json:"state"`
|
State DeviceState `json:"state"`
|
||||||
|
StationMode string `json:"station_mode,omitempty"` // ptp|ptmp|wifi
|
||||||
StpPriority string `json:"stp_priority,omitempty"` // 0|4096|8192|12288|16384|20480|24576|28672|32768|36864|40960|45056|49152|53248|57344|61440
|
StpPriority string `json:"stp_priority,omitempty"` // 0|4096|8192|12288|16384|20480|24576|28672|32768|36864|40960|45056|49152|53248|57344|61440
|
||||||
StpVersion string `json:"stp_version,omitempty"` // stp|rstp|disabled
|
StpVersion string `json:"stp_version,omitempty"` // stp|rstp|disabled
|
||||||
SwitchVLANEnabled bool `json:"switch_vlan_enabled,omitempty"`
|
SwitchVLANEnabled bool `json:"switch_vlan_enabled,omitempty"`
|
||||||
@@ -104,8 +109,6 @@ type Device struct {
|
|||||||
X float64 `json:"x,omitempty"`
|
X float64 `json:"x,omitempty"`
|
||||||
XBaresipPassword string `json:"x_baresip_password,omitempty"` // ^[a-zA-Z0-9_.\-!~*'()]*
|
XBaresipPassword string `json:"x_baresip_password,omitempty"` // ^[a-zA-Z0-9_.\-!~*'()]*
|
||||||
Y float64 `json:"y,omitempty"`
|
Y float64 `json:"y,omitempty"`
|
||||||
|
|
||||||
PortTable []PortTable `json:"port_table,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dst *Device) UnmarshalJSON(b []byte) error {
|
func (dst *Device) UnmarshalJSON(b []byte) error {
|
||||||
@@ -114,6 +117,7 @@ func (dst *Device) UnmarshalJSON(b []byte) error {
|
|||||||
GatewayVrrpPriority emptyStringInt `json:"gateway_vrrp_priority"`
|
GatewayVrrpPriority emptyStringInt `json:"gateway_vrrp_priority"`
|
||||||
LcmBrightness emptyStringInt `json:"lcm_brightness"`
|
LcmBrightness emptyStringInt `json:"lcm_brightness"`
|
||||||
LcmIDleTimeout emptyStringInt `json:"lcm_idle_timeout"`
|
LcmIDleTimeout emptyStringInt `json:"lcm_idle_timeout"`
|
||||||
|
LcmOrientationOverride emptyStringInt `json:"lcm_orientation_override"`
|
||||||
LedOverrideColorBrightness emptyStringInt `json:"led_override_color_brightness"`
|
LedOverrideColorBrightness emptyStringInt `json:"led_override_color_brightness"`
|
||||||
LteExtAnt booleanishString `json:"lte_ext_ant"`
|
LteExtAnt booleanishString `json:"lte_ext_ant"`
|
||||||
LteHardLimit emptyStringInt `json:"lte_hard_limit"`
|
LteHardLimit emptyStringInt `json:"lte_hard_limit"`
|
||||||
@@ -136,6 +140,7 @@ func (dst *Device) UnmarshalJSON(b []byte) error {
|
|||||||
dst.GatewayVrrpPriority = int(aux.GatewayVrrpPriority)
|
dst.GatewayVrrpPriority = int(aux.GatewayVrrpPriority)
|
||||||
dst.LcmBrightness = int(aux.LcmBrightness)
|
dst.LcmBrightness = int(aux.LcmBrightness)
|
||||||
dst.LcmIDleTimeout = int(aux.LcmIDleTimeout)
|
dst.LcmIDleTimeout = int(aux.LcmIDleTimeout)
|
||||||
|
dst.LcmOrientationOverride = int(aux.LcmOrientationOverride)
|
||||||
dst.LedOverrideColorBrightness = int(aux.LedOverrideColorBrightness)
|
dst.LedOverrideColorBrightness = int(aux.LedOverrideColorBrightness)
|
||||||
dst.LteExtAnt = bool(aux.LteExtAnt)
|
dst.LteExtAnt = bool(aux.LteExtAnt)
|
||||||
dst.LteHardLimit = int(aux.LteHardLimit)
|
dst.LteHardLimit = int(aux.LteHardLimit)
|
||||||
@@ -176,29 +181,10 @@ func (dst *DeviceConfigNetwork) UnmarshalJSON(b []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type DeviceConnectedBatteryOverrides struct {
|
|
||||||
MAC string `json:"mac,omitempty"` // ^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dst *DeviceConnectedBatteryOverrides) UnmarshalJSON(b []byte) error {
|
|
||||||
type Alias DeviceConnectedBatteryOverrides
|
|
||||||
aux := &struct {
|
|
||||||
*Alias
|
|
||||||
}{
|
|
||||||
Alias: (*Alias)(dst),
|
|
||||||
}
|
|
||||||
|
|
||||||
err := json.Unmarshal(b, &aux)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("unable to unmarshal alias: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type DeviceEtherLighting struct {
|
type DeviceEtherLighting struct {
|
||||||
Behavior string `json:"behavior,omitempty"` // breath|steady
|
Behavior string `json:"behavior,omitempty"` // breath|steady
|
||||||
Brightness int `json:"brightness,omitempty"` // [1-9]|[1-9][0-9]|100
|
Brightness int `json:"brightness,omitempty"` // [1-9]|[1-9][0-9]|100
|
||||||
|
LedMode string `json:"led_mode,omitempty"` // standard|etherlighting
|
||||||
Mode string `json:"mode,omitempty"` // speed|network
|
Mode string `json:"mode,omitempty"` // speed|network
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,12 +268,13 @@ type DevicePortOverrides struct {
|
|||||||
Isolation bool `json:"isolation,omitempty"`
|
Isolation bool `json:"isolation,omitempty"`
|
||||||
LldpmedEnabled bool `json:"lldpmed_enabled,omitempty"`
|
LldpmedEnabled bool `json:"lldpmed_enabled,omitempty"`
|
||||||
LldpmedNotifyEnabled bool `json:"lldpmed_notify_enabled,omitempty"`
|
LldpmedNotifyEnabled bool `json:"lldpmed_notify_enabled,omitempty"`
|
||||||
MirrorPortIDX int `json:"mirror_port_idx,omitempty"` // [1-9]|[1-4][0-9]|5[0-2]
|
MirrorPortIDX int `json:"mirror_port_idx,omitempty"` // [1-9]|[1-4][0-9]|5[0-6]
|
||||||
|
MulticastRouterNetworkIDs []string `json:"multicast_router_networkconf_ids,omitempty"`
|
||||||
NATiveNetworkID string `json:"native_networkconf_id,omitempty"`
|
NATiveNetworkID string `json:"native_networkconf_id,omitempty"`
|
||||||
Name string `json:"name,omitempty"` // .{0,128}
|
Name string `json:"name,omitempty"` // .{0,128}
|
||||||
OpMode string `json:"op_mode,omitempty"` // switch|mirror|aggregate
|
OpMode string `json:"op_mode,omitempty"` // switch|mirror|aggregate
|
||||||
PoeMode string `json:"poe_mode,omitempty"` // auto|pasv24|passthrough|off
|
PoeMode string `json:"poe_mode,omitempty"` // auto|pasv24|passthrough|off
|
||||||
PortIDX int `json:"port_idx,omitempty"` // [1-9]|[1-4][0-9]|5[0-2]
|
PortIDX int `json:"port_idx,omitempty"` // [1-9]|[1-4][0-9]|5[0-6]
|
||||||
PortKeepaliveEnabled bool `json:"port_keepalive_enabled,omitempty"`
|
PortKeepaliveEnabled bool `json:"port_keepalive_enabled,omitempty"`
|
||||||
PortProfileID string `json:"portconf_id,omitempty"` // [\d\w]+
|
PortProfileID string `json:"portconf_id,omitempty"` // [\d\w]+
|
||||||
PortSecurityEnabled bool `json:"port_security_enabled,omitempty"`
|
PortSecurityEnabled bool `json:"port_security_enabled,omitempty"`
|
||||||
@@ -312,8 +299,6 @@ type DevicePortOverrides struct {
|
|||||||
StpPortMode bool `json:"stp_port_mode,omitempty"`
|
StpPortMode bool `json:"stp_port_mode,omitempty"`
|
||||||
TaggedVLANMgmt string `json:"tagged_vlan_mgmt,omitempty"` // auto|block_all|custom
|
TaggedVLANMgmt string `json:"tagged_vlan_mgmt,omitempty"` // auto|block_all|custom
|
||||||
VoiceNetworkID string `json:"voice_networkconf_id,omitempty"`
|
VoiceNetworkID string `json:"voice_networkconf_id,omitempty"`
|
||||||
|
|
||||||
PortPoe *bool `json:"port_poe,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dst *DevicePortOverrides) UnmarshalJSON(b []byte) error {
|
func (dst *DevicePortOverrides) UnmarshalJSON(b []byte) error {
|
||||||
|
|||||||
141
unifi/firewall_policy.go
Normal file
141
unifi/firewall_policy.go
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
package unifi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type FirewallDestination struct {
|
||||||
|
IPGroupID string `json:"ip_group_id"`
|
||||||
|
IPs []string `json:"ips,omitempty"`
|
||||||
|
MatchOppositeIPs bool `json:"match_opposite_ips"`
|
||||||
|
MatchOppositePorts bool `json:"match_opposite_ports"`
|
||||||
|
MatchingTarget string `json:"matching_target"`
|
||||||
|
MatchingTargetType string `json:"matching_target_type"`
|
||||||
|
NetworkIDs [] string `json:"network_ids,omitempty"`
|
||||||
|
Port string `json:"port,omitempty"`
|
||||||
|
PortGroupID string `json:"port_group_id"`
|
||||||
|
PortMatchingType string `json:"port_matching_type"`
|
||||||
|
Regions []string `json:"regions,omitempty"`
|
||||||
|
ZoneID string `json:"zone_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type FirewallSource struct {
|
||||||
|
ClientMacs []string `json:"client_macs,omitempty"`
|
||||||
|
IPs []string `json:"ips,omitempty"`
|
||||||
|
MatchMac bool `json:"match_mac"`
|
||||||
|
MatchOppositeIPs bool `json:"match_opposite_ips"`
|
||||||
|
MatchOppositeNetworks bool `json:"match_opposite_networks"`
|
||||||
|
MatchOppositePorts bool `json:"match_opposite_ports"`
|
||||||
|
MatchingTarget string `json:"matching_target,omitempty"`
|
||||||
|
MatchingTargetType string `json:"matching_target_type,omitempty"`
|
||||||
|
NetworkIDs []string `json:"network_ids,omitempty"`
|
||||||
|
Port string `json:"port,omitempty"`
|
||||||
|
PortMatchingType string `json:"port_matching_type,omitempty"`
|
||||||
|
ZoneID string `json:"zone_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type FirewallSchedule struct {
|
||||||
|
Mode string `json:"mode"`
|
||||||
|
DateStart string `json:"date_start,omitempty"`
|
||||||
|
DateEnd string `json:"date_end,omitempty"`
|
||||||
|
RepeatOnDays []string `json:"repeat_on_days"`
|
||||||
|
TimeAllDay bool `json:"time_all_day"`
|
||||||
|
TimeRangeStart string `json:"time_range_start,omitempty"`
|
||||||
|
TimeRangeEnd string `json:"time_range_end,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type FirewallPolicy struct {
|
||||||
|
ID string `json:"_id,omitempty"`
|
||||||
|
|
||||||
|
// Hidden bool `json:"attr_hidden,omitempty"`
|
||||||
|
// HiddenID string `json:"attr_hidden_id,omitempty"`
|
||||||
|
// NoDelete bool `json:"attr_no_delete,omitempty"`
|
||||||
|
// NoEdit bool `json:"attr_no_edit,omitempty"`
|
||||||
|
|
||||||
|
Action string `json:"action"`
|
||||||
|
ConnectionStateType string `json:"connection_state_type"`
|
||||||
|
ConnectionStates []string `json:"connection_states"`
|
||||||
|
CreateAllowRespond bool `json:"create_allow_respond"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
Destination FirewallDestination `json:"destination"`
|
||||||
|
Enabled bool `json:"enabled"`
|
||||||
|
ICMPTypename string `json:"icmp_typename"`
|
||||||
|
ICMPV6Typename string `json:"icmp_v6_typename"`
|
||||||
|
Index int64 `json:"index"`
|
||||||
|
IPVersion string `json:"ip_version"`
|
||||||
|
Logging bool `json:"logging"`
|
||||||
|
MatchIPSec bool `json:"match_ip_sec"`
|
||||||
|
MatchIPSecType string `json:"match_ip_sec_type,omitempty"`
|
||||||
|
MatchOppositeProtocol bool `json:"match_opposite_protocol"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
OriginID string `json:"origin_id,omitempty"`
|
||||||
|
OriginType string `json:"origin_type,omitempty"`
|
||||||
|
Predefined bool `json:"predefined"`
|
||||||
|
Protocol string `json:"protocol"`
|
||||||
|
Schedule FirewallSchedule `json:"schedule"`
|
||||||
|
Source FirewallSource `json:"source"`
|
||||||
|
|
||||||
|
// Role string `json:"role"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) ListFirewallPolicy(ctx context.Context, site string) ([]FirewallPolicy, error) {
|
||||||
|
var respBody []FirewallPolicy
|
||||||
|
|
||||||
|
err := c.do_versioned(ctx, "V2", "GET", fmt.Sprintf("site/%s/firewall-policies", site), nil, &respBody)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return respBody, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) GetFirewallPolicy(ctx context.Context, site, id string) (*FirewallPolicy, error) {
|
||||||
|
|
||||||
|
var respBody FirewallPolicy
|
||||||
|
err := c.do_versioned(ctx, "V2", "GET", fmt.Sprintf("site/%s/firewall-policies/%s", site,id), nil, &respBody)
|
||||||
|
if err != nil {
|
||||||
|
return nil, &NotFoundError{}
|
||||||
|
}
|
||||||
|
|
||||||
|
new := respBody
|
||||||
|
return &new, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) DeleteFirewallPolicy(ctx context.Context, site, id string) error {
|
||||||
|
var respBody FirewallPolicy
|
||||||
|
err := c.do_versioned(ctx, "V2", "DELETE", fmt.Sprintf("site/%s/firewall-policies/%s", site, id), nil, &respBody)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) CreateFirewallPolicy(ctx context.Context, site string, d *FirewallPolicy) (*FirewallPolicy, error) {
|
||||||
|
var respBody FirewallPolicy
|
||||||
|
|
||||||
|
err := c.do_versioned(ctx, "V2", "POST", fmt.Sprintf("site/%s/firewall-policies", site), d, &respBody)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
new := respBody
|
||||||
|
|
||||||
|
return &new, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) UpdateFirewallPolicy(ctx context.Context, site string, d *FirewallPolicy) (*FirewallPolicy, error) {
|
||||||
|
var respBody FirewallPolicy
|
||||||
|
|
||||||
|
err := c.do_versioned(ctx, "V2", "PUT", fmt.Sprintf("site/%s/firewall-policies/%s", site, d.ID), d, &respBody)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
new := respBody
|
||||||
|
|
||||||
|
return &new, nil
|
||||||
|
}
|
||||||
|
|
||||||
10
unifi/firewall_rule.generated.go
generated
10
unifi/firewall_rule.generated.go
generated
@@ -26,7 +26,6 @@ type FirewallRule struct {
|
|||||||
NoEdit bool `json:"attr_no_edit,omitempty"`
|
NoEdit bool `json:"attr_no_edit,omitempty"`
|
||||||
|
|
||||||
Action string `json:"action,omitempty"` // drop|reject|accept
|
Action string `json:"action,omitempty"` // drop|reject|accept
|
||||||
Contiguous bool `json:"contiguous"`
|
|
||||||
DstAddress string `json:"dst_address,omitempty"`
|
DstAddress string `json:"dst_address,omitempty"`
|
||||||
DstAddressIPV6 string `json:"dst_address_ipv6,omitempty"`
|
DstAddressIPV6 string `json:"dst_address_ipv6,omitempty"`
|
||||||
DstFirewallGroupIDs []string `json:"dst_firewallgroup_ids,omitempty"` // [\d\w]+
|
DstFirewallGroupIDs []string `json:"dst_firewallgroup_ids,omitempty"` // [\d\w]+
|
||||||
@@ -38,8 +37,6 @@ type FirewallRule struct {
|
|||||||
ICMPv6Typename string `json:"icmpv6_typename"` // ^$|address-unreachable|bad-header|beyond-scope|communication-prohibited|destination-unreachable|echo-reply|echo-request|failed-policy|neighbor-advertisement|neighbor-solicitation|no-route|packet-too-big|parameter-problem|port-unreachable|redirect|reject-route|router-advertisement|router-solicitation|time-exceeded|ttl-zero-during-reassembly|ttl-zero-during-transit|unknown-header-type|unknown-option
|
ICMPv6Typename string `json:"icmpv6_typename"` // ^$|address-unreachable|bad-header|beyond-scope|communication-prohibited|destination-unreachable|echo-reply|echo-request|failed-policy|neighbor-advertisement|neighbor-solicitation|no-route|packet-too-big|parameter-problem|port-unreachable|redirect|reject-route|router-advertisement|router-solicitation|time-exceeded|ttl-zero-during-reassembly|ttl-zero-during-transit|unknown-header-type|unknown-option
|
||||||
IPSec string `json:"ipsec"` // match-ipsec|match-none|^$
|
IPSec string `json:"ipsec"` // match-ipsec|match-none|^$
|
||||||
Logging bool `json:"logging"`
|
Logging bool `json:"logging"`
|
||||||
MonthDays string `json:"monthdays"` // ^$|^(([1-9]|[12][0-9]|3[01])(,([1-9]|[12][0-9]|3[01])){0,30})$
|
|
||||||
MonthDaysNegate bool `json:"monthdays_negate"`
|
|
||||||
Name string `json:"name,omitempty"` // .{1,128}
|
Name string `json:"name,omitempty"` // .{1,128}
|
||||||
Protocol string `json:"protocol"` // ^$|all|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])|tcp_udp|ah|ax.25|dccp|ddp|egp|eigrp|encap|esp|etherip|fc|ggp|gre|hip|hmp|icmp|idpr-cmtp|idrp|igmp|igp|ip|ipcomp|ipencap|ipip|ipv6|ipv6-frag|ipv6-icmp|ipv6-nonxt|ipv6-opts|ipv6-route|isis|iso-tp4|l2tp|manet|mobility-header|mpls-in-ip|ospf|pim|pup|rdp|rohc|rspf|rsvp|sctp|shim6|skip|st|tcp|udp|udplite|vmtp|vrrp|wesp|xns-idp|xtp
|
Protocol string `json:"protocol"` // ^$|all|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])|tcp_udp|ah|ax.25|dccp|ddp|egp|eigrp|encap|esp|etherip|fc|ggp|gre|hip|hmp|icmp|idpr-cmtp|idrp|igmp|igp|ip|ipcomp|ipencap|ipip|ipv6|ipv6-frag|ipv6-icmp|ipv6-nonxt|ipv6-opts|ipv6-route|isis|iso-tp4|l2tp|manet|mobility-header|mpls-in-ip|ospf|pim|pup|rdp|rohc|rspf|rsvp|sctp|shim6|skip|st|tcp|udp|udplite|vmtp|vrrp|wesp|xns-idp|xtp
|
||||||
ProtocolMatchExcepted bool `json:"protocol_match_excepted"`
|
ProtocolMatchExcepted bool `json:"protocol_match_excepted"`
|
||||||
@@ -54,17 +51,10 @@ type FirewallRule struct {
|
|||||||
SrcNetworkID string `json:"src_networkconf_id"` // [\d\w]+|^$
|
SrcNetworkID string `json:"src_networkconf_id"` // [\d\w]+|^$
|
||||||
SrcNetworkType string `json:"src_networkconf_type,omitempty"` // ADDRv4|NETv4
|
SrcNetworkType string `json:"src_networkconf_type,omitempty"` // ADDRv4|NETv4
|
||||||
SrcPort string `json:"src_port,omitempty"`
|
SrcPort string `json:"src_port,omitempty"`
|
||||||
StartDate string `json:"startdate"` // ^$|^(20[0-9]{2}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9])$
|
|
||||||
StartTime string `json:"starttime"` // ^$|^(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9])$
|
|
||||||
StateEstablished bool `json:"state_established"`
|
StateEstablished bool `json:"state_established"`
|
||||||
StateInvalid bool `json:"state_invalid"`
|
StateInvalid bool `json:"state_invalid"`
|
||||||
StateNew bool `json:"state_new"`
|
StateNew bool `json:"state_new"`
|
||||||
StateRelated bool `json:"state_related"`
|
StateRelated bool `json:"state_related"`
|
||||||
StopDate string `json:"stopdate"` // ^$|^(20[0-9]{2}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9])$
|
|
||||||
StopTime string `json:"stoptime"` // ^$|^(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9])$
|
|
||||||
UTC bool `json:"utc"`
|
|
||||||
Weekdays string `json:"weekdays"` // ^$|^((Mon|Tue|Wed|Thu|Fri|Sat|Sun)(,(Mon|Tue|Wed|Thu|Fri|Sat|Sun)){0,6})$
|
|
||||||
WeekdaysNegate bool `json:"weekdays_negate"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dst *FirewallRule) UnmarshalJSON(b []byte) error {
|
func (dst *FirewallRule) UnmarshalJSON(b []byte) error {
|
||||||
|
|||||||
48
unifi/firewall_zone.go
Normal file
48
unifi/firewall_zone.go
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
package unifi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type FirewallZone struct {
|
||||||
|
ID string `json:"_id,omitempty"`
|
||||||
|
|
||||||
|
// Hidden bool `json:"attr_hidden,omitempty"`
|
||||||
|
// HiddenID string `json:"attr_hidden_id,omitempty"`
|
||||||
|
// NoDelete bool `json:"attr_no_delete,omitempty"`
|
||||||
|
// NoEdit bool `json:"attr_no_edit,omitempty"`
|
||||||
|
|
||||||
|
Name string `json:"name"`
|
||||||
|
DefaultZone bool `json:"default_zone,omitempty"`
|
||||||
|
NetworkIDs []string `json:"network_ids,omitempty"`
|
||||||
|
ZoneKey string `json:"zone_key,omitempty"`
|
||||||
|
|
||||||
|
// Role string `json:"role"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) ListFirewallZones(ctx context.Context, site string) ([]FirewallZone, error) {
|
||||||
|
var respBody []FirewallZone
|
||||||
|
|
||||||
|
err := c.do_versioned(ctx, "V2", "GET", fmt.Sprintf("site/%s/firewall/zone", site), nil, &respBody)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return respBody, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) GetFirewallZone(ctx context.Context, site, id string) (*FirewallZone, error) {
|
||||||
|
firewallzones, err := c.ListFirewallZones(ctx, site)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, z := range firewallzones {
|
||||||
|
if z.ID == id {
|
||||||
|
return &z, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, &NotFoundError{}
|
||||||
|
}
|
||||||
35
unifi/network.generated.go
generated
35
unifi/network.generated.go
generated
@@ -75,15 +75,18 @@ type Network struct {
|
|||||||
DomainName string `json:"domain_name"` // (?=^.{3,253}$)(^((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\.)+[a-zA-Z]{2,63}$)|^$|[a-zA-Z0-9-]{1,63}
|
DomainName string `json:"domain_name"` // (?=^.{3,253}$)(^((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\.)+[a-zA-Z]{2,63}$)|^$|[a-zA-Z0-9-]{1,63}
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
ExposedToSiteVPN bool `json:"exposed_to_site_vpn"`
|
ExposedToSiteVPN bool `json:"exposed_to_site_vpn"`
|
||||||
|
FirewallZoneID string `json:"firewall_zone_id"`
|
||||||
GatewayDevice string `json:"gateway_device"` // (^$|^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})$)
|
GatewayDevice string `json:"gateway_device"` // (^$|^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})$)
|
||||||
GatewayType string `json:"gateway_type,omitempty"` // default|switch
|
GatewayType string `json:"gateway_type,omitempty"` // default|switch
|
||||||
IGMPFastleave bool `json:"igmp_fastleave"`
|
IGMPFastleave bool `json:"igmp_fastleave"`
|
||||||
|
IGMPForwardUnknownMulticast bool `json:"igmp_forward_unknown_multicast"`
|
||||||
IGMPGroupmembership int `json:"igmp_groupmembership,omitempty"` // [2-9]|[1-9][0-9]{1,2}|[1-2][0-9]{3}|3[0-5][0-9]{2}|3600|^$
|
IGMPGroupmembership int `json:"igmp_groupmembership,omitempty"` // [2-9]|[1-9][0-9]{1,2}|[1-2][0-9]{3}|3[0-5][0-9]{2}|3600|^$
|
||||||
IGMPMaxresponse int `json:"igmp_maxresponse,omitempty"` // [1-9]|1[0-9]|2[0-5]|^$
|
IGMPMaxresponse int `json:"igmp_maxresponse,omitempty"` // [1-9]|1[0-9]|2[0-5]|^$
|
||||||
IGMPMcrtrexpiretime int `json:"igmp_mcrtrexpiretime,omitempty"` // [0-9]|[1-9][0-9]{1,2}|[1-2][0-9]{3}|3[0-5][0-9]{2}|3600|^$
|
IGMPMcrtrexpiretime int `json:"igmp_mcrtrexpiretime,omitempty"` // [0-9]|[1-9][0-9]{1,2}|[1-2][0-9]{3}|3[0-5][0-9]{2}|3600|^$
|
||||||
IGMPProxyDownstream bool `json:"igmp_proxy_downstream"`
|
IGMPProxyDownstreamNetworkIDs []string `json:"igmp_proxy_downstream_networkconf_ids,omitempty"`
|
||||||
|
IGMPProxyFor string `json:"igmp_proxy_for,omitempty"` // all|some|none
|
||||||
IGMPProxyUpstream bool `json:"igmp_proxy_upstream"`
|
IGMPProxyUpstream bool `json:"igmp_proxy_upstream"`
|
||||||
IGMPQuerier string `json:"igmp_querier"` // ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^$
|
IGMPQuerierSwitches []NetworkIGMPQuerierSwitches `json:"igmp_querier_switches,omitempty"`
|
||||||
IGMPSnooping bool `json:"igmp_snooping"`
|
IGMPSnooping bool `json:"igmp_snooping"`
|
||||||
IGMPSupression bool `json:"igmp_supression"`
|
IGMPSupression bool `json:"igmp_supression"`
|
||||||
IPSecDhGroup int `json:"ipsec_dh_group,omitempty"` // 2|5|14|15|16|19|20|21|25|26
|
IPSecDhGroup int `json:"ipsec_dh_group,omitempty"` // 2|5|14|15|16|19|20|21|25|26
|
||||||
@@ -92,12 +95,12 @@ type Network struct {
|
|||||||
IPSecEspDhGroup int `json:"ipsec_esp_dh_group,omitempty"` // 1|2|5|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32
|
IPSecEspDhGroup int `json:"ipsec_esp_dh_group,omitempty"` // 1|2|5|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32
|
||||||
IPSecEspEncryption string `json:"ipsec_esp_encryption,omitempty"` // aes128|aes192|aes256|3des
|
IPSecEspEncryption string `json:"ipsec_esp_encryption,omitempty"` // aes128|aes192|aes256|3des
|
||||||
IPSecEspHash string `json:"ipsec_esp_hash,omitempty"` // sha1|md5|sha256|sha384|sha512
|
IPSecEspHash string `json:"ipsec_esp_hash,omitempty"` // sha1|md5|sha256|sha384|sha512
|
||||||
IPSecEspLifetime string `json:"ipsec_esp_lifetime,omitempty"` // ^(?:3[0-9]|[4-9][0-9]|[1-9][0-9]{2,3}|[1-7][0-9]{4}|8[0-5][0-9]{3}|86[0-3][0-9]{2}|86400)$
|
IPSecEspLifetime int `json:"ipsec_esp_lifetime,omitempty"` // ^(?:3[0-9]|[4-9][0-9]|[1-9][0-9]{2,3}|[1-7][0-9]{4}|8[0-5][0-9]{3}|86[0-3][0-9]{2}|86400)$
|
||||||
IPSecHash string `json:"ipsec_hash,omitempty"` // sha1|md5|sha256|sha384|sha512
|
IPSecHash string `json:"ipsec_hash,omitempty"` // sha1|md5|sha256|sha384|sha512
|
||||||
IPSecIkeDhGroup int `json:"ipsec_ike_dh_group,omitempty"` // 1|2|5|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32
|
IPSecIkeDhGroup int `json:"ipsec_ike_dh_group,omitempty"` // 1|2|5|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32
|
||||||
IPSecIkeEncryption string `json:"ipsec_ike_encryption,omitempty"` // aes128|aes192|aes256|3des
|
IPSecIkeEncryption string `json:"ipsec_ike_encryption,omitempty"` // aes128|aes192|aes256|3des
|
||||||
IPSecIkeHash string `json:"ipsec_ike_hash,omitempty"` // sha1|md5|sha256|sha384|sha512
|
IPSecIkeHash string `json:"ipsec_ike_hash,omitempty"` // sha1|md5|sha256|sha384|sha512
|
||||||
IPSecIkeLifetime string `json:"ipsec_ike_lifetime,omitempty"` // ^(?:3[0-9]|[4-9][0-9]|[1-9][0-9]{2,3}|[1-7][0-9]{4}|8[0-5][0-9]{3}|86[0-3][0-9]{2}|86400)$
|
IPSecIkeLifetime int `json:"ipsec_ike_lifetime,omitempty"` // ^(?:3[0-9]|[4-9][0-9]|[1-9][0-9]{2,3}|[1-7][0-9]{4}|8[0-5][0-9]{3}|86[0-3][0-9]{2}|86400)$
|
||||||
IPSecInterface string `json:"ipsec_interface,omitempty"` // wan|wan2
|
IPSecInterface string `json:"ipsec_interface,omitempty"` // wan|wan2
|
||||||
IPSecKeyExchange string `json:"ipsec_key_exchange,omitempty"` // ikev1|ikev2
|
IPSecKeyExchange string `json:"ipsec_key_exchange,omitempty"` // ikev1|ikev2
|
||||||
IPSecLocalIDentifier string `json:"ipsec_local_identifier,omitempty"`
|
IPSecLocalIDentifier string `json:"ipsec_local_identifier,omitempty"`
|
||||||
@@ -169,6 +172,7 @@ type Network struct {
|
|||||||
ReportWANEvent bool `json:"report_wan_event"`
|
ReportWANEvent bool `json:"report_wan_event"`
|
||||||
RequireMschapv2 bool `json:"require_mschapv2"`
|
RequireMschapv2 bool `json:"require_mschapv2"`
|
||||||
RouteDistance int `json:"route_distance,omitempty"` // ^[1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]$|^$
|
RouteDistance int `json:"route_distance,omitempty"` // ^[1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]$|^$
|
||||||
|
SdwanRemoteSiteID string `json:"sdwan_remote_site_id"`
|
||||||
SettingPreference string `json:"setting_preference,omitempty"` // auto|manual
|
SettingPreference string `json:"setting_preference,omitempty"` // auto|manual
|
||||||
SingleNetworkLan string `json:"single_network_lan,omitempty"`
|
SingleNetworkLan string `json:"single_network_lan,omitempty"`
|
||||||
UidPolicyEnabled bool `json:"uid_policy_enabled"`
|
UidPolicyEnabled bool `json:"uid_policy_enabled"`
|
||||||
@@ -192,7 +196,7 @@ type Network struct {
|
|||||||
VPNClientDefaultRoute bool `json:"vpn_client_default_route"`
|
VPNClientDefaultRoute bool `json:"vpn_client_default_route"`
|
||||||
VPNClientPullDNS bool `json:"vpn_client_pull_dns"`
|
VPNClientPullDNS bool `json:"vpn_client_pull_dns"`
|
||||||
VPNProtocol string `json:"vpn_protocol,omitempty"` // TCP|UDP
|
VPNProtocol string `json:"vpn_protocol,omitempty"` // TCP|UDP
|
||||||
VPNType string `json:"vpn_type,omitempty"` // auto|ipsec-vpn|openvpn-client|openvpn-server|openvpn-vpn|pptp-client|l2tp-server|pptp-server|uid-server|wireguard-server|wireguard-client
|
VPNType string `json:"vpn_type,omitempty"` // auto|ipsec-vpn|openvpn-client|openvpn-server|openvpn-vpn|pptp-client|l2tp-server|pptp-server|sdwan-hub-spoke-tunnel|sdwan-mesh-tunnel|uid-server|wireguard-server|wireguard-client
|
||||||
VrrpIPSubnetGw1 string `json:"vrrp_ip_subnet_gw1,omitempty"` // ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\/([1-9]|[1-2][0-9]|30)$
|
VrrpIPSubnetGw1 string `json:"vrrp_ip_subnet_gw1,omitempty"` // ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\/([1-9]|[1-2][0-9]|30)$
|
||||||
VrrpIPSubnetGw2 string `json:"vrrp_ip_subnet_gw2,omitempty"` // ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\/([1-9]|[1-2][0-9]|30)$
|
VrrpIPSubnetGw2 string `json:"vrrp_ip_subnet_gw2,omitempty"` // ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\/([1-9]|[1-2][0-9]|30)$
|
||||||
VrrpVrid int `json:"vrrp_vrid,omitempty"` // [1-9]|[1-9][0-9]
|
VrrpVrid int `json:"vrrp_vrid,omitempty"` // [1-9]|[1-9][0-9]
|
||||||
@@ -338,6 +342,27 @@ func (dst *Network) UnmarshalJSON(b []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type NetworkIGMPQuerierSwitches struct {
|
||||||
|
QuerierAddress string `json:"querier_address"` // ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^$
|
||||||
|
SwitchMAC string `json:"switch_mac,omitempty"` // ^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dst *NetworkIGMPQuerierSwitches) UnmarshalJSON(b []byte) error {
|
||||||
|
type Alias NetworkIGMPQuerierSwitches
|
||||||
|
aux := &struct {
|
||||||
|
*Alias
|
||||||
|
}{
|
||||||
|
Alias: (*Alias)(dst),
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(b, &aux)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to unmarshal alias: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type NetworkNATOutboundIPAddresses struct {
|
type NetworkNATOutboundIPAddresses struct {
|
||||||
IPAddress string `json:"ip_address"` // ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^$
|
IPAddress string `json:"ip_address"` // ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^$
|
||||||
IPAddressPool []string `json:"ip_address_pool,omitempty"` // ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])-(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$
|
IPAddressPool []string `json:"ip_address_pool,omitempty"` // ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])-(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/ubiquiti-community/go-unifi/unifi"
|
"github.com/vegardengen/go-unifi/unifi"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNetworkUnmarshalJSON(t *testing.T) {
|
func TestNetworkUnmarshalJSON(t *testing.T) {
|
||||||
|
|||||||
1
unifi/port_profile.generated.go
generated
1
unifi/port_profile.generated.go
generated
@@ -37,6 +37,7 @@ type PortProfile struct {
|
|||||||
Isolation bool `json:"isolation"`
|
Isolation bool `json:"isolation"`
|
||||||
LldpmedEnabled bool `json:"lldpmed_enabled"`
|
LldpmedEnabled bool `json:"lldpmed_enabled"`
|
||||||
LldpmedNotifyEnabled bool `json:"lldpmed_notify_enabled"`
|
LldpmedNotifyEnabled bool `json:"lldpmed_notify_enabled"`
|
||||||
|
MulticastRouterNetworkIDs []string `json:"multicast_router_networkconf_ids,omitempty"`
|
||||||
NATiveNetworkID string `json:"native_networkconf_id"`
|
NATiveNetworkID string `json:"native_networkconf_id"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
OpMode string `json:"op_mode,omitempty"` // switch
|
OpMode string `json:"op_mode,omitempty"` // switch
|
||||||
|
|||||||
28
unifi/radius_profile.generated.go
generated
28
unifi/radius_profile.generated.go
generated
@@ -31,10 +31,17 @@ type RADIUSProfile struct {
|
|||||||
InterimUpdateEnabled bool `json:"interim_update_enabled"`
|
InterimUpdateEnabled bool `json:"interim_update_enabled"`
|
||||||
InterimUpdateInterval int `json:"interim_update_interval,omitempty"` // ^([6-9][0-9]|[1-9][0-9]{2,3}|[1-7][0-9]{4}|8[0-5][0-9]{3}|86[0-3][0-9][0-9]|86400)$
|
InterimUpdateInterval int `json:"interim_update_interval,omitempty"` // ^([6-9][0-9]|[1-9][0-9]{2,3}|[1-7][0-9]{4}|8[0-5][0-9]{3}|86[0-3][0-9][0-9]|86400)$
|
||||||
Name string `json:"name,omitempty"` // .{1,128}
|
Name string `json:"name,omitempty"` // .{1,128}
|
||||||
|
TlsEnabled bool `json:"tls_enabled"`
|
||||||
UseUsgAcctServer bool `json:"use_usg_acct_server"`
|
UseUsgAcctServer bool `json:"use_usg_acct_server"`
|
||||||
UseUsgAuthServer bool `json:"use_usg_auth_server"`
|
UseUsgAuthServer bool `json:"use_usg_auth_server"`
|
||||||
VLANEnabled bool `json:"vlan_enabled"`
|
VLANEnabled bool `json:"vlan_enabled"`
|
||||||
VLANWLANMode string `json:"vlan_wlan_mode,omitempty"` // disabled|optional|required
|
VLANWLANMode string `json:"vlan_wlan_mode,omitempty"` // disabled|optional|required
|
||||||
|
XCaCrts []RADIUSProfileXCaCrts `json:"x_ca_crts,omitempty"`
|
||||||
|
XClientCrt string `json:"x_client_crt,omitempty"`
|
||||||
|
XClientCrtFilename string `json:"x_client_crt_filename,omitempty"`
|
||||||
|
XClientPrivateKey string `json:"x_client_private_key,omitempty"`
|
||||||
|
XClientPrivateKeyFilename string `json:"x_client_private_key_filename,omitempty"`
|
||||||
|
XClientPrivateKeyPassword string `json:"x_client_private_key_password,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dst *RADIUSProfile) UnmarshalJSON(b []byte) error {
|
func (dst *RADIUSProfile) UnmarshalJSON(b []byte) error {
|
||||||
@@ -106,6 +113,27 @@ func (dst *RADIUSProfileAuthServers) UnmarshalJSON(b []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RADIUSProfileXCaCrts struct {
|
||||||
|
Filename string `json:"filename,omitempty"`
|
||||||
|
XCaCrt string `json:"x_ca_crt,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dst *RADIUSProfileXCaCrts) UnmarshalJSON(b []byte) error {
|
||||||
|
type Alias RADIUSProfileXCaCrts
|
||||||
|
aux := &struct {
|
||||||
|
*Alias
|
||||||
|
}{
|
||||||
|
Alias: (*Alias)(dst),
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(b, &aux)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to unmarshal alias: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Client) listRADIUSProfile(ctx context.Context, site string) ([]RADIUSProfile, error) {
|
func (c *Client) listRADIUSProfile(ctx context.Context, site string) ([]RADIUSProfile, error) {
|
||||||
var respBody struct {
|
var respBody struct {
|
||||||
Meta meta `json:"meta"`
|
Meta meta `json:"meta"`
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ type Setting struct {
|
|||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Setting) newFields() (interface{}, error) {
|
func (s *Setting) newFields() (any, error) {
|
||||||
switch s.Key {
|
switch s.Key {
|
||||||
case "auto_speedtest":
|
case "auto_speedtest":
|
||||||
return &SettingAutoSpeedtest{}, nil
|
return &SettingAutoSpeedtest{}, nil
|
||||||
@@ -79,7 +79,7 @@ func (s *Setting) newFields() (interface{}, error) {
|
|||||||
return nil, fmt.Errorf("unexpected key %q", s.Key)
|
return nil, fmt.Errorf("unexpected key %q", s.Key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetSetting(ctx context.Context, site, key string) (*Setting, interface{}, error) {
|
func (c *Client) GetSetting(ctx context.Context, site, key string) (*Setting, any, error) {
|
||||||
var respBody struct {
|
var respBody struct {
|
||||||
Meta meta `json:"meta"`
|
Meta meta `json:"meta"`
|
||||||
Data []json.RawMessage `json:"data"`
|
Data []json.RawMessage `json:"data"`
|
||||||
|
|||||||
5
unifi/setting_dashboard.generated.go
generated
5
unifi/setting_dashboard.generated.go
generated
@@ -27,7 +27,7 @@ type SettingDashboard struct {
|
|||||||
|
|
||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
|
|
||||||
LayoutPreference string `json:"layout_preference,omitempty"` // auto|custom
|
LayoutPreference string `json:"layout_preference,omitempty"` // auto|manual
|
||||||
Widgets []SettingDashboardWidgets `json:"widgets,omitempty"`
|
Widgets []SettingDashboardWidgets `json:"widgets,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,8 @@ func (dst *SettingDashboard) UnmarshalJSON(b []byte) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SettingDashboardWidgets struct {
|
type SettingDashboardWidgets struct {
|
||||||
Name string `json:"name,omitempty"` // traffic_identification|connection_types|wifi_technology|most_active_clients|most_active_aps|meshing|network_activity|wireless_experience|internet|wifi_activity|wifi_channels|wifi_client_experience|wifi_tx_retries|admin_activity|device_client_count|server_ip
|
Enabled bool `json:"enabled"`
|
||||||
|
Name string `json:"name,omitempty"` // cybersecure|traffic_identification|wifi_technology|wifi_channels|wifi_client_experience|wifi_tx_retries|most_active_apps_aps_clients|most_active_apps_clients|most_active_aps_clients|most_active_apps_aps|most_active_apps|v2_most_active_aps|v2_most_active_clients|wifi_connectivity|ap_radio_density
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dst *SettingDashboardWidgets) UnmarshalJSON(b []byte) error {
|
func (dst *SettingDashboardWidgets) UnmarshalJSON(b []byte) error {
|
||||||
|
|||||||
25
unifi/setting_doh.generated.go
generated
25
unifi/setting_doh.generated.go
generated
@@ -27,8 +27,9 @@ type SettingDoh struct {
|
|||||||
|
|
||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
|
|
||||||
|
CustomServers []SettingDohCustomServers `json:"custom_servers,omitempty"`
|
||||||
ServerNames []string `json:"server_names,omitempty"`
|
ServerNames []string `json:"server_names,omitempty"`
|
||||||
State string `json:"state,omitempty"` // off|auto|manual
|
State string `json:"state,omitempty"` // off|auto|manual|custom
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dst *SettingDoh) UnmarshalJSON(b []byte) error {
|
func (dst *SettingDoh) UnmarshalJSON(b []byte) error {
|
||||||
@@ -47,6 +48,28 @@ func (dst *SettingDoh) UnmarshalJSON(b []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SettingDohCustomServers struct {
|
||||||
|
Enabled bool `json:"enabled"`
|
||||||
|
SdnsStamp string `json:"sdns_stamp,omitempty"`
|
||||||
|
ServerName string `json:"server_name,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dst *SettingDohCustomServers) UnmarshalJSON(b []byte) error {
|
||||||
|
type Alias SettingDohCustomServers
|
||||||
|
aux := &struct {
|
||||||
|
*Alias
|
||||||
|
}{
|
||||||
|
Alias: (*Alias)(dst),
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(b, &aux)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to unmarshal alias: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Client) getSettingDoh(ctx context.Context, site string) (*SettingDoh, error) {
|
func (c *Client) getSettingDoh(ctx context.Context, site string) (*SettingDoh, error) {
|
||||||
var respBody struct {
|
var respBody struct {
|
||||||
Meta meta `json:"meta"`
|
Meta meta `json:"meta"`
|
||||||
|
|||||||
7
unifi/setting_ips.generated.go
generated
7
unifi/setting_ips.generated.go
generated
@@ -29,16 +29,15 @@ type SettingIps struct {
|
|||||||
|
|
||||||
AdBlockingConfigurations []SettingIpsAdBlockingConfigurations `json:"ad_blocking_configurations,omitempty"`
|
AdBlockingConfigurations []SettingIpsAdBlockingConfigurations `json:"ad_blocking_configurations,omitempty"`
|
||||||
AdBlockingEnabled bool `json:"ad_blocking_enabled"`
|
AdBlockingEnabled bool `json:"ad_blocking_enabled"`
|
||||||
AdvancedFilteringPreference string `json:"advanced_filtering_preference,omitempty"` // |auto|manual|disabled
|
AdvancedFilteringPreference string `json:"advanced_filtering_preference,omitempty"` // |manual|disabled
|
||||||
DNSFiltering bool `json:"dns_filtering"`
|
DNSFiltering bool `json:"dns_filtering"`
|
||||||
DNSFilters []SettingIpsDNSFilters `json:"dns_filters,omitempty"`
|
DNSFilters []SettingIpsDNSFilters `json:"dns_filters,omitempty"`
|
||||||
EnabledCategories []string `json:"enabled_categories,omitempty"` // emerging-activex|emerging-attackresponse|botcc|emerging-chat|ciarmy|compromised|emerging-dns|emerging-dos|dshield|emerging-exploit|emerging-ftp|emerging-games|emerging-icmp|emerging-icmpinfo|emerging-imap|emerging-inappropriate|emerging-info|emerging-malware|emerging-misc|emerging-mobile|emerging-netbios|emerging-p2p|emerging-policy|emerging-pop3|emerging-rpc|emerging-scada|emerging-scan|emerging-shellcode|emerging-smtp|emerging-snmp|emerging-sql|emerging-telnet|emerging-tftp|tor|emerging-trojan|emerging-useragent|emerging-voip|emerging-webapps|emerging-webclient|emerging-webserver|emerging-worm|exploit-kit|adware-pup|botcc-portgrouped|phishing|threatview-cs-c2|3coresec|chat|coinminer|current-events|drop|hunting|icmp-info|inappropriate|info|ja3|policy|scada
|
EnabledCategories []string `json:"enabled_categories,omitempty"` // emerging-activex|emerging-attackresponse|botcc|emerging-chat|ciarmy|compromised|emerging-dns|emerging-dos|dshield|emerging-exploit|emerging-ftp|emerging-games|emerging-icmp|emerging-icmpinfo|emerging-imap|emerging-inappropriate|emerging-info|emerging-malware|emerging-misc|emerging-mobile|emerging-netbios|emerging-p2p|emerging-policy|emerging-pop3|emerging-rpc|emerging-scada|emerging-scan|emerging-shellcode|emerging-smtp|emerging-snmp|emerging-sql|emerging-telnet|emerging-tftp|tor|emerging-useragent|emerging-voip|emerging-webapps|emerging-webclient|emerging-webserver|emerging-worm|exploit-kit|adware-pup|botcc-portgrouped|phishing|threatview-cs-c2|3coresec|chat|coinminer|current-events|drop|hunting|icmp-info|inappropriate|info|ja3|policy|scada|dark-web-blocker-list|malicious-hosts
|
||||||
EnabledNetworks []string `json:"enabled_networks,omitempty"`
|
EnabledNetworks []string `json:"enabled_networks,omitempty"`
|
||||||
Honeypot []SettingIpsHoneypot `json:"honeypot,omitempty"`
|
Honeypot []SettingIpsHoneypot `json:"honeypot,omitempty"`
|
||||||
HoneypotEnabled bool `json:"honeypot_enabled"`
|
HoneypotEnabled bool `json:"honeypot_enabled"`
|
||||||
IPsMode string `json:"ips_mode,omitempty"` // ids|ips|ipsInline|disabled
|
IPsMode string `json:"ips_mode,omitempty"` // ids|ips|ipsInline|disabled
|
||||||
RestrictIPAddresses bool `json:"restrict_ip_addresses"`
|
MemoryOptimized bool `json:"memory_optimized"`
|
||||||
RestrictTor bool `json:"restrict_tor"`
|
|
||||||
RestrictTorrents bool `json:"restrict_torrents"`
|
RestrictTorrents bool `json:"restrict_torrents"`
|
||||||
Suppression SettingIpsSuppression `json:"suppression,omitempty"`
|
Suppression SettingIpsSuppression `json:"suppression,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
110
unifi/setting_netflow.generated.go
generated
Normal file
110
unifi/setting_netflow.generated.go
generated
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
// Code generated from ace.jar fields *.json files
|
||||||
|
// DO NOT EDIT.
|
||||||
|
|
||||||
|
package unifi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
// just to fix compile issues with the import
|
||||||
|
var (
|
||||||
|
_ context.Context
|
||||||
|
_ fmt.Formatter
|
||||||
|
_ json.Marshaler
|
||||||
|
)
|
||||||
|
|
||||||
|
type SettingNetflow struct {
|
||||||
|
ID string `json:"_id,omitempty"`
|
||||||
|
SiteID string `json:"site_id,omitempty"`
|
||||||
|
|
||||||
|
Hidden bool `json:"attr_hidden,omitempty"`
|
||||||
|
HiddenID string `json:"attr_hidden_id,omitempty"`
|
||||||
|
NoDelete bool `json:"attr_no_delete,omitempty"`
|
||||||
|
NoEdit bool `json:"attr_no_edit,omitempty"`
|
||||||
|
|
||||||
|
Key string `json:"key"`
|
||||||
|
|
||||||
|
AutoEngineIDEnabled bool `json:"auto_engine_id_enabled"`
|
||||||
|
Enabled bool `json:"enabled"`
|
||||||
|
EngineID int `json:"engine_id,omitempty"` // ^$|[1-9][0-9]*
|
||||||
|
ExportFrequency int `json:"export_frequency,omitempty"`
|
||||||
|
NetworkIDs []string `json:"network_ids,omitempty"`
|
||||||
|
Port int `json:"port,omitempty"` // 102[4-9]|10[3-9][0-9]|1[1-9][0-9]{2}|[2-9][0-9]{3}|[1-5][0-9]{4}|[6][0-4][0-9]{3}|[6][5][0-4][0-9]{2}|[6][5][5][0-2][0-9]|[6][5][5][3][0-5]
|
||||||
|
RefreshRate int `json:"refresh_rate,omitempty"`
|
||||||
|
SamplingMode string `json:"sampling_mode,omitempty"` // off|hash|random|deterministic
|
||||||
|
SamplingRate int `json:"sampling_rate,omitempty"` // [2-9]|[1-9][0-9]{1,3}|1[0-5][0-9]{3}|16[0-2][0-9]{2}|163[0-7][0-9]|1638[0-3]|^$
|
||||||
|
Server string `json:"server,omitempty"` // .{0,252}[^\.]$
|
||||||
|
Version int `json:"version,omitempty"` // 5|9|10
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dst *SettingNetflow) UnmarshalJSON(b []byte) error {
|
||||||
|
type Alias SettingNetflow
|
||||||
|
aux := &struct {
|
||||||
|
EngineID emptyStringInt `json:"engine_id"`
|
||||||
|
ExportFrequency emptyStringInt `json:"export_frequency"`
|
||||||
|
Port emptyStringInt `json:"port"`
|
||||||
|
RefreshRate emptyStringInt `json:"refresh_rate"`
|
||||||
|
SamplingRate emptyStringInt `json:"sampling_rate"`
|
||||||
|
Version emptyStringInt `json:"version"`
|
||||||
|
|
||||||
|
*Alias
|
||||||
|
}{
|
||||||
|
Alias: (*Alias)(dst),
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(b, &aux)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to unmarshal alias: %w", err)
|
||||||
|
}
|
||||||
|
dst.EngineID = int(aux.EngineID)
|
||||||
|
dst.ExportFrequency = int(aux.ExportFrequency)
|
||||||
|
dst.Port = int(aux.Port)
|
||||||
|
dst.RefreshRate = int(aux.RefreshRate)
|
||||||
|
dst.SamplingRate = int(aux.SamplingRate)
|
||||||
|
dst.Version = int(aux.Version)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) getSettingNetflow(ctx context.Context, site string) (*SettingNetflow, error) {
|
||||||
|
var respBody struct {
|
||||||
|
Meta meta `json:"meta"`
|
||||||
|
Data []SettingNetflow `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/netflow", site), nil, &respBody)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(respBody.Data) != 1 {
|
||||||
|
return nil, &NotFoundError{}
|
||||||
|
}
|
||||||
|
|
||||||
|
d := respBody.Data[0]
|
||||||
|
return &d, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) updateSettingNetflow(ctx context.Context, site string, d *SettingNetflow) (*SettingNetflow, error) {
|
||||||
|
var respBody struct {
|
||||||
|
Meta meta `json:"meta"`
|
||||||
|
Data []SettingNetflow `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
d.Key = "netflow"
|
||||||
|
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/netflow", site), d, &respBody)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(respBody.Data) != 1 {
|
||||||
|
return nil, &NotFoundError{}
|
||||||
|
}
|
||||||
|
|
||||||
|
new := respBody.Data[0]
|
||||||
|
|
||||||
|
return &new, nil
|
||||||
|
}
|
||||||
16
unifi/setting_netflow.go
Normal file
16
unifi/setting_netflow.go
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
// Code generated from ace.jar fields *.json files
|
||||||
|
// DO NOT EDIT.
|
||||||
|
|
||||||
|
package unifi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (c *Client) GetSettingNetflow(ctx context.Context, site string) (*SettingNetflow, error) {
|
||||||
|
return c.getSettingNetflow(ctx, site)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) UpdateSettingNetflow(ctx context.Context, site string, d *SettingNetflow) (*SettingNetflow, error) {
|
||||||
|
return c.updateSettingNetflow(ctx, site, d)
|
||||||
|
}
|
||||||
28
unifi/setting_radio_ai.generated.go
generated
28
unifi/setting_radio_ai.generated.go
generated
@@ -29,6 +29,7 @@ type SettingRadioAi struct {
|
|||||||
|
|
||||||
AutoAdjustChannelsToCountry bool `json:"auto_adjust_channels_to_country"`
|
AutoAdjustChannelsToCountry bool `json:"auto_adjust_channels_to_country"`
|
||||||
Channels6E []int `json:"channels_6e,omitempty"` // [1-9]|[1-2][0-9]|3[3-9]|[4-5][0-9]|6[0-1]|6[5-9]|[7-8][0-9]|9[0-3]|9[7-9]|1[0-1][0-9]|12[0-5]|129|1[3-4][0-9]|15[0-7]|16[1-9]|1[7-8][0-9]|19[3-9]|2[0-1][0-9]|22[0-1]|22[5-9]|233
|
Channels6E []int `json:"channels_6e,omitempty"` // [1-9]|[1-2][0-9]|3[3-9]|[4-5][0-9]|6[0-1]|6[5-9]|[7-8][0-9]|9[0-3]|9[7-9]|1[0-1][0-9]|12[0-5]|129|1[3-4][0-9]|15[0-7]|16[1-9]|1[7-8][0-9]|19[3-9]|2[0-1][0-9]|22[0-1]|22[5-9]|233
|
||||||
|
ChannelsBlacklist []SettingRadioAiChannelsBlacklist `json:"channels_blacklist,omitempty"`
|
||||||
ChannelsNa []int `json:"channels_na,omitempty"` // 34|36|38|40|42|44|46|48|52|56|60|64|100|104|108|112|116|120|124|128|132|136|140|144|149|153|157|161|165|169
|
ChannelsNa []int `json:"channels_na,omitempty"` // 34|36|38|40|42|44|46|48|52|56|60|64|100|104|108|112|116|120|124|128|132|136|140|144|149|153|157|161|165|169
|
||||||
ChannelsNg []int `json:"channels_ng,omitempty"` // 1|2|3|4|5|6|7|8|9|10|11|12|13|14
|
ChannelsNg []int `json:"channels_ng,omitempty"` // 1|2|3|4|5|6|7|8|9|10|11|12|13|14
|
||||||
CronExpr string `json:"cron_expr,omitempty"`
|
CronExpr string `json:"cron_expr,omitempty"`
|
||||||
@@ -85,6 +86,33 @@ func (dst *SettingRadioAi) UnmarshalJSON(b []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SettingRadioAiChannelsBlacklist struct {
|
||||||
|
Channel int `json:"channel,omitempty"` // [1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-9]|2[0-1][0-9]|22[0-1]|22[5-9]|233
|
||||||
|
ChannelWidth int `json:"channel_width,omitempty"` // 20|40|80|160|240|320
|
||||||
|
Radio string `json:"radio,omitempty"` // na|ng|6e
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dst *SettingRadioAiChannelsBlacklist) UnmarshalJSON(b []byte) error {
|
||||||
|
type Alias SettingRadioAiChannelsBlacklist
|
||||||
|
aux := &struct {
|
||||||
|
Channel emptyStringInt `json:"channel"`
|
||||||
|
ChannelWidth emptyStringInt `json:"channel_width"`
|
||||||
|
|
||||||
|
*Alias
|
||||||
|
}{
|
||||||
|
Alias: (*Alias)(dst),
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(b, &aux)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to unmarshal alias: %w", err)
|
||||||
|
}
|
||||||
|
dst.Channel = int(aux.Channel)
|
||||||
|
dst.ChannelWidth = int(aux.ChannelWidth)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Client) getSettingRadioAi(ctx context.Context, site string) (*SettingRadioAi, error) {
|
func (c *Client) getSettingRadioAi(ctx context.Context, site string) (*SettingRadioAi, error) {
|
||||||
var respBody struct {
|
var respBody struct {
|
||||||
Meta meta `json:"meta"`
|
Meta meta `json:"meta"`
|
||||||
|
|||||||
2
unifi/setting_rsyslogd.generated.go
generated
2
unifi/setting_rsyslogd.generated.go
generated
@@ -27,9 +27,11 @@ type SettingRsyslogd struct {
|
|||||||
|
|
||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
|
|
||||||
|
Contents []string `json:"contents,omitempty"` // device|client|firewall_default_policy|triggers|updates|admin_activity|critical|security_detections|vpn
|
||||||
Debug bool `json:"debug"`
|
Debug bool `json:"debug"`
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
IP string `json:"ip,omitempty"`
|
IP string `json:"ip,omitempty"`
|
||||||
|
LogAllContents bool `json:"log_all_contents"`
|
||||||
NetconsoleEnabled bool `json:"netconsole_enabled"`
|
NetconsoleEnabled bool `json:"netconsole_enabled"`
|
||||||
NetconsoleHost string `json:"netconsole_host,omitempty"`
|
NetconsoleHost string `json:"netconsole_host,omitempty"`
|
||||||
NetconsolePort int `json:"netconsole_port,omitempty"` // [1-9][0-9]{0,3}|[1-5][0-9]{4}|[6][0-4][0-9]{3}|[6][5][0-4][0-9]{2}|[6][5][5][0-2][0-9]|[6][5][5][3][0-5]
|
NetconsolePort int `json:"netconsole_port,omitempty"` // [1-9][0-9]{0,3}|[1-5][0-9]{4}|[6][0-4][0-9]{3}|[6][5][0-4][0-9]{2}|[6][5][5][0-2][0-9]|[6][5][5][3][0-5]
|
||||||
|
|||||||
28
unifi/setting_usg.generated.go
generated
28
unifi/setting_usg.generated.go
generated
@@ -41,11 +41,9 @@ type SettingUsg struct {
|
|||||||
DHCPRelayServer3 string `json:"dhcp_relay_server_3"` // ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^$
|
DHCPRelayServer3 string `json:"dhcp_relay_server_3"` // ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^$
|
||||||
DHCPRelayServer4 string `json:"dhcp_relay_server_4"` // ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^$
|
DHCPRelayServer4 string `json:"dhcp_relay_server_4"` // ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^$
|
||||||
DHCPRelayServer5 string `json:"dhcp_relay_server_5"` // ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^$
|
DHCPRelayServer5 string `json:"dhcp_relay_server_5"` // ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^$
|
||||||
|
DNSVerification SettingUsgDNSVerification `json:"dns_verification,omitempty"`
|
||||||
DNSmasqAllServers bool `json:"dnsmasq_all_servers"`
|
DNSmasqAllServers bool `json:"dnsmasq_all_servers"`
|
||||||
EchoServer string `json:"echo_server,omitempty"` // [^\"\' ]{1,255}
|
EchoServer string `json:"echo_server,omitempty"` // [^\"\' ]{1,255}
|
||||||
FirewallGuestDefaultLog bool `json:"firewall_guest_default_log"`
|
|
||||||
FirewallLanDefaultLog bool `json:"firewall_lan_default_log"`
|
|
||||||
FirewallWANDefaultLog bool `json:"firewall_wan_default_log"`
|
|
||||||
FtpModule bool `json:"ftp_module"`
|
FtpModule bool `json:"ftp_module"`
|
||||||
GeoIPFilteringBlock string `json:"geo_ip_filtering_block,omitempty"` // block|allow
|
GeoIPFilteringBlock string `json:"geo_ip_filtering_block,omitempty"` // block|allow
|
||||||
GeoIPFilteringCountries string `json:"geo_ip_filtering_countries,omitempty"` // ^([A-Z]{2})?(,[A-Z]{2}){0,149}$
|
GeoIPFilteringCountries string `json:"geo_ip_filtering_countries,omitempty"` // ^([A-Z]{2})?(,[A-Z]{2}){0,149}$
|
||||||
@@ -79,6 +77,7 @@ type SettingUsg struct {
|
|||||||
TimeoutSettingPreference string `json:"timeout_setting_preference,omitempty"` // auto|manual
|
TimeoutSettingPreference string `json:"timeout_setting_preference,omitempty"` // auto|manual
|
||||||
UDPOtherTimeout int `json:"udp_other_timeout,omitempty"`
|
UDPOtherTimeout int `json:"udp_other_timeout,omitempty"`
|
||||||
UDPStreamTimeout int `json:"udp_stream_timeout,omitempty"`
|
UDPStreamTimeout int `json:"udp_stream_timeout,omitempty"`
|
||||||
|
UnbindWANMonitors bool `json:"unbind_wan_monitors"`
|
||||||
UpnpEnabled bool `json:"upnp_enabled"`
|
UpnpEnabled bool `json:"upnp_enabled"`
|
||||||
UpnpNATPmpEnabled bool `json:"upnp_nat_pmp_enabled"`
|
UpnpNATPmpEnabled bool `json:"upnp_nat_pmp_enabled"`
|
||||||
UpnpSecureMode bool `json:"upnp_secure_mode"`
|
UpnpSecureMode bool `json:"upnp_secure_mode"`
|
||||||
@@ -136,6 +135,29 @@ func (dst *SettingUsg) UnmarshalJSON(b []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SettingUsgDNSVerification struct {
|
||||||
|
Domain string `json:"domain,omitempty"`
|
||||||
|
PrimaryDNSServer string `json:"primary_dns_server,omitempty"`
|
||||||
|
SecondaryDNSServer string `json:"secondary_dns_server,omitempty"`
|
||||||
|
SettingPreference string `json:"setting_preference,omitempty"` // auto|manual
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dst *SettingUsgDNSVerification) UnmarshalJSON(b []byte) error {
|
||||||
|
type Alias SettingUsgDNSVerification
|
||||||
|
aux := &struct {
|
||||||
|
*Alias
|
||||||
|
}{
|
||||||
|
Alias: (*Alias)(dst),
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(b, &aux)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to unmarshal alias: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Client) getSettingUsg(ctx context.Context, site string) (*SettingUsg, error) {
|
func (c *Client) getSettingUsg(ctx context.Context, site string) (*SettingUsg, error) {
|
||||||
var respBody struct {
|
var respBody struct {
|
||||||
Meta meta `json:"meta"`
|
Meta meta `json:"meta"`
|
||||||
|
|||||||
@@ -190,11 +190,23 @@ func (c *Client) Login(ctx context.Context, user, pass string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) do(ctx context.Context, method, relativeURL string, reqBody interface{}, respBody interface{}) error {
|
func (c *Client) do(ctx context.Context, method, relativeURL string, reqBody any, respBody any) error {
|
||||||
|
return c.do_versioned(ctx, "V1", method, relativeURL, reqBody, respBody)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) do_versioned(ctx context.Context, version, method, relativeURL string, reqBody any, respBody any) error {
|
||||||
// single threading requests, this is mostly to assist in CSRF token propagation
|
// single threading requests, this is mostly to assist in CSRF token propagation
|
||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
|
|
||||||
|
var apiPath string
|
||||||
|
|
||||||
|
if version == "V2" {
|
||||||
|
apiPath = c.apiV2Path
|
||||||
|
} else {
|
||||||
|
apiPath = c.apiPath
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
reqReader io.Reader
|
reqReader io.Reader
|
||||||
err error
|
err error
|
||||||
@@ -213,7 +225,7 @@ func (c *Client) do(ctx context.Context, method, relativeURL string, reqBody int
|
|||||||
return fmt.Errorf("unable to parse URL: %s %s %w", method, relativeURL, err)
|
return fmt.Errorf("unable to parse URL: %s %s %w", method, relativeURL, err)
|
||||||
}
|
}
|
||||||
if !strings.HasPrefix(relativeURL, "/") && !reqURL.IsAbs() {
|
if !strings.HasPrefix(relativeURL, "/") && !reqURL.IsAbs() {
|
||||||
reqURL.Path = path.Join(c.apiPath, reqURL.Path)
|
reqURL.Path = path.Join(apiPath, reqURL.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
url := c.baseURL.ResolveReference(reqURL)
|
url := c.baseURL.ResolveReference(reqURL)
|
||||||
@@ -243,7 +255,7 @@ func (c *Client) do(ctx context.Context, method, relativeURL string, reqBody int
|
|||||||
c.csrf = resp.Header.Get("X-Csrf-Token")
|
c.csrf = resp.Header.Get("X-Csrf-Token")
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusCreated {
|
||||||
errBody := struct {
|
errBody := struct {
|
||||||
Meta meta `json:"meta"`
|
Meta meta `json:"meta"`
|
||||||
Data []struct {
|
Data []struct {
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ func (c *Client) CreateUser(ctx context.Context, site string, d *User) (*User, e
|
|||||||
return &user, nil
|
return &user, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) stamgr(ctx context.Context, site, cmd string, data map[string]interface{}) ([]User, error) {
|
func (c *Client) stamgr(ctx context.Context, site, cmd string, data map[string]any) ([]User, error) {
|
||||||
reqBody := map[string]interface{}{}
|
reqBody := map[string]any{}
|
||||||
|
|
||||||
for k, v := range data {
|
for k, v := range data {
|
||||||
reqBody[k] = v
|
reqBody[k] = v
|
||||||
@@ -94,7 +94,7 @@ func (c *Client) stamgr(ctx context.Context, site, cmd string, data map[string]i
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) BlockUserByMAC(ctx context.Context, site, mac string) error {
|
func (c *Client) BlockUserByMAC(ctx context.Context, site, mac string) error {
|
||||||
users, err := c.stamgr(ctx, site, "block-sta", map[string]interface{}{
|
users, err := c.stamgr(ctx, site, "block-sta", map[string]any{
|
||||||
"mac": mac,
|
"mac": mac,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -107,7 +107,7 @@ func (c *Client) BlockUserByMAC(ctx context.Context, site, mac string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) UnblockUserByMAC(ctx context.Context, site, mac string) error {
|
func (c *Client) UnblockUserByMAC(ctx context.Context, site, mac string) error {
|
||||||
users, err := c.stamgr(ctx, site, "unblock-sta", map[string]interface{}{
|
users, err := c.stamgr(ctx, site, "unblock-sta", map[string]any{
|
||||||
"mac": mac,
|
"mac": mac,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -120,7 +120,7 @@ func (c *Client) UnblockUserByMAC(ctx context.Context, site, mac string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) DeleteUserByMAC(ctx context.Context, site, mac string) error {
|
func (c *Client) DeleteUserByMAC(ctx context.Context, site, mac string) error {
|
||||||
users, err := c.stamgr(ctx, site, "forget-sta", map[string]interface{}{
|
users, err := c.stamgr(ctx, site, "forget-sta", map[string]any{
|
||||||
"macs": []string{mac},
|
"macs": []string{mac},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -133,7 +133,7 @@ func (c *Client) DeleteUserByMAC(ctx context.Context, site, mac string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) KickUserByMAC(ctx context.Context, site, mac string) error {
|
func (c *Client) KickUserByMAC(ctx context.Context, site, mac string) error {
|
||||||
users, err := c.stamgr(ctx, site, "kick-sta", map[string]interface{}{
|
users, err := c.stamgr(ctx, site, "kick-sta", map[string]any{
|
||||||
"mac": mac,
|
"mac": mac,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -146,7 +146,7 @@ func (c *Client) KickUserByMAC(ctx context.Context, site, mac string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) OverrideUserFingerprint(ctx context.Context, site, mac string, devIdOveride int) error {
|
func (c *Client) OverrideUserFingerprint(ctx context.Context, site, mac string, devIdOveride int) error {
|
||||||
reqBody := map[string]interface{}{
|
reqBody := map[string]any{
|
||||||
"mac": mac,
|
"mac": mac,
|
||||||
"dev_id_override": devIdOveride,
|
"dev_id_override": devIdOveride,
|
||||||
"search_query": "",
|
"search_query": "",
|
||||||
|
|||||||
2
unifi/version.generated.go
generated
2
unifi/version.generated.go
generated
@@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
package unifi
|
package unifi
|
||||||
|
|
||||||
const UnifiVersion = "8.3.32"
|
const UnifiVersion = "9.0.114"
|
||||||
|
|||||||
230
unifi/wlan.generated.go
generated
230
unifi/wlan.generated.go
generated
@@ -41,11 +41,12 @@ type WLAN struct {
|
|||||||
DTIMNg int `json:"dtim_ng,omitempty"` // ^([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^$
|
DTIMNg int `json:"dtim_ng,omitempty"` // ^([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^$
|
||||||
ElementAdopt bool `json:"element_adopt"`
|
ElementAdopt bool `json:"element_adopt"`
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
|
EnhancedIot bool `json:"enhanced_iot"`
|
||||||
FastRoamingEnabled bool `json:"fast_roaming_enabled"`
|
FastRoamingEnabled bool `json:"fast_roaming_enabled"`
|
||||||
GroupRekey int `json:"group_rekey,omitempty"` // ^(0|[6-9][0-9]|[1-9][0-9]{2,3}|[1-7][0-9]{4}|8[0-5][0-9]{3}|86[0-3][0-9][0-9]|86400)$
|
GroupRekey int `json:"group_rekey,omitempty"` // ^(0|[6-9][0-9]|[1-9][0-9]{2,3}|[1-7][0-9]{4}|8[0-5][0-9]{3}|86[0-3][0-9][0-9]|86400)$
|
||||||
HideSSID bool `json:"hide_ssid"`
|
HideSSID bool `json:"hide_ssid"`
|
||||||
|
Hotspot2 WLANHotspot2 `json:"hotspot2,omitempty"`
|
||||||
Hotspot2ConfEnabled bool `json:"hotspot2conf_enabled"`
|
Hotspot2ConfEnabled bool `json:"hotspot2conf_enabled"`
|
||||||
Hotspot2ConfID string `json:"hotspot2conf_id"`
|
|
||||||
IappEnabled bool `json:"iapp_enabled"`
|
IappEnabled bool `json:"iapp_enabled"`
|
||||||
IsGuest bool `json:"is_guest"`
|
IsGuest bool `json:"is_guest"`
|
||||||
L2Isolation bool `json:"l2_isolation"`
|
L2Isolation bool `json:"l2_isolation"`
|
||||||
@@ -65,6 +66,8 @@ type WLAN struct {
|
|||||||
Name string `json:"name,omitempty"` // .{1,32}
|
Name string `json:"name,omitempty"` // .{1,32}
|
||||||
NameCombineEnabled bool `json:"name_combine_enabled"`
|
NameCombineEnabled bool `json:"name_combine_enabled"`
|
||||||
NameCombineSuffix string `json:"name_combine_suffix,omitempty"` // .{0,8}
|
NameCombineSuffix string `json:"name_combine_suffix,omitempty"` // .{0,8}
|
||||||
|
NasIDentifier string `json:"nas_identifier,omitempty"` // .{0,48}
|
||||||
|
NasIDentifierType string `json:"nas_identifier_type,omitempty"` // ap_name|ap_mac|bssid|site_name|custom
|
||||||
NetworkID string `json:"networkconf_id"`
|
NetworkID string `json:"networkconf_id"`
|
||||||
No2GhzOui bool `json:"no2ghz_oui"`
|
No2GhzOui bool `json:"no2ghz_oui"`
|
||||||
OptimizeIotWifiConnectivity bool `json:"optimize_iot_wifi_connectivity"`
|
OptimizeIotWifiConnectivity bool `json:"optimize_iot_wifi_connectivity"`
|
||||||
@@ -160,6 +163,188 @@ func (dst *WLAN) UnmarshalJSON(b []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WLANCapab struct {
|
||||||
|
Port int `json:"port,omitempty"` // ^(0|[1-9][0-9]{0,3}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])|$
|
||||||
|
Protocol string `json:"protocol,omitempty"` // icmp|tcp_udp|tcp|udp|esp
|
||||||
|
Status string `json:"status,omitempty"` // closed|open|unknown
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dst *WLANCapab) UnmarshalJSON(b []byte) error {
|
||||||
|
type Alias WLANCapab
|
||||||
|
aux := &struct {
|
||||||
|
Port emptyStringInt `json:"port"`
|
||||||
|
|
||||||
|
*Alias
|
||||||
|
}{
|
||||||
|
Alias: (*Alias)(dst),
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(b, &aux)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to unmarshal alias: %w", err)
|
||||||
|
}
|
||||||
|
dst.Port = int(aux.Port)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type WLANCellularNetworkList struct {
|
||||||
|
CountryCode int `json:"country_code,omitempty"` // [1-9]{1}[0-9]{0,3}
|
||||||
|
Mcc int `json:"mcc,omitempty"`
|
||||||
|
Mnc int `json:"mnc,omitempty"`
|
||||||
|
Name string `json:"name,omitempty"` // .{1,128}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dst *WLANCellularNetworkList) UnmarshalJSON(b []byte) error {
|
||||||
|
type Alias WLANCellularNetworkList
|
||||||
|
aux := &struct {
|
||||||
|
CountryCode emptyStringInt `json:"country_code"`
|
||||||
|
Mcc emptyStringInt `json:"mcc"`
|
||||||
|
Mnc emptyStringInt `json:"mnc"`
|
||||||
|
|
||||||
|
*Alias
|
||||||
|
}{
|
||||||
|
Alias: (*Alias)(dst),
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(b, &aux)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to unmarshal alias: %w", err)
|
||||||
|
}
|
||||||
|
dst.CountryCode = int(aux.CountryCode)
|
||||||
|
dst.Mcc = int(aux.Mcc)
|
||||||
|
dst.Mnc = int(aux.Mnc)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type WLANFriendlyName struct {
|
||||||
|
Language string `json:"language,omitempty"` // [a-z]{3}
|
||||||
|
Text string `json:"text,omitempty"` // .{1,128}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dst *WLANFriendlyName) UnmarshalJSON(b []byte) error {
|
||||||
|
type Alias WLANFriendlyName
|
||||||
|
aux := &struct {
|
||||||
|
*Alias
|
||||||
|
}{
|
||||||
|
Alias: (*Alias)(dst),
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(b, &aux)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to unmarshal alias: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type WLANHotspot2 struct {
|
||||||
|
Capab []WLANCapab `json:"capab,omitempty"`
|
||||||
|
CellularNetworkList []WLANCellularNetworkList `json:"cellular_network_list,omitempty"`
|
||||||
|
DomainNameList []string `json:"domain_name_list,omitempty"` // .{1,128}
|
||||||
|
FriendlyName []WLANFriendlyName `json:"friendly_name,omitempty"`
|
||||||
|
IPaddrTypeAvailV4 int `json:"ipaddr_type_avail_v4,omitempty"` // 0|1|2|3|4|5|6|7
|
||||||
|
IPaddrTypeAvailV6 int `json:"ipaddr_type_avail_v6,omitempty"` // 0|1|2
|
||||||
|
MetricsDownlinkLoad int `json:"metrics_downlink_load,omitempty"`
|
||||||
|
MetricsDownlinkLoadSet bool `json:"metrics_downlink_load_set"`
|
||||||
|
MetricsDownlinkSpeed int `json:"metrics_downlink_speed,omitempty"`
|
||||||
|
MetricsDownlinkSpeedSet bool `json:"metrics_downlink_speed_set"`
|
||||||
|
MetricsInfoAtCapacity bool `json:"metrics_info_at_capacity"`
|
||||||
|
MetricsInfoLinkStatus string `json:"metrics_info_link_status,omitempty"` // up|down|test
|
||||||
|
MetricsInfoSymmetric bool `json:"metrics_info_symmetric"`
|
||||||
|
MetricsMeasurement int `json:"metrics_measurement,omitempty"`
|
||||||
|
MetricsMeasurementSet bool `json:"metrics_measurement_set"`
|
||||||
|
MetricsStatus bool `json:"metrics_status"`
|
||||||
|
MetricsUplinkLoad int `json:"metrics_uplink_load,omitempty"`
|
||||||
|
MetricsUplinkLoadSet bool `json:"metrics_uplink_load_set"`
|
||||||
|
MetricsUplinkSpeed int `json:"metrics_uplink_speed,omitempty"`
|
||||||
|
MetricsUplinkSpeedSet bool `json:"metrics_uplink_speed_set"`
|
||||||
|
NaiRealmList []WLANNaiRealmList `json:"nai_realm_list,omitempty"`
|
||||||
|
NetworkType int `json:"network_type,omitempty"` // 0|1|2|3|4|5|14|15
|
||||||
|
RoamingConsortiumList []WLANRoamingConsortiumList `json:"roaming_consortium_list,omitempty"`
|
||||||
|
VenueGroup int `json:"venue_group,omitempty"` // 0|1|2|3|4|5|6|7|8|9|10|11
|
||||||
|
VenueName []WLANVenueName `json:"venue_name,omitempty"`
|
||||||
|
VenueType int `json:"venue_type,omitempty"` // 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dst *WLANHotspot2) UnmarshalJSON(b []byte) error {
|
||||||
|
type Alias WLANHotspot2
|
||||||
|
aux := &struct {
|
||||||
|
IPaddrTypeAvailV4 emptyStringInt `json:"ipaddr_type_avail_v4"`
|
||||||
|
IPaddrTypeAvailV6 emptyStringInt `json:"ipaddr_type_avail_v6"`
|
||||||
|
MetricsDownlinkLoad emptyStringInt `json:"metrics_downlink_load"`
|
||||||
|
MetricsDownlinkSpeed emptyStringInt `json:"metrics_downlink_speed"`
|
||||||
|
MetricsMeasurement emptyStringInt `json:"metrics_measurement"`
|
||||||
|
MetricsUplinkLoad emptyStringInt `json:"metrics_uplink_load"`
|
||||||
|
MetricsUplinkSpeed emptyStringInt `json:"metrics_uplink_speed"`
|
||||||
|
NetworkType emptyStringInt `json:"network_type"`
|
||||||
|
VenueGroup emptyStringInt `json:"venue_group"`
|
||||||
|
VenueType emptyStringInt `json:"venue_type"`
|
||||||
|
|
||||||
|
*Alias
|
||||||
|
}{
|
||||||
|
Alias: (*Alias)(dst),
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(b, &aux)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to unmarshal alias: %w", err)
|
||||||
|
}
|
||||||
|
dst.IPaddrTypeAvailV4 = int(aux.IPaddrTypeAvailV4)
|
||||||
|
dst.IPaddrTypeAvailV6 = int(aux.IPaddrTypeAvailV6)
|
||||||
|
dst.MetricsDownlinkLoad = int(aux.MetricsDownlinkLoad)
|
||||||
|
dst.MetricsDownlinkSpeed = int(aux.MetricsDownlinkSpeed)
|
||||||
|
dst.MetricsMeasurement = int(aux.MetricsMeasurement)
|
||||||
|
dst.MetricsUplinkLoad = int(aux.MetricsUplinkLoad)
|
||||||
|
dst.MetricsUplinkSpeed = int(aux.MetricsUplinkSpeed)
|
||||||
|
dst.NetworkType = int(aux.NetworkType)
|
||||||
|
dst.VenueGroup = int(aux.VenueGroup)
|
||||||
|
dst.VenueType = int(aux.VenueType)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type WLANNaiRealmList struct {
|
||||||
|
AuthIDs []int `json:"auth_ids,omitempty"` // 0|1|2|3|4|5
|
||||||
|
AuthVals []int `json:"auth_vals,omitempty"` // 0|1|2|3|4|5|6|7|8|9|10
|
||||||
|
EapMethod int `json:"eap_method,omitempty"` // 13|21|18|23|50
|
||||||
|
Encoding int `json:"encoding,omitempty"` // 0|1
|
||||||
|
Name string `json:"name,omitempty"` // .{1,128}
|
||||||
|
Status bool `json:"status"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dst *WLANNaiRealmList) UnmarshalJSON(b []byte) error {
|
||||||
|
type Alias WLANNaiRealmList
|
||||||
|
aux := &struct {
|
||||||
|
AuthIDs []emptyStringInt `json:"auth_ids"`
|
||||||
|
AuthVals []emptyStringInt `json:"auth_vals"`
|
||||||
|
EapMethod emptyStringInt `json:"eap_method"`
|
||||||
|
Encoding emptyStringInt `json:"encoding"`
|
||||||
|
|
||||||
|
*Alias
|
||||||
|
}{
|
||||||
|
Alias: (*Alias)(dst),
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(b, &aux)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to unmarshal alias: %w", err)
|
||||||
|
}
|
||||||
|
dst.AuthIDs = make([]int, len(aux.AuthIDs))
|
||||||
|
for i, v := range aux.AuthIDs {
|
||||||
|
dst.AuthIDs[i] = int(v)
|
||||||
|
}
|
||||||
|
dst.AuthVals = make([]int, len(aux.AuthVals))
|
||||||
|
for i, v := range aux.AuthVals {
|
||||||
|
dst.AuthVals[i] = int(v)
|
||||||
|
}
|
||||||
|
dst.EapMethod = int(aux.EapMethod)
|
||||||
|
dst.Encoding = int(aux.Encoding)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type WLANPrivatePresharedKeys struct {
|
type WLANPrivatePresharedKeys struct {
|
||||||
NetworkID string `json:"networkconf_id"`
|
NetworkID string `json:"networkconf_id"`
|
||||||
Password string `json:"password,omitempty"` // [\x20-\x7E]{8,255}
|
Password string `json:"password,omitempty"` // [\x20-\x7E]{8,255}
|
||||||
@@ -181,6 +366,27 @@ func (dst *WLANPrivatePresharedKeys) UnmarshalJSON(b []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WLANRoamingConsortiumList struct {
|
||||||
|
Name string `json:"name,omitempty"` // .{1,128}
|
||||||
|
Oid string `json:"oid,omitempty"` // .{1,128}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dst *WLANRoamingConsortiumList) UnmarshalJSON(b []byte) error {
|
||||||
|
type Alias WLANRoamingConsortiumList
|
||||||
|
aux := &struct {
|
||||||
|
*Alias
|
||||||
|
}{
|
||||||
|
Alias: (*Alias)(dst),
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(b, &aux)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to unmarshal alias: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type WLANSaePsk struct {
|
type WLANSaePsk struct {
|
||||||
ID string `json:"id"` // .{0,128}
|
ID string `json:"id"` // .{0,128}
|
||||||
MAC string `json:"mac,omitempty"` // ^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})$
|
MAC string `json:"mac,omitempty"` // ^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})$
|
||||||
@@ -238,6 +444,28 @@ func (dst *WLANScheduleWithDuration) UnmarshalJSON(b []byte) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type WLANVenueName struct {
|
||||||
|
Language string `json:"language,omitempty"` // [a-z]{0,3}
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
Url string `json:"url,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (dst *WLANVenueName) UnmarshalJSON(b []byte) error {
|
||||||
|
type Alias WLANVenueName
|
||||||
|
aux := &struct {
|
||||||
|
*Alias
|
||||||
|
}{
|
||||||
|
Alias: (*Alias)(dst),
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(b, &aux)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to unmarshal alias: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Client) listWLAN(ctx context.Context, site string) ([]WLAN, error) {
|
func (c *Client) listWLAN(ctx context.Context, site string) ([]WLAN, error) {
|
||||||
var respBody struct {
|
var respBody struct {
|
||||||
Meta meta `json:"meta"`
|
Meta meta `json:"meta"`
|
||||||
|
|||||||
Reference in New Issue
Block a user