Set d.Key for all settings updates
This commit is contained in:
@@ -153,6 +153,7 @@ func (c *Client) update{{ .StructName }}(ctx context.Context, site string, d *{{
|
||||
Data []{{ .StructName }} `json:"data"`
|
||||
}
|
||||
{{ if .IsSetting }}
|
||||
d.Key = "{{ .ResourcePath }}"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/{{ .ResourcePath }}", site), d, &respBody)
|
||||
{{- else }}
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/{{ .ResourcePath }}/%s", site, d.ID), d, &respBody)
|
||||
|
||||
126
unifi/ap_group.generated.go
Normal file
126
unifi/ap_group.generated.go
Normal file
@@ -0,0 +1,126 @@
|
||||
// Code generated from ace.jar fields *.json files
|
||||
// DO NOT EDIT.
|
||||
|
||||
package unifi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// just to fix compile issues with the import
|
||||
var (
|
||||
_ context.Context
|
||||
_ fmt.Formatter
|
||||
_ json.Marshaler
|
||||
)
|
||||
|
||||
type APGroup struct {
|
||||
ID string `json:"_id,omitempty"`
|
||||
SiteID string `json:"site_id,omitempty"`
|
||||
|
||||
Hidden bool `json:"attr_hidden,omitempty"`
|
||||
HiddenID string `json:"attr_hidden_id,omitempty"`
|
||||
NoDelete bool `json:"attr_no_delete,omitempty"`
|
||||
NoEdit bool `json:"attr_no_edit,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty"` // .{1,128}
|
||||
}
|
||||
|
||||
func (dst *APGroup) UnmarshalJSON(b []byte) error {
|
||||
type Alias APGroup
|
||||
aux := &struct {
|
||||
*Alias
|
||||
}{
|
||||
Alias: (*Alias)(dst),
|
||||
}
|
||||
|
||||
err := json.Unmarshal(b, &aux)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to unmarshal alias: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) listAPGroup(ctx context.Context, site string) ([]APGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Data []APGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/apgroups", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return respBody.Data, nil
|
||||
}
|
||||
|
||||
func (c *Client) getAPGroup(ctx context.Context, site, id string) (*APGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Data []APGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/apgroups/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
return &d, nil
|
||||
}
|
||||
|
||||
func (c *Client) deleteAPGroup(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/apgroups/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) createAPGroup(ctx context.Context, site string, d *APGroup) (*APGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Data []APGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/apgroups", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
return &new, nil
|
||||
}
|
||||
|
||||
func (c *Client) updateAPGroup(ctx context.Context, site string, d *APGroup) (*APGroup, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Data []APGroup `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/apgroups/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
return &new, nil
|
||||
}
|
||||
@@ -75,6 +75,7 @@ func (c *Client) updateSettingAutoSpeedtest(ctx context.Context, site string, d
|
||||
Data []SettingAutoSpeedtest `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "auto_speedtest"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/auto_speedtest", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -74,6 +74,7 @@ func (c *Client) updateSettingBaresip(ctx context.Context, site string, d *Setti
|
||||
Data []SettingBaresip `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "baresip"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/baresip", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -76,6 +76,7 @@ func (c *Client) updateSettingBroadcast(ctx context.Context, site string, d *Set
|
||||
Data []SettingBroadcast `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "broadcast"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/broadcast", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -76,6 +76,7 @@ func (c *Client) updateSettingConnectivity(ctx context.Context, site string, d *
|
||||
Data []SettingConnectivity `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "connectivity"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/connectivity", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -74,6 +74,7 @@ func (c *Client) updateSettingCountry(ctx context.Context, site string, d *Setti
|
||||
Data []SettingCountry `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "country"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/country", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -72,6 +72,7 @@ func (c *Client) updateSettingDpi(ctx context.Context, site string, d *SettingDp
|
||||
Data []SettingDpi `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "dpi"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/dpi", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -73,6 +73,7 @@ func (c *Client) updateSettingElementAdopt(ctx context.Context, site string, d *
|
||||
Data []SettingElementAdopt `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "element_adopt"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/element_adopt", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -168,6 +168,7 @@ func (c *Client) updateSettingGuestAccess(ctx context.Context, site string, d *S
|
||||
Data []SettingGuestAccess `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "guest_access"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/guest_access", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -225,6 +225,7 @@ func (c *Client) updateSettingIps(ctx context.Context, site string, d *SettingIp
|
||||
Data []SettingIps `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "ips"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/ips", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -80,6 +80,7 @@ func (c *Client) updateSettingLcm(ctx context.Context, site string, d *SettingLc
|
||||
Data []SettingLcm `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "lcm"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/lcm", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -71,6 +71,7 @@ func (c *Client) updateSettingLocale(ctx context.Context, site string, d *Settin
|
||||
Data []SettingLocale `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "locale"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/locale", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -87,6 +87,7 @@ func (c *Client) updateSettingMgmt(ctx context.Context, site string, d *SettingM
|
||||
Data []SettingMgmt `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "mgmt"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/mgmt", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -71,6 +71,7 @@ func (c *Client) updateSettingNetworkOptimization(ctx context.Context, site stri
|
||||
Data []SettingNetworkOptimization `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "network_optimization"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/network_optimization", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -74,6 +74,7 @@ func (c *Client) updateSettingNtp(ctx context.Context, site string, d *SettingNt
|
||||
Data []SettingNtp `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "ntp"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/ntp", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -71,6 +71,7 @@ func (c *Client) updateSettingPorta(ctx context.Context, site string, d *Setting
|
||||
Data []SettingPorta `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "porta"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/porta", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -78,6 +78,7 @@ func (c *Client) updateSettingProviderCapabilities(ctx context.Context, site str
|
||||
Data []SettingProviderCapabilities `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "provider_capabilities"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/provider_capabilities", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -102,6 +102,7 @@ func (c *Client) updateSettingRadioAi(ctx context.Context, site string, d *Setti
|
||||
Data []SettingRadioAi `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "radio_ai"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/radio_ai", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -85,6 +85,7 @@ func (c *Client) updateSettingRadius(ctx context.Context, site string, d *Settin
|
||||
Data []SettingRadius `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "radius"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/radius", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -84,6 +84,7 @@ func (c *Client) updateSettingRsyslogd(ctx context.Context, site string, d *Sett
|
||||
Data []SettingRsyslogd `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "rsyslogd"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/rsyslogd", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -75,6 +75,7 @@ func (c *Client) updateSettingSnmp(ctx context.Context, site string, d *SettingS
|
||||
Data []SettingSnmp `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "snmp"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/snmp", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -77,6 +77,7 @@ func (c *Client) updateSettingSuperCloudaccess(ctx context.Context, site string,
|
||||
Data []SettingSuperCloudaccess `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "super_cloudaccess"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/super_cloudaccess", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -71,6 +71,7 @@ func (c *Client) updateSettingSuperEvents(ctx context.Context, site string, d *S
|
||||
Data []SettingSuperEvents `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "super_events"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/super_events", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -73,6 +73,7 @@ func (c *Client) updateSettingSuperFwupdate(ctx context.Context, site string, d
|
||||
Data []SettingSuperFwupdate `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "super_fwupdate"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/super_fwupdate", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -72,6 +72,7 @@ func (c *Client) updateSettingSuperIdentity(ctx context.Context, site string, d
|
||||
Data []SettingSuperIdentity `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "super_identity"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/super_identity", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -71,6 +71,7 @@ func (c *Client) updateSettingSuperMail(ctx context.Context, site string, d *Set
|
||||
Data []SettingSuperMail `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "super_mail"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/super_mail", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -67,7 +67,6 @@ type SettingSuperMgmt struct {
|
||||
LiveUpdates string `json:"live_updates,omitempty"` // disabled|live|auto
|
||||
MinimumUsableHdSpace int `json:"minimum_usable_hd_space,omitempty"`
|
||||
MinimumUsableSdSpace int `json:"minimum_usable_sd_space,omitempty"`
|
||||
MultipleSitesEnabled bool `json:"multiple_sites_enabled"`
|
||||
OverrideInformHost bool `json:"override_inform_host"`
|
||||
StoreEnabled string `json:"store_enabled,omitempty"` // disabled|super-only|everyone
|
||||
TimeSeriesPerClientStatsEnabled bool `json:"time_series_per_client_stats_enabled"`
|
||||
@@ -135,6 +134,7 @@ func (c *Client) updateSettingSuperMgmt(ctx context.Context, site string, d *Set
|
||||
Data []SettingSuperMgmt `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "super_mgmt"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/super_mgmt", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -80,6 +80,7 @@ func (c *Client) updateSettingSuperSdn(ctx context.Context, site string, d *Sett
|
||||
Data []SettingSuperSdn `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "super_sdn"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/super_sdn", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -82,6 +82,7 @@ func (c *Client) updateSettingSuperSmtp(ctx context.Context, site string, d *Set
|
||||
Data []SettingSuperSmtp `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "super_smtp"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/super_smtp", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -160,6 +160,7 @@ func (c *Client) updateSettingUsg(ctx context.Context, site string, d *SettingUs
|
||||
Data []SettingUsg `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "usg"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/usg", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -71,6 +71,7 @@ func (c *Client) updateSettingUsw(ctx context.Context, site string, d *SettingUs
|
||||
Data []SettingUsw `json:"data"`
|
||||
}
|
||||
|
||||
d.Key = "usw"
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/set/setting/usw", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user