diff --git a/.gitignore b/.gitignore index d1597a7..271f744 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ - .envrc .vscode dist diff --git a/go.mod b/go.mod index d419f22..3480dd1 100644 --- a/go.mod +++ b/go.mod @@ -18,6 +18,7 @@ require ( github.com/hashicorp/terraform-plugin-sdk v1.4.1 github.com/hashicorp/terraform-svchost v0.0.0-20191119180714-d2e4933b9136 // indirect github.com/hashicorp/yamux v0.0.0-20190923154419-df201c70410d // indirect + github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334 github.com/jstemmer/go-junit-report v0.9.1 // indirect github.com/mattn/go-isatty v0.0.11 // indirect github.com/posener/complete v1.2.3 // indirect diff --git a/go.sum b/go.sum index 03972a7..0916478 100644 --- a/go.sum +++ b/go.sum @@ -228,6 +228,8 @@ github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKe github.com/hashicorp/yamux v0.0.0-20190923154419-df201c70410d h1:W+SIwDdl3+jXWeidYySAgzytE3piq6GumXeBjFBG67c= github.com/hashicorp/yamux v0.0.0-20190923154419-df201c70410d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334 h1:VHgatEHNcBFEB7inlalqfNqw65aNkM1lGX2yt3NmbS8= +github.com/iancoleman/strcase v0.0.0-20191112232945-16388991a334/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= diff --git a/internal/provider/resource_network.go b/internal/provider/resource_network.go index 814bb10..d9b0fc6 100644 --- a/internal/provider/resource_network.go +++ b/internal/provider/resource_network.go @@ -1,9 +1,6 @@ package provider import ( - "fmt" - "strconv" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -89,7 +86,7 @@ func resourceNetworkGetResourceData(d *schema.ResourceData) (*unifi.Network, err return &unifi.Network{ Name: d.Get("name").(string), Purpose: d.Get("purpose").(string), - VLAN: fmt.Sprintf("%d", d.Get("vlan_id").(int)), + VLAN: vlan, IPSubnet: d.Get("subnet").(string), NetworkGroup: d.Get("network_group").(string), DHCPDStart: d.Get("dhcp_start").(string), @@ -108,13 +105,9 @@ func resourceNetworkGetResourceData(d *schema.ResourceData) (*unifi.Network, err } func resourceNetworkSetResourceData(resp *unifi.Network, d *schema.ResourceData) error { - var err error vlan := 0 if resp.VLANEnabled { - vlan, err = strconv.Atoi(resp.VLAN) - if err != nil { - return err - } + vlan = resp.VLAN } dhcpLease := resp.DHCPDLeaseTime diff --git a/internal/provider/resource_wlan.go b/internal/provider/resource_wlan.go index 2d53d74..f9dc716 100644 --- a/internal/provider/resource_wlan.go +++ b/internal/provider/resource_wlan.go @@ -1,9 +1,6 @@ package provider import ( - "fmt" - "strconv" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" @@ -68,7 +65,7 @@ func resourceWLANCreate(d *schema.ResourceData, meta interface{}) error { req := &unifi.WLAN{ Name: d.Get("name").(string), - VLAN: fmt.Sprintf("%d", vlan), + VLAN: vlan, XPassphrase: d.Get("passphrase").(string), HideSSID: d.Get("hide_ssid").(bool), IsGuest: d.Get("is_guest").(bool), @@ -101,13 +98,9 @@ func resourceWLANCreate(d *schema.ResourceData, meta interface{}) error { } func resourceWLANSetResourceData(resp *unifi.WLAN, d *schema.ResourceData) error { - var err error vlan := 0 if resp.VLANEnabled { - vlan, err = strconv.Atoi(resp.VLAN) - if err != nil { - return err - } + vlan = resp.VLAN } d.Set("name", resp.Name) diff --git a/unifi/account.generated.go b/unifi/account.generated.go new file mode 100644 index 0000000..0bc03d7 --- /dev/null +++ b/unifi/account.generated.go @@ -0,0 +1,22 @@ +// Code generated from ace.jar fields *.json files +// DO NOT EDIT. + +package unifi + +type Account 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"` + + IP string `json:"ip"` // ^(([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"` // ^[^"' ]+$ + TunnelConfigType string `json:"tunnel_config_type,omitempty"` // vpn|802.1x|custom + TunnelMediumType int `json:"tunnel_medium_type,omitempty"` // [1-9]|1[0-5]|^$ + TunnelType int `json:"tunnel_type,omitempty"` // [1-9]|1[0-3]|^$ + 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"` +} diff --git a/unifi/broadcast_group.generated.go b/unifi/broadcast_group.generated.go new file mode 100644 index 0000000..0ff5934 --- /dev/null +++ b/unifi/broadcast_group.generated.go @@ -0,0 +1,17 @@ +// Code generated from ace.jar fields *.json files +// DO NOT EDIT. + +package unifi + +type BroadcastGroup 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"` + + MemberTable []string `json:"member_table,omitempty"` + Name string `json:"name,omitempty"` +} diff --git a/unifi/dhcp_option.generated.go b/unifi/dhcp_option.generated.go new file mode 100644 index 0000000..635a51e --- /dev/null +++ b/unifi/dhcp_option.generated.go @@ -0,0 +1,20 @@ +// Code generated from ace.jar fields *.json files +// DO NOT EDIT. + +package unifi + +type DHCPOption 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"` + + Code string `json:"code,omitempty"` // ^(?!(?:15|42|43|44|51|66|67|252)$)([7-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-4])$ + Name string `json:"name,omitempty"` // ^[A-Za-z0-9-_]{1,25}$ + Signed bool `json:"signed"` + Type string `json:"type,omitempty"` // ^(boolean|hexarray|integer|ipaddress|macaddress|text)$ + Width int `json:"width,omitempty"` // ^(8|16|32)$ +} diff --git a/unifi/dpi_app.generated.go b/unifi/dpi_app.generated.go new file mode 100644 index 0000000..e348338 --- /dev/null +++ b/unifi/dpi_app.generated.go @@ -0,0 +1,23 @@ +// Code generated from ace.jar fields *.json files +// DO NOT EDIT. + +package unifi + +type DpiApp 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"` + + Apps []int `json:"apps,omitempty"` + Blocked bool `json:"blocked"` + Cats []int `json:"cats,omitempty"` + Enabled bool `json:"enabled"` + Log bool `json:"log"` + Name string `json:"name,omitempty"` // .{1,128} + QOSRateMaxDown int `json:"qos_rate_max_down,omitempty"` // -1|[2-9]|[1-9][0-9]{1,4}|100000|10[0-1][0-9]{3}|102[0-3][0-9]{2}|102400 + QOSRateMaxUp int `json:"qos_rate_max_up,omitempty"` // -1|[2-9]|[1-9][0-9]{1,4}|100000|10[0-1][0-9]{3}|102[0-3][0-9]{2}|102400 +} diff --git a/unifi/dpi_group.generated.go b/unifi/dpi_group.generated.go new file mode 100644 index 0000000..6a9097a --- /dev/null +++ b/unifi/dpi_group.generated.go @@ -0,0 +1,18 @@ +// Code generated from ace.jar fields *.json files +// DO NOT EDIT. + +package unifi + +type DpiGroup 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"` + + DPIappIDs []string `json:"dpiapp_ids,omitempty"` // [\d\w]+ + Enabled bool `json:"enabled"` + Name string `json:"name,omitempty"` // .{1,128} +} diff --git a/unifi/dynamic_dns.generated.go b/unifi/dynamic_dns.generated.go new file mode 100644 index 0000000..6b54bc6 --- /dev/null +++ b/unifi/dynamic_dns.generated.go @@ -0,0 +1,23 @@ +// Code generated from ace.jar fields *.json files +// DO NOT EDIT. + +package unifi + +type DynamicDNS 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"` + + CustomService string `json:"custom_service,omitempty"` // ^[^"' ]+$ + HostName string `json:"host_name,omitempty"` // ^[^"' ]+$ + Interface string `json:"interface,omitempty"` // wan|wan2 + Login string `json:"login,omitempty"` // ^[^"' ]+$ + Options []string `json:"options,omitempty"` // ^[^"' ]+$ + Server string `json:"server"` // ^[^"' ]+$|^$ + Service string `json:"service,omitempty"` // afraid|changeip|cloudflare|dnspark|dslreports|dyndns|easydns|googledomains|namecheap|noip|sitelutions|zoneedit|custom + XPassword string `json:"x_password,omitempty"` // ^[^"' ]+$ +} diff --git a/unifi/fields/5.12.35/Account.json b/unifi/fields/5.12.35/Account.json new file mode 100644 index 0000000..9f104aa --- /dev/null +++ b/unifi/fields/5.12.35/Account.json @@ -0,0 +1,9 @@ +{ + "name": "^[^\"' ]+$", + "x_password": "", + "vlan": "[2-9]|[1-9][0-9]{1,2}|[1-3][0-9]{3}|400[0-9]|^$", + "ip":"^(([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])$|^$", + "tunnel_config_type": "vpn|802.1x|custom", + "tunnel_type": "[1-9]|1[0-3]|^$", + "tunnel_medium_type": "[1-9]|1[0-5]|^$" +} diff --git a/unifi/fields/5.12.35/BroadcastGroup.json b/unifi/fields/5.12.35/BroadcastGroup.json new file mode 100644 index 0000000..677d265 --- /dev/null +++ b/unifi/fields/5.12.35/BroadcastGroup.json @@ -0,0 +1,4 @@ +{ + "name": "", + "member_table": [""] +} diff --git a/unifi/fields/5.12.35/ChannelPlan.json b/unifi/fields/5.12.35/ChannelPlan.json new file mode 100644 index 0000000..a790643 --- /dev/null +++ b/unifi/fields/5.12.35/ChannelPlan.json @@ -0,0 +1,35 @@ +{ + "conf_source": "manual|radio-ai", + "date": "^$|^(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])Z?$", + "fitness": "^[0-9]+\\.?[0-9]*$", + "note": ".{0,1024}", + "radio": "na|ng|ng\\+na", + "radio_table": [{ + "device_mac": "^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})$", + "name": "[a-z]*[0-9]*", + "channel": "[0-9]|[1][0-4]|16|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|183|184|185|187|188|189|192|196|auto", + "backup_channel": "[0-9]|[1][0-4]|16|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|183|184|185|187|188|189|192|196|auto", + "width": "20|40|80|160", + "tx_power": "[\\d]+|auto", + "tx_power_mode": "auto|medium|high|low|custom" + }], + "satisfaction_table": [{ + "device_mac": "^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})$", + "satisfaction": "^[0-9]+\\.?[0-9]*$" + }], + "site_blacklisted_channels": [{ + "channel": "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|183|184|185|187|188|189|192|196", + "timestamp": "[1-9][0-9]{12}" + }], + "ap_blacklisted_channels": [{ + "mac": "^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})$", + "channel": "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|183|184|185|187|188|189|192|196", + "timestamp": "[1-9][0-9]{12}" + }], + "coupling": [{ + "source": "^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2}).*$", + "target": "^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2}).*$", + "rssi": "-?[0-9]{1,3}" + }], + "satisfaction": "^[0-9]+\\.?[0-9]*$" +} diff --git a/unifi/fields/5.12.35/Dashboard.json b/unifi/fields/5.12.35/Dashboard.json new file mode 100644 index 0000000..eb5bc1f --- /dev/null +++ b/unifi/fields/5.12.35/Dashboard.json @@ -0,0 +1,12 @@ +{ + "name": "", + "desc": "", + "is_public": "true|false", + "controller_version": "", + "modules":[{ + "id": "", + "module_id": "", + "config": "", + "restrictions": "" + }] +} diff --git a/unifi/fields/5.12.35/Device.json b/unifi/fields/5.12.35/Device.json new file mode 100644 index 0000000..a9bbbad --- /dev/null +++ b/unifi/fields/5.12.35/Device.json @@ -0,0 +1,133 @@ +{ + "name": ".{1,128}", + "x": "", + "y": "", + "heightInMeters": "^([-]?[\\d]+[.]?[\\d]*)$", + "locked": "true|false", + "map_id": "", + "disabled": "true|false", + "led_override": "default|on|off", + "led_override_color": "^#(?:[0-9a-fA-F]{3}){1,2}$", + "led_override_color_brightness": "^[0-9][0-9]?$|^100$", + "outdoor_mode_override": "default|on|off", + "mesh_sta_vap_enabled": "true|false", + "config_network": { + "bonding_enabled": "true|false", + "type": "dhcp|static", + "ip": "^(([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])$", + "netmask": "^((128|192|224|240|248|252|254)\\.0\\.0\\.0)|(255\\.(((0|128|192|224|240|248|252|254)\\.0\\.0)|(255\\.(((0|128|192|224|240|248|252|254)\\.0)|255\\.(0|128|192|224|240|248|252|254)))))$", + "gateway": "^(([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])$|^$", + "dns1": "^(([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-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$|^$", + "dns2": "^(([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-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$|^$", + "dnssuffix": "" + }, + "radio_table": [{ + "radio": "ng|na|ad", + "channel": "[0-9]|[1][0-4]|4.5|16|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|183|184|185|187|188|189|192|196|auto", + "backup_channel": "[0-9]|[1][0-4]|16|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|183|184|185|187|188|189|192|196|auto", + "ht": "20|40|80|160|1080|2160", + "tx_power_mode": "auto|medium|high|low|custom", + "tx_power": "[\\d]+|auto", + "min_rssi_enabled": "true|false", + "min_rssi": "^-([1-9]|[1-8][0-9]|9[0-4])$", + "name": "", + "hard_noise_floor_enabled": "true|false", + "sens_level_enabled": "true|false", + "sens_level": "^-([5-8][0-9]|90)$", + "antenna_gain": "^-?([0-9]|[1-9][0-9])", + "antenna_id": "-1|[0-9]", + "wlangroup_id": "[\\d\\w]+", + "vwire_enabled":"true|false" + }], + "wlan_overrides": [{ + "enabled":"true|false", + "name":".{1,32}", + "name_combine_enabled":"true|false", + "name_combine_suffix":".{0,8}", + "vlan":"[2-9]|[1-9][0-9]{1,2}|[1-3][0-9]{3}|40[0-8][0-9]|409[0-5]|^$", + "vlan_enabled":"true|false", + "x_passphrase": "[\\x20-\\x7E]{8,63}|[0-9a-fA-F]{64}", + "wlan_id":"[\\d\\w]+", + "radio":"ng|na", + "radio_name":"" + }], + "ethernet_overrides": [{ + "ifname": "eth[0-9]{1,2}", + "networkgroup": "LAN[2-8]?|WAN[2]?" + }], + "jumboframe_enabled": "true|false", + "flowctrl_enabled": "true|false", + "stp_version": "stp|rstp|disabled", + "stp_priority": "0|4096|8192|12288|16384|20480|24576|28672|32768|36864|40960|45056|49152|53248|57344|61440", + "dot1x_portctrl_enabled": "true|false", + "dot1x_fallback_networkconf_id": "[\\d\\w]+|", + "radiusprofile_id": "", + "atf_enabled": "true|false", + "bandsteering_mode": "off|equal|prefer_5g", + "dpi_enabled": "true|false", + "resetbtn_enabled": "on|off", + "mgmt_network_id": "[\\d\\w]+", + "switch_vlan_enabled": "false|true", + "port_overrides": [{ + "port_idx":"[1-9]|[1-4][0-9]|5[0-2]", + "name":".{0,128}", + "op_mode":"switch|mirror|aggregate", + "autoneg":"true|false", + "speed":"10|100|1000|2500|5000|10000|20000|25000|40000|50000|100000", + "full_duplex":"true|false", + "poe_mode":"auto|pasv24|passthrough|off", + "isolation":"true|false", + "dot1x_ctrl":"auto|force_authorized|force_unauthorized|mac_based|multi_host", + "stormctrl_type": "level|rate", + "stormctrl_ucast_enabled": "true|false", + "stormctrl_ucast_level": "[0-9]|[1-9][0-9]|100", + "stormctrl_ucast_rate": "[0-9]|[1-9][0-9]{1,6}|1[0-3][0-9]{6}|14[0-7][0-9]{5}|148[0-7][0-9]{4}|14880000", + "stormctrl_mcast_enabled": "true|false", + "stormctrl_mcast_level": "[0-9]|[1-9][0-9]|100", + "stormctrl_mcast_rate": "[0-9]|[1-9][0-9]{1,6}|1[0-3][0-9]{6}|14[0-7][0-9]{5}|148[0-7][0-9]{4}|14880000", + "stormctrl_bcast_enabled": "true|false", + "stormctrl_bcast_level": "[0-9]|[1-9][0-9]|100", + "stormctrl_bcast_rate": "[0-9]|[1-9][0-9]{1,6}|1[0-3][0-9]{6}|14[0-7][0-9]{5}|148[0-7][0-9]{4}|14880000", + "priority_queue1_level": "[0-9]|[1-9][0-9]|100", + "priority_queue2_level": "[0-9]|[1-9][0-9]|100", + "priority_queue3_level": "[0-9]|[1-9][0-9]|100", + "priority_queue4_level": "[0-9]|[1-9][0-9]|100", + "portconf_id":"[\\d\\w]+", + "mirror_port_idx":"[1-9]|[1-4][0-9]|5[0-2]", + "lldpmed_enabled": "true|false", + "lldpmed_notify_enabled": "true|false", + "stp_port_mode": "true|false", + "egress_rate_limit_kbps_enabled": "true|false", + "egress_rate_limit_kbps": "6[4-9]|[7-9][0-9]|[1-9][0-9]{2,6}", + "aggregate_num_ports":"[2-4]", + "port_security_enabled": "true|false", + "port_security_mac_address": ["^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$"] + }], + "power_source_ctrl_enabled": "true|false", + "power_source_ctrl": "auto|8023af|8023at|8023bt-type3|8023bt-type4|pasv24|poe-injector|ac|adapter|dc|rps", + "snmp_location": ".{0,255}", + "snmp_contact": ".{0,255}", + "baresip_enabled": "true|false", + "baresip_extension": "^\\+?[a-zA-Z0-9_.\\-!~*'()]*", + "baresip_auth_user": "^\\+?[a-zA-Z0-9_.\\-!~*'()]*", + "x_baresip_password": "^[a-zA-Z0-9_.\\-!~*'()]*", + "volume": "[0-9]|[1-9][0-9]|100", + "lte_ext_ant": "true|false", + "lte_poe": "true|false", + "lte_soft_limit": "\\d+", + "lcm_brightness_override": "true|false", + "lcm_brightness": "[1-9]|[1-9][0-9]|100", + "lcm_idle_timeout_override": "true|false", + "lcm_idle_timeout": "[1-9][0-9]|[1-9][0-9][0-9]|[1-2][0-9][0-9][0-9]|3[0-5][0-9][0-9]|3600", + "rps_override": { + "power_management_mode": "dynamic|static", + "rps_port_table": [{ + "port_idx": "[1-6]", + "name": ".{0,32}", + "port_mode":"auto|force_active|manual|disabled" + }] + }, + "lcm_tracker_seed": ".{0,50}", + "lcm_tracker_enabled": "true|false", + "ubb_pair_name": ".{1,128}" +} diff --git a/unifi/fields/5.12.35/DhcpOption.json b/unifi/fields/5.12.35/DhcpOption.json new file mode 100644 index 0000000..63f9c8d --- /dev/null +++ b/unifi/fields/5.12.35/DhcpOption.json @@ -0,0 +1,8 @@ +{ + "type": "^(boolean|hexarray|integer|ipaddress|macaddress|text)$", + "code": "^(?!(?:15|42|43|44|51|66|67|252)$)([7-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-4])$", + "name": "^[A-Za-z0-9-_]{1,25}$", + "signed": "^(true|false)$", + "width": "^(8|16|32)$" +} + diff --git a/unifi/fields/5.12.35/DpiApp.json b/unifi/fields/5.12.35/DpiApp.json new file mode 100644 index 0000000..55760c2 --- /dev/null +++ b/unifi/fields/5.12.35/DpiApp.json @@ -0,0 +1,10 @@ +{ + "name": ".{1,128}", + "enabled": "false|true", + "apps": [ "[0-9]{1,8}" ], + "cats": [ "[0-9]{1,3}" ], + "blocked": "false|true", + "log": "false|true", + "qos_rate_max_up": "-1|[2-9]|[1-9][0-9]{1,4}|100000|10[0-1][0-9]{3}|102[0-3][0-9]{2}|102400", + "qos_rate_max_down": "-1|[2-9]|[1-9][0-9]{1,4}|100000|10[0-1][0-9]{3}|102[0-3][0-9]{2}|102400" +} diff --git a/unifi/fields/5.12.35/DpiGroup.json b/unifi/fields/5.12.35/DpiGroup.json new file mode 100644 index 0000000..de915a1 --- /dev/null +++ b/unifi/fields/5.12.35/DpiGroup.json @@ -0,0 +1,5 @@ +{ + "name":".{1,128}", + "enabled": "false|true", + "dpiapp_ids": [ "[\\d\\w]+" ] +} diff --git a/unifi/fields/5.12.35/DynamicDNS.json b/unifi/fields/5.12.35/DynamicDNS.json new file mode 100644 index 0000000..b866f64 --- /dev/null +++ b/unifi/fields/5.12.35/DynamicDNS.json @@ -0,0 +1,10 @@ +{ + "interface": "wan|wan2", + "service": "afraid|changeip|cloudflare|dnspark|dslreports|dyndns|easydns|googledomains|namecheap|noip|sitelutions|zoneedit|custom", + "custom_service": "^[^\"' ]+$", + "host_name": "^[^\"' ]+$", + "login": "^[^\"' ]+$", + "x_password": "^[^\"' ]+$", + "server": "^[^\"' ]+$|^$", + "options": ["^[^\"' ]+$"] +} diff --git a/unifi/fields/5.12.35/FirewallGroup.json b/unifi/fields/5.12.35/FirewallGroup.json new file mode 100644 index 0000000..a148c69 --- /dev/null +++ b/unifi/fields/5.12.35/FirewallGroup.json @@ -0,0 +1,5 @@ +{ + "name": ".{1,64}", + "group_type": "address-group|port-group|ipv6-address-group", + "group_members": [ "" ] +} diff --git a/unifi/fields/5.12.35/FirewallRule.json b/unifi/fields/5.12.35/FirewallRule.json new file mode 100644 index 0000000..f3add04 --- /dev/null +++ b/unifi/fields/5.12.35/FirewallRule.json @@ -0,0 +1,48 @@ +{ + "name": ".{1,128}", + "ruleset": "WAN_IN|WAN_OUT|WAN_LOCAL|LAN_IN|LAN_OUT|LAN_LOCAL|GUEST_IN|GUEST_OUT|GUEST_LOCAL|WANv6_IN|WANv6_OUT|WANv6_LOCAL|LANv6_IN|LANv6_OUT|LANv6_LOCAL|GUESTv6_IN|GUESTv6_OUT|GUESTv6_LOCAL", + "rule_index": "2[0-9]{3}|4[0-9]{3}", + + "enabled": "true|false", + "action": "drop|reject|accept", + "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_v6": "^$|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])|ah|all|dccp|eigrp|esp|gre|icmpv6|ipcomp|ipv6|ipv6-frag|ipv6-icmp|ipv6-nonxt|ipv6-opts|ipv6-route|isis|l2tp|manet|mobility-header|mpls-in-ip|ospf|pim|rsvp|sctp|shim6|tcp|tcp_udp|udp|vrrp", + "protocol_match_excepted": "false|true", + + "state_established": "false|true", + "state_invalid": "false|true", + "state_new": "false|true", + "state_related": "false|true", + + "ipsec": "match-ipsec|match-none|^$", + "icmp_typename" : "^$|communication-prohibited|destination-unreachable|echo-reply|echo-request|fragmentation-needed|host-precedence-violation|host-prohibited|host-redirect|host-unknown|host-unreachable|ip-header-bad|network-prohibited|network-redirect|network-unknown|network-unreachable|parameter-problem|port-unreachable|protocol-unreachable|redirect|required-option-missing|router-advertisement|router-solicitation|source-route-failed|timestamp-reply|timestamp-request|TOS-host-redirect|TOS-host-unreachable|TOS-network-redirect|TOS-network-unreachable|ttl-exceeded|ttl-zero-during-reassembly|ttl-zero-during-transit", + "icmpv6_typename" : "^$|address-unreachable|bad-header|communication-prohibited|destination-unreachable|echo-reply|echo-request|neighbor-advertisement|neighbor-solicitation|no-route|packet-too-big|parameter-problem|port-unreachable|redirect|router-advertisement|router-solicitation|time-exceeded|ttl-zero-during-reassembly|ttl-zero-during-transit|unknown-header-type|unknown-option", + + "dst_address": "", + "dst_address_ipv6": "", + "dst_port": "", + "dst_firewallgroup_ids": [ "[\\d\\w]+" ], + "dst_networkconf_id": "[\\d\\w]+|^$", + "dst_networkconf_type": "ADDRv4|NETv4", + + "src_address": "", + "src_address_ipv6": "", + "src_port": "", + "src_firewallgroup_ids": [ "[\\d\\w]+" ], + "src_networkconf_id": "[\\d\\w]+|^$", + "src_networkconf_type": "ADDRv4|NETv4", + "src_mac_address": "^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})$|^$", + + "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])$", + "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])$", + "starttime": "^$|^(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9])$", + "stoptime": "^$|^(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9])$", + "monthdays": "^$|^(([1-9]|[12][0-9]|3[01])(,([1-9]|[12][0-9]|3[01])){0,30})$", + "monthdays_negate": "false|true", + "weekdays": "^$|^((Mon|Tue|Wed|Thu|Fri|Sat|Sun)(,(Mon|Tue|Wed|Thu|Fri|Sat|Sun)){0,6})$", + "weekdays_negate": "false|true", + "utc": "false|true", + "contiguous": "false|true", + + "logging": "false|true" +} diff --git a/unifi/fields/5.12.35/HeatMap.json b/unifi/fields/5.12.35/HeatMap.json new file mode 100644 index 0000000..eaa6021 --- /dev/null +++ b/unifi/fields/5.12.35/HeatMap.json @@ -0,0 +1,6 @@ +{ + "map_id": "", + "type": "download|upload", + "name": ".*[^\\s]+.*", + "description": "" +} diff --git a/unifi/fields/5.12.35/HeatMapPoint.json b/unifi/fields/5.12.35/HeatMapPoint.json new file mode 100644 index 0000000..f119f69 --- /dev/null +++ b/unifi/fields/5.12.35/HeatMapPoint.json @@ -0,0 +1,7 @@ +{ + "heatmap_id": "", + "x": "[-+]?[0-9]*\\.?[0-9]+", + "y": "[-+]?[0-9]*\\.?[0-9]+", + "upload_speed": "[-+]?[0-9]*\\.?[0-9]+", + "download_speed": "[-+]?[0-9]*\\.?[0-9]+" +} diff --git a/unifi/fields/5.12.35/Hotspot2Conf.json b/unifi/fields/5.12.35/Hotspot2Conf.json new file mode 100644 index 0000000..653b33e --- /dev/null +++ b/unifi/fields/5.12.35/Hotspot2Conf.json @@ -0,0 +1,122 @@ +{ + "name": ".{1,128}", + "venue_name": [ + { + "language": "[a-z]{3}", + "name": ".{1,128}" + } + ], + "venue_group": "0|1|2|3|4|5|6|7|8|9|10|11", + "venue_type": "0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15", + "network_type": "0|1|2|3|4|5|14|15", + "network_access_internet": "true|false", + "network_access_asra": "true|false", + "network_access_esr": "true|false", + "network_access_uesa": "true|false", + "hessid": "^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})$|^$", + "disable_dgaf": "true|false", + "deauth_req_timeout" : "[1-9][0-9]|[1-9][0-9][0-9]|[1-2][0-9][0-9][0-9]|3[0-5][0-9][0-9]|3600", + "osu_ssid": "", + "nai_realm_list": [ + { + "name": ".{1,128}", + "status": "true|false", + "encoding": "0|1", + "eap_method": "13|21|18|23|50", + "auth_ids": "", + "auth_vals": "" + } + ], + "domain_name_list": [".{1,128}"], + "roaming_consortium_list": [ + { + "name": ".{1,128}", + "oid": ".{1,128}" + } + ], + "cellular_network_list": [ + { + "name": ".{1,128}", + "mcc": "[0-9]{3}", + "mnc": "[0-9]{3}" + } + ], + "friendly_name" : [ + { + "language": "[a-z]{3}", + "text": ".{1,128}" + } + ], + "t_c_filename" : ".{1,256}", + "t_c_timestamp" : "[0-9]{1,12}", + "icons" : [ + { + "name" : ".{1,256}", + "width": "[0-9]{1,8}", + "height": "[0-9]{1,8}", + "media": ".{1,256}", + "language": "[a-z]{3}", + "filename": ".{1,256}", + "data": "", + "size": "[0-9]{1,8}" + } + ], + "metrics_status" : "true|false", + "metrics_info" : "[0-9A-Fa-f]{1,2}", + "metrics_downlink_speed": "[0-9]{1,10}", + "metrics_uplink_speed": "[0-9]{1,10}", + "metrics_downlink_load": "[0-9]{1,3}", + "metrics_uplink_load": "[0-9]{1,3}", + "metrics_measurement": "[0-9]{1,5}", + "capab" : [ + { + "protocol" : "icmp|tcp_udp|tcp|udp", + "port": "(([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])|([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])-([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]))+(,([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])|,([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])-([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])){0,14}", + "status" : "closed|open|unknown" + } + ], + "osu" : [ + { + "server_uri": "", + "friendly_name" : [ + { + "language": "[a-z]{3}", + "text": ".{1,128}" + } + ], + "description" : [ + { + "language": "[a-z]{3}", + "text": ".{1,128}" + } + ], + "nai" : "", + "nai2" : "", + "operating_class" : "[0-9A-Fa-f]{12}", + "method_soap_xml_spp": "true|false", + "method_oma_dm": "true|false", + "icon" : [ + { + "name": ".{1,128}" + } + ] + } + ], + "proxy_arp" : "true|false", + "ap_isolate" : "true|false", + "p2p" : "true|false", + "gas_comeback_delay" : "[1-9][0-9]|[1-9][0-9][0-9]|[1-2][0-9][0-9][0-9]|3[0-5][0-9][0-9]|300", + "qos_map_status" : "true|false", + "qos_map_exceptions" : [ + { + "dcsp" : "[0-9]{1,2}", + "up" : "[0-7]" + } + ], + "qos_map_dcsp" : [ + { + "low" : "[0-9]{1,3}", + "high" : "[0-9]{1,3}" + } + ] +} diff --git a/unifi/fields/5.12.35/HotspotOp.json b/unifi/fields/5.12.35/HotspotOp.json new file mode 100644 index 0000000..aa464df --- /dev/null +++ b/unifi/fields/5.12.35/HotspotOp.json @@ -0,0 +1,5 @@ +{ + "name": ".{1,256}", + "x_password": ".{1,256}", + "note": "" +} diff --git a/unifi/fields/5.12.35/HotspotPackage.json b/unifi/fields/5.12.35/HotspotPackage.json new file mode 100644 index 0000000..840ae4a --- /dev/null +++ b/unifi/fields/5.12.35/HotspotPackage.json @@ -0,0 +1,31 @@ +{ + "name": "", + "charged_as": "", + "amount": "^([\\d]+[.]?[\\d]*)$", + "currency": "[A-Z]{3}", + "hours": "[\\d]+", + "trial_reset": "^([\\d]+[.]?[\\d]*)$|^$", + "limit_overwrite": "true|false", + "limit_up": "[\\d]+|^$", + "limit_down": "[\\d]+|^$", + "limit_quota": "[\\d]+|^$", + "index": "[\\d]+", + "custom_payment_fields_enabled": "true|false", + "payment_fields_address_enabled": "true|false", + "payment_fields_address_required": "true|false", + "payment_fields_city_enabled": "true|false", + "payment_fields_city_required": "true|false", + "payment_fields_country_enabled": "true|false", + "payment_fields_country_required": "true|false", + "payment_fields_country_default": "", + "payment_fields_email_enabled": "true|false", + "payment_fields_email_required": "true|false", + "payment_fields_first_name_enabled": "true|false", + "payment_fields_first_name_required": "true|false", + "payment_fields_last_name_enabled": "true|false", + "payment_fields_last_name_required": "true|false", + "payment_fields_state_enabled": "true|false", + "payment_fields_state_required": "true|false", + "payment_fields_zip_enabled": "true|false", + "payment_fields_zip_required": "true|false" +} diff --git a/unifi/fields/5.12.35/Map.json b/unifi/fields/5.12.35/Map.json new file mode 100644 index 0000000..0fa5c6d --- /dev/null +++ b/unifi/fields/5.12.35/Map.json @@ -0,0 +1,15 @@ +{ + "name": "", + "mapTypeId": "satellite|roadmap|hybrid|terrain", + "tilt": "[\\d]+", + "type": "designerMap|imageMap|googleMap", + "upp": "^([\\d]+[.]?[\\d]*)$", + "unit": "m|f", + "lat": "^([-]?[\\d]+[.]?[\\d]*([eE][-+]?[\\d]+)?)$", + "lng": "^([-]?[\\d]+[.]?[\\d]*([eE][-+]?[\\d]+)?)$", + "selected": "true|false", + "zoom": "[\\d]+", + "offset_top": "^([-]?[\\d]+[.]?[\\d]*)$", + "offset_left": "^([-]?[\\d]+[.]?[\\d]*)$", + "opacity": "^(0(\\.[\\d]{1,2})?|1)$|^$" +} diff --git a/unifi/fields/5.12.35/MediaFile.json b/unifi/fields/5.12.35/MediaFile.json new file mode 100644 index 0000000..7c98cf6 --- /dev/null +++ b/unifi/fields/5.12.35/MediaFile.json @@ -0,0 +1,3 @@ +{ + "name": "" +} diff --git a/unifi/fields/5.12.35/NetworkConf.json b/unifi/fields/5.12.35/NetworkConf.json new file mode 100644 index 0000000..6befb19 --- /dev/null +++ b/unifi/fields/5.12.35/NetworkConf.json @@ -0,0 +1,139 @@ +{ + "name": ".{1,128}", + "enabled": "true|false", + "purpose": "corporate|guest|remote-user-vpn|site-vpn|vlan-only|vpn-client|wan", + "vpn_type": "auto|ipsec-vpn|openvpn-vpn|pptp-client|l2tp-server|pptp-server", + "vlan_enabled": "false|true", + "vlan": "[2-9]|[1-9][0-9]{1,2}|[1-3][0-9]{3}|400[0-9]|^$", + "priority": "[1-4]", + "igmp_snooping": "true|false", + "igmp_fastleave": "true|false", + "igmp_supression": "true|false", + "igmp_maxresponse": "[1-9]|1[0-9]|2[0-5]|^$", + "igmp_mcrtrexpiretime": "[0-9]|[1-9][0-9]{1,2}|[1-2][0-9]{3}|3[0-5][0-9]{2}|3600|^$", + "igmp_groupmembership": "[2-9]|[1-9][0-9]{1,2}|[1-2][0-9]{3}|3[0-5][0-9]{2}|3600|^$", + "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])$|^$", + "ip_subnet": "^(([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)$", + "ipv6_subnet": "", + + "ipv6_interface_type": "static|pd|none", + "ipv6_pd_interface": "wan|wan2", + "ipv6_pd_prefixid": "^$|[a-fA-F0-9]{1,4}", + "ipv6_ra_enabled": "false|true", + "ipv6_ra_priority": "high|medium|low", + "ipv6_ra_valid_lifetime": "^([0-9]|[1-8][0-9]|9[0-9]|[1-8][0-9]{2}|9[0-8][0-9]|99[0-9]|[1-8][0-9]{3}|9[0-8][0-9]{2}|99[0-8][0-9]|999[0-9]|[1-8][0-9]{4}|9[0-8][0-9]{3}|99[0-8][0-9]{2}|999[0-8][0-9]|9999[0-9]|[1-8][0-9]{5}|9[0-8][0-9]{4}|99[0-8][0-9]{3}|999[0-8][0-9]{2}|9999[0-8][0-9]|99999[0-9]|[1-8][0-9]{6}|9[0-8][0-9]{5}|99[0-8][0-9]{4}|999[0-8][0-9]{3}|9999[0-8][0-9]{2}|99999[0-8][0-9]|999999[0-9]|[12][0-9]{7}|30[0-9]{6}|31[0-4][0-9]{5}|315[0-2][0-9]{4}|3153[0-5][0-9]{3}|31536000)$|^$", + "ipv6_ra_preferred_lifetime": "^([0-9]|[1-8][0-9]|9[0-9]|[1-8][0-9]{2}|9[0-8][0-9]|99[0-9]|[1-8][0-9]{3}|9[0-8][0-9]{2}|99[0-8][0-9]|999[0-9]|[1-8][0-9]{4}|9[0-8][0-9]{3}|99[0-8][0-9]{2}|999[0-8][0-9]|9999[0-9]|[1-8][0-9]{5}|9[0-8][0-9]{4}|99[0-8][0-9]{3}|999[0-8][0-9]{2}|9999[0-8][0-9]|99999[0-9]|[1-8][0-9]{6}|9[0-8][0-9]{5}|99[0-8][0-9]{4}|999[0-8][0-9]{3}|9999[0-8][0-9]{2}|99999[0-8][0-9]|999999[0-9]|[12][0-9]{7}|30[0-9]{6}|31[0-4][0-9]{5}|315[0-2][0-9]{4}|3153[0-5][0-9]{3}|31536000)$|^$", + "ipv6_pd_start": "", + "ipv6_pd_stop": "", + "domain_name": "(?=^.{3,253}$)(^((?!-)[a-zA-Z0-9-]{1,63}(? 1 { + return "", "", false, fmt.Errorf("unknown validation %#v", validation) + } + elementType, elementComment, _, err := typeFromValidation(validation[0]) + if err != nil { + return "", "", false, err + } + return fmt.Sprintf("[]%s", elementType), elementComment, true, nil + case string: + comment := validation + normalized := normalizeValidation(validation) + allowEmpty := strings.HasSuffix(validation, "|^$") || strings.HasPrefix(validation, "^$|") + switch { + case normalized == "falsetrue" || normalized == "truefalse": + return "bool", "", false, nil + default: + if _, err := strconv.ParseFloat(normalized, 64); err == nil { + if normalized == "09" || normalized == "09.09" { + comment = "" + } + + if strings.Contains(normalized, ".") { + if strings.Contains(validation, "\\.){3}") { + break + } + + return "float64", comment, true, nil + } + + return "int", comment, true, nil + } + } + if validation != "" && normalized != "" { + fmt.Printf("normalize %q to %q\n", validation, normalized) + } + return "string", validation, !allowEmpty, nil + } + return "", "", false, fmt.Errorf("unable to determine type from validation %q", validation) +} + +func generateField(name string, validation interface{}) (string, error) { + field := strcase.ToCamel(name) + field = cleanName(field, fieldReps) + fieldType, comment, omitempty, err := typeFromValidation(validation) + if err != nil { + return "", err + } + + comment = strings.TrimSpace(fmt.Sprintf("// %s", comment)) + if comment == "//" { + comment = "" + } + + if fieldType == "string" && strings.HasSuffix(field, "ID") { + omitempty = false + } + + omitemptyCode := "" + if omitempty { + omitemptyCode = ",omitempty" + } + + return fmt.Sprintf("\t%s %s `json:\"%s%s\"` %s", field, fieldType, name, omitemptyCode, comment), nil +} diff --git a/unifi/fields/main_test.go b/unifi/fields/main_test.go new file mode 100644 index 0000000..28a924c --- /dev/null +++ b/unifi/fields/main_test.go @@ -0,0 +1,47 @@ +package main + +import ( + "fmt" + "testing" +) + +func TestTypeFromValidation(t *testing.T) { + for i, c := range []struct { + expectedType string + expectedComment string + expectedOmitEmpty bool + validation interface{} + }{ + {"string", "", true, ""}, + {"string", "default|custom", true, "default|custom"}, + {"string", ".{0,32}", true, ".{0,32}"}, + {"string", "^(([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])$|^$", false, "^(([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])$|^$"}, + + {"int", "^([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^$", false, "^([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^$"}, + {"int", "", true, "^[0-9]*$"}, + + {"float64", "", true, "[-+]?[0-9]*\\.?[0-9]+"}, + // this one is really an error as the . is not escaped + {"float64", "", true, "^([-]?[\\d]+[.]?[\\d]*)$"}, + {"float64", "", true, "^([\\d]+[.]?[\\d]*)$"}, + + {"bool", "", false, "false|true"}, + {"bool", "", false, "true|false"}, + } { + t.Run(fmt.Sprintf("%d %s %s", i, c.expectedType, c.validation), func(t *testing.T) { + actualType, actualComment, actualOmitEmpty, err := typeFromValidation(c.validation) + if err != nil { + t.Fatal(err) + } + if actualType != c.expectedType { + t.Fatalf("expected type %q got %q", c.expectedType, actualType) + } + if actualComment != c.expectedComment { + t.Fatalf("expected comment %q got %q", c.expectedComment, actualComment) + } + if actualOmitEmpty != c.expectedOmitEmpty { + t.Fatalf("expected omitempty %t got %t", c.expectedOmitEmpty, actualOmitEmpty) + } + }) + } +} diff --git a/unifi/firewall_group.generated.go b/unifi/firewall_group.generated.go new file mode 100644 index 0000000..f351f24 --- /dev/null +++ b/unifi/firewall_group.generated.go @@ -0,0 +1,18 @@ +// Code generated from ace.jar fields *.json files +// DO NOT EDIT. + +package unifi + +type FirewallGroup 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"` + + GroupMembers []string `json:"group_members,omitempty"` + GroupType string `json:"group_type,omitempty"` // address-group|port-group|ipv6-address-group + Name string `json:"name,omitempty"` // .{1,64} +} diff --git a/unifi/firewall_rule.generated.go b/unifi/firewall_rule.generated.go new file mode 100644 index 0000000..c12b48b --- /dev/null +++ b/unifi/firewall_rule.generated.go @@ -0,0 +1,54 @@ +// Code generated from ace.jar fields *.json files +// DO NOT EDIT. + +package unifi + +type FirewallRule 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"` + + Action string `json:"action,omitempty"` // drop|reject|accept + Contiguous bool `json:"contiguous"` + DstAddress string `json:"dst_address,omitempty"` + DstAddressIPV6 string `json:"dst_address_ipv6,omitempty"` + DstFirewallgroupIDs []string `json:"dst_firewallgroup_ids,omitempty"` // [\d\w]+ + DstNetworkconfID string `json:"dst_networkconf_id"` // [\d\w]+|^$ + DstNetworkconfType string `json:"dst_networkconf_type,omitempty"` // ADDRv4|NETv4 + DstPort string `json:"dst_port,omitempty"` + Enabled bool `json:"enabled"` + IcmpTypename string `json:"icmp_typename"` // ^$|communication-prohibited|destination-unreachable|echo-reply|echo-request|fragmentation-needed|host-precedence-violation|host-prohibited|host-redirect|host-unknown|host-unreachable|ip-header-bad|network-prohibited|network-redirect|network-unknown|network-unreachable|parameter-problem|port-unreachable|protocol-unreachable|redirect|required-option-missing|router-advertisement|router-solicitation|source-route-failed|timestamp-reply|timestamp-request|TOS-host-redirect|TOS-host-unreachable|TOS-network-redirect|TOS-network-unreachable|ttl-exceeded|ttl-zero-during-reassembly|ttl-zero-during-transit + Icmpv6Typename string `json:"icmpv6_typename"` // ^$|address-unreachable|bad-header|communication-prohibited|destination-unreachable|echo-reply|echo-request|neighbor-advertisement|neighbor-solicitation|no-route|packet-too-big|parameter-problem|port-unreachable|redirect|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|^$ + 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} + 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"` + ProtocolV6 string `json:"protocol_v6"` // ^$|([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])|ah|all|dccp|eigrp|esp|gre|icmpv6|ipcomp|ipv6|ipv6-frag|ipv6-icmp|ipv6-nonxt|ipv6-opts|ipv6-route|isis|l2tp|manet|mobility-header|mpls-in-ip|ospf|pim|rsvp|sctp|shim6|tcp|tcp_udp|udp|vrrp + RuleIndex int `json:"rule_index,omitempty"` // 2[0-9]{3}|4[0-9]{3} + Ruleset string `json:"ruleset,omitempty"` // WAN_IN|WAN_OUT|WAN_LOCAL|LAN_IN|LAN_OUT|LAN_LOCAL|GUEST_IN|GUEST_OUT|GUEST_LOCAL|WANv6_IN|WANv6_OUT|WANv6_LOCAL|LANv6_IN|LANv6_OUT|LANv6_LOCAL|GUESTv6_IN|GUESTv6_OUT|GUESTv6_LOCAL + SrcAddress string `json:"src_address,omitempty"` + SrcAddressIPV6 string `json:"src_address_ipv6,omitempty"` + SrcFirewallgroupIDs []string `json:"src_firewallgroup_ids,omitempty"` // [\d\w]+ + SrcMACAddress string `json:"src_mac_address"` // ^([0-9A-Fa-f]{2}:){5}([0-9A-Fa-f]{2})$|^$ + SrcNetworkconfID string `json:"src_networkconf_id"` // [\d\w]+|^$ + SrcNetworkconfType string `json:"src_networkconf_type,omitempty"` // ADDRv4|NETv4 + 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"` + StateInvalid bool `json:"state_invalid"` + StateNew bool `json:"state_new"` + 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"` +} diff --git a/unifi/heat_map.generated.go b/unifi/heat_map.generated.go new file mode 100644 index 0000000..1aad270 --- /dev/null +++ b/unifi/heat_map.generated.go @@ -0,0 +1,19 @@ +// Code generated from ace.jar fields *.json files +// DO NOT EDIT. + +package unifi + +type HeatMap 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"` + + Description string `json:"description,omitempty"` + MapID string `json:"map_id"` + Name string `json:"name,omitempty"` // .*[^\s]+.* + Type string `json:"type,omitempty"` // download|upload +} diff --git a/unifi/heat_map_point.generated.go b/unifi/heat_map_point.generated.go new file mode 100644 index 0000000..3f57507 --- /dev/null +++ b/unifi/heat_map_point.generated.go @@ -0,0 +1,20 @@ +// Code generated from ace.jar fields *.json files +// DO NOT EDIT. + +package unifi + +type HeatMapPoint 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"` + + DownloadSpeed float64 `json:"download_speed,omitempty"` + HeatmapID string `json:"heatmap_id"` + UploadSpeed float64 `json:"upload_speed,omitempty"` + X float64 `json:"x,omitempty"` + Y float64 `json:"y,omitempty"` +} diff --git a/unifi/hotspot_op.generated.go b/unifi/hotspot_op.generated.go new file mode 100644 index 0000000..c758b0a --- /dev/null +++ b/unifi/hotspot_op.generated.go @@ -0,0 +1,18 @@ +// Code generated from ace.jar fields *.json files +// DO NOT EDIT. + +package unifi + +type HotspotOp 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"` + + Name string `json:"name,omitempty"` // .{1,256} + Note string `json:"note,omitempty"` + XPassword string `json:"x_password,omitempty"` // .{1,256} +} diff --git a/unifi/hotspot_package.generated.go b/unifi/hotspot_package.generated.go new file mode 100644 index 0000000..d0fcd23 --- /dev/null +++ b/unifi/hotspot_package.generated.go @@ -0,0 +1,44 @@ +// Code generated from ace.jar fields *.json files +// DO NOT EDIT. + +package unifi + +type HotspotPackage 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"` + + Amount float64 `json:"amount,omitempty"` + ChargedAs string `json:"charged_as,omitempty"` + Currency string `json:"currency,omitempty"` // [A-Z]{3} + CustomPaymentFieldsEnabled bool `json:"custom_payment_fields_enabled"` + Hours int `json:"hours,omitempty"` + Index int `json:"index,omitempty"` + LimitDown int `json:"limit_down,omitempty"` + LimitOverwrite bool `json:"limit_overwrite"` + LimitQuota int `json:"limit_quota,omitempty"` + LimitUp int `json:"limit_up,omitempty"` + Name string `json:"name,omitempty"` + PaymentFieldsAddressEnabled bool `json:"payment_fields_address_enabled"` + PaymentFieldsAddressRequired bool `json:"payment_fields_address_required"` + PaymentFieldsCityEnabled bool `json:"payment_fields_city_enabled"` + PaymentFieldsCityRequired bool `json:"payment_fields_city_required"` + PaymentFieldsCountryDefault string `json:"payment_fields_country_default,omitempty"` + PaymentFieldsCountryEnabled bool `json:"payment_fields_country_enabled"` + PaymentFieldsCountryRequired bool `json:"payment_fields_country_required"` + PaymentFieldsEmailEnabled bool `json:"payment_fields_email_enabled"` + PaymentFieldsEmailRequired bool `json:"payment_fields_email_required"` + PaymentFieldsFirstNameEnabled bool `json:"payment_fields_first_name_enabled"` + PaymentFieldsFirstNameRequired bool `json:"payment_fields_first_name_required"` + PaymentFieldsLastNameEnabled bool `json:"payment_fields_last_name_enabled"` + PaymentFieldsLastNameRequired bool `json:"payment_fields_last_name_required"` + PaymentFieldsStateEnabled bool `json:"payment_fields_state_enabled"` + PaymentFieldsStateRequired bool `json:"payment_fields_state_required"` + PaymentFieldsZipEnabled bool `json:"payment_fields_zip_enabled"` + PaymentFieldsZipRequired bool `json:"payment_fields_zip_required"` + TrialReset float64 `json:"trial_reset,omitempty"` +} diff --git a/unifi/map.generated.go b/unifi/map.generated.go new file mode 100644 index 0000000..fad7bf8 --- /dev/null +++ b/unifi/map.generated.go @@ -0,0 +1,28 @@ +// Code generated from ace.jar fields *.json files +// DO NOT EDIT. + +package unifi + +type Map 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"` + + Lat string `json:"lat,omitempty"` // ^([-]?[\d]+[.]?[\d]*([eE][-+]?[\d]+)?)$ + Lng string `json:"lng,omitempty"` // ^([-]?[\d]+[.]?[\d]*([eE][-+]?[\d]+)?)$ + MapTypeID string `json:"mapTypeId"` // satellite|roadmap|hybrid|terrain + Name string `json:"name,omitempty"` + OffsetLeft float64 `json:"offset_left,omitempty"` + OffsetTop float64 `json:"offset_top,omitempty"` + Opacity float64 `json:"opacity,omitempty"` // ^(0(\.[\d]{1,2})?|1)$|^$ + Selected bool `json:"selected"` + Tilt int `json:"tilt,omitempty"` + Type string `json:"type,omitempty"` // designerMap|imageMap|googleMap + Unit string `json:"unit,omitempty"` // m|f + Upp float64 `json:"upp,omitempty"` + Zoom int `json:"zoom,omitempty"` +} diff --git a/unifi/media_file.generated.go b/unifi/media_file.generated.go new file mode 100644 index 0000000..54f16da --- /dev/null +++ b/unifi/media_file.generated.go @@ -0,0 +1,16 @@ +// Code generated from ace.jar fields *.json files +// DO NOT EDIT. + +package unifi + +type MediaFile 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"` + + Name string `json:"name,omitempty"` +} diff --git a/unifi/network.generated.go b/unifi/network.generated.go new file mode 100644 index 0000000..009e1fd --- /dev/null +++ b/unifi/network.generated.go @@ -0,0 +1,151 @@ +// Code generated from ace.jar fields *.json files +// DO NOT EDIT. + +package unifi + +type Network 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"` + + DHCPRelayEnabled bool `json:"dhcp_relay_enabled"` + DHCPDBootEnabled bool `json:"dhcpd_boot_enabled"` + DHCPDBootFilename string `json:"dhcpd_boot_filename,omitempty"` // .{1,256} + DHCPDBootServer string `json:"dhcpd_boot_server"` // ^(([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])$|^$|(?=^.{3,253}$)(^((?!-)[a-zA-Z0-9-]{1,63}(?