chore: apply linter fixes
This commit is contained in:
committed by
Mateusz Filipowicz
parent
685572d5ce
commit
d79f581c1f
6
unifi/account.generated.go
generated
6
unifi/account.generated.go
generated
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
|
||||
6
unifi/broadcast_group.generated.go
generated
6
unifi/broadcast_group.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/channel_plan.generated.go
generated
6
unifi/channel_plan.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/dashboard.generated.go
generated
6
unifi/dashboard.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/device.generated.go
generated
6
unifi/device.generated.go
generated
@@ -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]
|
||||
|
||||
@@ -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 {
|
||||
|
||||
6
unifi/dhcp_option.generated.go
generated
6
unifi/dhcp_option.generated.go
generated
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
6
unifi/dpi_app.generated.go
generated
6
unifi/dpi_app.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/dpi_group.generated.go
generated
6
unifi/dpi_group.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/dynamic_dns.generated.go
generated
6
unifi/dynamic_dns.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/firewall_group.generated.go
generated
6
unifi/firewall_group.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/firewall_rule.generated.go
generated
6
unifi/firewall_rule.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/heat_map.generated.go
generated
6
unifi/heat_map.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/heat_map_point.generated.go
generated
6
unifi/heat_map_point.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/hotspot_2_conf.generated.go
generated
6
unifi/hotspot_2_conf.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/hotspot_op.generated.go
generated
6
unifi/hotspot_op.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/hotspot_package.generated.go
generated
6
unifi/hotspot_package.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/map.generated.go
generated
6
unifi/map.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/media_file.generated.go
generated
6
unifi/media_file.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/network.generated.go
generated
6
unifi/network.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/port_forward.generated.go
generated
6
unifi/port_forward.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/port_profile.generated.go
generated
6
unifi/port_profile.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/radius_profile.generated.go
generated
6
unifi/radius_profile.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/routing.generated.go
generated
6
unifi/routing.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/schedule_task.generated.go
generated
6
unifi/schedule_task.generated.go
generated
@@ -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]
|
||||
|
||||
@@ -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()
|
||||
|
||||
4
unifi/setting_auto_speedtest.generated.go
generated
4
unifi/setting_auto_speedtest.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_baresip.generated.go
generated
4
unifi/setting_baresip.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_broadcast.generated.go
generated
4
unifi/setting_broadcast.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_connectivity.generated.go
generated
4
unifi/setting_connectivity.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_country.generated.go
generated
4
unifi/setting_country.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_dashboard.generated.go
generated
4
unifi/setting_dashboard.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_doh.generated.go
generated
4
unifi/setting_doh.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_dpi.generated.go
generated
4
unifi/setting_dpi.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_element_adopt.generated.go
generated
4
unifi/setting_element_adopt.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_ether_lighting.generated.go
generated
4
unifi/setting_ether_lighting.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_evaluation_score.generated.go
generated
4
unifi/setting_evaluation_score.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_global_ap.generated.go
generated
4
unifi/setting_global_ap.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_global_nat.generated.go
generated
4
unifi/setting_global_nat.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_global_switch.generated.go
generated
4
unifi/setting_global_switch.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_guest_access.generated.go
generated
4
unifi/setting_guest_access.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_ips.generated.go
generated
4
unifi/setting_ips.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_lcm.generated.go
generated
4
unifi/setting_lcm.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_locale.generated.go
generated
4
unifi/setting_locale.generated.go
generated
@@ -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]
|
||||
|
||||
@@ -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]
|
||||
|
||||
4
unifi/setting_mgmt.generated.go
generated
4
unifi/setting_mgmt.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_netflow.generated.go
generated
4
unifi/setting_netflow.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_network_optimization.generated.go
generated
4
unifi/setting_network_optimization.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_ntp.generated.go
generated
4
unifi/setting_ntp.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_porta.generated.go
generated
4
unifi/setting_porta.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_provider_capabilities.generated.go
generated
4
unifi/setting_provider_capabilities.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_radio_ai.generated.go
generated
4
unifi/setting_radio_ai.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_radius.generated.go
generated
4
unifi/setting_radius.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_rsyslogd.generated.go
generated
4
unifi/setting_rsyslogd.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_snmp.generated.go
generated
4
unifi/setting_snmp.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_ssl_inspection.generated.go
generated
4
unifi/setting_ssl_inspection.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_super_cloudaccess.generated.go
generated
4
unifi/setting_super_cloudaccess.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_super_events.generated.go
generated
4
unifi/setting_super_events.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_super_fwupdate.generated.go
generated
4
unifi/setting_super_fwupdate.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_super_identity.generated.go
generated
4
unifi/setting_super_identity.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_super_mail.generated.go
generated
4
unifi/setting_super_mail.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_super_mgmt.generated.go
generated
4
unifi/setting_super_mgmt.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_super_sdn.generated.go
generated
4
unifi/setting_super_sdn.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_super_smtp.generated.go
generated
4
unifi/setting_super_smtp.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_teleport.generated.go
generated
4
unifi/setting_teleport.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_usg.generated.go
generated
4
unifi/setting_usg.generated.go
generated
@@ -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]
|
||||
|
||||
4
unifi/setting_usw.generated.go
generated
4
unifi/setting_usw.generated.go
generated
@@ -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]
|
||||
|
||||
@@ -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) {
|
||||
|
||||
6
unifi/spatial_record.generated.go
generated
6
unifi/spatial_record.generated.go
generated
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
6
unifi/tag.generated.go
generated
6
unifi/tag.generated.go
generated
@@ -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]
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
6
unifi/user.generated.go
generated
6
unifi/user.generated.go
generated
@@ -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]
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
6
unifi/user_group.generated.go
generated
6
unifi/user_group.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/virtual_device.generated.go
generated
6
unifi/virtual_device.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/wlan.generated.go
generated
6
unifi/wlan.generated.go
generated
@@ -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]
|
||||
|
||||
6
unifi/wlan_group.generated.go
generated
6
unifi/wlan_group.generated.go
generated
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user