feat: new, more customizable client supporting API Key and user/password authentication
This commit is contained in:
committed by
Mateusz Filipowicz
parent
8a0cf33e75
commit
f79f21c4ad
24
unifi/account.generated.go
generated
24
unifi/account.generated.go
generated
@@ -62,11 +62,11 @@ func (dst *Account) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listAccount(ctx context.Context, site string) ([]Account, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Account `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/account", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/account", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -76,17 +76,17 @@ func (c *Client) listAccount(ctx context.Context, site string) ([]Account, error
|
||||
|
||||
func (c *Client) getAccount(ctx context.Context, site, id string) (*Account, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Account `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/account/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/account/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -94,7 +94,7 @@ func (c *Client) getAccount(ctx context.Context, site, id string) (*Account, err
|
||||
}
|
||||
|
||||
func (c *Client) deleteAccount(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/account/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/account/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -103,17 +103,17 @@ func (c *Client) deleteAccount(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createAccount(ctx context.Context, site string, d *Account) (*Account, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Account `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/account", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/account", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -123,17 +123,17 @@ func (c *Client) createAccount(ctx context.Context, site string, d *Account) (*A
|
||||
|
||||
func (c *Client) updateAccount(ctx context.Context, site string, d *Account) (*Account, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Account `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/account/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/account/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
@@ -28,7 +28,7 @@ type APGroup struct {
|
||||
func (c *Client) ListAPGroup(ctx context.Context, site string) ([]APGroup, error) {
|
||||
var respBody []APGroup
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("%s/site/%s/apgroups", c.apiV2Path, site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("%s/site/%s/apgroups", c.apiPaths.ApiV2Path, site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -38,17 +38,17 @@ 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 Meta `json:"Meta"`
|
||||
// Data []WLANGroup `json:"data"`
|
||||
// }
|
||||
|
||||
// err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/wlangroup/%s", site, id), nil, &respBody)
|
||||
// err := c.Get(ctx, fmt.Sprintf("s/%s/rest/wlangroup/%s", site, id), nil, &respBody)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// if len(respBody.Data) != 1 {
|
||||
// return nil, &NotFoundError{}
|
||||
// return nil, NotFoundError
|
||||
// }
|
||||
|
||||
// d := respBody.Data[0]
|
||||
@@ -56,7 +56,7 @@ func (c *Client) ListAPGroup(ctx context.Context, site string) ([]APGroup, error
|
||||
// }
|
||||
|
||||
// func (c *Client) deleteWLANGroup(ctx context.Context, site, id string) error {
|
||||
// err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/wlangroup/%s", site, id), struct{}{}, nil)
|
||||
// err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/wlangroup/%s", site, id), struct{}{}, nil)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
@@ -66,7 +66,7 @@ func (c *Client) ListAPGroup(ctx context.Context, site string) ([]APGroup, error
|
||||
func (c *Client) CreateAPGroup(ctx context.Context, site string, d *APGroup) (*APGroup, error) {
|
||||
var respBody APGroup
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("%s/site/%s/apgroups", c.apiV2Path, site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("%s/site/%s/apgroups", c.apiPaths.ApiV2Path, site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -76,17 +76,17 @@ 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 Meta `json:"Meta"`
|
||||
// Data []WLANGroup `json:"data"`
|
||||
// }
|
||||
|
||||
// err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/wlangroup/%s", site, d.ID), d, &respBody)
|
||||
// err := c.Put(ctx, fmt.Sprintf("s/%s/rest/wlangroup/%s", site, d.ID), d, &respBody)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// if len(respBody.Data) != 1 {
|
||||
// return nil, &NotFoundError{}
|
||||
// return nil, NotFoundError
|
||||
// }
|
||||
|
||||
// new := respBody.Data[0]
|
||||
|
||||
24
unifi/broadcast_group.generated.go
generated
24
unifi/broadcast_group.generated.go
generated
@@ -47,11 +47,11 @@ func (dst *BroadcastGroup) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listBroadcastGroup(ctx context.Context, site string) ([]BroadcastGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []BroadcastGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/broadcastgroup", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/broadcastgroup", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -61,17 +61,17 @@ func (c *Client) listBroadcastGroup(ctx context.Context, site string) ([]Broadca
|
||||
|
||||
func (c *Client) getBroadcastGroup(ctx context.Context, site, id string) (*BroadcastGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []BroadcastGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/broadcastgroup/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/broadcastgroup/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -79,7 +79,7 @@ func (c *Client) getBroadcastGroup(ctx context.Context, site, id string) (*Broad
|
||||
}
|
||||
|
||||
func (c *Client) deleteBroadcastGroup(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/broadcastgroup/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/broadcastgroup/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -88,17 +88,17 @@ func (c *Client) deleteBroadcastGroup(ctx context.Context, site, id string) erro
|
||||
|
||||
func (c *Client) createBroadcastGroup(ctx context.Context, site string, d *BroadcastGroup) (*BroadcastGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []BroadcastGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/broadcastgroup", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/broadcastgroup", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -108,17 +108,17 @@ func (c *Client) createBroadcastGroup(ctx context.Context, site string, d *Broad
|
||||
|
||||
func (c *Client) updateBroadcastGroup(ctx context.Context, site string, d *BroadcastGroup) (*BroadcastGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []BroadcastGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/broadcastgroup/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/broadcastgroup/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/channel_plan.generated.go
generated
24
unifi/channel_plan.generated.go
generated
@@ -190,11 +190,11 @@ func (dst *ChannelPlanSiteBlacklistedChannels) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listChannelPlan(ctx context.Context, site string) ([]ChannelPlan, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []ChannelPlan `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/channelplan", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/channelplan", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -204,17 +204,17 @@ func (c *Client) listChannelPlan(ctx context.Context, site string) ([]ChannelPla
|
||||
|
||||
func (c *Client) getChannelPlan(ctx context.Context, site, id string) (*ChannelPlan, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []ChannelPlan `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/channelplan/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/channelplan/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -222,7 +222,7 @@ func (c *Client) getChannelPlan(ctx context.Context, site, id string) (*ChannelP
|
||||
}
|
||||
|
||||
func (c *Client) deleteChannelPlan(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/channelplan/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/channelplan/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -231,17 +231,17 @@ func (c *Client) deleteChannelPlan(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createChannelPlan(ctx context.Context, site string, d *ChannelPlan) (*ChannelPlan, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []ChannelPlan `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/channelplan", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/channelplan", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -251,17 +251,17 @@ func (c *Client) createChannelPlan(ctx context.Context, site string, d *ChannelP
|
||||
|
||||
func (c *Client) updateChannelPlan(ctx context.Context, site string, d *ChannelPlan) (*ChannelPlan, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []ChannelPlan `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/channelplan/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/channelplan/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package unifi
|
||||
|
||||
// This will generate the *.generated.go files in this package for the specified
|
||||
// Unifi controller version.
|
||||
// Client controller version.
|
||||
//go:generate go run ../codegen/ -version-base-dir=../codegen/ latest
|
||||
|
||||
24
unifi/dashboard.generated.go
generated
24
unifi/dashboard.generated.go
generated
@@ -73,11 +73,11 @@ func (dst *DashboardModules) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listDashboard(ctx context.Context, site string) ([]Dashboard, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Dashboard `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/dashboard", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/dashboard", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -87,17 +87,17 @@ func (c *Client) listDashboard(ctx context.Context, site string) ([]Dashboard, e
|
||||
|
||||
func (c *Client) getDashboard(ctx context.Context, site, id string) (*Dashboard, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Dashboard `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/dashboard/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/dashboard/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -105,7 +105,7 @@ func (c *Client) getDashboard(ctx context.Context, site, id string) (*Dashboard,
|
||||
}
|
||||
|
||||
func (c *Client) deleteDashboard(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/dashboard/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/dashboard/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -114,17 +114,17 @@ func (c *Client) deleteDashboard(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createDashboard(ctx context.Context, site string, d *Dashboard) (*Dashboard, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Dashboard `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/dashboard", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/dashboard", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -134,17 +134,17 @@ func (c *Client) createDashboard(ctx context.Context, site string, d *Dashboard)
|
||||
|
||||
func (c *Client) updateDashboard(ctx context.Context, site string, d *Dashboard) (*Dashboard, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Dashboard `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/dashboard/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/dashboard/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/device.generated.go
generated
24
unifi/device.generated.go
generated
@@ -586,11 +586,11 @@ func (dst *DeviceRpsPortTable) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listDevice(ctx context.Context, site string) ([]Device, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Device `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/stat/device", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/stat/device", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -600,17 +600,17 @@ func (c *Client) listDevice(ctx context.Context, site string) ([]Device, error)
|
||||
|
||||
func (c *Client) getDevice(ctx context.Context, site, id string) (*Device, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Device `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/stat/device/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/stat/device/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -618,7 +618,7 @@ func (c *Client) getDevice(ctx context.Context, site, id string) (*Device, error
|
||||
}
|
||||
|
||||
func (c *Client) deleteDevice(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/device/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/device/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -627,17 +627,17 @@ func (c *Client) deleteDevice(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createDevice(ctx context.Context, site string, d *Device) (*Device, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Device `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/device", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/device", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -647,17 +647,17 @@ func (c *Client) createDevice(ctx context.Context, site string, d *Device) (*Dev
|
||||
|
||||
func (c *Client) updateDevice(ctx context.Context, site string, d *Device) (*Device, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Device `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/device/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/device/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
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, NotFoundError
|
||||
}
|
||||
|
||||
func (c *Client) AdoptDevice(ctx context.Context, site, mac string) error {
|
||||
@@ -68,10 +68,10 @@ func (c *Client) AdoptDevice(ctx context.Context, site, mac string) error {
|
||||
}
|
||||
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"Meta"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/cmd/devmgr", site), reqBody, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/cmd/devmgr", site), reqBody, &respBody)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -89,11 +89,11 @@ func (c *Client) ForgetDevice(ctx context.Context, site, mac string) error {
|
||||
}
|
||||
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"Meta"`
|
||||
Data []Device `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/cmd/sitemgr", site), reqBody, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/cmd/sitemgr", site), reqBody, &respBody)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
24
unifi/dhcp_option.generated.go
generated
24
unifi/dhcp_option.generated.go
generated
@@ -53,11 +53,11 @@ func (dst *DHCPOption) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listDHCPOption(ctx context.Context, site string) ([]DHCPOption, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []DHCPOption `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/dhcpoption", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/dhcpoption", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -67,17 +67,17 @@ func (c *Client) listDHCPOption(ctx context.Context, site string) ([]DHCPOption,
|
||||
|
||||
func (c *Client) getDHCPOption(ctx context.Context, site, id string) (*DHCPOption, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []DHCPOption `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/dhcpoption/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/dhcpoption/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -85,7 +85,7 @@ func (c *Client) getDHCPOption(ctx context.Context, site, id string) (*DHCPOptio
|
||||
}
|
||||
|
||||
func (c *Client) deleteDHCPOption(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/dhcpoption/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/dhcpoption/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -94,17 +94,17 @@ func (c *Client) deleteDHCPOption(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createDHCPOption(ctx context.Context, site string, d *DHCPOption) (*DHCPOption, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []DHCPOption `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/dhcpoption", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/dhcpoption", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -114,17 +114,17 @@ func (c *Client) createDHCPOption(ctx context.Context, site string, d *DHCPOptio
|
||||
|
||||
func (c *Client) updateDHCPOption(ctx context.Context, site string, d *DHCPOption) (*DHCPOption, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []DHCPOption `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/dhcpoption/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/dhcpoption/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Custom package for handling DNS records in Unifi Controller
|
||||
// Custom package for handling DNS records in Client Controller
|
||||
|
||||
package unifi
|
||||
|
||||
@@ -54,7 +54,7 @@ func (dst *DNSRecord) UnmarshalJSON(b []byte) error {
|
||||
func (c *Client) ListDNSRecord(ctx context.Context, site string) ([]DNSRecord, error) {
|
||||
var respBody []DNSRecord
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("%s/site/%s/static-dns", c.apiV2Path, site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("%s/site/%s/static-dns", c.apiPaths.ApiV2Path, site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -65,20 +65,20 @@ func (c *Client) ListDNSRecord(ctx context.Context, site string) ([]DNSRecord, e
|
||||
func (c *Client) GetDNSRecord(ctx context.Context, site, id string) (*DNSRecord, error) {
|
||||
var respBody DNSRecord
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("%s/site/%s/static-dns/%s", c.apiV2Path, site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("%s/site/%s/static-dns/%s", c.apiPaths.ApiV2Path, site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if respBody.ID == "" {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
return &respBody, nil
|
||||
}
|
||||
|
||||
func (c *Client) DeleteDNSRecord(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("%s/site/%s/static-dns/%s", c.apiV2Path, site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("%s/site/%s/static-dns/%s", c.apiPaths.ApiV2Path, site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -87,7 +87,7 @@ func (c *Client) DeleteDNSRecord(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) CreateDNSRecord(ctx context.Context, site string, d *DNSRecord) (*DNSRecord, error) {
|
||||
var respBody DNSRecord
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("%s/site/%s/static-dns", c.apiV2Path, site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("%s/site/%s/static-dns", c.apiPaths.ApiV2Path, site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -97,13 +97,13 @@ func (c *Client) CreateDNSRecord(ctx context.Context, site string, d *DNSRecord)
|
||||
func (c *Client) UpdateDNSRecord(ctx context.Context, site string, d *DNSRecord) (*DNSRecord, error) {
|
||||
var respBody DNSRecord
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("%s/site/%s/static-dns/%s", c.apiV2Path, site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("%s/site/%s/static-dns/%s", c.apiPaths.ApiV2Path, site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// if len(respBody) != nil {
|
||||
// return nil, &NotFoundError{}
|
||||
// return nil, NotFoundError
|
||||
// }
|
||||
|
||||
return &respBody, nil
|
||||
|
||||
24
unifi/dpi_app.generated.go
generated
24
unifi/dpi_app.generated.go
generated
@@ -68,11 +68,11 @@ func (dst *DpiApp) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listDpiApp(ctx context.Context, site string) ([]DpiApp, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []DpiApp `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/dpiapp", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/dpiapp", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -82,17 +82,17 @@ func (c *Client) listDpiApp(ctx context.Context, site string) ([]DpiApp, error)
|
||||
|
||||
func (c *Client) getDpiApp(ctx context.Context, site, id string) (*DpiApp, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []DpiApp `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/dpiapp/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/dpiapp/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -100,7 +100,7 @@ func (c *Client) getDpiApp(ctx context.Context, site, id string) (*DpiApp, error
|
||||
}
|
||||
|
||||
func (c *Client) deleteDpiApp(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/dpiapp/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/dpiapp/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -109,17 +109,17 @@ func (c *Client) deleteDpiApp(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createDpiApp(ctx context.Context, site string, d *DpiApp) (*DpiApp, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []DpiApp `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/dpiapp", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/dpiapp", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -129,17 +129,17 @@ func (c *Client) createDpiApp(ctx context.Context, site string, d *DpiApp) (*Dpi
|
||||
|
||||
func (c *Client) updateDpiApp(ctx context.Context, site string, d *DpiApp) (*DpiApp, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []DpiApp `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/dpiapp/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/dpiapp/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/dpi_group.generated.go
generated
24
unifi/dpi_group.generated.go
generated
@@ -48,11 +48,11 @@ func (dst *DpiGroup) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listDpiGroup(ctx context.Context, site string) ([]DpiGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []DpiGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/dpigroup", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/dpigroup", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -62,17 +62,17 @@ func (c *Client) listDpiGroup(ctx context.Context, site string) ([]DpiGroup, err
|
||||
|
||||
func (c *Client) getDpiGroup(ctx context.Context, site, id string) (*DpiGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []DpiGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/dpigroup/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/dpigroup/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -80,7 +80,7 @@ func (c *Client) getDpiGroup(ctx context.Context, site, id string) (*DpiGroup, e
|
||||
}
|
||||
|
||||
func (c *Client) deleteDpiGroup(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/dpigroup/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/dpigroup/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -89,17 +89,17 @@ func (c *Client) deleteDpiGroup(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createDpiGroup(ctx context.Context, site string, d *DpiGroup) (*DpiGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []DpiGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/dpigroup", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/dpigroup", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -109,17 +109,17 @@ func (c *Client) createDpiGroup(ctx context.Context, site string, d *DpiGroup) (
|
||||
|
||||
func (c *Client) updateDpiGroup(ctx context.Context, site string, d *DpiGroup) (*DpiGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []DpiGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/dpigroup/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/dpigroup/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/dynamic_dns.generated.go
generated
24
unifi/dynamic_dns.generated.go
generated
@@ -53,11 +53,11 @@ func (dst *DynamicDNS) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listDynamicDNS(ctx context.Context, site string) ([]DynamicDNS, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []DynamicDNS `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/dynamicdns", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/dynamicdns", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -67,17 +67,17 @@ func (c *Client) listDynamicDNS(ctx context.Context, site string) ([]DynamicDNS,
|
||||
|
||||
func (c *Client) getDynamicDNS(ctx context.Context, site, id string) (*DynamicDNS, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []DynamicDNS `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/dynamicdns/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/dynamicdns/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -85,7 +85,7 @@ func (c *Client) getDynamicDNS(ctx context.Context, site, id string) (*DynamicDN
|
||||
}
|
||||
|
||||
func (c *Client) deleteDynamicDNS(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/dynamicdns/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/dynamicdns/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -94,17 +94,17 @@ func (c *Client) deleteDynamicDNS(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createDynamicDNS(ctx context.Context, site string, d *DynamicDNS) (*DynamicDNS, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []DynamicDNS `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/dynamicdns", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/dynamicdns", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -114,17 +114,17 @@ func (c *Client) createDynamicDNS(ctx context.Context, site string, d *DynamicDN
|
||||
|
||||
func (c *Client) updateDynamicDNS(ctx context.Context, site string, d *DynamicDNS) (*DynamicDNS, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []DynamicDNS `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/dynamicdns/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/dynamicdns/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/firewall_group.generated.go
generated
24
unifi/firewall_group.generated.go
generated
@@ -48,11 +48,11 @@ func (dst *FirewallGroup) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listFirewallGroup(ctx context.Context, site string) ([]FirewallGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []FirewallGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/firewallgroup", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/firewallgroup", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -62,17 +62,17 @@ func (c *Client) listFirewallGroup(ctx context.Context, site string) ([]Firewall
|
||||
|
||||
func (c *Client) getFirewallGroup(ctx context.Context, site, id string) (*FirewallGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []FirewallGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/firewallgroup/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/firewallgroup/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -80,7 +80,7 @@ func (c *Client) getFirewallGroup(ctx context.Context, site, id string) (*Firewa
|
||||
}
|
||||
|
||||
func (c *Client) deleteFirewallGroup(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/firewallgroup/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/firewallgroup/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -89,17 +89,17 @@ func (c *Client) deleteFirewallGroup(ctx context.Context, site, id string) error
|
||||
|
||||
func (c *Client) createFirewallGroup(ctx context.Context, site string, d *FirewallGroup) (*FirewallGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []FirewallGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/firewallgroup", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/firewallgroup", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -109,17 +109,17 @@ func (c *Client) createFirewallGroup(ctx context.Context, site string, d *Firewa
|
||||
|
||||
func (c *Client) updateFirewallGroup(ctx context.Context, site string, d *FirewallGroup) (*FirewallGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []FirewallGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/firewallgroup/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/firewallgroup/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/firewall_rule.generated.go
generated
24
unifi/firewall_rule.generated.go
generated
@@ -78,11 +78,11 @@ func (dst *FirewallRule) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listFirewallRule(ctx context.Context, site string) ([]FirewallRule, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []FirewallRule `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/firewallrule", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/firewallrule", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -92,17 +92,17 @@ func (c *Client) listFirewallRule(ctx context.Context, site string) ([]FirewallR
|
||||
|
||||
func (c *Client) getFirewallRule(ctx context.Context, site, id string) (*FirewallRule, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []FirewallRule `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/firewallrule/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/firewallrule/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -110,7 +110,7 @@ func (c *Client) getFirewallRule(ctx context.Context, site, id string) (*Firewal
|
||||
}
|
||||
|
||||
func (c *Client) deleteFirewallRule(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/firewallrule/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/firewallrule/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -119,17 +119,17 @@ func (c *Client) deleteFirewallRule(ctx context.Context, site, id string) error
|
||||
|
||||
func (c *Client) createFirewallRule(ctx context.Context, site string, d *FirewallRule) (*FirewallRule, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []FirewallRule `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/firewallrule", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/firewallrule", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -139,17 +139,17 @@ func (c *Client) createFirewallRule(ctx context.Context, site string, d *Firewal
|
||||
|
||||
func (c *Client) updateFirewallRule(ctx context.Context, site string, d *FirewallRule) (*FirewallRule, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []FirewallRule `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/firewallrule/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/firewallrule/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
@@ -40,7 +40,7 @@ func (c *Client) ReorderFirewallRules(ctx context.Context, site, ruleset string,
|
||||
Ruleset: ruleset,
|
||||
Rules: reorder,
|
||||
}
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/cmd/firewall", site), reqBody, nil)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/cmd/firewall", site), reqBody, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
24
unifi/heat_map.generated.go
generated
24
unifi/heat_map.generated.go
generated
@@ -49,11 +49,11 @@ func (dst *HeatMap) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listHeatMap(ctx context.Context, site string) ([]HeatMap, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []HeatMap `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/heatmap", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/heatmap", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -63,17 +63,17 @@ func (c *Client) listHeatMap(ctx context.Context, site string) ([]HeatMap, error
|
||||
|
||||
func (c *Client) getHeatMap(ctx context.Context, site, id string) (*HeatMap, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []HeatMap `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/heatmap/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/heatmap/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -81,7 +81,7 @@ func (c *Client) getHeatMap(ctx context.Context, site, id string) (*HeatMap, err
|
||||
}
|
||||
|
||||
func (c *Client) deleteHeatMap(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/heatmap/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/heatmap/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -90,17 +90,17 @@ func (c *Client) deleteHeatMap(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createHeatMap(ctx context.Context, site string, d *HeatMap) (*HeatMap, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []HeatMap `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/heatmap", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/heatmap", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -110,17 +110,17 @@ func (c *Client) createHeatMap(ctx context.Context, site string, d *HeatMap) (*H
|
||||
|
||||
func (c *Client) updateHeatMap(ctx context.Context, site string, d *HeatMap) (*HeatMap, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []HeatMap `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/heatmap/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/heatmap/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/heat_map_point.generated.go
generated
24
unifi/heat_map_point.generated.go
generated
@@ -50,11 +50,11 @@ func (dst *HeatMapPoint) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listHeatMapPoint(ctx context.Context, site string) ([]HeatMapPoint, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []HeatMapPoint `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/heatmappoint", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/heatmappoint", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -64,17 +64,17 @@ func (c *Client) listHeatMapPoint(ctx context.Context, site string) ([]HeatMapPo
|
||||
|
||||
func (c *Client) getHeatMapPoint(ctx context.Context, site, id string) (*HeatMapPoint, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []HeatMapPoint `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/heatmappoint/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/heatmappoint/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -82,7 +82,7 @@ func (c *Client) getHeatMapPoint(ctx context.Context, site, id string) (*HeatMap
|
||||
}
|
||||
|
||||
func (c *Client) deleteHeatMapPoint(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/heatmappoint/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/heatmappoint/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -91,17 +91,17 @@ func (c *Client) deleteHeatMapPoint(ctx context.Context, site, id string) error
|
||||
|
||||
func (c *Client) createHeatMapPoint(ctx context.Context, site string, d *HeatMapPoint) (*HeatMapPoint, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []HeatMapPoint `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/heatmappoint", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/heatmappoint", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -111,17 +111,17 @@ func (c *Client) createHeatMapPoint(ctx context.Context, site string, d *HeatMap
|
||||
|
||||
func (c *Client) updateHeatMapPoint(ctx context.Context, site string, d *HeatMapPoint) (*HeatMapPoint, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []HeatMapPoint `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/heatmappoint/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/heatmappoint/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/hotspot_2_conf.generated.go
generated
24
unifi/hotspot_2_conf.generated.go
generated
@@ -429,11 +429,11 @@ func (dst *Hotspot2ConfVenueName) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listHotspot2Conf(ctx context.Context, site string) ([]Hotspot2Conf, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Hotspot2Conf `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/hotspot2conf", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/hotspot2conf", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -443,17 +443,17 @@ func (c *Client) listHotspot2Conf(ctx context.Context, site string) ([]Hotspot2C
|
||||
|
||||
func (c *Client) getHotspot2Conf(ctx context.Context, site, id string) (*Hotspot2Conf, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Hotspot2Conf `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/hotspot2conf/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/hotspot2conf/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -461,7 +461,7 @@ func (c *Client) getHotspot2Conf(ctx context.Context, site, id string) (*Hotspot
|
||||
}
|
||||
|
||||
func (c *Client) deleteHotspot2Conf(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/hotspot2conf/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/hotspot2conf/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -470,17 +470,17 @@ func (c *Client) deleteHotspot2Conf(ctx context.Context, site, id string) error
|
||||
|
||||
func (c *Client) createHotspot2Conf(ctx context.Context, site string, d *Hotspot2Conf) (*Hotspot2Conf, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Hotspot2Conf `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/hotspot2conf", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/hotspot2conf", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -490,17 +490,17 @@ func (c *Client) createHotspot2Conf(ctx context.Context, site string, d *Hotspot
|
||||
|
||||
func (c *Client) updateHotspot2Conf(ctx context.Context, site string, d *Hotspot2Conf) (*Hotspot2Conf, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Hotspot2Conf `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/hotspot2conf/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/hotspot2conf/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/hotspot_op.generated.go
generated
24
unifi/hotspot_op.generated.go
generated
@@ -48,11 +48,11 @@ func (dst *HotspotOp) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listHotspotOp(ctx context.Context, site string) ([]HotspotOp, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []HotspotOp `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/hotspotop", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/hotspotop", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -62,17 +62,17 @@ func (c *Client) listHotspotOp(ctx context.Context, site string) ([]HotspotOp, e
|
||||
|
||||
func (c *Client) getHotspotOp(ctx context.Context, site, id string) (*HotspotOp, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []HotspotOp `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/hotspotop/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/hotspotop/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -80,7 +80,7 @@ func (c *Client) getHotspotOp(ctx context.Context, site, id string) (*HotspotOp,
|
||||
}
|
||||
|
||||
func (c *Client) deleteHotspotOp(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/hotspotop/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/hotspotop/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -89,17 +89,17 @@ func (c *Client) deleteHotspotOp(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createHotspotOp(ctx context.Context, site string, d *HotspotOp) (*HotspotOp, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []HotspotOp `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/hotspotop", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/hotspotop", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -109,17 +109,17 @@ func (c *Client) createHotspotOp(ctx context.Context, site string, d *HotspotOp)
|
||||
|
||||
func (c *Client) updateHotspotOp(ctx context.Context, site string, d *HotspotOp) (*HotspotOp, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []HotspotOp `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/hotspotop/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/hotspotop/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/hotspot_package.generated.go
generated
24
unifi/hotspot_package.generated.go
generated
@@ -87,11 +87,11 @@ func (dst *HotspotPackage) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listHotspotPackage(ctx context.Context, site string) ([]HotspotPackage, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []HotspotPackage `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/hotspotpackage", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/hotspotpackage", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -101,17 +101,17 @@ func (c *Client) listHotspotPackage(ctx context.Context, site string) ([]Hotspot
|
||||
|
||||
func (c *Client) getHotspotPackage(ctx context.Context, site, id string) (*HotspotPackage, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []HotspotPackage `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/hotspotpackage/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/hotspotpackage/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -119,7 +119,7 @@ func (c *Client) getHotspotPackage(ctx context.Context, site, id string) (*Hotsp
|
||||
}
|
||||
|
||||
func (c *Client) deleteHotspotPackage(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/hotspotpackage/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/hotspotpackage/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -128,17 +128,17 @@ func (c *Client) deleteHotspotPackage(ctx context.Context, site, id string) erro
|
||||
|
||||
func (c *Client) createHotspotPackage(ctx context.Context, site string, d *HotspotPackage) (*HotspotPackage, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []HotspotPackage `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/hotspotpackage", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/hotspotpackage", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -148,17 +148,17 @@ func (c *Client) createHotspotPackage(ctx context.Context, site string, d *Hotsp
|
||||
|
||||
func (c *Client) updateHotspotPackage(ctx context.Context, site string, d *HotspotPackage) (*HotspotPackage, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []HotspotPackage `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/hotspotpackage/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/hotspotpackage/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/map.generated.go
generated
24
unifi/map.generated.go
generated
@@ -63,11 +63,11 @@ func (dst *Map) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listMap(ctx context.Context, site string) ([]Map, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Map `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/map", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/map", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -77,17 +77,17 @@ func (c *Client) listMap(ctx context.Context, site string) ([]Map, error) {
|
||||
|
||||
func (c *Client) getMap(ctx context.Context, site, id string) (*Map, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Map `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/map/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/map/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -95,7 +95,7 @@ func (c *Client) getMap(ctx context.Context, site, id string) (*Map, error) {
|
||||
}
|
||||
|
||||
func (c *Client) deleteMap(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/map/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/map/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -104,17 +104,17 @@ func (c *Client) deleteMap(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createMap(ctx context.Context, site string, d *Map) (*Map, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Map `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/map", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/map", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -124,17 +124,17 @@ func (c *Client) createMap(ctx context.Context, site string, d *Map) (*Map, erro
|
||||
|
||||
func (c *Client) updateMap(ctx context.Context, site string, d *Map) (*Map, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Map `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/map/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/map/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/media_file.generated.go
generated
24
unifi/media_file.generated.go
generated
@@ -46,11 +46,11 @@ func (dst *MediaFile) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listMediaFile(ctx context.Context, site string) ([]MediaFile, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []MediaFile `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/mediafile", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/mediafile", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -60,17 +60,17 @@ func (c *Client) listMediaFile(ctx context.Context, site string) ([]MediaFile, e
|
||||
|
||||
func (c *Client) getMediaFile(ctx context.Context, site, id string) (*MediaFile, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []MediaFile `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/mediafile/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/mediafile/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -78,7 +78,7 @@ func (c *Client) getMediaFile(ctx context.Context, site, id string) (*MediaFile,
|
||||
}
|
||||
|
||||
func (c *Client) deleteMediaFile(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/mediafile/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/mediafile/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -87,17 +87,17 @@ func (c *Client) deleteMediaFile(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createMediaFile(ctx context.Context, site string, d *MediaFile) (*MediaFile, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []MediaFile `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/mediafile", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/mediafile", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -107,17 +107,17 @@ func (c *Client) createMediaFile(ctx context.Context, site string, d *MediaFile)
|
||||
|
||||
func (c *Client) updateMediaFile(ctx context.Context, site string, d *MediaFile) (*MediaFile, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []MediaFile `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/mediafile/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/mediafile/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/network.generated.go
generated
24
unifi/network.generated.go
generated
@@ -438,11 +438,11 @@ func (dst *NetworkWANProviderCapabilities) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listNetwork(ctx context.Context, site string) ([]Network, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Network `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/networkconf", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/networkconf", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -452,17 +452,17 @@ func (c *Client) listNetwork(ctx context.Context, site string) ([]Network, error
|
||||
|
||||
func (c *Client) getNetwork(ctx context.Context, site, id string) (*Network, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Network `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/networkconf/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/networkconf/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -470,7 +470,7 @@ func (c *Client) getNetwork(ctx context.Context, site, id string) (*Network, err
|
||||
}
|
||||
|
||||
func (c *Client) deleteNetwork(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/networkconf/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/networkconf/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -479,17 +479,17 @@ func (c *Client) deleteNetwork(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createNetwork(ctx context.Context, site string, d *Network) (*Network, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Network `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/networkconf", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/networkconf", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -499,17 +499,17 @@ func (c *Client) createNetwork(ctx context.Context, site string, d *Network) (*N
|
||||
|
||||
func (c *Client) updateNetwork(ctx context.Context, site string, d *Network) (*Network, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Network `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/networkconf/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/networkconf/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
@@ -27,7 +27,7 @@ func (dst *Network) MarshalJSON() ([]byte, error) {
|
||||
}
|
||||
|
||||
func (c *Client) DeleteNetwork(ctx context.Context, site, id, name string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/networkconf/%s", site, id), struct {
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/networkconf/%s", site, id), struct {
|
||||
Name string `json:"name"`
|
||||
}{
|
||||
Name: name,
|
||||
|
||||
24
unifi/port_forward.generated.go
generated
24
unifi/port_forward.generated.go
generated
@@ -80,11 +80,11 @@ func (dst *PortForwardDestinationIPs) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listPortForward(ctx context.Context, site string) ([]PortForward, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []PortForward `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/portforward", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/portforward", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -94,17 +94,17 @@ func (c *Client) listPortForward(ctx context.Context, site string) ([]PortForwar
|
||||
|
||||
func (c *Client) getPortForward(ctx context.Context, site, id string) (*PortForward, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []PortForward `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/portforward/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/portforward/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -112,7 +112,7 @@ func (c *Client) getPortForward(ctx context.Context, site, id string) (*PortForw
|
||||
}
|
||||
|
||||
func (c *Client) deletePortForward(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/portforward/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/portforward/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -121,17 +121,17 @@ func (c *Client) deletePortForward(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createPortForward(ctx context.Context, site string, d *PortForward) (*PortForward, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []PortForward `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/portforward", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/portforward", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -141,17 +141,17 @@ func (c *Client) createPortForward(ctx context.Context, site string, d *PortForw
|
||||
|
||||
func (c *Client) updatePortForward(ctx context.Context, site string, d *PortForward) (*PortForward, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []PortForward `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/portforward/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/portforward/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/port_profile.generated.go
generated
24
unifi/port_profile.generated.go
generated
@@ -222,11 +222,11 @@ func (dst *PortProfileQOSProfile) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listPortProfile(ctx context.Context, site string) ([]PortProfile, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []PortProfile `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/portconf", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/portconf", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -236,17 +236,17 @@ func (c *Client) listPortProfile(ctx context.Context, site string) ([]PortProfil
|
||||
|
||||
func (c *Client) getPortProfile(ctx context.Context, site, id string) (*PortProfile, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []PortProfile `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/portconf/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/portconf/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -254,7 +254,7 @@ func (c *Client) getPortProfile(ctx context.Context, site, id string) (*PortProf
|
||||
}
|
||||
|
||||
func (c *Client) deletePortProfile(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/portconf/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/portconf/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -263,17 +263,17 @@ func (c *Client) deletePortProfile(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createPortProfile(ctx context.Context, site string, d *PortProfile) (*PortProfile, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []PortProfile `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/portconf", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/portconf", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -283,17 +283,17 @@ func (c *Client) createPortProfile(ctx context.Context, site string, d *PortProf
|
||||
|
||||
func (c *Client) updatePortProfile(ctx context.Context, site string, d *PortProfile) (*PortProfile, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []PortProfile `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/portconf/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/portconf/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/radius_profile.generated.go
generated
24
unifi/radius_profile.generated.go
generated
@@ -136,11 +136,11 @@ func (dst *RADIUSProfileXCaCrts) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listRADIUSProfile(ctx context.Context, site string) ([]RADIUSProfile, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []RADIUSProfile `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/radiusprofile", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/radiusprofile", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -150,17 +150,17 @@ func (c *Client) listRADIUSProfile(ctx context.Context, site string) ([]RADIUSPr
|
||||
|
||||
func (c *Client) getRADIUSProfile(ctx context.Context, site, id string) (*RADIUSProfile, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []RADIUSProfile `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/radiusprofile/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/radiusprofile/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -168,7 +168,7 @@ func (c *Client) getRADIUSProfile(ctx context.Context, site, id string) (*RADIUS
|
||||
}
|
||||
|
||||
func (c *Client) deleteRADIUSProfile(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/radiusprofile/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/radiusprofile/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -177,17 +177,17 @@ func (c *Client) deleteRADIUSProfile(ctx context.Context, site, id string) error
|
||||
|
||||
func (c *Client) createRADIUSProfile(ctx context.Context, site string, d *RADIUSProfile) (*RADIUSProfile, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []RADIUSProfile `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/radiusprofile", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/radiusprofile", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -197,17 +197,17 @@ func (c *Client) createRADIUSProfile(ctx context.Context, site string, d *RADIUS
|
||||
|
||||
func (c *Client) updateRADIUSProfile(ctx context.Context, site string, d *RADIUSProfile) (*RADIUSProfile, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []RADIUSProfile `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/radiusprofile/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/radiusprofile/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/routing.generated.go
generated
24
unifi/routing.generated.go
generated
@@ -58,11 +58,11 @@ func (dst *Routing) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listRouting(ctx context.Context, site string) ([]Routing, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Routing `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/routing", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/routing", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -72,17 +72,17 @@ func (c *Client) listRouting(ctx context.Context, site string) ([]Routing, error
|
||||
|
||||
func (c *Client) getRouting(ctx context.Context, site, id string) (*Routing, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Routing `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/routing/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/routing/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -90,7 +90,7 @@ func (c *Client) getRouting(ctx context.Context, site, id string) (*Routing, err
|
||||
}
|
||||
|
||||
func (c *Client) deleteRouting(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/routing/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/routing/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -99,17 +99,17 @@ func (c *Client) deleteRouting(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createRouting(ctx context.Context, site string, d *Routing) (*Routing, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Routing `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/routing", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/routing", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -119,17 +119,17 @@ func (c *Client) createRouting(ctx context.Context, site string, d *Routing) (*R
|
||||
|
||||
func (c *Client) updateRouting(ctx context.Context, site string, d *Routing) (*Routing, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Routing `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/routing/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/routing/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/schedule_task.generated.go
generated
24
unifi/schedule_task.generated.go
generated
@@ -70,11 +70,11 @@ func (dst *ScheduleTaskUpgradeTargets) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listScheduleTask(ctx context.Context, site string) ([]ScheduleTask, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []ScheduleTask `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/scheduletask", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/scheduletask", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -84,17 +84,17 @@ func (c *Client) listScheduleTask(ctx context.Context, site string) ([]ScheduleT
|
||||
|
||||
func (c *Client) getScheduleTask(ctx context.Context, site, id string) (*ScheduleTask, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []ScheduleTask `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/scheduletask/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/scheduletask/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -102,7 +102,7 @@ func (c *Client) getScheduleTask(ctx context.Context, site, id string) (*Schedul
|
||||
}
|
||||
|
||||
func (c *Client) deleteScheduleTask(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/scheduletask/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/scheduletask/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -111,17 +111,17 @@ func (c *Client) deleteScheduleTask(ctx context.Context, site, id string) error
|
||||
|
||||
func (c *Client) createScheduleTask(ctx context.Context, site string, d *ScheduleTask) (*ScheduleTask, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []ScheduleTask `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/scheduletask", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/scheduletask", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -131,17 +131,17 @@ func (c *Client) createScheduleTask(ctx context.Context, site string, d *Schedul
|
||||
|
||||
func (c *Client) updateScheduleTask(ctx context.Context, site string, d *ScheduleTask) (*ScheduleTask, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []ScheduleTask `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/scheduletask/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/scheduletask/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
@@ -81,11 +81,11 @@ func (s *Setting) newFields() (interface{}, error) {
|
||||
|
||||
func (c *Client) GetSetting(ctx context.Context, site, key string) (*Setting, interface{}, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"Meta"`
|
||||
Data []json.RawMessage `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -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, NotFoundError
|
||||
}
|
||||
|
||||
fields, err := setting.newFields()
|
||||
|
||||
12
unifi/setting_auto_speedtest.generated.go
generated
12
unifi/setting_auto_speedtest.generated.go
generated
@@ -49,17 +49,17 @@ func (dst *SettingAutoSpeedtest) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingAutoSpeedtest(ctx context.Context, site string) (*SettingAutoSpeedtest, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingAutoSpeedtest `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/auto_speedtest", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/auto_speedtest", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -68,18 +68,18 @@ func (c *Client) getSettingAutoSpeedtest(ctx context.Context, site string) (*Set
|
||||
|
||||
func (c *Client) updateSettingAutoSpeedtest(ctx context.Context, site string, d *SettingAutoSpeedtest) (*SettingAutoSpeedtest, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingAutoSpeedtest `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "auto_speedtest"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/auto_speedtest", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/auto_speedtest", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_baresip.generated.go
generated
12
unifi/setting_baresip.generated.go
generated
@@ -51,17 +51,17 @@ func (dst *SettingBaresip) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingBaresip(ctx context.Context, site string) (*SettingBaresip, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingBaresip `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/baresip", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/baresip", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -70,18 +70,18 @@ func (c *Client) getSettingBaresip(ctx context.Context, site string) (*SettingBa
|
||||
|
||||
func (c *Client) updateSettingBaresip(ctx context.Context, site string, d *SettingBaresip) (*SettingBaresip, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingBaresip `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "baresip"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/baresip", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/baresip", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_broadcast.generated.go
generated
12
unifi/setting_broadcast.generated.go
generated
@@ -53,17 +53,17 @@ func (dst *SettingBroadcast) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingBroadcast(ctx context.Context, site string) (*SettingBroadcast, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingBroadcast `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/broadcast", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/broadcast", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -72,18 +72,18 @@ func (c *Client) getSettingBroadcast(ctx context.Context, site string) (*Setting
|
||||
|
||||
func (c *Client) updateSettingBroadcast(ctx context.Context, site string, d *SettingBroadcast) (*SettingBroadcast, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingBroadcast `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "broadcast"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/broadcast", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/broadcast", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_connectivity.generated.go
generated
12
unifi/setting_connectivity.generated.go
generated
@@ -53,17 +53,17 @@ func (dst *SettingConnectivity) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingConnectivity(ctx context.Context, site string) (*SettingConnectivity, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingConnectivity `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/connectivity", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/connectivity", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -72,18 +72,18 @@ func (c *Client) getSettingConnectivity(ctx context.Context, site string) (*Sett
|
||||
|
||||
func (c *Client) updateSettingConnectivity(ctx context.Context, site string, d *SettingConnectivity) (*SettingConnectivity, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingConnectivity `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "connectivity"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/connectivity", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/connectivity", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_country.generated.go
generated
12
unifi/setting_country.generated.go
generated
@@ -51,17 +51,17 @@ func (dst *SettingCountry) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingCountry(ctx context.Context, site string) (*SettingCountry, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingCountry `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/country", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/country", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -70,18 +70,18 @@ func (c *Client) getSettingCountry(ctx context.Context, site string) (*SettingCo
|
||||
|
||||
func (c *Client) updateSettingCountry(ctx context.Context, site string, d *SettingCountry) (*SettingCountry, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingCountry `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "country"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/country", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/country", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_dashboard.generated.go
generated
12
unifi/setting_dashboard.generated.go
generated
@@ -70,17 +70,17 @@ func (dst *SettingDashboardWidgets) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingDashboard(ctx context.Context, site string) (*SettingDashboard, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingDashboard `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/dashboard", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/dashboard", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -89,18 +89,18 @@ func (c *Client) getSettingDashboard(ctx context.Context, site string) (*Setting
|
||||
|
||||
func (c *Client) updateSettingDashboard(ctx context.Context, site string, d *SettingDashboard) (*SettingDashboard, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingDashboard `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "dashboard"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/dashboard", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/dashboard", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_doh.generated.go
generated
12
unifi/setting_doh.generated.go
generated
@@ -72,17 +72,17 @@ func (dst *SettingDohCustomServers) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingDoh(ctx context.Context, site string) (*SettingDoh, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingDoh `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/doh", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/doh", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -91,18 +91,18 @@ func (c *Client) getSettingDoh(ctx context.Context, site string) (*SettingDoh, e
|
||||
|
||||
func (c *Client) updateSettingDoh(ctx context.Context, site string, d *SettingDoh) (*SettingDoh, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingDoh `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "doh"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/doh", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/doh", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_dpi.generated.go
generated
12
unifi/setting_dpi.generated.go
generated
@@ -49,17 +49,17 @@ func (dst *SettingDpi) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingDpi(ctx context.Context, site string) (*SettingDpi, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingDpi `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/dpi", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/dpi", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -68,18 +68,18 @@ func (c *Client) getSettingDpi(ctx context.Context, site string) (*SettingDpi, e
|
||||
|
||||
func (c *Client) updateSettingDpi(ctx context.Context, site string, d *SettingDpi) (*SettingDpi, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingDpi `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "dpi"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/dpi", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/dpi", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_element_adopt.generated.go
generated
12
unifi/setting_element_adopt.generated.go
generated
@@ -50,17 +50,17 @@ func (dst *SettingElementAdopt) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingElementAdopt(ctx context.Context, site string) (*SettingElementAdopt, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingElementAdopt `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/element_adopt", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/element_adopt", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -69,18 +69,18 @@ func (c *Client) getSettingElementAdopt(ctx context.Context, site string) (*Sett
|
||||
|
||||
func (c *Client) updateSettingElementAdopt(ctx context.Context, site string, d *SettingElementAdopt) (*SettingElementAdopt, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingElementAdopt `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "element_adopt"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/element_adopt", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/element_adopt", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_ether_lighting.generated.go
generated
12
unifi/setting_ether_lighting.generated.go
generated
@@ -91,17 +91,17 @@ func (dst *SettingEtherLightingSpeedOverrides) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingEtherLighting(ctx context.Context, site string) (*SettingEtherLighting, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingEtherLighting `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/ether_lighting", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/ether_lighting", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -110,18 +110,18 @@ func (c *Client) getSettingEtherLighting(ctx context.Context, site string) (*Set
|
||||
|
||||
func (c *Client) updateSettingEtherLighting(ctx context.Context, site string, d *SettingEtherLighting) (*SettingEtherLighting, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingEtherLighting `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "ether_lighting"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/ether_lighting", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/ether_lighting", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_evaluation_score.generated.go
generated
12
unifi/setting_evaluation_score.generated.go
generated
@@ -48,17 +48,17 @@ func (dst *SettingEvaluationScore) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingEvaluationScore(ctx context.Context, site string) (*SettingEvaluationScore, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingEvaluationScore `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/evaluation_score", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/evaluation_score", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -67,18 +67,18 @@ func (c *Client) getSettingEvaluationScore(ctx context.Context, site string) (*S
|
||||
|
||||
func (c *Client) updateSettingEvaluationScore(ctx context.Context, site string, d *SettingEvaluationScore) (*SettingEvaluationScore, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingEvaluationScore `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "evaluation_score"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/evaluation_score", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/evaluation_score", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_global_ap.generated.go
generated
12
unifi/setting_global_ap.generated.go
generated
@@ -70,17 +70,17 @@ func (dst *SettingGlobalAp) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingGlobalAp(ctx context.Context, site string) (*SettingGlobalAp, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingGlobalAp `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/global_ap", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/global_ap", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -89,18 +89,18 @@ func (c *Client) getSettingGlobalAp(ctx context.Context, site string) (*SettingG
|
||||
|
||||
func (c *Client) updateSettingGlobalAp(ctx context.Context, site string, d *SettingGlobalAp) (*SettingGlobalAp, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingGlobalAp `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "global_ap"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/global_ap", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/global_ap", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_global_nat.generated.go
generated
12
unifi/setting_global_nat.generated.go
generated
@@ -49,17 +49,17 @@ func (dst *SettingGlobalNat) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingGlobalNat(ctx context.Context, site string) (*SettingGlobalNat, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingGlobalNat `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/global_nat", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/global_nat", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -68,18 +68,18 @@ func (c *Client) getSettingGlobalNat(ctx context.Context, site string) (*Setting
|
||||
|
||||
func (c *Client) updateSettingGlobalNat(ctx context.Context, site string, d *SettingGlobalNat) (*SettingGlobalNat, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingGlobalNat `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "global_nat"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/global_nat", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/global_nat", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_global_switch.generated.go
generated
12
unifi/setting_global_switch.generated.go
generated
@@ -78,17 +78,17 @@ func (dst *SettingGlobalSwitchAclL3Isolation) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingGlobalSwitch(ctx context.Context, site string) (*SettingGlobalSwitch, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingGlobalSwitch `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/global_switch", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/global_switch", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -97,18 +97,18 @@ func (c *Client) getSettingGlobalSwitch(ctx context.Context, site string) (*Sett
|
||||
|
||||
func (c *Client) updateSettingGlobalSwitch(ctx context.Context, site string, d *SettingGlobalSwitch) (*SettingGlobalSwitch, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingGlobalSwitch `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "global_switch"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/global_switch", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/global_switch", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_guest_access.generated.go
generated
12
unifi/setting_guest_access.generated.go
generated
@@ -157,17 +157,17 @@ func (dst *SettingGuestAccess) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingGuestAccess(ctx context.Context, site string) (*SettingGuestAccess, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingGuestAccess `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/guest_access", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/guest_access", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -176,18 +176,18 @@ func (c *Client) getSettingGuestAccess(ctx context.Context, site string) (*Setti
|
||||
|
||||
func (c *Client) updateSettingGuestAccess(ctx context.Context, site string, d *SettingGuestAccess) (*SettingGuestAccess, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingGuestAccess `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "guest_access"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/guest_access", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/guest_access", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_ips.generated.go
generated
12
unifi/setting_ips.generated.go
generated
@@ -224,17 +224,17 @@ func (dst *SettingIpsWhitelist) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingIps(ctx context.Context, site string) (*SettingIps, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingIps `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/ips", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/ips", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -243,18 +243,18 @@ func (c *Client) getSettingIps(ctx context.Context, site string) (*SettingIps, e
|
||||
|
||||
func (c *Client) updateSettingIps(ctx context.Context, site string, d *SettingIps) (*SettingIps, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingIps `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "ips"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/ips", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/ips", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_lcm.generated.go
generated
12
unifi/setting_lcm.generated.go
generated
@@ -57,17 +57,17 @@ func (dst *SettingLcm) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingLcm(ctx context.Context, site string) (*SettingLcm, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingLcm `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/lcm", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/lcm", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -76,18 +76,18 @@ func (c *Client) getSettingLcm(ctx context.Context, site string) (*SettingLcm, e
|
||||
|
||||
func (c *Client) updateSettingLcm(ctx context.Context, site string, d *SettingLcm) (*SettingLcm, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingLcm `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "lcm"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/lcm", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/lcm", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_locale.generated.go
generated
12
unifi/setting_locale.generated.go
generated
@@ -48,17 +48,17 @@ func (dst *SettingLocale) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingLocale(ctx context.Context, site string) (*SettingLocale, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingLocale `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/locale", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/locale", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -67,18 +67,18 @@ func (c *Client) getSettingLocale(ctx context.Context, site string) (*SettingLoc
|
||||
|
||||
func (c *Client) updateSettingLocale(ctx context.Context, site string, d *SettingLocale) (*SettingLocale, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingLocale `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "locale"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/locale", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/locale", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_magic_site_to_site_vpn.generated.go
generated
12
unifi/setting_magic_site_to_site_vpn.generated.go
generated
@@ -48,17 +48,17 @@ func (dst *SettingMagicSiteToSiteVpn) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingMagicSiteToSiteVpn(ctx context.Context, site string) (*SettingMagicSiteToSiteVpn, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingMagicSiteToSiteVpn `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/magic_site_to_site_vpn", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/magic_site_to_site_vpn", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -67,18 +67,18 @@ func (c *Client) getSettingMagicSiteToSiteVpn(ctx context.Context, site string)
|
||||
|
||||
func (c *Client) updateSettingMagicSiteToSiteVpn(ctx context.Context, site string, d *SettingMagicSiteToSiteVpn) (*SettingMagicSiteToSiteVpn, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingMagicSiteToSiteVpn `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "magic_site_to_site_vpn"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/magic_site_to_site_vpn", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/magic_site_to_site_vpn", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_mgmt.generated.go
generated
12
unifi/setting_mgmt.generated.go
generated
@@ -95,17 +95,17 @@ func (dst *SettingMgmtXSshKeys) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingMgmt(ctx context.Context, site string) (*SettingMgmt, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingMgmt `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/mgmt", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/mgmt", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -114,18 +114,18 @@ func (c *Client) getSettingMgmt(ctx context.Context, site string) (*SettingMgmt,
|
||||
|
||||
func (c *Client) updateSettingMgmt(ctx context.Context, site string, d *SettingMgmt) (*SettingMgmt, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingMgmt `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "mgmt"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/mgmt", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/mgmt", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_netflow.generated.go
generated
12
unifi/setting_netflow.generated.go
generated
@@ -71,17 +71,17 @@ func (dst *SettingNetflow) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingNetflow(ctx context.Context, site string) (*SettingNetflow, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingNetflow `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/netflow", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/netflow", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -90,18 +90,18 @@ func (c *Client) getSettingNetflow(ctx context.Context, site string) (*SettingNe
|
||||
|
||||
func (c *Client) updateSettingNetflow(ctx context.Context, site string, d *SettingNetflow) (*SettingNetflow, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingNetflow `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "netflow"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/netflow", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/netflow", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_network_optimization.generated.go
generated
12
unifi/setting_network_optimization.generated.go
generated
@@ -48,17 +48,17 @@ func (dst *SettingNetworkOptimization) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingNetworkOptimization(ctx context.Context, site string) (*SettingNetworkOptimization, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingNetworkOptimization `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/network_optimization", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/network_optimization", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -67,18 +67,18 @@ func (c *Client) getSettingNetworkOptimization(ctx context.Context, site string)
|
||||
|
||||
func (c *Client) updateSettingNetworkOptimization(ctx context.Context, site string, d *SettingNetworkOptimization) (*SettingNetworkOptimization, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingNetworkOptimization `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "network_optimization"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/network_optimization", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/network_optimization", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_ntp.generated.go
generated
12
unifi/setting_ntp.generated.go
generated
@@ -52,17 +52,17 @@ func (dst *SettingNtp) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingNtp(ctx context.Context, site string) (*SettingNtp, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingNtp `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/ntp", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/ntp", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -71,18 +71,18 @@ func (c *Client) getSettingNtp(ctx context.Context, site string) (*SettingNtp, e
|
||||
|
||||
func (c *Client) updateSettingNtp(ctx context.Context, site string, d *SettingNtp) (*SettingNtp, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingNtp `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "ntp"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/ntp", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/ntp", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_porta.generated.go
generated
12
unifi/setting_porta.generated.go
generated
@@ -48,17 +48,17 @@ func (dst *SettingPorta) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingPorta(ctx context.Context, site string) (*SettingPorta, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingPorta `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/porta", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/porta", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -67,18 +67,18 @@ func (c *Client) getSettingPorta(ctx context.Context, site string) (*SettingPort
|
||||
|
||||
func (c *Client) updateSettingPorta(ctx context.Context, site string, d *SettingPorta) (*SettingPorta, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingPorta `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "porta"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/porta", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/porta", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_provider_capabilities.generated.go
generated
12
unifi/setting_provider_capabilities.generated.go
generated
@@ -55,17 +55,17 @@ func (dst *SettingProviderCapabilities) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingProviderCapabilities(ctx context.Context, site string) (*SettingProviderCapabilities, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"Meta"`
|
||||
Data []SettingProviderCapabilities `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/provider_capabilities", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/provider_capabilities", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -74,18 +74,18 @@ func (c *Client) getSettingProviderCapabilities(ctx context.Context, site string
|
||||
|
||||
func (c *Client) updateSettingProviderCapabilities(ctx context.Context, site string, d *SettingProviderCapabilities) (*SettingProviderCapabilities, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"Meta"`
|
||||
Data []SettingProviderCapabilities `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "provider_capabilities"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/provider_capabilities", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/provider_capabilities", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_radio_ai.generated.go
generated
12
unifi/setting_radio_ai.generated.go
generated
@@ -115,17 +115,17 @@ func (dst *SettingRadioAiChannelsBlacklist) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingRadioAi(ctx context.Context, site string) (*SettingRadioAi, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingRadioAi `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/radio_ai", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/radio_ai", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -134,18 +134,18 @@ func (c *Client) getSettingRadioAi(ctx context.Context, site string) (*SettingRa
|
||||
|
||||
func (c *Client) updateSettingRadioAi(ctx context.Context, site string, d *SettingRadioAi) (*SettingRadioAi, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingRadioAi `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "radio_ai"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/radio_ai", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/radio_ai", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_radius.generated.go
generated
12
unifi/setting_radius.generated.go
generated
@@ -62,17 +62,17 @@ func (dst *SettingRadius) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingRadius(ctx context.Context, site string) (*SettingRadius, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingRadius `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/radius", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/radius", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -81,18 +81,18 @@ func (c *Client) getSettingRadius(ctx context.Context, site string) (*SettingRad
|
||||
|
||||
func (c *Client) updateSettingRadius(ctx context.Context, site string, d *SettingRadius) (*SettingRadius, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingRadius `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "radius"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/radius", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/radius", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_rsyslogd.generated.go
generated
12
unifi/setting_rsyslogd.generated.go
generated
@@ -63,17 +63,17 @@ func (dst *SettingRsyslogd) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingRsyslogd(ctx context.Context, site string) (*SettingRsyslogd, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingRsyslogd `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/rsyslogd", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/rsyslogd", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -82,18 +82,18 @@ func (c *Client) getSettingRsyslogd(ctx context.Context, site string) (*SettingR
|
||||
|
||||
func (c *Client) updateSettingRsyslogd(ctx context.Context, site string, d *SettingRsyslogd) (*SettingRsyslogd, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingRsyslogd `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "rsyslogd"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/rsyslogd", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/rsyslogd", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_snmp.generated.go
generated
12
unifi/setting_snmp.generated.go
generated
@@ -52,17 +52,17 @@ func (dst *SettingSnmp) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingSnmp(ctx context.Context, site string) (*SettingSnmp, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSnmp `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/snmp", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/snmp", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -71,18 +71,18 @@ func (c *Client) getSettingSnmp(ctx context.Context, site string) (*SettingSnmp,
|
||||
|
||||
func (c *Client) updateSettingSnmp(ctx context.Context, site string, d *SettingSnmp) (*SettingSnmp, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSnmp `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "snmp"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/snmp", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/snmp", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_ssl_inspection.generated.go
generated
12
unifi/setting_ssl_inspection.generated.go
generated
@@ -48,17 +48,17 @@ func (dst *SettingSslInspection) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingSslInspection(ctx context.Context, site string) (*SettingSslInspection, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSslInspection `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/ssl_inspection", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/ssl_inspection", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -67,18 +67,18 @@ func (c *Client) getSettingSslInspection(ctx context.Context, site string) (*Set
|
||||
|
||||
func (c *Client) updateSettingSslInspection(ctx context.Context, site string, d *SettingSslInspection) (*SettingSslInspection, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSslInspection `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "ssl_inspection"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/ssl_inspection", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/ssl_inspection", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_super_cloudaccess.generated.go
generated
12
unifi/setting_super_cloudaccess.generated.go
generated
@@ -54,17 +54,17 @@ func (dst *SettingSuperCloudaccess) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingSuperCloudaccess(ctx context.Context, site string) (*SettingSuperCloudaccess, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSuperCloudaccess `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/super_cloudaccess", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/super_cloudaccess", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -73,18 +73,18 @@ func (c *Client) getSettingSuperCloudaccess(ctx context.Context, site string) (*
|
||||
|
||||
func (c *Client) updateSettingSuperCloudaccess(ctx context.Context, site string, d *SettingSuperCloudaccess) (*SettingSuperCloudaccess, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSuperCloudaccess `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "super_cloudaccess"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/super_cloudaccess", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/super_cloudaccess", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_super_events.generated.go
generated
12
unifi/setting_super_events.generated.go
generated
@@ -48,17 +48,17 @@ func (dst *SettingSuperEvents) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingSuperEvents(ctx context.Context, site string) (*SettingSuperEvents, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSuperEvents `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/super_events", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/super_events", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -67,18 +67,18 @@ func (c *Client) getSettingSuperEvents(ctx context.Context, site string) (*Setti
|
||||
|
||||
func (c *Client) updateSettingSuperEvents(ctx context.Context, site string, d *SettingSuperEvents) (*SettingSuperEvents, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSuperEvents `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "super_events"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/super_events", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/super_events", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_super_fwupdate.generated.go
generated
12
unifi/setting_super_fwupdate.generated.go
generated
@@ -50,17 +50,17 @@ func (dst *SettingSuperFwupdate) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingSuperFwupdate(ctx context.Context, site string) (*SettingSuperFwupdate, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSuperFwupdate `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/super_fwupdate", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/super_fwupdate", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -69,18 +69,18 @@ func (c *Client) getSettingSuperFwupdate(ctx context.Context, site string) (*Set
|
||||
|
||||
func (c *Client) updateSettingSuperFwupdate(ctx context.Context, site string, d *SettingSuperFwupdate) (*SettingSuperFwupdate, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSuperFwupdate `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "super_fwupdate"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/super_fwupdate", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/super_fwupdate", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_super_identity.generated.go
generated
12
unifi/setting_super_identity.generated.go
generated
@@ -49,17 +49,17 @@ func (dst *SettingSuperIdentity) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingSuperIdentity(ctx context.Context, site string) (*SettingSuperIdentity, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSuperIdentity `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/super_identity", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/super_identity", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -68,18 +68,18 @@ func (c *Client) getSettingSuperIdentity(ctx context.Context, site string) (*Set
|
||||
|
||||
func (c *Client) updateSettingSuperIdentity(ctx context.Context, site string, d *SettingSuperIdentity) (*SettingSuperIdentity, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSuperIdentity `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "super_identity"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/super_identity", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/super_identity", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_super_mail.generated.go
generated
12
unifi/setting_super_mail.generated.go
generated
@@ -48,17 +48,17 @@ func (dst *SettingSuperMail) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingSuperMail(ctx context.Context, site string) (*SettingSuperMail, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSuperMail `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/super_mail", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/super_mail", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -67,18 +67,18 @@ func (c *Client) getSettingSuperMail(ctx context.Context, site string) (*Setting
|
||||
|
||||
func (c *Client) updateSettingSuperMail(ctx context.Context, site string, d *SettingSuperMail) (*SettingSuperMail, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSuperMail `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "super_mail"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/super_mail", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/super_mail", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_super_mgmt.generated.go
generated
12
unifi/setting_super_mgmt.generated.go
generated
@@ -113,17 +113,17 @@ func (dst *SettingSuperMgmt) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingSuperMgmt(ctx context.Context, site string) (*SettingSuperMgmt, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSuperMgmt `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/super_mgmt", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/super_mgmt", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -132,18 +132,18 @@ func (c *Client) getSettingSuperMgmt(ctx context.Context, site string) (*Setting
|
||||
|
||||
func (c *Client) updateSettingSuperMgmt(ctx context.Context, site string, d *SettingSuperMgmt) (*SettingSuperMgmt, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSuperMgmt `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "super_mgmt"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/super_mgmt", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/super_mgmt", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_super_sdn.generated.go
generated
12
unifi/setting_super_sdn.generated.go
generated
@@ -53,17 +53,17 @@ func (dst *SettingSuperSdn) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingSuperSdn(ctx context.Context, site string) (*SettingSuperSdn, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSuperSdn `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/super_sdn", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/super_sdn", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -72,18 +72,18 @@ func (c *Client) getSettingSuperSdn(ctx context.Context, site string) (*SettingS
|
||||
|
||||
func (c *Client) updateSettingSuperSdn(ctx context.Context, site string, d *SettingSuperSdn) (*SettingSuperSdn, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSuperSdn `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "super_sdn"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/super_sdn", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/super_sdn", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_super_smtp.generated.go
generated
12
unifi/setting_super_smtp.generated.go
generated
@@ -59,17 +59,17 @@ func (dst *SettingSuperSmtp) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingSuperSmtp(ctx context.Context, site string) (*SettingSuperSmtp, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSuperSmtp `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/super_smtp", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/super_smtp", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -78,18 +78,18 @@ func (c *Client) getSettingSuperSmtp(ctx context.Context, site string) (*Setting
|
||||
|
||||
func (c *Client) updateSettingSuperSmtp(ctx context.Context, site string, d *SettingSuperSmtp) (*SettingSuperSmtp, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingSuperSmtp `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "super_smtp"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/super_smtp", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/super_smtp", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_teleport.generated.go
generated
12
unifi/setting_teleport.generated.go
generated
@@ -49,17 +49,17 @@ func (dst *SettingTeleport) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingTeleport(ctx context.Context, site string) (*SettingTeleport, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingTeleport `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/teleport", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/teleport", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -68,18 +68,18 @@ func (c *Client) getSettingTeleport(ctx context.Context, site string) (*SettingT
|
||||
|
||||
func (c *Client) updateSettingTeleport(ctx context.Context, site string, d *SettingTeleport) (*SettingTeleport, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingTeleport `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "teleport"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/teleport", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/teleport", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_usg.generated.go
generated
12
unifi/setting_usg.generated.go
generated
@@ -160,17 +160,17 @@ func (dst *SettingUsgDNSVerification) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingUsg(ctx context.Context, site string) (*SettingUsg, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingUsg `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/usg", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/usg", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -179,18 +179,18 @@ func (c *Client) getSettingUsg(ctx context.Context, site string) (*SettingUsg, e
|
||||
|
||||
func (c *Client) updateSettingUsg(ctx context.Context, site string, d *SettingUsg) (*SettingUsg, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingUsg `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "usg"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/usg", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/usg", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
12
unifi/setting_usw.generated.go
generated
12
unifi/setting_usw.generated.go
generated
@@ -48,17 +48,17 @@ func (dst *SettingUsw) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) getSettingUsw(ctx context.Context, site string) (*SettingUsw, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingUsw `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/get/setting/usw", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/usw", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -67,18 +67,18 @@ func (c *Client) getSettingUsw(ctx context.Context, site string) (*SettingUsw, e
|
||||
|
||||
func (c *Client) updateSettingUsw(ctx context.Context, site string, d *SettingUsw) (*SettingUsw, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SettingUsw `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "usw"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/usw", site), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/usw", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
@@ -21,11 +21,11 @@ type Site struct {
|
||||
|
||||
func (c *Client) ListSites(ctx context.Context) ([]Site, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"Meta"`
|
||||
Data []Site `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", "self/sites", nil, &respBody)
|
||||
err := c.Get(ctx, "self/sites", nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -45,7 +45,7 @@ func (c *Client) GetSite(ctx context.Context, id string) (*Site, error) {
|
||||
}
|
||||
}
|
||||
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
func (c *Client) CreateSite(ctx context.Context, description string) ([]Site, error) {
|
||||
@@ -58,11 +58,11 @@ func (c *Client) CreateSite(ctx context.Context, description string) ([]Site, er
|
||||
}
|
||||
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"Meta"`
|
||||
Data []Site `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", "s/default/cmd/sitemgr", reqBody, &respBody)
|
||||
err := c.Post(ctx, "s/default/cmd/sitemgr", reqBody, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -80,11 +80,11 @@ func (c *Client) DeleteSite(ctx context.Context, id string) ([]Site, error) {
|
||||
}
|
||||
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"Meta"`
|
||||
Data []Site `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", "s/default/cmd/sitemgr", reqBody, &respBody)
|
||||
err := c.Post(ctx, "s/default/cmd/sitemgr", reqBody, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -102,11 +102,11 @@ func (c *Client) UpdateSite(ctx context.Context, name, description string) ([]Si
|
||||
}
|
||||
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"Meta"`
|
||||
Data []Site `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/cmd/sitemgr", name), reqBody, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/cmd/sitemgr", name), reqBody, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
24
unifi/spatial_record.generated.go
generated
24
unifi/spatial_record.generated.go
generated
@@ -90,11 +90,11 @@ func (dst *SpatialRecordPosition) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listSpatialRecord(ctx context.Context, site string) ([]SpatialRecord, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SpatialRecord `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/spatialrecord", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/spatialrecord", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -104,17 +104,17 @@ func (c *Client) listSpatialRecord(ctx context.Context, site string) ([]SpatialR
|
||||
|
||||
func (c *Client) getSpatialRecord(ctx context.Context, site, id string) (*SpatialRecord, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SpatialRecord `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/spatialrecord/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/spatialrecord/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -122,7 +122,7 @@ func (c *Client) getSpatialRecord(ctx context.Context, site, id string) (*Spatia
|
||||
}
|
||||
|
||||
func (c *Client) deleteSpatialRecord(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/spatialrecord/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/spatialrecord/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -131,17 +131,17 @@ func (c *Client) deleteSpatialRecord(ctx context.Context, site, id string) error
|
||||
|
||||
func (c *Client) createSpatialRecord(ctx context.Context, site string, d *SpatialRecord) (*SpatialRecord, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SpatialRecord `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/spatialrecord", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/spatialrecord", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -151,17 +151,17 @@ func (c *Client) createSpatialRecord(ctx context.Context, site string, d *Spatia
|
||||
|
||||
func (c *Client) updateSpatialRecord(ctx context.Context, site string, d *SpatialRecord) (*SpatialRecord, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []SpatialRecord `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/spatialrecord/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/spatialrecord/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
@@ -15,7 +15,7 @@ type sysInfo struct {
|
||||
/*
|
||||
|
||||
{
|
||||
"meta": {
|
||||
"Meta": {
|
||||
"rc": "ok"
|
||||
},
|
||||
"data": [
|
||||
@@ -68,17 +68,17 @@ type sysInfo struct {
|
||||
|
||||
func (c *Client) sysinfo(ctx context.Context, id string) (*sysInfo, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"Meta"`
|
||||
Data []sysInfo `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/stat/sysinfo", id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/stat/sysinfo", id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
return &respBody.Data[0], nil
|
||||
|
||||
24
unifi/tag.generated.go
generated
24
unifi/tag.generated.go
generated
@@ -47,11 +47,11 @@ func (dst *Tag) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listTag(ctx context.Context, site string) ([]Tag, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Tag `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/tag", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/tag", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -61,17 +61,17 @@ func (c *Client) listTag(ctx context.Context, site string) ([]Tag, error) {
|
||||
|
||||
func (c *Client) getTag(ctx context.Context, site, id string) (*Tag, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Tag `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/tag/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/tag/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -79,7 +79,7 @@ func (c *Client) getTag(ctx context.Context, site, id string) (*Tag, error) {
|
||||
}
|
||||
|
||||
func (c *Client) deleteTag(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/tag/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/tag/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -88,17 +88,17 @@ func (c *Client) deleteTag(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createTag(ctx context.Context, site string, d *Tag) (*Tag, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Tag `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/tag", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/tag", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -108,17 +108,17 @@ func (c *Client) createTag(ctx context.Context, site string, d *Tag) (*Tag, erro
|
||||
|
||||
func (c *Client) updateTag(ctx context.Context, site string, d *Tag) (*Tag, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Tag `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/tag/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/tag/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
725
unifi/unifi.go
725
unifi/unifi.go
@@ -3,6 +3,7 @@ package unifi
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@@ -11,8 +12,12 @@ import (
|
||||
"net/http/cookiejar"
|
||||
"net/url"
|
||||
"path"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/publicsuffix"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -27,13 +32,16 @@ const (
|
||||
|
||||
statusPath = "/status"
|
||||
statusPathNew = "/proxy/network/status"
|
||||
|
||||
logoutPath = "/api/logout"
|
||||
|
||||
defaultUserAgent = "go-unifi/0.0.1"
|
||||
)
|
||||
|
||||
type NotFoundError struct{}
|
||||
|
||||
func (err *NotFoundError) Error() string {
|
||||
return "not found"
|
||||
}
|
||||
var (
|
||||
AuthenticationFailedError = fmt.Errorf("authentication failed")
|
||||
NotFoundError = fmt.Errorf("not found")
|
||||
)
|
||||
|
||||
type APIError struct {
|
||||
RC string
|
||||
@@ -54,246 +62,12 @@ func (err *APIError) Is(target error) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
// single thread client calls for CSRF, etc.
|
||||
sync.Mutex
|
||||
|
||||
c *http.Client
|
||||
baseURL *url.URL
|
||||
|
||||
apiPath string
|
||||
apiV2Path string
|
||||
loginPath string
|
||||
statusPath string
|
||||
|
||||
csrf string
|
||||
|
||||
version string
|
||||
}
|
||||
|
||||
func (c *Client) CSRFToken() string {
|
||||
return c.csrf
|
||||
}
|
||||
|
||||
func (c *Client) Version() string {
|
||||
return c.version
|
||||
}
|
||||
|
||||
func (c *Client) SetBaseURL(base string) error {
|
||||
var err error
|
||||
c.baseURL, err = url.Parse(base)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// error for people who are still passing hard coded old paths
|
||||
if path := strings.TrimSuffix(c.baseURL.Path, "/"); path == apiPath {
|
||||
return fmt.Errorf("expected a base URL without the `/api`, got: %q", c.baseURL)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) SetHTTPClient(hc *http.Client) error {
|
||||
c.c = hc
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) setAPIUrlStyle(ctx context.Context) error {
|
||||
// check if new style API
|
||||
// this is modified from the unifi-poller (https://github.com/unifi-poller/unifi) implementation.
|
||||
// see https://github.com/unifi-poller/unifi/blob/4dc44f11f61a2e08bf7ec5b20c71d5bced837b5d/unifi.go#L101-L104
|
||||
// and https://github.com/unifi-poller/unifi/commit/43a6b225031a28f2b358f52d03a7217c7b524143
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.baseURL.String(), nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// We can't share these cookies with other requests, so make a new client.
|
||||
// Checking the return code on the first request so don't follow a redirect.
|
||||
client := &http.Client{
|
||||
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
},
|
||||
Transport: c.c.Transport,
|
||||
}
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
_, _ = io.Copy(io.Discard, resp.Body)
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
// the new API returns a 200 for a / request
|
||||
c.apiPath = apiPathNew
|
||||
c.apiV2Path = apiV2PathNew
|
||||
c.loginPath = loginPathNew
|
||||
c.statusPath = statusPathNew
|
||||
return nil
|
||||
}
|
||||
|
||||
// The old version returns a "302" (to /manage) for a / request
|
||||
c.apiPath = apiPath
|
||||
c.apiV2Path = apiV2Path
|
||||
c.loginPath = loginPath
|
||||
c.statusPath = statusPath
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) Login(ctx context.Context, user, pass string) error {
|
||||
if c.c == nil {
|
||||
c.c = &http.Client{}
|
||||
|
||||
jar, _ := cookiejar.New(nil)
|
||||
c.c.Jar = jar
|
||||
}
|
||||
|
||||
err := c.setAPIUrlStyle(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to determine API URL style: %w", err)
|
||||
}
|
||||
|
||||
var status struct {
|
||||
Meta struct {
|
||||
ServerVersion string `json:"server_version"`
|
||||
UUID string `json:"uuid"`
|
||||
} `json:"meta"`
|
||||
}
|
||||
|
||||
err = c.do(ctx, "POST", c.loginPath, &struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
}{
|
||||
Username: user,
|
||||
Password: pass,
|
||||
}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = c.do(ctx, "GET", c.statusPath, nil, &status)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if version := status.Meta.ServerVersion; version != "" {
|
||||
c.version = status.Meta.ServerVersion
|
||||
return nil
|
||||
}
|
||||
|
||||
// newer version of 6.0 controller, use sysinfo to determine version
|
||||
// using default site since it must exist
|
||||
si, err := c.sysinfo(ctx, "default")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c.version = si.Version
|
||||
|
||||
if c.version == "" {
|
||||
return errors.New("unable to determine controller version")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) do(ctx context.Context, method, relativeURL string, reqBody interface{}, respBody interface{}) error {
|
||||
// single threading requests, this is mostly to assist in CSRF token propagation
|
||||
c.Lock()
|
||||
defer c.Unlock()
|
||||
|
||||
var (
|
||||
reqReader io.Reader
|
||||
err error
|
||||
reqBytes []byte
|
||||
)
|
||||
if reqBody != nil {
|
||||
reqBytes, err = json.Marshal(reqBody)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to marshal JSON: %s %s %w", method, relativeURL, err)
|
||||
}
|
||||
reqReader = bytes.NewReader(reqBytes)
|
||||
}
|
||||
|
||||
reqURL, err := url.Parse(relativeURL)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to parse URL: %s %s %w", method, relativeURL, err)
|
||||
}
|
||||
if !strings.HasPrefix(relativeURL, "/") && !reqURL.IsAbs() {
|
||||
reqURL.Path = path.Join(c.apiPath, reqURL.Path)
|
||||
}
|
||||
|
||||
url := c.baseURL.ResolveReference(reqURL)
|
||||
req, err := http.NewRequestWithContext(ctx, method, url.String(), reqReader)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to create request: %s %s %w", method, relativeURL, err)
|
||||
}
|
||||
|
||||
req.Header.Set("User-Agent", "terraform-provider-unifi/0.1")
|
||||
req.Header.Add("Content-Type", "application/json; charset=utf-8")
|
||||
|
||||
if c.csrf != "" {
|
||||
req.Header.Set("X-Csrf-Token", c.csrf)
|
||||
}
|
||||
|
||||
resp, err := c.c.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to perform request: %s %s %w", method, relativeURL, err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode == http.StatusNotFound {
|
||||
return &NotFoundError{}
|
||||
}
|
||||
|
||||
if csrf := resp.Header.Get("X-Csrf-Token"); csrf != "" {
|
||||
c.csrf = resp.Header.Get("X-Csrf-Token")
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
errBody := struct {
|
||||
Meta meta `json:"meta"`
|
||||
Data []struct {
|
||||
Meta meta `json:"meta"`
|
||||
} `json:"data"`
|
||||
}{}
|
||||
if err = json.NewDecoder(resp.Body).Decode(&errBody); err != nil {
|
||||
return err
|
||||
}
|
||||
var apiErr error
|
||||
if len(errBody.Data) > 0 && errBody.Data[0].Meta.RC == "error" {
|
||||
// check first error in data, should we look for more than one?
|
||||
apiErr = errBody.Data[0].Meta.error()
|
||||
}
|
||||
if apiErr == nil {
|
||||
apiErr = errBody.Meta.error()
|
||||
}
|
||||
return fmt.Errorf("%w (%s) for %s %s", apiErr, resp.Status, method, url.String())
|
||||
}
|
||||
|
||||
if respBody == nil || resp.ContentLength == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO: check rc in addition to status code?
|
||||
|
||||
err = json.NewDecoder(resp.Body).Decode(respBody)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode body: %s %s %w", method, relativeURL, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type meta struct {
|
||||
type Meta struct {
|
||||
RC string `json:"rc"`
|
||||
Message string `json:"msg"`
|
||||
}
|
||||
|
||||
func (m *meta) error() error {
|
||||
func (m *Meta) error() error {
|
||||
if m.RC != "ok" {
|
||||
return &APIError{
|
||||
RC: m.RC,
|
||||
@@ -303,3 +77,472 @@ func (m *meta) error() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type ClientConfig struct {
|
||||
User string
|
||||
Pass string
|
||||
APIKey string
|
||||
URL string
|
||||
Timeout time.Duration // how long to wait for replies, default: forever.
|
||||
VerifySSL bool
|
||||
Interceptors []ClientInterceptor
|
||||
HttpCustomizer HttpCustomizer
|
||||
UserAgent string
|
||||
ErrorHandler ResponseErrorHandler
|
||||
UseLocking bool
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
BaseURL *url.URL
|
||||
ServerInfo *ServerInfo
|
||||
apiPaths *ApiPaths
|
||||
config *ClientConfig
|
||||
http *http.Client
|
||||
interceptors []ClientInterceptor
|
||||
errorHandler ResponseErrorHandler
|
||||
lock sync.Mutex
|
||||
}
|
||||
|
||||
type ApiPaths struct {
|
||||
ApiPath string
|
||||
ApiV2Path string
|
||||
LoginPath string
|
||||
StatusPath string
|
||||
LogoutPath string
|
||||
}
|
||||
|
||||
var (
|
||||
OldStyleAPI = ApiPaths{
|
||||
ApiPath: apiPath,
|
||||
ApiV2Path: apiV2Path,
|
||||
LoginPath: loginPath,
|
||||
StatusPath: statusPath,
|
||||
LogoutPath: logoutPath,
|
||||
}
|
||||
NewStyleAPI = ApiPaths{
|
||||
ApiPath: apiPathNew,
|
||||
ApiV2Path: apiV2PathNew,
|
||||
LoginPath: loginPathNew,
|
||||
StatusPath: statusPathNew,
|
||||
LogoutPath: logoutPath,
|
||||
}
|
||||
)
|
||||
|
||||
type ServerInfo struct {
|
||||
Up bool `json:"up"`
|
||||
ServerVersion string `fake:"{appversion}" json:"server_version"`
|
||||
UUID string `fake:"{uuid}" json:"uuid"`
|
||||
}
|
||||
|
||||
type HttpCustomizer func(transport *http.Transport) error
|
||||
|
||||
type ClientInterceptor interface {
|
||||
InterceptRequest(req *http.Request) error
|
||||
InterceptResponse(resp *http.Response) error
|
||||
}
|
||||
type ApiTokenAuthInterceptor struct {
|
||||
apiKey string
|
||||
}
|
||||
|
||||
func (a *ApiTokenAuthInterceptor) InterceptRequest(req *http.Request) error {
|
||||
req.Header.Set("X-API-Key", a.apiKey)
|
||||
return nil
|
||||
}
|
||||
func (a *ApiTokenAuthInterceptor) InterceptResponse(_ *http.Response) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type CsrfInterceptor struct {
|
||||
csrfToken string
|
||||
}
|
||||
|
||||
func (c *CsrfInterceptor) InterceptRequest(req *http.Request) error {
|
||||
if c.csrfToken != "" {
|
||||
req.Header.Set("X-Csrf-Token", c.csrfToken)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *CsrfInterceptor) InterceptResponse(resp *http.Response) error {
|
||||
if csrf := resp.Header.Get("X-Csrf-Token"); csrf != "" {
|
||||
c.csrfToken = csrf
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DefaultHeadersInterceptor struct {
|
||||
headers map[string]string
|
||||
}
|
||||
|
||||
func (d *DefaultHeadersInterceptor) InterceptRequest(req *http.Request) error {
|
||||
for key, value := range d.headers {
|
||||
req.Header.Set(key, value)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *DefaultHeadersInterceptor) InterceptResponse(_ *http.Response) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) RegisterInterceptor(interceptor *ClientInterceptor) {
|
||||
// ensure no duplicate interceptors
|
||||
if !slices.Contains(c.interceptors, *interceptor) {
|
||||
c.interceptors = append(c.interceptors, *interceptor)
|
||||
}
|
||||
}
|
||||
|
||||
type ResponseErrorHandler interface {
|
||||
HandleError(resp *http.Response) error
|
||||
}
|
||||
|
||||
type DefaultResponseErrorHandler struct{}
|
||||
|
||||
func (d *DefaultResponseErrorHandler) HandleError(resp *http.Response) error {
|
||||
switch resp.StatusCode {
|
||||
case http.StatusOK:
|
||||
return nil
|
||||
case http.StatusNotFound:
|
||||
return NotFoundError
|
||||
case http.StatusUnauthorized:
|
||||
return AuthenticationFailedError
|
||||
}
|
||||
errBody := struct {
|
||||
Meta Meta `json:"Meta"`
|
||||
Data []struct {
|
||||
Meta Meta `json:"Meta"`
|
||||
} `json:"data"`
|
||||
}{}
|
||||
if err := json.NewDecoder(resp.Body).Decode(&errBody); err != nil {
|
||||
return err
|
||||
}
|
||||
var apiErr error
|
||||
if len(errBody.Data) > 0 && errBody.Data[0].Meta.RC == "error" {
|
||||
// check first error in data, should we look for more than one?
|
||||
apiErr = errBody.Data[0].Meta.error()
|
||||
}
|
||||
if apiErr == nil {
|
||||
apiErr = errBody.Meta.error()
|
||||
}
|
||||
|
||||
// TODO: check rc in addition to status code?
|
||||
return fmt.Errorf("%w (%s) for %s %s", apiErr, resp.Status, resp.Request.Method, resp.Request.URL.String())
|
||||
}
|
||||
|
||||
// NewClient creates a http.Client with authenticated cookies.
|
||||
// Used to make additional, authenticated requests to the APIs.
|
||||
// Start here.
|
||||
func NewClient(config *ClientConfig) (*Client, error) {
|
||||
u, err := newUnifi(config)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed creating unifi client: %w", err)
|
||||
}
|
||||
if err = u.determineApiStyle(); err != nil {
|
||||
return u, fmt.Errorf("failed determining API style: %w", err)
|
||||
}
|
||||
|
||||
if err = u.Login(); err != nil {
|
||||
return u, fmt.Errorf("failed logging in: %w", err)
|
||||
}
|
||||
|
||||
if serverInfo, err := u.GetServerInfo(); err != nil {
|
||||
return u, fmt.Errorf("failed getting server info: %w", err)
|
||||
} else {
|
||||
u.ServerInfo = serverInfo
|
||||
}
|
||||
return u, nil
|
||||
}
|
||||
|
||||
func parseBaseUrl(base string) (*url.URL, error) {
|
||||
var err error
|
||||
baseURL, err := url.Parse(base)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// error for people who are still passing hard coded old paths
|
||||
if path := strings.TrimSuffix(baseURL.Path, "/"); path == apiPath {
|
||||
return nil, fmt.Errorf("expected a base URL without the `/api`, got: %q", baseURL)
|
||||
}
|
||||
|
||||
return baseURL, nil
|
||||
}
|
||||
|
||||
func newUnifi(config *ClientConfig) (*Client, error) {
|
||||
var err error
|
||||
|
||||
config.URL = strings.TrimRight(config.URL, "/")
|
||||
transport := &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: !config.VerifySSL}, // nolint: gosec
|
||||
}
|
||||
|
||||
if config.HttpCustomizer != nil {
|
||||
if err = config.HttpCustomizer(transport); err != nil {
|
||||
return nil, fmt.Errorf("failed customizing HTTP transport: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
client := &http.Client{
|
||||
Timeout: config.Timeout,
|
||||
Transport: transport,
|
||||
}
|
||||
|
||||
if config.APIKey == "" {
|
||||
// old user/pass style use the cookie jar
|
||||
jar, err := cookiejar.New(&cookiejar.Options{PublicSuffixList: publicsuffix.List})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed creating cookiejar: %w", err)
|
||||
}
|
||||
client.Jar = jar
|
||||
}
|
||||
baseURL, err := parseBaseUrl(config.URL)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed parsing base URL: %w", err)
|
||||
}
|
||||
var interceptors []ClientInterceptor
|
||||
|
||||
if config.APIKey != "" {
|
||||
interceptors = append(interceptors, &ApiTokenAuthInterceptor{apiKey: config.APIKey})
|
||||
} else {
|
||||
// CSRF is only needed for user/pass auth
|
||||
interceptors = append(interceptors, &CsrfInterceptor{})
|
||||
}
|
||||
if len(config.UserAgent) == 0 {
|
||||
config.UserAgent = defaultUserAgent
|
||||
}
|
||||
interceptors = append(interceptors, &DefaultHeadersInterceptor{headers: map[string]string{
|
||||
"User-Agent": config.UserAgent,
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
}})
|
||||
|
||||
var errorHandler ResponseErrorHandler
|
||||
if config.ErrorHandler != nil {
|
||||
errorHandler = config.ErrorHandler
|
||||
} else {
|
||||
errorHandler = &DefaultResponseErrorHandler{}
|
||||
}
|
||||
u := &Client{
|
||||
BaseURL: baseURL,
|
||||
config: config,
|
||||
http: client,
|
||||
interceptors: interceptors,
|
||||
errorHandler: errorHandler,
|
||||
lock: sync.Mutex{},
|
||||
}
|
||||
for _, interceptor := range config.Interceptors {
|
||||
// add any custom interceptors and ensure no duplicates
|
||||
u.RegisterInterceptor(&interceptor)
|
||||
}
|
||||
|
||||
return u, nil
|
||||
}
|
||||
|
||||
// Login is a helper method. It can be called to grab a new authentication cookie.
|
||||
func (c *Client) Login() error {
|
||||
if c.config.APIKey != "" {
|
||||
// no need to login on api-key auth
|
||||
return nil
|
||||
}
|
||||
|
||||
ctx, cancel := c.createRequestContext()
|
||||
defer cancel()
|
||||
|
||||
err := c.Post(ctx, c.apiPaths.LoginPath, &struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
}{
|
||||
Username: c.config.User,
|
||||
Password: c.config.Pass,
|
||||
}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Logout closes the current session.
|
||||
func (c *Client) Logout() error {
|
||||
if c.config.APIKey != "" {
|
||||
// no need to logout on api-key auth
|
||||
return nil
|
||||
}
|
||||
ctx, cancel := c.createRequestContext()
|
||||
defer cancel()
|
||||
|
||||
// a post is needed for logout
|
||||
err := c.Post(ctx, c.apiPaths.LogoutPath, nil, nil)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Client) createRequestContext() (context.Context, context.CancelFunc) {
|
||||
var (
|
||||
ctx = context.Background()
|
||||
cancel = func() {}
|
||||
)
|
||||
if c.config.Timeout != 0 {
|
||||
ctx, cancel = context.WithTimeout(ctx, c.config.Timeout)
|
||||
}
|
||||
return ctx, cancel
|
||||
}
|
||||
|
||||
// with the release of controller version 5.12.55 on UDM in Jan 2020 the api paths
|
||||
// changed and broke this library. This function runs when `NewClient()` is called to
|
||||
// check if this is a newer controller or not. If it is, we set new to true.
|
||||
// Setting new to true makes the path() method return different (new) paths.
|
||||
func (c *Client) determineApiStyle() error {
|
||||
ctx, cancel := c.createRequestContext()
|
||||
defer cancel()
|
||||
|
||||
//c.DebugLog("Requesting %s/ to determine API paths", c.URL)
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.BaseURL.String(), nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// We can't share these cookies with other requests, so make a new client.
|
||||
// Checking the return code on the first request so don't follow a redirect.
|
||||
client := &http.Client{
|
||||
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
},
|
||||
Transport: c.http.Transport,
|
||||
}
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer resp.Body.Close() // we need no data here.
|
||||
_, _ = io.Copy(io.Discard, resp.Body) // avoid leaking.
|
||||
|
||||
switch resp.StatusCode {
|
||||
case http.StatusOK:
|
||||
c.apiPaths = &NewStyleAPI // The new version returns a "200" for a / request.
|
||||
case http.StatusFound:
|
||||
c.apiPaths = &OldStyleAPI // The old version returns a "302" (to /manage) for a / request.
|
||||
default:
|
||||
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 nil
|
||||
}
|
||||
|
||||
// GetServerInfo sets the controller's version and UUID. Only call this if you
|
||||
// previously called Login and suspect the controller version has changed.
|
||||
func (c *Client) GetServerInfo() (*ServerInfo, error) {
|
||||
ctx, cancel := c.createRequestContext()
|
||||
defer cancel()
|
||||
|
||||
var response struct {
|
||||
Data ServerInfo `json:"Meta"`
|
||||
}
|
||||
|
||||
err := c.Get(ctx, c.apiPaths.StatusPath, nil, &response)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &response.Data, nil
|
||||
}
|
||||
|
||||
func marshalRequest(reqBody interface{}) (io.Reader, error) {
|
||||
if reqBody == nil {
|
||||
return nil, nil
|
||||
}
|
||||
reqBytes, err := json.Marshal(reqBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return bytes.NewReader(reqBytes), nil
|
||||
}
|
||||
|
||||
func (c *Client) createRequestURL(apiPath string) (*url.URL, error) {
|
||||
reqURL, err := url.Parse(apiPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !strings.HasPrefix(apiPath, "/") && !reqURL.IsAbs() {
|
||||
reqURL.Path = path.Join(c.apiPaths.ApiPath, reqURL.Path)
|
||||
}
|
||||
|
||||
return c.BaseURL.ResolveReference(reqURL), nil
|
||||
}
|
||||
|
||||
func (c *Client) Do(ctx context.Context, method, apiPath string, reqBody interface{}, respBody interface{}) error {
|
||||
reqReader, err := marshalRequest(reqBody)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to marshal request: %w", err)
|
||||
}
|
||||
|
||||
url, err := c.createRequestURL(apiPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to create request URL: %w", err)
|
||||
}
|
||||
req, err := http.NewRequestWithContext(ctx, method, url.String(), reqReader)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to create request: %s %s %w", method, apiPath, err)
|
||||
}
|
||||
if c.config.UseLocking {
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
}
|
||||
|
||||
for _, interceptor := range c.interceptors {
|
||||
if err := interceptor.InterceptRequest(req); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
resp, err := c.http.Do(req)
|
||||
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)
|
||||
|
||||
for _, interceptor := range c.interceptors {
|
||||
if err := interceptor.InterceptResponse(resp); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := c.errorHandler.HandleError(resp); err != nil {
|
||||
return err
|
||||
}
|
||||
if respBody == nil || resp.ContentLength == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
err = json.NewDecoder(resp.Body).Decode(respBody)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to decode body: %s %s %w", method, apiPath, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) Get(context context.Context, apiPath string, reqBody interface{}, respBody interface{}) error {
|
||||
return c.Do(context, http.MethodGet, apiPath, reqBody, respBody)
|
||||
}
|
||||
|
||||
func (c *Client) Post(context context.Context, apiPath string, reqBody interface{}, respBody interface{}) error {
|
||||
return c.Do(context, http.MethodPost, apiPath, reqBody, respBody)
|
||||
}
|
||||
|
||||
func (c *Client) Put(context context.Context, apiPath string, reqBody interface{}, respBody interface{}) error {
|
||||
return c.Do(context, http.MethodPut, apiPath, reqBody, respBody)
|
||||
}
|
||||
|
||||
func (c *Client) Delete(context context.Context, apiPath string, reqBody interface{}, respBody interface{}) error {
|
||||
return c.Do(context, http.MethodDelete, apiPath, reqBody, respBody)
|
||||
}
|
||||
|
||||
24
unifi/user.generated.go
generated
24
unifi/user.generated.go
generated
@@ -67,11 +67,11 @@ func (dst *User) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listUser(ctx context.Context, site string) ([]User, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []User `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/user", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/user", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -81,17 +81,17 @@ func (c *Client) listUser(ctx context.Context, site string) ([]User, error) {
|
||||
|
||||
func (c *Client) getUser(ctx context.Context, site, id string) (*User, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []User `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/user/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/user/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -99,7 +99,7 @@ func (c *Client) getUser(ctx context.Context, site, id string) (*User, error) {
|
||||
}
|
||||
|
||||
func (c *Client) deleteUser(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/user/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/user/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -108,17 +108,17 @@ func (c *Client) deleteUser(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createUser(ctx context.Context, site string, d *User) (*User, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []User `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/user", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/user", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -128,17 +128,17 @@ func (c *Client) createUser(ctx context.Context, site string, d *User) (*User, e
|
||||
|
||||
func (c *Client) updateUser(ctx context.Context, site string, d *User) (*User, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []User `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/user/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/user/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
@@ -11,17 +11,17 @@ import (
|
||||
// by this method.
|
||||
func (c *Client) GetUserByMAC(ctx context.Context, site, mac string) (*User, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"Meta"`
|
||||
Data []User `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/stat/user/%s", site, mac), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/stat/user/%s", site, mac), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -42,14 +42,14 @@ func (c *Client) CreateUser(ctx context.Context, site string, d *User) (*User, e
|
||||
}
|
||||
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"Meta"`
|
||||
Data []struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"Meta"`
|
||||
Data []User `json:"data"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/group/user", site), reqBody, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/group/user", site), reqBody, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -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, NotFoundError
|
||||
}
|
||||
|
||||
user := respBody.Data[0].Data[0]
|
||||
@@ -81,11 +81,11 @@ func (c *Client) stamgr(ctx context.Context, site, cmd string, data map[string]i
|
||||
reqBody["cmd"] = cmd
|
||||
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"Meta"`
|
||||
Data []User `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/cmd/stamgr", site), reqBody, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/cmd/stamgr", site), reqBody, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -101,7 +101,7 @@ func (c *Client) BlockUserByMAC(ctx context.Context, site, mac string) error {
|
||||
return err
|
||||
}
|
||||
if len(users) != 1 {
|
||||
return &NotFoundError{}
|
||||
return NotFoundError
|
||||
}
|
||||
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 NotFoundError
|
||||
}
|
||||
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 NotFoundError
|
||||
}
|
||||
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 NotFoundError
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -165,7 +165,7 @@ func (c *Client) OverrideUserFingerprint(ctx context.Context, site, mac string,
|
||||
SearchQuery string `json:"search_query"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, reqMethod, fmt.Sprintf("%s/site/%s/station/%s/fingerprint_override", c.apiV2Path, site, mac), reqBody, &respBody)
|
||||
err := c.Do(ctx, reqMethod, fmt.Sprintf("%s/site/%s/station/%s/fingerprint_override", c.apiPaths.ApiV2Path, site, mac), reqBody, &respBody)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
24
unifi/user_group.generated.go
generated
24
unifi/user_group.generated.go
generated
@@ -53,11 +53,11 @@ func (dst *UserGroup) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listUserGroup(ctx context.Context, site string) ([]UserGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []UserGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/usergroup", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/usergroup", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -67,17 +67,17 @@ func (c *Client) listUserGroup(ctx context.Context, site string) ([]UserGroup, e
|
||||
|
||||
func (c *Client) getUserGroup(ctx context.Context, site, id string) (*UserGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []UserGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/usergroup/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/usergroup/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -85,7 +85,7 @@ func (c *Client) getUserGroup(ctx context.Context, site, id string) (*UserGroup,
|
||||
}
|
||||
|
||||
func (c *Client) deleteUserGroup(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/usergroup/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/usergroup/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -94,17 +94,17 @@ func (c *Client) deleteUserGroup(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createUserGroup(ctx context.Context, site string, d *UserGroup) (*UserGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []UserGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/usergroup", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/usergroup", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -114,17 +114,17 @@ func (c *Client) createUserGroup(ctx context.Context, site string, d *UserGroup)
|
||||
|
||||
func (c *Client) updateUserGroup(ctx context.Context, site string, d *UserGroup) (*UserGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []UserGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/usergroup/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/usergroup/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/virtual_device.generated.go
generated
24
unifi/virtual_device.generated.go
generated
@@ -51,11 +51,11 @@ func (dst *VirtualDevice) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listVirtualDevice(ctx context.Context, site string) ([]VirtualDevice, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []VirtualDevice `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/virtualdevice", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/virtualdevice", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -65,17 +65,17 @@ func (c *Client) listVirtualDevice(ctx context.Context, site string) ([]VirtualD
|
||||
|
||||
func (c *Client) getVirtualDevice(ctx context.Context, site, id string) (*VirtualDevice, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []VirtualDevice `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/virtualdevice/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/virtualdevice/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -83,7 +83,7 @@ func (c *Client) getVirtualDevice(ctx context.Context, site, id string) (*Virtua
|
||||
}
|
||||
|
||||
func (c *Client) deleteVirtualDevice(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/virtualdevice/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/virtualdevice/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -92,17 +92,17 @@ func (c *Client) deleteVirtualDevice(ctx context.Context, site, id string) error
|
||||
|
||||
func (c *Client) createVirtualDevice(ctx context.Context, site string, d *VirtualDevice) (*VirtualDevice, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []VirtualDevice `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/virtualdevice", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/virtualdevice", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -112,17 +112,17 @@ func (c *Client) createVirtualDevice(ctx context.Context, site string, d *Virtua
|
||||
|
||||
func (c *Client) updateVirtualDevice(ctx context.Context, site string, d *VirtualDevice) (*VirtualDevice, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []VirtualDevice `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/virtualdevice/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/virtualdevice/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/wlan.generated.go
generated
24
unifi/wlan.generated.go
generated
@@ -468,11 +468,11 @@ func (dst *WLANVenueName) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listWLAN(ctx context.Context, site string) ([]WLAN, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []WLAN `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/wlanconf", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/wlanconf", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -482,17 +482,17 @@ func (c *Client) listWLAN(ctx context.Context, site string) ([]WLAN, error) {
|
||||
|
||||
func (c *Client) getWLAN(ctx context.Context, site, id string) (*WLAN, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []WLAN `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/wlanconf/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/wlanconf/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -500,7 +500,7 @@ func (c *Client) getWLAN(ctx context.Context, site, id string) (*WLAN, error) {
|
||||
}
|
||||
|
||||
func (c *Client) deleteWLAN(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/wlanconf/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/wlanconf/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -509,17 +509,17 @@ func (c *Client) deleteWLAN(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createWLAN(ctx context.Context, site string, d *WLAN) (*WLAN, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []WLAN `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/wlanconf", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/wlanconf", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -529,17 +529,17 @@ func (c *Client) createWLAN(ctx context.Context, site string, d *WLAN) (*WLAN, e
|
||||
|
||||
func (c *Client) updateWLAN(ctx context.Context, site string, d *WLAN) (*WLAN, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []WLAN `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/wlanconf/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/wlanconf/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
24
unifi/wlan_group.generated.go
generated
24
unifi/wlan_group.generated.go
generated
@@ -46,11 +46,11 @@ func (dst *WLANGroup) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listWLANGroup(ctx context.Context, site string) ([]WLANGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []WLANGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/wlangroup", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/wlangroup", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -60,17 +60,17 @@ func (c *Client) listWLANGroup(ctx context.Context, site string) ([]WLANGroup, e
|
||||
|
||||
func (c *Client) getWLANGroup(ctx context.Context, site, id string) (*WLANGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []WLANGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/wlangroup/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/rest/wlangroup/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -78,7 +78,7 @@ func (c *Client) getWLANGroup(ctx context.Context, site, id string) (*WLANGroup,
|
||||
}
|
||||
|
||||
func (c *Client) deleteWLANGroup(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/wlangroup/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/wlangroup/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -87,17 +87,17 @@ func (c *Client) deleteWLANGroup(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createWLANGroup(ctx context.Context, site string, d *WLANGroup) (*WLANGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []WLANGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/wlangroup", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/wlangroup", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -107,17 +107,17 @@ func (c *Client) createWLANGroup(ctx context.Context, site string, d *WLANGroup)
|
||||
|
||||
func (c *Client) updateWLANGroup(ctx context.Context, site string, d *WLANGroup) (*WLANGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []WLANGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/wlangroup/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/wlangroup/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
Reference in New Issue
Block a user