From d79f581c1f53a4eab967010bdbe22f3e28c1002c Mon Sep 17 00:00:00 2001 From: Mateusz Filipowicz Date: Sun, 9 Feb 2025 01:42:44 +0100 Subject: [PATCH] chore: apply linter fixes --- unifi/account.generated.go | 6 +- unifi/ap_group.go | 8 +- unifi/broadcast_group.generated.go | 6 +- unifi/channel_plan.generated.go | 6 +- unifi/dashboard.generated.go | 6 +- unifi/device.generated.go | 6 +- unifi/device.go | 2 +- unifi/dhcp_option.generated.go | 6 +- unifi/dns_record.go | 4 +- unifi/dpi_app.generated.go | 6 +- unifi/dpi_group.generated.go | 6 +- unifi/dynamic_dns.generated.go | 6 +- unifi/firewall_group.generated.go | 6 +- unifi/firewall_rule.generated.go | 6 +- unifi/heat_map.generated.go | 6 +- unifi/heat_map_point.generated.go | 6 +- unifi/hotspot_2_conf.generated.go | 6 +- unifi/hotspot_op.generated.go | 6 +- unifi/hotspot_package.generated.go | 6 +- unifi/map.generated.go | 6 +- unifi/media_file.generated.go | 6 +- unifi/network.generated.go | 6 +- unifi/port_forward.generated.go | 6 +- unifi/port_profile.generated.go | 6 +- unifi/radius_profile.generated.go | 6 +- unifi/routing.generated.go | 6 +- unifi/schedule_task.generated.go | 6 +- unifi/setting.go | 2 +- unifi/setting_auto_speedtest.generated.go | 4 +- unifi/setting_baresip.generated.go | 4 +- unifi/setting_broadcast.generated.go | 4 +- unifi/setting_connectivity.generated.go | 4 +- unifi/setting_country.generated.go | 4 +- unifi/setting_dashboard.generated.go | 4 +- unifi/setting_doh.generated.go | 4 +- unifi/setting_dpi.generated.go | 4 +- unifi/setting_element_adopt.generated.go | 4 +- unifi/setting_ether_lighting.generated.go | 4 +- unifi/setting_evaluation_score.generated.go | 4 +- unifi/setting_global_ap.generated.go | 4 +- unifi/setting_global_nat.generated.go | 4 +- unifi/setting_global_switch.generated.go | 4 +- unifi/setting_guest_access.generated.go | 4 +- unifi/setting_ips.generated.go | 4 +- unifi/setting_lcm.generated.go | 4 +- unifi/setting_locale.generated.go | 4 +- ...etting_magic_site_to_site_vpn.generated.go | 4 +- unifi/setting_mgmt.generated.go | 4 +- unifi/setting_netflow.generated.go | 4 +- .../setting_network_optimization.generated.go | 4 +- unifi/setting_ntp.generated.go | 4 +- unifi/setting_porta.generated.go | 4 +- ...setting_provider_capabilities.generated.go | 4 +- unifi/setting_radio_ai.generated.go | 4 +- unifi/setting_radius.generated.go | 4 +- unifi/setting_rsyslogd.generated.go | 4 +- unifi/setting_snmp.generated.go | 4 +- unifi/setting_ssl_inspection.generated.go | 4 +- unifi/setting_super_cloudaccess.generated.go | 4 +- unifi/setting_super_events.generated.go | 4 +- unifi/setting_super_fwupdate.generated.go | 4 +- unifi/setting_super_identity.generated.go | 4 +- unifi/setting_super_mail.generated.go | 4 +- unifi/setting_super_mgmt.generated.go | 4 +- unifi/setting_super_sdn.generated.go | 4 +- unifi/setting_super_smtp.generated.go | 4 +- unifi/setting_teleport.generated.go | 4 +- unifi/setting_usg.generated.go | 4 +- unifi/setting_usw.generated.go | 4 +- unifi/sites.go | 2 +- unifi/spatial_record.generated.go | 6 +- unifi/sysinfo.go | 6 +- unifi/tag.generated.go | 6 +- unifi/unifi.go | 27 +++--- unifi/unifi_test.go | 93 +++++++++++-------- unifi/user.generated.go | 6 +- unifi/user.go | 12 +-- unifi/user_group.generated.go | 6 +- unifi/virtual_device.generated.go | 6 +- unifi/wlan.generated.go | 6 +- unifi/wlan_group.generated.go | 6 +- 81 files changed, 259 insertions(+), 247 deletions(-) diff --git a/unifi/account.generated.go b/unifi/account.generated.go index c087f56..e78e280 100644 --- a/unifi/account.generated.go +++ b/unifi/account.generated.go @@ -86,7 +86,7 @@ func (c *Client) getAccount(ctx context.Context, site, id string) (*Account, err } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -113,7 +113,7 @@ func (c *Client) createAccount(ctx context.Context, site string, d *Account) (*A } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -133,7 +133,7 @@ func (c *Client) updateAccount(ctx context.Context, site string, d *Account) (*A } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/ap_group.go b/unifi/ap_group.go index e8c6b9c..66a1214 100644 --- a/unifi/ap_group.go +++ b/unifi/ap_group.go @@ -38,7 +38,7 @@ func (c *Client) ListAPGroup(ctx context.Context, site string) ([]APGroup, error // func (c *Client) getWLANGroup(ctx context.Context, site, id string) (*WLANGroup, error) { // var respBody struct { -// Meta Meta `json:"Meta"` +// Meta `json:"Meta"` // Data []WLANGroup `json:"data"` // } @@ -48,7 +48,7 @@ func (c *Client) ListAPGroup(ctx context.Context, site string) ([]APGroup, error // } // if len(respBody.Data) != 1 { -// return nil, NotFoundError +// return nil, ErrNotFound // } // d := respBody.Data[0] @@ -76,7 +76,7 @@ func (c *Client) CreateAPGroup(ctx context.Context, site string, d *APGroup) (*A // func (c *Client) updateWLANGroup(ctx context.Context, site string, d *WLANGroup) (*WLANGroup, error) { // var respBody struct { -// Meta Meta `json:"Meta"` +// Meta `json:"Meta"` // Data []WLANGroup `json:"data"` // } @@ -86,7 +86,7 @@ func (c *Client) CreateAPGroup(ctx context.Context, site string, d *APGroup) (*A // } // if len(respBody.Data) != 1 { -// return nil, NotFoundError +// return nil, ErrNotFound // } // new := respBody.Data[0] diff --git a/unifi/broadcast_group.generated.go b/unifi/broadcast_group.generated.go index 863f224..78a5bc7 100644 --- a/unifi/broadcast_group.generated.go +++ b/unifi/broadcast_group.generated.go @@ -71,7 +71,7 @@ func (c *Client) getBroadcastGroup(ctx context.Context, site, id string) (*Broad } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -98,7 +98,7 @@ func (c *Client) createBroadcastGroup(ctx context.Context, site string, d *Broad } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -118,7 +118,7 @@ func (c *Client) updateBroadcastGroup(ctx context.Context, site string, d *Broad } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/channel_plan.generated.go b/unifi/channel_plan.generated.go index e743f1a..ed33dab 100644 --- a/unifi/channel_plan.generated.go +++ b/unifi/channel_plan.generated.go @@ -214,7 +214,7 @@ func (c *Client) getChannelPlan(ctx context.Context, site, id string) (*ChannelP } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -241,7 +241,7 @@ func (c *Client) createChannelPlan(ctx context.Context, site string, d *ChannelP } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -261,7 +261,7 @@ func (c *Client) updateChannelPlan(ctx context.Context, site string, d *ChannelP } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/dashboard.generated.go b/unifi/dashboard.generated.go index 01b6d3d..1c7966b 100644 --- a/unifi/dashboard.generated.go +++ b/unifi/dashboard.generated.go @@ -97,7 +97,7 @@ func (c *Client) getDashboard(ctx context.Context, site, id string) (*Dashboard, } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -124,7 +124,7 @@ func (c *Client) createDashboard(ctx context.Context, site string, d *Dashboard) } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -144,7 +144,7 @@ func (c *Client) updateDashboard(ctx context.Context, site string, d *Dashboard) } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/device.generated.go b/unifi/device.generated.go index 6610e70..7405b67 100644 --- a/unifi/device.generated.go +++ b/unifi/device.generated.go @@ -610,7 +610,7 @@ func (c *Client) getDevice(ctx context.Context, site, id string) (*Device, error } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -637,7 +637,7 @@ func (c *Client) createDevice(ctx context.Context, site string, d *Device) (*Dev } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -657,7 +657,7 @@ func (c *Client) updateDevice(ctx context.Context, site string, d *Device) (*Dev } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/device.go b/unifi/device.go index 50b2c15..a221e36 100644 --- a/unifi/device.go +++ b/unifi/device.go @@ -55,7 +55,7 @@ func (c *Client) GetDevice(ctx context.Context, site, id string) (*Device, error } } - return nil, NotFoundError + return nil, ErrNotFound } func (c *Client) AdoptDevice(ctx context.Context, site, mac string) error { diff --git a/unifi/dhcp_option.generated.go b/unifi/dhcp_option.generated.go index 218c581..d5c2377 100644 --- a/unifi/dhcp_option.generated.go +++ b/unifi/dhcp_option.generated.go @@ -77,7 +77,7 @@ func (c *Client) getDHCPOption(ctx context.Context, site, id string) (*DHCPOptio } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -104,7 +104,7 @@ func (c *Client) createDHCPOption(ctx context.Context, site string, d *DHCPOptio } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -124,7 +124,7 @@ func (c *Client) updateDHCPOption(ctx context.Context, site string, d *DHCPOptio } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/dns_record.go b/unifi/dns_record.go index 50c9408..a49cbab 100644 --- a/unifi/dns_record.go +++ b/unifi/dns_record.go @@ -71,7 +71,7 @@ func (c *Client) GetDNSRecord(ctx context.Context, site, id string) (*DNSRecord, } if respBody.ID == "" { - return nil, NotFoundError + return nil, ErrNotFound } return &respBody, nil @@ -103,7 +103,7 @@ func (c *Client) UpdateDNSRecord(ctx context.Context, site string, d *DNSRecord) } // if len(respBody) != nil { - // return nil, NotFoundError + // return nil, ErrNotFound // } return &respBody, nil diff --git a/unifi/dpi_app.generated.go b/unifi/dpi_app.generated.go index 024aefc..9a46c56 100644 --- a/unifi/dpi_app.generated.go +++ b/unifi/dpi_app.generated.go @@ -92,7 +92,7 @@ func (c *Client) getDpiApp(ctx context.Context, site, id string) (*DpiApp, error } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -119,7 +119,7 @@ func (c *Client) createDpiApp(ctx context.Context, site string, d *DpiApp) (*Dpi } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -139,7 +139,7 @@ func (c *Client) updateDpiApp(ctx context.Context, site string, d *DpiApp) (*Dpi } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/dpi_group.generated.go b/unifi/dpi_group.generated.go index 34acd28..9534d39 100644 --- a/unifi/dpi_group.generated.go +++ b/unifi/dpi_group.generated.go @@ -72,7 +72,7 @@ func (c *Client) getDpiGroup(ctx context.Context, site, id string) (*DpiGroup, e } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -99,7 +99,7 @@ func (c *Client) createDpiGroup(ctx context.Context, site string, d *DpiGroup) ( } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -119,7 +119,7 @@ func (c *Client) updateDpiGroup(ctx context.Context, site string, d *DpiGroup) ( } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/dynamic_dns.generated.go b/unifi/dynamic_dns.generated.go index 1b40fe1..56d59a2 100644 --- a/unifi/dynamic_dns.generated.go +++ b/unifi/dynamic_dns.generated.go @@ -77,7 +77,7 @@ func (c *Client) getDynamicDNS(ctx context.Context, site, id string) (*DynamicDN } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -104,7 +104,7 @@ func (c *Client) createDynamicDNS(ctx context.Context, site string, d *DynamicDN } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -124,7 +124,7 @@ func (c *Client) updateDynamicDNS(ctx context.Context, site string, d *DynamicDN } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/firewall_group.generated.go b/unifi/firewall_group.generated.go index 1d950ae..4c2f524 100644 --- a/unifi/firewall_group.generated.go +++ b/unifi/firewall_group.generated.go @@ -72,7 +72,7 @@ func (c *Client) getFirewallGroup(ctx context.Context, site, id string) (*Firewa } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -99,7 +99,7 @@ func (c *Client) createFirewallGroup(ctx context.Context, site string, d *Firewa } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -119,7 +119,7 @@ func (c *Client) updateFirewallGroup(ctx context.Context, site string, d *Firewa } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/firewall_rule.generated.go b/unifi/firewall_rule.generated.go index 17f3064..7210b97 100644 --- a/unifi/firewall_rule.generated.go +++ b/unifi/firewall_rule.generated.go @@ -102,7 +102,7 @@ func (c *Client) getFirewallRule(ctx context.Context, site, id string) (*Firewal } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -129,7 +129,7 @@ func (c *Client) createFirewallRule(ctx context.Context, site string, d *Firewal } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -149,7 +149,7 @@ func (c *Client) updateFirewallRule(ctx context.Context, site string, d *Firewal } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/heat_map.generated.go b/unifi/heat_map.generated.go index 292205c..e85c9f4 100644 --- a/unifi/heat_map.generated.go +++ b/unifi/heat_map.generated.go @@ -73,7 +73,7 @@ func (c *Client) getHeatMap(ctx context.Context, site, id string) (*HeatMap, err } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -100,7 +100,7 @@ func (c *Client) createHeatMap(ctx context.Context, site string, d *HeatMap) (*H } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -120,7 +120,7 @@ func (c *Client) updateHeatMap(ctx context.Context, site string, d *HeatMap) (*H } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/heat_map_point.generated.go b/unifi/heat_map_point.generated.go index 93c3acb..23b8fab 100644 --- a/unifi/heat_map_point.generated.go +++ b/unifi/heat_map_point.generated.go @@ -74,7 +74,7 @@ func (c *Client) getHeatMapPoint(ctx context.Context, site, id string) (*HeatMap } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -101,7 +101,7 @@ func (c *Client) createHeatMapPoint(ctx context.Context, site string, d *HeatMap } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -121,7 +121,7 @@ func (c *Client) updateHeatMapPoint(ctx context.Context, site string, d *HeatMap } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/hotspot_2_conf.generated.go b/unifi/hotspot_2_conf.generated.go index 13b449e..94c566e 100644 --- a/unifi/hotspot_2_conf.generated.go +++ b/unifi/hotspot_2_conf.generated.go @@ -453,7 +453,7 @@ func (c *Client) getHotspot2Conf(ctx context.Context, site, id string) (*Hotspot } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -480,7 +480,7 @@ func (c *Client) createHotspot2Conf(ctx context.Context, site string, d *Hotspot } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -500,7 +500,7 @@ func (c *Client) updateHotspot2Conf(ctx context.Context, site string, d *Hotspot } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/hotspot_op.generated.go b/unifi/hotspot_op.generated.go index ef881ce..13c44ca 100644 --- a/unifi/hotspot_op.generated.go +++ b/unifi/hotspot_op.generated.go @@ -72,7 +72,7 @@ func (c *Client) getHotspotOp(ctx context.Context, site, id string) (*HotspotOp, } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -99,7 +99,7 @@ func (c *Client) createHotspotOp(ctx context.Context, site string, d *HotspotOp) } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -119,7 +119,7 @@ func (c *Client) updateHotspotOp(ctx context.Context, site string, d *HotspotOp) } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/hotspot_package.generated.go b/unifi/hotspot_package.generated.go index 415d2e3..1b3b584 100644 --- a/unifi/hotspot_package.generated.go +++ b/unifi/hotspot_package.generated.go @@ -111,7 +111,7 @@ func (c *Client) getHotspotPackage(ctx context.Context, site, id string) (*Hotsp } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -138,7 +138,7 @@ func (c *Client) createHotspotPackage(ctx context.Context, site string, d *Hotsp } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -158,7 +158,7 @@ func (c *Client) updateHotspotPackage(ctx context.Context, site string, d *Hotsp } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/map.generated.go b/unifi/map.generated.go index cc7cf83..1d85cac 100644 --- a/unifi/map.generated.go +++ b/unifi/map.generated.go @@ -87,7 +87,7 @@ func (c *Client) getMap(ctx context.Context, site, id string) (*Map, error) { } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -114,7 +114,7 @@ func (c *Client) createMap(ctx context.Context, site string, d *Map) (*Map, erro } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -134,7 +134,7 @@ func (c *Client) updateMap(ctx context.Context, site string, d *Map) (*Map, erro } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/media_file.generated.go b/unifi/media_file.generated.go index 4d5b95f..8e7a4ab 100644 --- a/unifi/media_file.generated.go +++ b/unifi/media_file.generated.go @@ -70,7 +70,7 @@ func (c *Client) getMediaFile(ctx context.Context, site, id string) (*MediaFile, } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -97,7 +97,7 @@ func (c *Client) createMediaFile(ctx context.Context, site string, d *MediaFile) } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -117,7 +117,7 @@ func (c *Client) updateMediaFile(ctx context.Context, site string, d *MediaFile) } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/network.generated.go b/unifi/network.generated.go index ba6f19c..7c202b7 100644 --- a/unifi/network.generated.go +++ b/unifi/network.generated.go @@ -462,7 +462,7 @@ func (c *Client) getNetwork(ctx context.Context, site, id string) (*Network, err } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -489,7 +489,7 @@ func (c *Client) createNetwork(ctx context.Context, site string, d *Network) (*N } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -509,7 +509,7 @@ func (c *Client) updateNetwork(ctx context.Context, site string, d *Network) (*N } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/port_forward.generated.go b/unifi/port_forward.generated.go index 583eb7c..1cd85a6 100644 --- a/unifi/port_forward.generated.go +++ b/unifi/port_forward.generated.go @@ -104,7 +104,7 @@ func (c *Client) getPortForward(ctx context.Context, site, id string) (*PortForw } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -131,7 +131,7 @@ func (c *Client) createPortForward(ctx context.Context, site string, d *PortForw } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -151,7 +151,7 @@ func (c *Client) updatePortForward(ctx context.Context, site string, d *PortForw } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/port_profile.generated.go b/unifi/port_profile.generated.go index 4f9b148..0f902cb 100644 --- a/unifi/port_profile.generated.go +++ b/unifi/port_profile.generated.go @@ -246,7 +246,7 @@ func (c *Client) getPortProfile(ctx context.Context, site, id string) (*PortProf } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -273,7 +273,7 @@ func (c *Client) createPortProfile(ctx context.Context, site string, d *PortProf } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -293,7 +293,7 @@ func (c *Client) updatePortProfile(ctx context.Context, site string, d *PortProf } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/radius_profile.generated.go b/unifi/radius_profile.generated.go index 2db85fd..7f8f8ae 100644 --- a/unifi/radius_profile.generated.go +++ b/unifi/radius_profile.generated.go @@ -160,7 +160,7 @@ func (c *Client) getRADIUSProfile(ctx context.Context, site, id string) (*RADIUS } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -187,7 +187,7 @@ func (c *Client) createRADIUSProfile(ctx context.Context, site string, d *RADIUS } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -207,7 +207,7 @@ func (c *Client) updateRADIUSProfile(ctx context.Context, site string, d *RADIUS } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/routing.generated.go b/unifi/routing.generated.go index 8fe7cb9..da45457 100644 --- a/unifi/routing.generated.go +++ b/unifi/routing.generated.go @@ -82,7 +82,7 @@ func (c *Client) getRouting(ctx context.Context, site, id string) (*Routing, err } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -109,7 +109,7 @@ func (c *Client) createRouting(ctx context.Context, site string, d *Routing) (*R } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -129,7 +129,7 @@ func (c *Client) updateRouting(ctx context.Context, site string, d *Routing) (*R } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/schedule_task.generated.go b/unifi/schedule_task.generated.go index e4c6147..7394fd2 100644 --- a/unifi/schedule_task.generated.go +++ b/unifi/schedule_task.generated.go @@ -94,7 +94,7 @@ func (c *Client) getScheduleTask(ctx context.Context, site, id string) (*Schedul } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -121,7 +121,7 @@ func (c *Client) createScheduleTask(ctx context.Context, site string, d *Schedul } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -141,7 +141,7 @@ func (c *Client) updateScheduleTask(ctx context.Context, site string, d *Schedul } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting.go b/unifi/setting.go index 33ecbb7..8daa62d 100644 --- a/unifi/setting.go +++ b/unifi/setting.go @@ -103,7 +103,7 @@ func (c *Client) GetSetting(ctx context.Context, site, key string) (*Setting, in } } if setting == nil { - return nil, nil, NotFoundError + return nil, nil, ErrNotFound } fields, err := setting.newFields() diff --git a/unifi/setting_auto_speedtest.generated.go b/unifi/setting_auto_speedtest.generated.go index 3c495d3..7ba0492 100644 --- a/unifi/setting_auto_speedtest.generated.go +++ b/unifi/setting_auto_speedtest.generated.go @@ -59,7 +59,7 @@ func (c *Client) getSettingAutoSpeedtest(ctx context.Context, site string) (*Set } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -79,7 +79,7 @@ func (c *Client) updateSettingAutoSpeedtest(ctx context.Context, site string, d } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_baresip.generated.go b/unifi/setting_baresip.generated.go index 62566e4..1cee34d 100644 --- a/unifi/setting_baresip.generated.go +++ b/unifi/setting_baresip.generated.go @@ -61,7 +61,7 @@ func (c *Client) getSettingBaresip(ctx context.Context, site string) (*SettingBa } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -81,7 +81,7 @@ func (c *Client) updateSettingBaresip(ctx context.Context, site string, d *Setti } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_broadcast.generated.go b/unifi/setting_broadcast.generated.go index 33ff65f..735dea1 100644 --- a/unifi/setting_broadcast.generated.go +++ b/unifi/setting_broadcast.generated.go @@ -63,7 +63,7 @@ func (c *Client) getSettingBroadcast(ctx context.Context, site string) (*Setting } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -83,7 +83,7 @@ func (c *Client) updateSettingBroadcast(ctx context.Context, site string, d *Set } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_connectivity.generated.go b/unifi/setting_connectivity.generated.go index ada9569..5aa712e 100644 --- a/unifi/setting_connectivity.generated.go +++ b/unifi/setting_connectivity.generated.go @@ -63,7 +63,7 @@ func (c *Client) getSettingConnectivity(ctx context.Context, site string) (*Sett } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -83,7 +83,7 @@ func (c *Client) updateSettingConnectivity(ctx context.Context, site string, d * } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_country.generated.go b/unifi/setting_country.generated.go index f6ba59c..3dd65ef 100644 --- a/unifi/setting_country.generated.go +++ b/unifi/setting_country.generated.go @@ -61,7 +61,7 @@ func (c *Client) getSettingCountry(ctx context.Context, site string) (*SettingCo } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -81,7 +81,7 @@ func (c *Client) updateSettingCountry(ctx context.Context, site string, d *Setti } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_dashboard.generated.go b/unifi/setting_dashboard.generated.go index 7d65dfe..eb83ea8 100644 --- a/unifi/setting_dashboard.generated.go +++ b/unifi/setting_dashboard.generated.go @@ -80,7 +80,7 @@ func (c *Client) getSettingDashboard(ctx context.Context, site string) (*Setting } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -100,7 +100,7 @@ func (c *Client) updateSettingDashboard(ctx context.Context, site string, d *Set } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_doh.generated.go b/unifi/setting_doh.generated.go index 5797a1c..272c0e8 100644 --- a/unifi/setting_doh.generated.go +++ b/unifi/setting_doh.generated.go @@ -82,7 +82,7 @@ func (c *Client) getSettingDoh(ctx context.Context, site string) (*SettingDoh, e } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -102,7 +102,7 @@ func (c *Client) updateSettingDoh(ctx context.Context, site string, d *SettingDo } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_dpi.generated.go b/unifi/setting_dpi.generated.go index 2506657..d1acf01 100644 --- a/unifi/setting_dpi.generated.go +++ b/unifi/setting_dpi.generated.go @@ -59,7 +59,7 @@ func (c *Client) getSettingDpi(ctx context.Context, site string) (*SettingDpi, e } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -79,7 +79,7 @@ func (c *Client) updateSettingDpi(ctx context.Context, site string, d *SettingDp } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_element_adopt.generated.go b/unifi/setting_element_adopt.generated.go index a703a06..5ba5bfd 100644 --- a/unifi/setting_element_adopt.generated.go +++ b/unifi/setting_element_adopt.generated.go @@ -60,7 +60,7 @@ func (c *Client) getSettingElementAdopt(ctx context.Context, site string) (*Sett } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -80,7 +80,7 @@ func (c *Client) updateSettingElementAdopt(ctx context.Context, site string, d * } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_ether_lighting.generated.go b/unifi/setting_ether_lighting.generated.go index 8788495..5f8f5ce 100644 --- a/unifi/setting_ether_lighting.generated.go +++ b/unifi/setting_ether_lighting.generated.go @@ -101,7 +101,7 @@ func (c *Client) getSettingEtherLighting(ctx context.Context, site string) (*Set } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -121,7 +121,7 @@ func (c *Client) updateSettingEtherLighting(ctx context.Context, site string, d } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_evaluation_score.generated.go b/unifi/setting_evaluation_score.generated.go index 9f9ee62..3bcad96 100644 --- a/unifi/setting_evaluation_score.generated.go +++ b/unifi/setting_evaluation_score.generated.go @@ -58,7 +58,7 @@ func (c *Client) getSettingEvaluationScore(ctx context.Context, site string) (*S } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -78,7 +78,7 @@ func (c *Client) updateSettingEvaluationScore(ctx context.Context, site string, } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_global_ap.generated.go b/unifi/setting_global_ap.generated.go index 6d54dc0..4f16364 100644 --- a/unifi/setting_global_ap.generated.go +++ b/unifi/setting_global_ap.generated.go @@ -80,7 +80,7 @@ func (c *Client) getSettingGlobalAp(ctx context.Context, site string) (*SettingG } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -100,7 +100,7 @@ func (c *Client) updateSettingGlobalAp(ctx context.Context, site string, d *Sett } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_global_nat.generated.go b/unifi/setting_global_nat.generated.go index 317476d..9211a10 100644 --- a/unifi/setting_global_nat.generated.go +++ b/unifi/setting_global_nat.generated.go @@ -59,7 +59,7 @@ func (c *Client) getSettingGlobalNat(ctx context.Context, site string) (*Setting } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -79,7 +79,7 @@ func (c *Client) updateSettingGlobalNat(ctx context.Context, site string, d *Set } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_global_switch.generated.go b/unifi/setting_global_switch.generated.go index 9990415..5822012 100644 --- a/unifi/setting_global_switch.generated.go +++ b/unifi/setting_global_switch.generated.go @@ -88,7 +88,7 @@ func (c *Client) getSettingGlobalSwitch(ctx context.Context, site string) (*Sett } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -108,7 +108,7 @@ func (c *Client) updateSettingGlobalSwitch(ctx context.Context, site string, d * } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_guest_access.generated.go b/unifi/setting_guest_access.generated.go index 5459c95..fa4dfff 100644 --- a/unifi/setting_guest_access.generated.go +++ b/unifi/setting_guest_access.generated.go @@ -167,7 +167,7 @@ func (c *Client) getSettingGuestAccess(ctx context.Context, site string) (*Setti } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -187,7 +187,7 @@ func (c *Client) updateSettingGuestAccess(ctx context.Context, site string, d *S } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_ips.generated.go b/unifi/setting_ips.generated.go index 95d0e19..7b9ece8 100644 --- a/unifi/setting_ips.generated.go +++ b/unifi/setting_ips.generated.go @@ -234,7 +234,7 @@ func (c *Client) getSettingIps(ctx context.Context, site string) (*SettingIps, e } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -254,7 +254,7 @@ func (c *Client) updateSettingIps(ctx context.Context, site string, d *SettingIp } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_lcm.generated.go b/unifi/setting_lcm.generated.go index 514a2cc..68699d5 100644 --- a/unifi/setting_lcm.generated.go +++ b/unifi/setting_lcm.generated.go @@ -67,7 +67,7 @@ func (c *Client) getSettingLcm(ctx context.Context, site string) (*SettingLcm, e } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -87,7 +87,7 @@ func (c *Client) updateSettingLcm(ctx context.Context, site string, d *SettingLc } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_locale.generated.go b/unifi/setting_locale.generated.go index 3e88abf..4232de2 100644 --- a/unifi/setting_locale.generated.go +++ b/unifi/setting_locale.generated.go @@ -58,7 +58,7 @@ func (c *Client) getSettingLocale(ctx context.Context, site string) (*SettingLoc } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -78,7 +78,7 @@ func (c *Client) updateSettingLocale(ctx context.Context, site string, d *Settin } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_magic_site_to_site_vpn.generated.go b/unifi/setting_magic_site_to_site_vpn.generated.go index 57982a6..7cfcb0c 100644 --- a/unifi/setting_magic_site_to_site_vpn.generated.go +++ b/unifi/setting_magic_site_to_site_vpn.generated.go @@ -58,7 +58,7 @@ func (c *Client) getSettingMagicSiteToSiteVpn(ctx context.Context, site string) } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -78,7 +78,7 @@ func (c *Client) updateSettingMagicSiteToSiteVpn(ctx context.Context, site strin } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_mgmt.generated.go b/unifi/setting_mgmt.generated.go index 5db7e66..201c641 100644 --- a/unifi/setting_mgmt.generated.go +++ b/unifi/setting_mgmt.generated.go @@ -105,7 +105,7 @@ func (c *Client) getSettingMgmt(ctx context.Context, site string) (*SettingMgmt, } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -125,7 +125,7 @@ func (c *Client) updateSettingMgmt(ctx context.Context, site string, d *SettingM } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_netflow.generated.go b/unifi/setting_netflow.generated.go index 4bab8dc..b159470 100644 --- a/unifi/setting_netflow.generated.go +++ b/unifi/setting_netflow.generated.go @@ -81,7 +81,7 @@ func (c *Client) getSettingNetflow(ctx context.Context, site string) (*SettingNe } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -101,7 +101,7 @@ func (c *Client) updateSettingNetflow(ctx context.Context, site string, d *Setti } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_network_optimization.generated.go b/unifi/setting_network_optimization.generated.go index 51c8239..30b5f8c 100644 --- a/unifi/setting_network_optimization.generated.go +++ b/unifi/setting_network_optimization.generated.go @@ -58,7 +58,7 @@ func (c *Client) getSettingNetworkOptimization(ctx context.Context, site string) } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -78,7 +78,7 @@ func (c *Client) updateSettingNetworkOptimization(ctx context.Context, site stri } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_ntp.generated.go b/unifi/setting_ntp.generated.go index 6dd8b51..ca3da5b 100644 --- a/unifi/setting_ntp.generated.go +++ b/unifi/setting_ntp.generated.go @@ -62,7 +62,7 @@ func (c *Client) getSettingNtp(ctx context.Context, site string) (*SettingNtp, e } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -82,7 +82,7 @@ func (c *Client) updateSettingNtp(ctx context.Context, site string, d *SettingNt } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_porta.generated.go b/unifi/setting_porta.generated.go index e4021f0..718732c 100644 --- a/unifi/setting_porta.generated.go +++ b/unifi/setting_porta.generated.go @@ -58,7 +58,7 @@ func (c *Client) getSettingPorta(ctx context.Context, site string) (*SettingPort } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -78,7 +78,7 @@ func (c *Client) updateSettingPorta(ctx context.Context, site string, d *Setting } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_provider_capabilities.generated.go b/unifi/setting_provider_capabilities.generated.go index 95f4290..28bf0f5 100644 --- a/unifi/setting_provider_capabilities.generated.go +++ b/unifi/setting_provider_capabilities.generated.go @@ -65,7 +65,7 @@ func (c *Client) getSettingProviderCapabilities(ctx context.Context, site string } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -85,7 +85,7 @@ func (c *Client) updateSettingProviderCapabilities(ctx context.Context, site str } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_radio_ai.generated.go b/unifi/setting_radio_ai.generated.go index e3ee60f..78f3f0e 100644 --- a/unifi/setting_radio_ai.generated.go +++ b/unifi/setting_radio_ai.generated.go @@ -125,7 +125,7 @@ func (c *Client) getSettingRadioAi(ctx context.Context, site string) (*SettingRa } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -145,7 +145,7 @@ func (c *Client) updateSettingRadioAi(ctx context.Context, site string, d *Setti } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_radius.generated.go b/unifi/setting_radius.generated.go index 605346b..73847d2 100644 --- a/unifi/setting_radius.generated.go +++ b/unifi/setting_radius.generated.go @@ -72,7 +72,7 @@ func (c *Client) getSettingRadius(ctx context.Context, site string) (*SettingRad } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -92,7 +92,7 @@ func (c *Client) updateSettingRadius(ctx context.Context, site string, d *Settin } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_rsyslogd.generated.go b/unifi/setting_rsyslogd.generated.go index 5b4c64b..bdd550c 100644 --- a/unifi/setting_rsyslogd.generated.go +++ b/unifi/setting_rsyslogd.generated.go @@ -73,7 +73,7 @@ func (c *Client) getSettingRsyslogd(ctx context.Context, site string) (*SettingR } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -93,7 +93,7 @@ func (c *Client) updateSettingRsyslogd(ctx context.Context, site string, d *Sett } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_snmp.generated.go b/unifi/setting_snmp.generated.go index 1e369ce..e169d6a 100644 --- a/unifi/setting_snmp.generated.go +++ b/unifi/setting_snmp.generated.go @@ -62,7 +62,7 @@ func (c *Client) getSettingSnmp(ctx context.Context, site string) (*SettingSnmp, } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -82,7 +82,7 @@ func (c *Client) updateSettingSnmp(ctx context.Context, site string, d *SettingS } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_ssl_inspection.generated.go b/unifi/setting_ssl_inspection.generated.go index 7dc6cdc..4864037 100644 --- a/unifi/setting_ssl_inspection.generated.go +++ b/unifi/setting_ssl_inspection.generated.go @@ -58,7 +58,7 @@ func (c *Client) getSettingSslInspection(ctx context.Context, site string) (*Set } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -78,7 +78,7 @@ func (c *Client) updateSettingSslInspection(ctx context.Context, site string, d } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_super_cloudaccess.generated.go b/unifi/setting_super_cloudaccess.generated.go index 1eb284c..91d2294 100644 --- a/unifi/setting_super_cloudaccess.generated.go +++ b/unifi/setting_super_cloudaccess.generated.go @@ -64,7 +64,7 @@ func (c *Client) getSettingSuperCloudaccess(ctx context.Context, site string) (* } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -84,7 +84,7 @@ func (c *Client) updateSettingSuperCloudaccess(ctx context.Context, site string, } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_super_events.generated.go b/unifi/setting_super_events.generated.go index 48bd4ca..aa076f8 100644 --- a/unifi/setting_super_events.generated.go +++ b/unifi/setting_super_events.generated.go @@ -58,7 +58,7 @@ func (c *Client) getSettingSuperEvents(ctx context.Context, site string) (*Setti } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -78,7 +78,7 @@ func (c *Client) updateSettingSuperEvents(ctx context.Context, site string, d *S } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_super_fwupdate.generated.go b/unifi/setting_super_fwupdate.generated.go index 2cd461f..83ecd51 100644 --- a/unifi/setting_super_fwupdate.generated.go +++ b/unifi/setting_super_fwupdate.generated.go @@ -60,7 +60,7 @@ func (c *Client) getSettingSuperFwupdate(ctx context.Context, site string) (*Set } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -80,7 +80,7 @@ func (c *Client) updateSettingSuperFwupdate(ctx context.Context, site string, d } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_super_identity.generated.go b/unifi/setting_super_identity.generated.go index 447484a..26407ef 100644 --- a/unifi/setting_super_identity.generated.go +++ b/unifi/setting_super_identity.generated.go @@ -59,7 +59,7 @@ func (c *Client) getSettingSuperIdentity(ctx context.Context, site string) (*Set } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -79,7 +79,7 @@ func (c *Client) updateSettingSuperIdentity(ctx context.Context, site string, d } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_super_mail.generated.go b/unifi/setting_super_mail.generated.go index c662710..2a2ce34 100644 --- a/unifi/setting_super_mail.generated.go +++ b/unifi/setting_super_mail.generated.go @@ -58,7 +58,7 @@ func (c *Client) getSettingSuperMail(ctx context.Context, site string) (*Setting } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -78,7 +78,7 @@ func (c *Client) updateSettingSuperMail(ctx context.Context, site string, d *Set } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_super_mgmt.generated.go b/unifi/setting_super_mgmt.generated.go index a838317..ab3d3c8 100644 --- a/unifi/setting_super_mgmt.generated.go +++ b/unifi/setting_super_mgmt.generated.go @@ -123,7 +123,7 @@ func (c *Client) getSettingSuperMgmt(ctx context.Context, site string) (*Setting } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -143,7 +143,7 @@ func (c *Client) updateSettingSuperMgmt(ctx context.Context, site string, d *Set } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_super_sdn.generated.go b/unifi/setting_super_sdn.generated.go index cae225a..ebbfd2f 100644 --- a/unifi/setting_super_sdn.generated.go +++ b/unifi/setting_super_sdn.generated.go @@ -63,7 +63,7 @@ func (c *Client) getSettingSuperSdn(ctx context.Context, site string) (*SettingS } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -83,7 +83,7 @@ func (c *Client) updateSettingSuperSdn(ctx context.Context, site string, d *Sett } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_super_smtp.generated.go b/unifi/setting_super_smtp.generated.go index acca0b5..a27aac6 100644 --- a/unifi/setting_super_smtp.generated.go +++ b/unifi/setting_super_smtp.generated.go @@ -69,7 +69,7 @@ func (c *Client) getSettingSuperSmtp(ctx context.Context, site string) (*Setting } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -89,7 +89,7 @@ func (c *Client) updateSettingSuperSmtp(ctx context.Context, site string, d *Set } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_teleport.generated.go b/unifi/setting_teleport.generated.go index c7eeb46..12c40c9 100644 --- a/unifi/setting_teleport.generated.go +++ b/unifi/setting_teleport.generated.go @@ -59,7 +59,7 @@ func (c *Client) getSettingTeleport(ctx context.Context, site string) (*SettingT } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -79,7 +79,7 @@ func (c *Client) updateSettingTeleport(ctx context.Context, site string, d *Sett } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_usg.generated.go b/unifi/setting_usg.generated.go index 35f3071..f1f2e3c 100644 --- a/unifi/setting_usg.generated.go +++ b/unifi/setting_usg.generated.go @@ -170,7 +170,7 @@ func (c *Client) getSettingUsg(ctx context.Context, site string) (*SettingUsg, e } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -190,7 +190,7 @@ func (c *Client) updateSettingUsg(ctx context.Context, site string, d *SettingUs } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/setting_usw.generated.go b/unifi/setting_usw.generated.go index b2ab821..1971ec9 100644 --- a/unifi/setting_usw.generated.go +++ b/unifi/setting_usw.generated.go @@ -58,7 +58,7 @@ func (c *Client) getSettingUsw(ctx context.Context, site string) (*SettingUsw, e } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -78,7 +78,7 @@ func (c *Client) updateSettingUsw(ctx context.Context, site string, d *SettingUs } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/sites.go b/unifi/sites.go index 6ceae39..41a450e 100644 --- a/unifi/sites.go +++ b/unifi/sites.go @@ -45,7 +45,7 @@ func (c *Client) GetSite(ctx context.Context, id string) (*Site, error) { } } - return nil, NotFoundError + return nil, ErrNotFound } func (c *Client) CreateSite(ctx context.Context, description string) ([]Site, error) { diff --git a/unifi/spatial_record.generated.go b/unifi/spatial_record.generated.go index 3f696d1..3a733bd 100644 --- a/unifi/spatial_record.generated.go +++ b/unifi/spatial_record.generated.go @@ -114,7 +114,7 @@ func (c *Client) getSpatialRecord(ctx context.Context, site, id string) (*Spatia } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -141,7 +141,7 @@ func (c *Client) createSpatialRecord(ctx context.Context, site string, d *Spatia } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -161,7 +161,7 @@ func (c *Client) updateSpatialRecord(ctx context.Context, site string, d *Spatia } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/sysinfo.go b/unifi/sysinfo.go index 5cbb7dd..c217e8a 100644 --- a/unifi/sysinfo.go +++ b/unifi/sysinfo.go @@ -5,7 +5,7 @@ import ( "fmt" ) -type sysInfo struct { +type sysInfo struct { //nolint: unused Timezone string `json:"timezone"` Version string `json:"version"` PreviousVersion string `json:"previous_version"` @@ -66,7 +66,7 @@ type sysInfo struct { */ } -func (c *Client) sysinfo(ctx context.Context, id string) (*sysInfo, error) { +func (c *Client) sysinfo(ctx context.Context, id string) (*sysInfo, error) { //nolint: unused var respBody struct { Meta Meta `json:"Meta"` Data []sysInfo `json:"data"` @@ -78,7 +78,7 @@ func (c *Client) sysinfo(ctx context.Context, id string) (*sysInfo, error) { } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } return &respBody.Data[0], nil diff --git a/unifi/tag.generated.go b/unifi/tag.generated.go index e48238e..299c54a 100644 --- a/unifi/tag.generated.go +++ b/unifi/tag.generated.go @@ -71,7 +71,7 @@ func (c *Client) getTag(ctx context.Context, site, id string) (*Tag, error) { } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -98,7 +98,7 @@ func (c *Client) createTag(ctx context.Context, site string, d *Tag) (*Tag, erro } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -118,7 +118,7 @@ func (c *Client) updateTag(ctx context.Context, site string, d *Tag) (*Tag, erro } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/unifi.go b/unifi/unifi.go index 77b938f..8072e65 100644 --- a/unifi/unifi.go +++ b/unifi/unifi.go @@ -37,7 +37,7 @@ const ( defaultUserAgent = "go-unifi/0.0.1" - ApiKeyHeader = "X-API-Key" + ApiKeyHeader = "X-Api-Key" CsrfHeader = "X-Csrf-Token" UserAgentHeader = "User-Agent" AcceptHeader = "Accept" @@ -45,8 +45,8 @@ const ( ) var ( - AuthenticationFailedError = fmt.Errorf("authentication failed") - NotFoundError = fmt.Errorf("not found") + ErrAuthenticationFailed = errors.New("authentication failed") + ErrNotFound = errors.New("not found") ) type APIError struct { @@ -154,6 +154,7 @@ func (a *ApiKeyAuthInterceptor) InterceptRequest(req *http.Request) error { req.Header.Set(ApiKeyHeader, a.apiKey) return nil } + func (a *ApiKeyAuthInterceptor) InterceptResponse(_ *http.Response) error { return nil } @@ -209,9 +210,9 @@ func (d *DefaultResponseErrorHandler) HandleError(resp *http.Response) error { case http.StatusOK: return nil case http.StatusNotFound: - return NotFoundError + return ErrNotFound case http.StatusUnauthorized: - return AuthenticationFailedError + return ErrAuthenticationFailed } errBody := struct { Meta Meta `json:"Meta"` @@ -280,7 +281,7 @@ func newUnifi(config *ClientConfig) (*Client, error) { config.URL = strings.TrimRight(config.URL, "/") transport := &http.Transport{ Proxy: http.ProxyFromEnvironment, - TLSClientConfig: &tls.Config{InsecureSkipVerify: !config.VerifySSL}, // nolint: gosec + TLSClientConfig: &tls.Config{InsecureSkipVerify: !config.VerifySSL}, //nolint: gosec } if config.HttpCustomizer != nil { @@ -403,7 +404,7 @@ func (c *Client) determineApiStyle() error { ctx, cancel := c.createRequestContext() defer cancel() - //c.DebugLog("Requesting %s/ to determine API paths", c.URL) + // c.DebugLog("Requesting %s/ to determine API paths", c.URL) req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.BaseURL.String(), nil) if err != nil { @@ -435,7 +436,7 @@ func (c *Client) determineApiStyle() error { return fmt.Errorf("expected 200 or 302 status code, but got: %d", resp.StatusCode) } if c.apiPaths == &OldStyleAPI && c.config.APIKey != "" { - return fmt.Errorf("unable to use API key authentication with old style API. Switch to user/pass authentication or update controller to latest version") + return errors.New("unable to use API key authentication with old style API. Switch to user/pass authentication or update controller to latest version") } return nil } @@ -460,7 +461,7 @@ func (c *Client) GetServerInfo() (*ServerInfo, error) { func marshalRequest(reqBody interface{}) (io.Reader, error) { if reqBody == nil { - return nil, nil + return nil, nil //nolint: nilnil } reqBytes, err := json.Marshal(reqBody) if err != nil { @@ -511,13 +512,7 @@ func (c *Client) Do(ctx context.Context, method, apiPath string, reqBody interfa if err != nil { return fmt.Errorf("unable to perform request: %s %s %w", method, apiPath, err) } - defer func(body io.ReadCloser) { - err := body.Close() - if err != nil { - // TODO use logger - fmt.Printf("error closing body: %s", err) - } - }(resp.Body) + defer resp.Body.Close() for _, interceptor := range c.interceptors { if err := interceptor.InterceptResponse(resp); err != nil { diff --git a/unifi/unifi_test.go b/unifi/unifi_test.go index 63227d8..f75ee4e 100644 --- a/unifi/unifi_test.go +++ b/unifi/unifi_test.go @@ -1,10 +1,10 @@ -package unifi +package unifi //nolint: testpackage import ( "context" "encoding/json" + "errors" "fmt" - "github.com/stretchr/testify/assert" "io" "net/http" "net/http/httptest" @@ -12,6 +12,9 @@ import ( "slices" "strings" "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) const ( @@ -21,8 +24,8 @@ const ( func verifyContainsInterceptors(a *assert.Assertions, c *Client, interceptors ...interface{}) { var ( - expectedTypes []reflect.Type - matchingTypes []reflect.Type + expectedTypes = make([]reflect.Type, len(interceptors)) + matchingTypes = make([]reflect.Type, len(interceptors)) ) for _, i := range interceptors { expectedTypes = append(expectedTypes, reflect.TypeOf(i)) @@ -40,8 +43,8 @@ func verifyContainsInterceptors(a *assert.Assertions, c *Client, interceptors .. func verifyDoesNotContainInterceptors(a *assert.Assertions, c *Client, interceptors ...interface{}) { var ( - expectedTypes []reflect.Type - matchingTypes []reflect.Type + expectedTypes = make([]reflect.Type, 0, len(interceptors)) + matchingTypes = make([]reflect.Type, 0, len(interceptors)) ) for _, i := range interceptors { expectedTypes = append(expectedTypes, reflect.TypeOf(i)) @@ -66,7 +69,7 @@ func TestNewClient(t *testing.T) { Pass: "password", VerifySSL: false, }) - a.NotNil(err) + require.Error(t, err) a.EqualValues(localUrl, c.BaseURL.String()) a.Contains(err.Error(), "connection refused", "an invalid destination should produce a connection error.") verifyContainsInterceptors(a, c, &CsrfInterceptor{}, &DefaultHeadersInterceptor{}) @@ -84,7 +87,7 @@ func TestNewClientWithApiKey(t *testing.T) { }) // then - a.NotNil(err) + require.Error(t, err) a.EqualValues(localUrl, c.BaseURL.String()) a.Contains(err.Error(), "connection refused", "an invalid destination should produce a connection error.") verifyContainsInterceptors(a, c, &ApiKeyAuthInterceptor{}, &DefaultHeadersInterceptor{}) @@ -98,7 +101,7 @@ func TestCustomizeHttpClient(t *testing.T) { called := false // when - NewClient(&ClientConfig{ + _, err := NewClient(&ClientConfig{ URL: localUrl, HttpCustomizer: func(transport *http.Transport) error { called = true @@ -107,6 +110,7 @@ func TestCustomizeHttpClient(t *testing.T) { }) // then + require.Error(t, err) a.True(called, "http customizer not called") } @@ -127,10 +131,11 @@ func (i *TestInterceptor) IsResponseIntercepted() bool { func (i *TestInterceptor) InterceptRequest(req *http.Request) error { i.request = req if i.failOnRequest { - return fmt.Errorf("request interceptor failed") + return errors.New("request interceptor failed") } return nil } + func (i *TestInterceptor) InterceptResponse(resp *http.Response) error { i.response = resp return nil @@ -174,9 +179,10 @@ func TestInterceptors(t *testing.T) { c, interceptor := NewTestClientWithInterceptor() // when - c.Get(context.Background(), "/", nil, nil) + err := c.Get(context.Background(), "/", nil, nil) // then + require.Error(t, err) a.True(interceptor.IsRequestIntercepted(), "request interceptor not called") a.False(interceptor.IsResponseIntercepted(), "response interceptor called, but should not because of failed request") } @@ -192,7 +198,7 @@ func TestNoSendRequestWhenRequestInterceptorReturnsError(t *testing.T) { err := c.Get(context.Background(), "/", nil, nil) // then - a.NotNil(err) + require.Error(t, err) a.Contains(err.Error(), "request interceptor failed") } @@ -211,15 +217,18 @@ func TestProperRequestUrl(t *testing.T) { {"/test", testUrl + "/test"}, {"/test/test", testUrl + "/test/test"}, } - // given - c, interceptor := NewTestClientWithInterceptor() for _, tc := range testCases { t.Run(tc.path, func(t *testing.T) { + t.Parallel() + // given + c, interceptor := NewTestClientWithInterceptor() + // when - c.Get(context.Background(), tc.path, nil, nil) + err := c.Get(context.Background(), tc.path, nil, nil) // then + require.Error(t, err) a.EqualValues(tc.expected, interceptor.request.URL.String()) }) } @@ -232,9 +241,10 @@ func TestApiKeyAddedToRequest(t *testing.T) { c, interceptor := NewTestClientWithInterceptor() // when - c.Get(context.Background(), "/", nil, nil) + err := c.Get(context.Background(), "/", nil, nil) // then + require.Error(t, err) a.EqualValues("test-key", interceptor.RequestHeader(ApiKeyHeader)) } @@ -243,11 +253,12 @@ func TestDefaultHeadersAddedToRequest(t *testing.T) { a := assert.New(t) // given c, interceptor := NewTestClientWithInterceptor() - + // when - c.Get(context.Background(), "/", nil, nil) + err := c.Get(context.Background(), "/", nil, nil) // then + require.Error(t, err) a.EqualValues("application/json", interceptor.RequestHeader(AcceptHeader)) a.EqualValues("application/json; charset=utf-8", interceptor.RequestHeader(ContentTypeHeader)) a.EqualValues(defaultUserAgent, interceptor.RequestHeader(UserAgentHeader)) @@ -267,13 +278,13 @@ func TestRequestSentWithJson(t *testing.T) { } // when - c.Get(context.Background(), "/", data, nil) + err := c.Get(context.Background(), "/", data, nil) // then + require.Error(t, err) body := &TestData{} - err := json.NewDecoder(interceptor.request.Body).Decode(body) - - a.Nil(err) + err = json.NewDecoder(interceptor.request.Body).Decode(body) + require.NoError(t, err) a.Equal(data, body) } @@ -283,19 +294,18 @@ func TestRequestMethod(t *testing.T) { testCases := []string{ http.MethodGet, http.MethodPost, http.MethodPut, http.MethodDelete, http.MethodPatch, http.MethodOptions, http.MethodHead, http.MethodTrace, http.MethodConnect, } - // given - c, interceptor := NewTestClientWithInterceptor() - // when - c.Post(context.Background(), "/", nil, nil) - - // then for _, tc := range testCases { t.Run(tc, func(t *testing.T) { + t.Parallel() + // given + c, interceptor := NewTestClientWithInterceptor() + // when - c.Do(context.Background(), tc, "", nil, nil) + err := c.Do(context.Background(), tc, "", nil, nil) // then + require.Error(t, err) a.EqualValues(tc, interceptor.Method()) }) } @@ -308,9 +318,10 @@ func TestGetRequest(t *testing.T) { c, interceptor := NewTestClientWithInterceptor() // when - c.Get(context.Background(), "/", nil, nil) + err := c.Get(context.Background(), "/", nil, nil) // then + require.Error(t, err) a.EqualValues(http.MethodGet, interceptor.Method()) } @@ -321,9 +332,10 @@ func TestPostRequest(t *testing.T) { c, interceptor := NewTestClientWithInterceptor() // when - c.Post(context.Background(), "/", nil, nil) + err := c.Post(context.Background(), "/", nil, nil) // then + require.Error(t, err) a.EqualValues(http.MethodPost, interceptor.Method()) } @@ -334,9 +346,10 @@ func TestPutRequest(t *testing.T) { c, interceptor := NewTestClientWithInterceptor() // when - c.Put(context.Background(), "/", nil, nil) + err := c.Put(context.Background(), "/", nil, nil) // then + require.Error(t, err) a.EqualValues(http.MethodPut, interceptor.Method()) } @@ -347,9 +360,10 @@ func TestDeleteRequest(t *testing.T) { c, interceptor := NewTestClientWithInterceptor() // when - c.Delete(context.Background(), "/", nil, nil) + err := c.Delete(context.Background(), "/", nil, nil) // then + require.Error(t, err) a.EqualValues(http.MethodDelete, interceptor.Method()) } @@ -411,7 +425,7 @@ func TestUnifiIntegrationUserPassInjected(t *testing.T) { err := c.Login() // then - a.Nil(err, "user/pass login must not produce an error") + require.NoError(t, err, "user/pass login must not produce an error") a.EqualValues(http.MethodPost, interceptor.Method()) a.EqualValues(http.StatusOK, interceptor.response.StatusCode) } @@ -434,7 +448,7 @@ func TestResponseDataHandling(t *testing.T) { err := c.Get(context.Background(), "test", reqData, &data) // then - a.Nil(err) + require.NoError(t, err) a.EqualValues("test", data.Data) } @@ -451,16 +465,18 @@ func TestCsrfHandling(t *testing.T) { c.apiPaths = &NewStyleAPI // when - c.Get(context.Background(), "", nil, nil) + err := c.Get(context.Background(), "", nil, nil) // then + require.Error(t, err) a.EqualValues("", interceptor.RequestHeader(CsrfHeader)) a.EqualValues("csrf-token", interceptor.ResponseHeader(CsrfHeader)) // when - c.Get(context.Background(), "", nil, nil) + err = c.Get(context.Background(), "", nil, nil) // then + require.Error(t, err) a.EqualValues("csrf-token", interceptor.RequestHeader(CsrfHeader)) } @@ -477,8 +493,9 @@ func TestOverrideUserAgent(t *testing.T) { c.apiPaths = &NewStyleAPI // when - c.Get(context.Background(), "", nil, nil) + err := c.Get(context.Background(), "", nil, nil) // then + require.Error(t, err) a.EqualValues("test-agent", interceptor.RequestHeader(UserAgentHeader)) } diff --git a/unifi/user.generated.go b/unifi/user.generated.go index 1fd1b66..99c0282 100644 --- a/unifi/user.generated.go +++ b/unifi/user.generated.go @@ -91,7 +91,7 @@ func (c *Client) getUser(ctx context.Context, site, id string) (*User, error) { } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -118,7 +118,7 @@ func (c *Client) createUser(ctx context.Context, site string, d *User) (*User, e } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -138,7 +138,7 @@ func (c *Client) updateUser(ctx context.Context, site string, d *User) (*User, e } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/user.go b/unifi/user.go index 2f78093..0690590 100644 --- a/unifi/user.go +++ b/unifi/user.go @@ -21,7 +21,7 @@ func (c *Client) GetUserByMAC(ctx context.Context, site, mac string) (*User, err } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -63,7 +63,7 @@ func (c *Client) CreateUser(ctx context.Context, site string, d *User) (*User, e } if len(respBody.Data[0].Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } user := respBody.Data[0].Data[0] @@ -101,7 +101,7 @@ func (c *Client) BlockUserByMAC(ctx context.Context, site, mac string) error { return err } if len(users) != 1 { - return NotFoundError + return ErrNotFound } return nil } @@ -114,7 +114,7 @@ func (c *Client) UnblockUserByMAC(ctx context.Context, site, mac string) error { return err } if len(users) != 1 { - return NotFoundError + return ErrNotFound } return nil } @@ -127,7 +127,7 @@ func (c *Client) DeleteUserByMAC(ctx context.Context, site, mac string) error { return err } if len(users) != 1 { - return NotFoundError + return ErrNotFound } return nil } @@ -140,7 +140,7 @@ func (c *Client) KickUserByMAC(ctx context.Context, site, mac string) error { return err } if len(users) != 1 { - return NotFoundError + return ErrNotFound } return nil } diff --git a/unifi/user_group.generated.go b/unifi/user_group.generated.go index b29202a..d1dbba8 100644 --- a/unifi/user_group.generated.go +++ b/unifi/user_group.generated.go @@ -77,7 +77,7 @@ func (c *Client) getUserGroup(ctx context.Context, site, id string) (*UserGroup, } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -104,7 +104,7 @@ func (c *Client) createUserGroup(ctx context.Context, site string, d *UserGroup) } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -124,7 +124,7 @@ func (c *Client) updateUserGroup(ctx context.Context, site string, d *UserGroup) } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/virtual_device.generated.go b/unifi/virtual_device.generated.go index d0f5b35..e7523da 100644 --- a/unifi/virtual_device.generated.go +++ b/unifi/virtual_device.generated.go @@ -75,7 +75,7 @@ func (c *Client) getVirtualDevice(ctx context.Context, site, id string) (*Virtua } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -102,7 +102,7 @@ func (c *Client) createVirtualDevice(ctx context.Context, site string, d *Virtua } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -122,7 +122,7 @@ func (c *Client) updateVirtualDevice(ctx context.Context, site string, d *Virtua } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/wlan.generated.go b/unifi/wlan.generated.go index 311540b..319073b 100644 --- a/unifi/wlan.generated.go +++ b/unifi/wlan.generated.go @@ -492,7 +492,7 @@ func (c *Client) getWLAN(ctx context.Context, site, id string) (*WLAN, error) { } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -519,7 +519,7 @@ func (c *Client) createWLAN(ctx context.Context, site string, d *WLAN) (*WLAN, e } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -539,7 +539,7 @@ func (c *Client) updateWLAN(ctx context.Context, site string, d *WLAN) (*WLAN, e } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] diff --git a/unifi/wlan_group.generated.go b/unifi/wlan_group.generated.go index 0033e52..0bcaff3 100644 --- a/unifi/wlan_group.generated.go +++ b/unifi/wlan_group.generated.go @@ -70,7 +70,7 @@ func (c *Client) getWLANGroup(ctx context.Context, site, id string) (*WLANGroup, } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } d := respBody.Data[0] @@ -97,7 +97,7 @@ func (c *Client) createWLANGroup(ctx context.Context, site string, d *WLANGroup) } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0] @@ -117,7 +117,7 @@ func (c *Client) updateWLANGroup(ctx context.Context, site string, d *WLANGroup) } if len(respBody.Data) != 1 { - return nil, NotFoundError + return nil, ErrNotFound } new := respBody.Data[0]