feat(experimental): add support for reading and updating all settings (#25)

This commit is contained in:
Mateusz Filipowicz
2025-02-18 07:43:04 +01:00
committed by GitHub
parent 0e2736fa54
commit 7b35725921
47 changed files with 871 additions and 1211 deletions

View File

@@ -35,6 +35,10 @@ var (
_ json.Marshaler _ json.Marshaler
) )
{{ if .IsSetting }}
const {{ .StructName }}Key = "{{ .ResourcePath }}"
{{- end }}
{{ range $k, $v := .Types }} {{ range $k, $v := .Types }}
type {{ $k }} struct { type {{ $k }} struct {
{{ range $fk, $fv := $v.Fields }}{{ if not $fv }} {{ range $fk, $fv := $v.Fields }}{{ if not $fv }}
@@ -80,16 +84,26 @@ func (c *client) list{{ .StructName }}(ctx context.Context, site string) ([]{{ .
} }
{{- end }} {{- end }}
func (c *client) get{{ .StructName }}(ctx context.Context, site{{ if not .IsSetting }}, id{{ end }} string) (*{{ .StructName }}, error) { {{ if .IsSetting }}
// Update {{ .StructName }} Experimental! This function is not yet stable and may change in the future.
func (c *client) Get{{ .StructName }}(ctx context.Context, site string) (*{{ .StructName }}, error) {
s, f, err := c.GetSetting(ctx, site, {{ .StructName }}Key)
if err != nil {
return nil, err
}
if s.Key != {{ .StructName }}Key {
return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", {{ .StructName }}Key, s.Key)
}
return f.(*{{ .StructName }}), nil
}
{{- else }}
func (c *client) get{{ .StructName }}(ctx context.Context, site, id string) (*{{ .StructName }}, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []{{ .StructName }} `json:"data"` Data []{{ .StructName }} `json:"data"`
} }
{{ if .IsSetting }}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/{{ .ResourcePath }}", site), nil, &respBody)
{{- else }}
err := c.Get(ctx, fmt.Sprintf("s/%s/{{ if eq .StructName "Device" }}stat{{ else }}rest{{ end }}/{{ .ResourcePath }}/%s", site, id), nil, &respBody) err := c.Get(ctx, fmt.Sprintf("s/%s/{{ if eq .StructName "Device" }}stat{{ else }}rest{{ end }}/{{ .ResourcePath }}/%s", site, id), nil, &respBody)
{{- end }}
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -101,6 +115,7 @@ func (c *client) get{{ .StructName }}(ctx context.Context, site{{ if not .IsSett
d := respBody.Data[0] d := respBody.Data[0]
return &d, nil return &d, nil
} }
{{- end }}
{{ if not .IsSetting }} {{ if not .IsSetting }}
func (c *client) delete{{ .StructName }}(ctx context.Context, site, id string) error { func (c *client) delete{{ .StructName }}(ctx context.Context, site, id string) error {
@@ -132,17 +147,25 @@ func (c *client) create{{ .StructName }}(ctx context.Context, site string, d *{{
} }
{{- end }} {{- end }}
{{ if .IsSetting }}
// Update {{ .StructName }} Experimental! This function is not yet stable and may change in the future.
func (c *client) Update{{ .StructName }}(ctx context.Context, site string, s *{{ .StructName}}) (*{{ .StructName }}, error) {
result, err := c.SetSetting(ctx, site, {{ .StructName }}Key, s)
if err != nil {
return nil, err
}
return result.(*{{ .StructName }}), nil
}
{{- else }}
func (c *client) update{{ .StructName }}(ctx context.Context, site string, d *{{ .StructName }}) (*{{ .StructName }}, error) { func (c *client) update{{ .StructName }}(ctx context.Context, site string, d *{{ .StructName }}) (*{{ .StructName }}, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []{{ .StructName }} `json:"data"` Data []{{ .StructName }} `json:"data"`
} }
{{ if .IsSetting }}
d.Key = "{{ .ResourcePath }}"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/{{ .ResourcePath }}", site), d, &respBody)
{{- else }}
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/{{ .ResourcePath }}/%s", site, d.ID), d, &respBody) err := c.Put(ctx, fmt.Sprintf("s/%s/rest/{{ .ResourcePath }}/%s", site, d.ID), d, &respBody)
{{- end }}
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -155,3 +178,4 @@ func (c *client) update{{ .StructName }}(ctx context.Context, site string, d *{{
return &new, nil return &new, nil
} }
{{- end }}

View File

@@ -12,7 +12,6 @@ customizations:
- "Map" - "Map"
- "MediaFile" - "MediaFile"
- "ScheduleTask" - "ScheduleTask"
- "Setting*" # Exclude all resources that start with "Setting"
- "SpatialRecord" - "SpatialRecord"
- "Tag" - "Tag"
- "VirtualDevice" - "VirtualDevice"

View File

@@ -273,6 +273,326 @@ type Client interface {
GetSetting(ctx context.Context, site string, key string) (*Setting, interface{}, error) GetSetting(ctx context.Context, site string, key string) (*Setting, interface{}, error)
// ==== client methods for SettingAutoSpeedtest resource ====
// GetSettingAutoSpeedtest retrieves the settings for a resource
GetSettingAutoSpeedtest(ctx context.Context, site string) (*SettingAutoSpeedtest, error)
// UpdateSettingAutoSpeedtest updates a resource
UpdateSettingAutoSpeedtest(ctx context.Context, site string, s *SettingAutoSpeedtest) (*SettingAutoSpeedtest, error)
// ==== client methods for SettingBaresip resource ====
// GetSettingBaresip retrieves the settings for a resource
GetSettingBaresip(ctx context.Context, site string) (*SettingBaresip, error)
// UpdateSettingBaresip updates a resource
UpdateSettingBaresip(ctx context.Context, site string, s *SettingBaresip) (*SettingBaresip, error)
// ==== client methods for SettingBroadcast resource ====
// GetSettingBroadcast retrieves the settings for a resource
GetSettingBroadcast(ctx context.Context, site string) (*SettingBroadcast, error)
// UpdateSettingBroadcast updates a resource
UpdateSettingBroadcast(ctx context.Context, site string, s *SettingBroadcast) (*SettingBroadcast, error)
// ==== client methods for SettingConnectivity resource ====
// GetSettingConnectivity retrieves the settings for a resource
GetSettingConnectivity(ctx context.Context, site string) (*SettingConnectivity, error)
// UpdateSettingConnectivity updates a resource
UpdateSettingConnectivity(ctx context.Context, site string, s *SettingConnectivity) (*SettingConnectivity, error)
// ==== client methods for SettingCountry resource ====
// GetSettingCountry retrieves the settings for a resource
GetSettingCountry(ctx context.Context, site string) (*SettingCountry, error)
// UpdateSettingCountry updates a resource
UpdateSettingCountry(ctx context.Context, site string, s *SettingCountry) (*SettingCountry, error)
// ==== client methods for SettingDashboard resource ====
// GetSettingDashboard retrieves the settings for a resource
GetSettingDashboard(ctx context.Context, site string) (*SettingDashboard, error)
// UpdateSettingDashboard updates a resource
UpdateSettingDashboard(ctx context.Context, site string, s *SettingDashboard) (*SettingDashboard, error)
// ==== client methods for SettingDoh resource ====
// GetSettingDoh retrieves the settings for a resource
GetSettingDoh(ctx context.Context, site string) (*SettingDoh, error)
// UpdateSettingDoh updates a resource
UpdateSettingDoh(ctx context.Context, site string, s *SettingDoh) (*SettingDoh, error)
// ==== client methods for SettingDpi resource ====
// GetSettingDpi retrieves the settings for a resource
GetSettingDpi(ctx context.Context, site string) (*SettingDpi, error)
// UpdateSettingDpi updates a resource
UpdateSettingDpi(ctx context.Context, site string, s *SettingDpi) (*SettingDpi, error)
// ==== client methods for SettingElementAdopt resource ====
// GetSettingElementAdopt retrieves the settings for a resource
GetSettingElementAdopt(ctx context.Context, site string) (*SettingElementAdopt, error)
// UpdateSettingElementAdopt updates a resource
UpdateSettingElementAdopt(ctx context.Context, site string, s *SettingElementAdopt) (*SettingElementAdopt, error)
// ==== client methods for SettingEtherLighting resource ====
// GetSettingEtherLighting retrieves the settings for a resource
GetSettingEtherLighting(ctx context.Context, site string) (*SettingEtherLighting, error)
// UpdateSettingEtherLighting updates a resource
UpdateSettingEtherLighting(ctx context.Context, site string, s *SettingEtherLighting) (*SettingEtherLighting, error)
// ==== client methods for SettingEvaluationScore resource ====
// GetSettingEvaluationScore retrieves the settings for a resource
GetSettingEvaluationScore(ctx context.Context, site string) (*SettingEvaluationScore, error)
// UpdateSettingEvaluationScore updates a resource
UpdateSettingEvaluationScore(ctx context.Context, site string, s *SettingEvaluationScore) (*SettingEvaluationScore, error)
// ==== client methods for SettingGlobalAp resource ====
// GetSettingGlobalAp retrieves the settings for a resource
GetSettingGlobalAp(ctx context.Context, site string) (*SettingGlobalAp, error)
// UpdateSettingGlobalAp updates a resource
UpdateSettingGlobalAp(ctx context.Context, site string, s *SettingGlobalAp) (*SettingGlobalAp, error)
// ==== client methods for SettingGlobalNat resource ====
// GetSettingGlobalNat retrieves the settings for a resource
GetSettingGlobalNat(ctx context.Context, site string) (*SettingGlobalNat, error)
// UpdateSettingGlobalNat updates a resource
UpdateSettingGlobalNat(ctx context.Context, site string, s *SettingGlobalNat) (*SettingGlobalNat, error)
// ==== client methods for SettingGlobalSwitch resource ====
// GetSettingGlobalSwitch retrieves the settings for a resource
GetSettingGlobalSwitch(ctx context.Context, site string) (*SettingGlobalSwitch, error)
// UpdateSettingGlobalSwitch updates a resource
UpdateSettingGlobalSwitch(ctx context.Context, site string, s *SettingGlobalSwitch) (*SettingGlobalSwitch, error)
// ==== client methods for SettingGuestAccess resource ====
// GetSettingGuestAccess retrieves the settings for a resource
GetSettingGuestAccess(ctx context.Context, site string) (*SettingGuestAccess, error)
// UpdateSettingGuestAccess updates a resource
UpdateSettingGuestAccess(ctx context.Context, site string, s *SettingGuestAccess) (*SettingGuestAccess, error)
// ==== client methods for SettingIps resource ====
// GetSettingIps retrieves the settings for a resource
GetSettingIps(ctx context.Context, site string) (*SettingIps, error)
// UpdateSettingIps updates a resource
UpdateSettingIps(ctx context.Context, site string, s *SettingIps) (*SettingIps, error)
// ==== client methods for SettingLcm resource ====
// GetSettingLcm retrieves the settings for a resource
GetSettingLcm(ctx context.Context, site string) (*SettingLcm, error)
// UpdateSettingLcm updates a resource
UpdateSettingLcm(ctx context.Context, site string, s *SettingLcm) (*SettingLcm, error)
// ==== client methods for SettingLocale resource ====
// GetSettingLocale retrieves the settings for a resource
GetSettingLocale(ctx context.Context, site string) (*SettingLocale, error)
// UpdateSettingLocale updates a resource
UpdateSettingLocale(ctx context.Context, site string, s *SettingLocale) (*SettingLocale, error)
// ==== client methods for SettingMagicSiteToSiteVpn resource ====
// GetSettingMagicSiteToSiteVpn retrieves the settings for a resource
GetSettingMagicSiteToSiteVpn(ctx context.Context, site string) (*SettingMagicSiteToSiteVpn, error)
// UpdateSettingMagicSiteToSiteVpn updates a resource
UpdateSettingMagicSiteToSiteVpn(ctx context.Context, site string, s *SettingMagicSiteToSiteVpn) (*SettingMagicSiteToSiteVpn, error)
// ==== client methods for SettingMgmt resource ====
// GetSettingMgmt retrieves the settings for a resource
GetSettingMgmt(ctx context.Context, site string) (*SettingMgmt, error)
// UpdateSettingMgmt updates a resource
UpdateSettingMgmt(ctx context.Context, site string, s *SettingMgmt) (*SettingMgmt, error)
// ==== client methods for SettingNetflow resource ====
// GetSettingNetflow retrieves the settings for a resource
GetSettingNetflow(ctx context.Context, site string) (*SettingNetflow, error)
// UpdateSettingNetflow updates a resource
UpdateSettingNetflow(ctx context.Context, site string, s *SettingNetflow) (*SettingNetflow, error)
// ==== client methods for SettingNetworkOptimization resource ====
// GetSettingNetworkOptimization retrieves the settings for a resource
GetSettingNetworkOptimization(ctx context.Context, site string) (*SettingNetworkOptimization, error)
// UpdateSettingNetworkOptimization updates a resource
UpdateSettingNetworkOptimization(ctx context.Context, site string, s *SettingNetworkOptimization) (*SettingNetworkOptimization, error)
// ==== client methods for SettingNtp resource ====
// GetSettingNtp retrieves the settings for a resource
GetSettingNtp(ctx context.Context, site string) (*SettingNtp, error)
// UpdateSettingNtp updates a resource
UpdateSettingNtp(ctx context.Context, site string, s *SettingNtp) (*SettingNtp, error)
// ==== client methods for SettingPorta resource ====
// GetSettingPorta retrieves the settings for a resource
GetSettingPorta(ctx context.Context, site string) (*SettingPorta, error)
// UpdateSettingPorta updates a resource
UpdateSettingPorta(ctx context.Context, site string, s *SettingPorta) (*SettingPorta, error)
// ==== client methods for SettingRadioAi resource ====
// GetSettingRadioAi retrieves the settings for a resource
GetSettingRadioAi(ctx context.Context, site string) (*SettingRadioAi, error)
// UpdateSettingRadioAi updates a resource
UpdateSettingRadioAi(ctx context.Context, site string, s *SettingRadioAi) (*SettingRadioAi, error)
// ==== client methods for SettingRadius resource ====
// GetSettingRadius retrieves the settings for a resource
GetSettingRadius(ctx context.Context, site string) (*SettingRadius, error)
// UpdateSettingRadius updates a resource
UpdateSettingRadius(ctx context.Context, site string, s *SettingRadius) (*SettingRadius, error)
// ==== client methods for SettingRsyslogd resource ====
// GetSettingRsyslogd retrieves the settings for a resource
GetSettingRsyslogd(ctx context.Context, site string) (*SettingRsyslogd, error)
// UpdateSettingRsyslogd updates a resource
UpdateSettingRsyslogd(ctx context.Context, site string, s *SettingRsyslogd) (*SettingRsyslogd, error)
// ==== client methods for SettingSnmp resource ====
// GetSettingSnmp retrieves the settings for a resource
GetSettingSnmp(ctx context.Context, site string) (*SettingSnmp, error)
// UpdateSettingSnmp updates a resource
UpdateSettingSnmp(ctx context.Context, site string, s *SettingSnmp) (*SettingSnmp, error)
// ==== client methods for SettingSslInspection resource ====
// GetSettingSslInspection retrieves the settings for a resource
GetSettingSslInspection(ctx context.Context, site string) (*SettingSslInspection, error)
// UpdateSettingSslInspection updates a resource
UpdateSettingSslInspection(ctx context.Context, site string, s *SettingSslInspection) (*SettingSslInspection, error)
// ==== client methods for SettingSuperCloudaccess resource ====
// GetSettingSuperCloudaccess retrieves the settings for a resource
GetSettingSuperCloudaccess(ctx context.Context, site string) (*SettingSuperCloudaccess, error)
// UpdateSettingSuperCloudaccess updates a resource
UpdateSettingSuperCloudaccess(ctx context.Context, site string, s *SettingSuperCloudaccess) (*SettingSuperCloudaccess, error)
// ==== client methods for SettingSuperEvents resource ====
// GetSettingSuperEvents retrieves the settings for a resource
GetSettingSuperEvents(ctx context.Context, site string) (*SettingSuperEvents, error)
// UpdateSettingSuperEvents updates a resource
UpdateSettingSuperEvents(ctx context.Context, site string, s *SettingSuperEvents) (*SettingSuperEvents, error)
// ==== client methods for SettingSuperFwupdate resource ====
// GetSettingSuperFwupdate retrieves the settings for a resource
GetSettingSuperFwupdate(ctx context.Context, site string) (*SettingSuperFwupdate, error)
// UpdateSettingSuperFwupdate updates a resource
UpdateSettingSuperFwupdate(ctx context.Context, site string, s *SettingSuperFwupdate) (*SettingSuperFwupdate, error)
// ==== client methods for SettingSuperIdentity resource ====
// GetSettingSuperIdentity retrieves the settings for a resource
GetSettingSuperIdentity(ctx context.Context, site string) (*SettingSuperIdentity, error)
// UpdateSettingSuperIdentity updates a resource
UpdateSettingSuperIdentity(ctx context.Context, site string, s *SettingSuperIdentity) (*SettingSuperIdentity, error)
// ==== client methods for SettingSuperMail resource ====
// GetSettingSuperMail retrieves the settings for a resource
GetSettingSuperMail(ctx context.Context, site string) (*SettingSuperMail, error)
// UpdateSettingSuperMail updates a resource
UpdateSettingSuperMail(ctx context.Context, site string, s *SettingSuperMail) (*SettingSuperMail, error)
// ==== client methods for SettingSuperMgmt resource ====
// GetSettingSuperMgmt retrieves the settings for a resource
GetSettingSuperMgmt(ctx context.Context, site string) (*SettingSuperMgmt, error)
// UpdateSettingSuperMgmt updates a resource
UpdateSettingSuperMgmt(ctx context.Context, site string, s *SettingSuperMgmt) (*SettingSuperMgmt, error)
// ==== client methods for SettingSuperSdn resource ====
// GetSettingSuperSdn retrieves the settings for a resource
GetSettingSuperSdn(ctx context.Context, site string) (*SettingSuperSdn, error)
// UpdateSettingSuperSdn updates a resource
UpdateSettingSuperSdn(ctx context.Context, site string, s *SettingSuperSdn) (*SettingSuperSdn, error)
// ==== client methods for SettingSuperSmtp resource ====
// GetSettingSuperSmtp retrieves the settings for a resource
GetSettingSuperSmtp(ctx context.Context, site string) (*SettingSuperSmtp, error)
// UpdateSettingSuperSmtp updates a resource
UpdateSettingSuperSmtp(ctx context.Context, site string, s *SettingSuperSmtp) (*SettingSuperSmtp, error)
// ==== client methods for SettingTeleport resource ====
// GetSettingTeleport retrieves the settings for a resource
GetSettingTeleport(ctx context.Context, site string) (*SettingTeleport, error)
// UpdateSettingTeleport updates a resource
UpdateSettingTeleport(ctx context.Context, site string, s *SettingTeleport) (*SettingTeleport, error)
// ==== client methods for SettingUsg resource ====
// GetSettingUsg retrieves the settings for a resource
GetSettingUsg(ctx context.Context, site string) (*SettingUsg, error)
// UpdateSettingUsg updates a resource
UpdateSettingUsg(ctx context.Context, site string, s *SettingUsg) (*SettingUsg, error)
// ==== client methods for SettingUsw resource ====
// GetSettingUsw retrieves the settings for a resource
GetSettingUsw(ctx context.Context, site string) (*SettingUsw, error)
// UpdateSettingUsw updates a resource
UpdateSettingUsw(ctx context.Context, site string, s *SettingUsw) (*SettingUsw, error)
CreateSite(ctx context.Context, description string) ([]Site, error) CreateSite(ctx context.Context, description string) ([]Site, error)
DeleteSite(ctx context.Context, id string) ([]Site, error) DeleteSite(ctx context.Context, id string) ([]Site, error)

View File

@@ -77,6 +77,43 @@ func (s *Setting) newFields() (interface{}, error) {
return nil, fmt.Errorf("unexpected key %q", s.Key) return nil, fmt.Errorf("unexpected key %q", s.Key)
} }
func (c *client) SetSetting(ctx context.Context, site, key string, reqBody interface{}) (interface{}, error) {
var respBody struct {
Meta Meta `json:"meta"`
Data []json.RawMessage `json:"data"`
}
err := c.Post(ctx, fmt.Sprintf("s/%s/set/setting/%s", site, key), reqBody, respBody)
if err != nil {
return nil, err
}
var raw json.RawMessage
var setting *Setting
for _, d := range respBody.Data {
err = json.Unmarshal(d, &setting)
if err != nil {
return nil, err
}
if setting.Key == key {
raw = d
break
}
}
if setting == nil {
return nil, ErrNotFound
}
fields, err := setting.newFields()
if err != nil {
return nil, err
}
err = json.Unmarshal(raw, &fields)
if err != nil {
return nil, err
}
return fields, nil
}
func (c *client) GetSetting(ctx context.Context, site, key string) (*Setting, interface{}, error) { func (c *client) GetSetting(ctx context.Context, site, key string) (*Setting, interface{}, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"Meta"` Meta Meta `json:"Meta"`

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingAutoSpeedtestKey = "auto_speedtest"
type SettingAutoSpeedtest struct { type SettingAutoSpeedtest struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -47,42 +49,23 @@ func (dst *SettingAutoSpeedtest) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingAutoSpeedtest(ctx context.Context, site string) (*SettingAutoSpeedtest, error) { // Update SettingAutoSpeedtest Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingAutoSpeedtest(ctx context.Context, site string) (*SettingAutoSpeedtest, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingAutoSpeedtestKey)
Data []SettingAutoSpeedtest `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/auto_speedtest", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingAutoSpeedtestKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingAutoSpeedtestKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingAutoSpeedtest), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingAutoSpeedtest(ctx context.Context, site string, d *SettingAutoSpeedtest) (*SettingAutoSpeedtest, error) { // Update SettingAutoSpeedtest Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingAutoSpeedtest(ctx context.Context, site string, s *SettingAutoSpeedtest) (*SettingAutoSpeedtest, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingAutoSpeedtestKey, s)
Data []SettingAutoSpeedtest `json:"data"`
}
d.Key = "auto_speedtest"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/auto_speedtest", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingAutoSpeedtest), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingBaresipKey = "baresip"
type SettingBaresip struct { type SettingBaresip struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -49,42 +51,23 @@ func (dst *SettingBaresip) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingBaresip(ctx context.Context, site string) (*SettingBaresip, error) { // Update SettingBaresip Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingBaresip(ctx context.Context, site string) (*SettingBaresip, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingBaresipKey)
Data []SettingBaresip `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/baresip", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingBaresipKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingBaresipKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingBaresip), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingBaresip(ctx context.Context, site string, d *SettingBaresip) (*SettingBaresip, error) { // Update SettingBaresip Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingBaresip(ctx context.Context, site string, s *SettingBaresip) (*SettingBaresip, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingBaresipKey, s)
Data []SettingBaresip `json:"data"`
}
d.Key = "baresip"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/baresip", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingBaresip), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingBroadcastKey = "broadcast"
type SettingBroadcast struct { type SettingBroadcast struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -51,42 +53,23 @@ func (dst *SettingBroadcast) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingBroadcast(ctx context.Context, site string) (*SettingBroadcast, error) { // Update SettingBroadcast Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingBroadcast(ctx context.Context, site string) (*SettingBroadcast, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingBroadcastKey)
Data []SettingBroadcast `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/broadcast", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingBroadcastKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingBroadcastKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingBroadcast), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingBroadcast(ctx context.Context, site string, d *SettingBroadcast) (*SettingBroadcast, error) { // Update SettingBroadcast Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingBroadcast(ctx context.Context, site string, s *SettingBroadcast) (*SettingBroadcast, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingBroadcastKey, s)
Data []SettingBroadcast `json:"data"`
}
d.Key = "broadcast"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/broadcast", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingBroadcast), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingConnectivityKey = "connectivity"
type SettingConnectivity struct { type SettingConnectivity struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -51,42 +53,23 @@ func (dst *SettingConnectivity) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingConnectivity(ctx context.Context, site string) (*SettingConnectivity, error) { // Update SettingConnectivity Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingConnectivity(ctx context.Context, site string) (*SettingConnectivity, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingConnectivityKey)
Data []SettingConnectivity `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/connectivity", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingConnectivityKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingConnectivityKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingConnectivity), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingConnectivity(ctx context.Context, site string, d *SettingConnectivity) (*SettingConnectivity, error) { // Update SettingConnectivity Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingConnectivity(ctx context.Context, site string, s *SettingConnectivity) (*SettingConnectivity, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingConnectivityKey, s)
Data []SettingConnectivity `json:"data"`
}
d.Key = "connectivity"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/connectivity", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingConnectivity), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingCountryKey = "country"
type SettingCountry struct { type SettingCountry struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -49,42 +51,23 @@ func (dst *SettingCountry) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingCountry(ctx context.Context, site string) (*SettingCountry, error) { // Update SettingCountry Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingCountry(ctx context.Context, site string) (*SettingCountry, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingCountryKey)
Data []SettingCountry `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/country", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingCountryKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingCountryKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingCountry), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingCountry(ctx context.Context, site string, d *SettingCountry) (*SettingCountry, error) { // Update SettingCountry Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingCountry(ctx context.Context, site string, s *SettingCountry) (*SettingCountry, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingCountryKey, s)
Data []SettingCountry `json:"data"`
}
d.Key = "country"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/country", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingCountry), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingDashboardKey = "dashboard"
type SettingDashboard struct { type SettingDashboard struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -68,42 +70,23 @@ func (dst *SettingDashboardWidgets) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingDashboard(ctx context.Context, site string) (*SettingDashboard, error) { // Update SettingDashboard Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingDashboard(ctx context.Context, site string) (*SettingDashboard, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingDashboardKey)
Data []SettingDashboard `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/dashboard", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingDashboardKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingDashboardKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingDashboard), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingDashboard(ctx context.Context, site string, d *SettingDashboard) (*SettingDashboard, error) { // Update SettingDashboard Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingDashboard(ctx context.Context, site string, s *SettingDashboard) (*SettingDashboard, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingDashboardKey, s)
Data []SettingDashboard `json:"data"`
}
d.Key = "dashboard"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/dashboard", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingDashboard), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingDohKey = "doh"
type SettingDoh struct { type SettingDoh struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -70,42 +72,23 @@ func (dst *SettingDohCustomServers) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingDoh(ctx context.Context, site string) (*SettingDoh, error) { // Update SettingDoh Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingDoh(ctx context.Context, site string) (*SettingDoh, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingDohKey)
Data []SettingDoh `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/doh", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingDohKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingDohKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingDoh), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingDoh(ctx context.Context, site string, d *SettingDoh) (*SettingDoh, error) { // Update SettingDoh Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingDoh(ctx context.Context, site string, s *SettingDoh) (*SettingDoh, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingDohKey, s)
Data []SettingDoh `json:"data"`
}
d.Key = "doh"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/doh", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingDoh), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingDpiKey = "dpi"
type SettingDpi struct { type SettingDpi struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -47,42 +49,23 @@ func (dst *SettingDpi) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingDpi(ctx context.Context, site string) (*SettingDpi, error) { // Update SettingDpi Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingDpi(ctx context.Context, site string) (*SettingDpi, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingDpiKey)
Data []SettingDpi `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/dpi", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingDpiKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingDpiKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingDpi), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingDpi(ctx context.Context, site string, d *SettingDpi) (*SettingDpi, error) { // Update SettingDpi Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingDpi(ctx context.Context, site string, s *SettingDpi) (*SettingDpi, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingDpiKey, s)
Data []SettingDpi `json:"data"`
}
d.Key = "dpi"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/dpi", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingDpi), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingElementAdoptKey = "element_adopt"
type SettingElementAdopt struct { type SettingElementAdopt struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -48,42 +50,23 @@ func (dst *SettingElementAdopt) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingElementAdopt(ctx context.Context, site string) (*SettingElementAdopt, error) { // Update SettingElementAdopt Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingElementAdopt(ctx context.Context, site string) (*SettingElementAdopt, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingElementAdoptKey)
Data []SettingElementAdopt `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/element_adopt", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingElementAdoptKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingElementAdoptKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingElementAdopt), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingElementAdopt(ctx context.Context, site string, d *SettingElementAdopt) (*SettingElementAdopt, error) { // Update SettingElementAdopt Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingElementAdopt(ctx context.Context, site string, s *SettingElementAdopt) (*SettingElementAdopt, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingElementAdoptKey, s)
Data []SettingElementAdopt `json:"data"`
}
d.Key = "element_adopt"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/element_adopt", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingElementAdopt), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingEtherLightingKey = "ether_lighting"
type SettingEtherLighting struct { type SettingEtherLighting struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -89,42 +91,23 @@ func (dst *SettingEtherLightingSpeedOverrides) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingEtherLighting(ctx context.Context, site string) (*SettingEtherLighting, error) { // Update SettingEtherLighting Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingEtherLighting(ctx context.Context, site string) (*SettingEtherLighting, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingEtherLightingKey)
Data []SettingEtherLighting `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/ether_lighting", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingEtherLightingKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingEtherLightingKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingEtherLighting), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingEtherLighting(ctx context.Context, site string, d *SettingEtherLighting) (*SettingEtherLighting, error) { // Update SettingEtherLighting Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingEtherLighting(ctx context.Context, site string, s *SettingEtherLighting) (*SettingEtherLighting, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingEtherLightingKey, s)
Data []SettingEtherLighting `json:"data"`
}
d.Key = "ether_lighting"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/ether_lighting", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingEtherLighting), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingEvaluationScoreKey = "evaluation_score"
type SettingEvaluationScore struct { type SettingEvaluationScore struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -46,42 +48,23 @@ func (dst *SettingEvaluationScore) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingEvaluationScore(ctx context.Context, site string) (*SettingEvaluationScore, error) { // Update SettingEvaluationScore Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingEvaluationScore(ctx context.Context, site string) (*SettingEvaluationScore, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingEvaluationScoreKey)
Data []SettingEvaluationScore `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/evaluation_score", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingEvaluationScoreKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingEvaluationScoreKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingEvaluationScore), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingEvaluationScore(ctx context.Context, site string, d *SettingEvaluationScore) (*SettingEvaluationScore, error) { // Update SettingEvaluationScore Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingEvaluationScore(ctx context.Context, site string, s *SettingEvaluationScore) (*SettingEvaluationScore, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingEvaluationScoreKey, s)
Data []SettingEvaluationScore `json:"data"`
}
d.Key = "evaluation_score"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/evaluation_score", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingEvaluationScore), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingGlobalApKey = "global_ap"
type SettingGlobalAp struct { type SettingGlobalAp struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -68,42 +70,23 @@ func (dst *SettingGlobalAp) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingGlobalAp(ctx context.Context, site string) (*SettingGlobalAp, error) { // Update SettingGlobalAp Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingGlobalAp(ctx context.Context, site string) (*SettingGlobalAp, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingGlobalApKey)
Data []SettingGlobalAp `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/global_ap", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingGlobalApKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingGlobalApKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingGlobalAp), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingGlobalAp(ctx context.Context, site string, d *SettingGlobalAp) (*SettingGlobalAp, error) { // Update SettingGlobalAp Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingGlobalAp(ctx context.Context, site string, s *SettingGlobalAp) (*SettingGlobalAp, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingGlobalApKey, s)
Data []SettingGlobalAp `json:"data"`
}
d.Key = "global_ap"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/global_ap", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingGlobalAp), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingGlobalNatKey = "global_nat"
type SettingGlobalNat struct { type SettingGlobalNat struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -47,42 +49,23 @@ func (dst *SettingGlobalNat) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingGlobalNat(ctx context.Context, site string) (*SettingGlobalNat, error) { // Update SettingGlobalNat Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingGlobalNat(ctx context.Context, site string) (*SettingGlobalNat, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingGlobalNatKey)
Data []SettingGlobalNat `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/global_nat", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingGlobalNatKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingGlobalNatKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingGlobalNat), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingGlobalNat(ctx context.Context, site string, d *SettingGlobalNat) (*SettingGlobalNat, error) { // Update SettingGlobalNat Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingGlobalNat(ctx context.Context, site string, s *SettingGlobalNat) (*SettingGlobalNat, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingGlobalNatKey, s)
Data []SettingGlobalNat `json:"data"`
}
d.Key = "global_nat"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/global_nat", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingGlobalNat), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingGlobalSwitchKey = "global_switch"
type SettingGlobalSwitch struct { type SettingGlobalSwitch struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -76,42 +78,23 @@ func (dst *SettingGlobalSwitchAclL3Isolation) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingGlobalSwitch(ctx context.Context, site string) (*SettingGlobalSwitch, error) { // Update SettingGlobalSwitch Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingGlobalSwitch(ctx context.Context, site string) (*SettingGlobalSwitch, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingGlobalSwitchKey)
Data []SettingGlobalSwitch `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/global_switch", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingGlobalSwitchKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingGlobalSwitchKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingGlobalSwitch), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingGlobalSwitch(ctx context.Context, site string, d *SettingGlobalSwitch) (*SettingGlobalSwitch, error) { // Update SettingGlobalSwitch Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingGlobalSwitch(ctx context.Context, site string, s *SettingGlobalSwitch) (*SettingGlobalSwitch, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingGlobalSwitchKey, s)
Data []SettingGlobalSwitch `json:"data"`
}
d.Key = "global_switch"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/global_switch", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingGlobalSwitch), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingGuestAccessKey = "guest_access"
type SettingGuestAccess struct { type SettingGuestAccess struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -155,42 +157,23 @@ func (dst *SettingGuestAccess) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingGuestAccess(ctx context.Context, site string) (*SettingGuestAccess, error) { // Update SettingGuestAccess Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingGuestAccess(ctx context.Context, site string) (*SettingGuestAccess, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingGuestAccessKey)
Data []SettingGuestAccess `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/guest_access", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingGuestAccessKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingGuestAccessKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingGuestAccess), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingGuestAccess(ctx context.Context, site string, d *SettingGuestAccess) (*SettingGuestAccess, error) { // Update SettingGuestAccess Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingGuestAccess(ctx context.Context, site string, s *SettingGuestAccess) (*SettingGuestAccess, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingGuestAccessKey, s)
Data []SettingGuestAccess `json:"data"`
}
d.Key = "guest_access"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/guest_access", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingGuestAccess), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingIpsKey = "ips"
type SettingIps struct { type SettingIps struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -222,42 +224,23 @@ func (dst *SettingIpsWhitelist) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingIps(ctx context.Context, site string) (*SettingIps, error) { // Update SettingIps Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingIps(ctx context.Context, site string) (*SettingIps, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingIpsKey)
Data []SettingIps `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/ips", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingIpsKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingIpsKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingIps), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingIps(ctx context.Context, site string, d *SettingIps) (*SettingIps, error) { // Update SettingIps Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingIps(ctx context.Context, site string, s *SettingIps) (*SettingIps, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingIpsKey, s)
Data []SettingIps `json:"data"`
}
d.Key = "ips"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/ips", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingIps), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingLcmKey = "lcm"
type SettingLcm struct { type SettingLcm struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -55,42 +57,23 @@ func (dst *SettingLcm) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingLcm(ctx context.Context, site string) (*SettingLcm, error) { // Update SettingLcm Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingLcm(ctx context.Context, site string) (*SettingLcm, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingLcmKey)
Data []SettingLcm `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/lcm", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingLcmKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingLcmKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingLcm), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingLcm(ctx context.Context, site string, d *SettingLcm) (*SettingLcm, error) { // Update SettingLcm Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingLcm(ctx context.Context, site string, s *SettingLcm) (*SettingLcm, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingLcmKey, s)
Data []SettingLcm `json:"data"`
}
d.Key = "lcm"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/lcm", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingLcm), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingLocaleKey = "locale"
type SettingLocale struct { type SettingLocale struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -46,42 +48,23 @@ func (dst *SettingLocale) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingLocale(ctx context.Context, site string) (*SettingLocale, error) { // Update SettingLocale Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingLocale(ctx context.Context, site string) (*SettingLocale, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingLocaleKey)
Data []SettingLocale `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/locale", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingLocaleKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingLocaleKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingLocale), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingLocale(ctx context.Context, site string, d *SettingLocale) (*SettingLocale, error) { // Update SettingLocale Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingLocale(ctx context.Context, site string, s *SettingLocale) (*SettingLocale, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingLocaleKey, s)
Data []SettingLocale `json:"data"`
}
d.Key = "locale"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/locale", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingLocale), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingMagicSiteToSiteVpnKey = "magic_site_to_site_vpn"
type SettingMagicSiteToSiteVpn struct { type SettingMagicSiteToSiteVpn struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -46,42 +48,23 @@ func (dst *SettingMagicSiteToSiteVpn) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingMagicSiteToSiteVpn(ctx context.Context, site string) (*SettingMagicSiteToSiteVpn, error) { // Update SettingMagicSiteToSiteVpn Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingMagicSiteToSiteVpn(ctx context.Context, site string) (*SettingMagicSiteToSiteVpn, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingMagicSiteToSiteVpnKey)
Data []SettingMagicSiteToSiteVpn `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/magic_site_to_site_vpn", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingMagicSiteToSiteVpnKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingMagicSiteToSiteVpnKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingMagicSiteToSiteVpn), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingMagicSiteToSiteVpn(ctx context.Context, site string, d *SettingMagicSiteToSiteVpn) (*SettingMagicSiteToSiteVpn, error) { // Update SettingMagicSiteToSiteVpn Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingMagicSiteToSiteVpn(ctx context.Context, site string, s *SettingMagicSiteToSiteVpn) (*SettingMagicSiteToSiteVpn, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingMagicSiteToSiteVpnKey, s)
Data []SettingMagicSiteToSiteVpn `json:"data"`
}
d.Key = "magic_site_to_site_vpn"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/magic_site_to_site_vpn", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingMagicSiteToSiteVpn), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingMgmtKey = "mgmt"
type SettingMgmt struct { type SettingMgmt struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -93,42 +95,23 @@ func (dst *SettingMgmtXSshKeys) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingMgmt(ctx context.Context, site string) (*SettingMgmt, error) { // Update SettingMgmt Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingMgmt(ctx context.Context, site string) (*SettingMgmt, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingMgmtKey)
Data []SettingMgmt `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/mgmt", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingMgmtKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingMgmtKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingMgmt), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingMgmt(ctx context.Context, site string, d *SettingMgmt) (*SettingMgmt, error) { // Update SettingMgmt Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingMgmt(ctx context.Context, site string, s *SettingMgmt) (*SettingMgmt, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingMgmtKey, s)
Data []SettingMgmt `json:"data"`
}
d.Key = "mgmt"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/mgmt", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingMgmt), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -1,14 +0,0 @@
package unifi
import (
"context"
)
func (c *client) GetSettingMgmt(ctx context.Context, site string) (*SettingMgmt, error) {
return c.getSettingMgmt(ctx, site)
}
func (c *client) UpdateSettingMgmt(ctx context.Context, site string, d *SettingMgmt) (*SettingMgmt, error) {
d.Key = "mgmt"
return c.updateSettingMgmt(ctx, site, d)
}

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingNetflowKey = "netflow"
type SettingNetflow struct { type SettingNetflow struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -69,42 +71,23 @@ func (dst *SettingNetflow) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingNetflow(ctx context.Context, site string) (*SettingNetflow, error) { // Update SettingNetflow Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingNetflow(ctx context.Context, site string) (*SettingNetflow, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingNetflowKey)
Data []SettingNetflow `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/netflow", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingNetflowKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingNetflowKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingNetflow), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingNetflow(ctx context.Context, site string, d *SettingNetflow) (*SettingNetflow, error) { // Update SettingNetflow Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingNetflow(ctx context.Context, site string, s *SettingNetflow) (*SettingNetflow, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingNetflowKey, s)
Data []SettingNetflow `json:"data"`
}
d.Key = "netflow"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/netflow", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingNetflow), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingNetworkOptimizationKey = "network_optimization"
type SettingNetworkOptimization struct { type SettingNetworkOptimization struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -46,42 +48,23 @@ func (dst *SettingNetworkOptimization) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingNetworkOptimization(ctx context.Context, site string) (*SettingNetworkOptimization, error) { // Update SettingNetworkOptimization Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingNetworkOptimization(ctx context.Context, site string) (*SettingNetworkOptimization, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingNetworkOptimizationKey)
Data []SettingNetworkOptimization `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/network_optimization", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingNetworkOptimizationKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingNetworkOptimizationKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingNetworkOptimization), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingNetworkOptimization(ctx context.Context, site string, d *SettingNetworkOptimization) (*SettingNetworkOptimization, error) { // Update SettingNetworkOptimization Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingNetworkOptimization(ctx context.Context, site string, s *SettingNetworkOptimization) (*SettingNetworkOptimization, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingNetworkOptimizationKey, s)
Data []SettingNetworkOptimization `json:"data"`
}
d.Key = "network_optimization"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/network_optimization", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingNetworkOptimization), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingNtpKey = "ntp"
type SettingNtp struct { type SettingNtp struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -50,42 +52,23 @@ func (dst *SettingNtp) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingNtp(ctx context.Context, site string) (*SettingNtp, error) { // Update SettingNtp Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingNtp(ctx context.Context, site string) (*SettingNtp, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingNtpKey)
Data []SettingNtp `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/ntp", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingNtpKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingNtpKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingNtp), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingNtp(ctx context.Context, site string, d *SettingNtp) (*SettingNtp, error) { // Update SettingNtp Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingNtp(ctx context.Context, site string, s *SettingNtp) (*SettingNtp, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingNtpKey, s)
Data []SettingNtp `json:"data"`
}
d.Key = "ntp"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/ntp", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingNtp), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingPortaKey = "porta"
type SettingPorta struct { type SettingPorta struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -46,42 +48,23 @@ func (dst *SettingPorta) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingPorta(ctx context.Context, site string) (*SettingPorta, error) { // Update SettingPorta Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingPorta(ctx context.Context, site string) (*SettingPorta, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingPortaKey)
Data []SettingPorta `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/porta", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingPortaKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingPortaKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingPorta), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingPorta(ctx context.Context, site string, d *SettingPorta) (*SettingPorta, error) { // Update SettingPorta Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingPorta(ctx context.Context, site string, s *SettingPorta) (*SettingPorta, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingPortaKey, s)
Data []SettingPorta `json:"data"`
}
d.Key = "porta"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/porta", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingPorta), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingRadioAiKey = "radio_ai"
type SettingRadioAi struct { type SettingRadioAi struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -113,42 +115,23 @@ func (dst *SettingRadioAiChannelsBlacklist) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingRadioAi(ctx context.Context, site string) (*SettingRadioAi, error) { // Update SettingRadioAi Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingRadioAi(ctx context.Context, site string) (*SettingRadioAi, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingRadioAiKey)
Data []SettingRadioAi `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/radio_ai", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingRadioAiKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingRadioAiKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingRadioAi), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingRadioAi(ctx context.Context, site string, d *SettingRadioAi) (*SettingRadioAi, error) { // Update SettingRadioAi Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingRadioAi(ctx context.Context, site string, s *SettingRadioAi) (*SettingRadioAi, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingRadioAiKey, s)
Data []SettingRadioAi `json:"data"`
}
d.Key = "radio_ai"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/radio_ai", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingRadioAi), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingRadiusKey = "radius"
type SettingRadius struct { type SettingRadius struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -60,42 +62,23 @@ func (dst *SettingRadius) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingRadius(ctx context.Context, site string) (*SettingRadius, error) { // Update SettingRadius Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingRadius(ctx context.Context, site string) (*SettingRadius, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingRadiusKey)
Data []SettingRadius `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/radius", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingRadiusKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingRadiusKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingRadius), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingRadius(ctx context.Context, site string, d *SettingRadius) (*SettingRadius, error) { // Update SettingRadius Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingRadius(ctx context.Context, site string, s *SettingRadius) (*SettingRadius, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingRadiusKey, s)
Data []SettingRadius `json:"data"`
}
d.Key = "radius"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/radius", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingRadius), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -1,13 +0,0 @@
package unifi
import (
"context"
)
func (c *client) GetSettingRadius(ctx context.Context, site string) (*SettingRadius, error) {
return c.getSettingRadius(ctx, site)
}
func (c *client) UpdateSettingRadius(ctx context.Context, site string, d *SettingRadius) (*SettingRadius, error) {
return c.updateSettingRadius(ctx, site, d)
}

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingRsyslogdKey = "rsyslogd"
type SettingRsyslogd struct { type SettingRsyslogd struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -61,42 +63,23 @@ func (dst *SettingRsyslogd) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingRsyslogd(ctx context.Context, site string) (*SettingRsyslogd, error) { // Update SettingRsyslogd Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingRsyslogd(ctx context.Context, site string) (*SettingRsyslogd, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingRsyslogdKey)
Data []SettingRsyslogd `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/rsyslogd", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingRsyslogdKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingRsyslogdKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingRsyslogd), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingRsyslogd(ctx context.Context, site string, d *SettingRsyslogd) (*SettingRsyslogd, error) { // Update SettingRsyslogd Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingRsyslogd(ctx context.Context, site string, s *SettingRsyslogd) (*SettingRsyslogd, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingRsyslogdKey, s)
Data []SettingRsyslogd `json:"data"`
}
d.Key = "rsyslogd"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/rsyslogd", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingRsyslogd), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingSnmpKey = "snmp"
type SettingSnmp struct { type SettingSnmp struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -50,42 +52,23 @@ func (dst *SettingSnmp) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingSnmp(ctx context.Context, site string) (*SettingSnmp, error) { // Update SettingSnmp Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingSnmp(ctx context.Context, site string) (*SettingSnmp, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingSnmpKey)
Data []SettingSnmp `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/snmp", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingSnmpKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingSnmpKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingSnmp), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingSnmp(ctx context.Context, site string, d *SettingSnmp) (*SettingSnmp, error) { // Update SettingSnmp Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingSnmp(ctx context.Context, site string, s *SettingSnmp) (*SettingSnmp, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingSnmpKey, s)
Data []SettingSnmp `json:"data"`
}
d.Key = "snmp"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/snmp", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingSnmp), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingSslInspectionKey = "ssl_inspection"
type SettingSslInspection struct { type SettingSslInspection struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -46,42 +48,23 @@ func (dst *SettingSslInspection) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingSslInspection(ctx context.Context, site string) (*SettingSslInspection, error) { // Update SettingSslInspection Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingSslInspection(ctx context.Context, site string) (*SettingSslInspection, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingSslInspectionKey)
Data []SettingSslInspection `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/ssl_inspection", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingSslInspectionKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingSslInspectionKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingSslInspection), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingSslInspection(ctx context.Context, site string, d *SettingSslInspection) (*SettingSslInspection, error) { // Update SettingSslInspection Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingSslInspection(ctx context.Context, site string, s *SettingSslInspection) (*SettingSslInspection, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingSslInspectionKey, s)
Data []SettingSslInspection `json:"data"`
}
d.Key = "ssl_inspection"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/ssl_inspection", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingSslInspection), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingSuperCloudaccessKey = "super_cloudaccess"
type SettingSuperCloudaccess struct { type SettingSuperCloudaccess struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -52,42 +54,23 @@ func (dst *SettingSuperCloudaccess) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingSuperCloudaccess(ctx context.Context, site string) (*SettingSuperCloudaccess, error) { // Update SettingSuperCloudaccess Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingSuperCloudaccess(ctx context.Context, site string) (*SettingSuperCloudaccess, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingSuperCloudaccessKey)
Data []SettingSuperCloudaccess `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/super_cloudaccess", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingSuperCloudaccessKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingSuperCloudaccessKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingSuperCloudaccess), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingSuperCloudaccess(ctx context.Context, site string, d *SettingSuperCloudaccess) (*SettingSuperCloudaccess, error) { // Update SettingSuperCloudaccess Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingSuperCloudaccess(ctx context.Context, site string, s *SettingSuperCloudaccess) (*SettingSuperCloudaccess, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingSuperCloudaccessKey, s)
Data []SettingSuperCloudaccess `json:"data"`
}
d.Key = "super_cloudaccess"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/super_cloudaccess", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingSuperCloudaccess), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingSuperEventsKey = "super_events"
type SettingSuperEvents struct { type SettingSuperEvents struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -46,42 +48,23 @@ func (dst *SettingSuperEvents) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingSuperEvents(ctx context.Context, site string) (*SettingSuperEvents, error) { // Update SettingSuperEvents Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingSuperEvents(ctx context.Context, site string) (*SettingSuperEvents, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingSuperEventsKey)
Data []SettingSuperEvents `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/super_events", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingSuperEventsKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingSuperEventsKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingSuperEvents), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingSuperEvents(ctx context.Context, site string, d *SettingSuperEvents) (*SettingSuperEvents, error) { // Update SettingSuperEvents Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingSuperEvents(ctx context.Context, site string, s *SettingSuperEvents) (*SettingSuperEvents, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingSuperEventsKey, s)
Data []SettingSuperEvents `json:"data"`
}
d.Key = "super_events"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/super_events", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingSuperEvents), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingSuperFwupdateKey = "super_fwupdate"
type SettingSuperFwupdate struct { type SettingSuperFwupdate struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -48,42 +50,23 @@ func (dst *SettingSuperFwupdate) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingSuperFwupdate(ctx context.Context, site string) (*SettingSuperFwupdate, error) { // Update SettingSuperFwupdate Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingSuperFwupdate(ctx context.Context, site string) (*SettingSuperFwupdate, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingSuperFwupdateKey)
Data []SettingSuperFwupdate `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/super_fwupdate", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingSuperFwupdateKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingSuperFwupdateKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingSuperFwupdate), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingSuperFwupdate(ctx context.Context, site string, d *SettingSuperFwupdate) (*SettingSuperFwupdate, error) { // Update SettingSuperFwupdate Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingSuperFwupdate(ctx context.Context, site string, s *SettingSuperFwupdate) (*SettingSuperFwupdate, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingSuperFwupdateKey, s)
Data []SettingSuperFwupdate `json:"data"`
}
d.Key = "super_fwupdate"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/super_fwupdate", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingSuperFwupdate), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingSuperIdentityKey = "super_identity"
type SettingSuperIdentity struct { type SettingSuperIdentity struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -47,42 +49,23 @@ func (dst *SettingSuperIdentity) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingSuperIdentity(ctx context.Context, site string) (*SettingSuperIdentity, error) { // Update SettingSuperIdentity Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingSuperIdentity(ctx context.Context, site string) (*SettingSuperIdentity, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingSuperIdentityKey)
Data []SettingSuperIdentity `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/super_identity", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingSuperIdentityKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingSuperIdentityKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingSuperIdentity), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingSuperIdentity(ctx context.Context, site string, d *SettingSuperIdentity) (*SettingSuperIdentity, error) { // Update SettingSuperIdentity Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingSuperIdentity(ctx context.Context, site string, s *SettingSuperIdentity) (*SettingSuperIdentity, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingSuperIdentityKey, s)
Data []SettingSuperIdentity `json:"data"`
}
d.Key = "super_identity"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/super_identity", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingSuperIdentity), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingSuperMailKey = "super_mail"
type SettingSuperMail struct { type SettingSuperMail struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -46,42 +48,23 @@ func (dst *SettingSuperMail) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingSuperMail(ctx context.Context, site string) (*SettingSuperMail, error) { // Update SettingSuperMail Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingSuperMail(ctx context.Context, site string) (*SettingSuperMail, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingSuperMailKey)
Data []SettingSuperMail `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/super_mail", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingSuperMailKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingSuperMailKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingSuperMail), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingSuperMail(ctx context.Context, site string, d *SettingSuperMail) (*SettingSuperMail, error) { // Update SettingSuperMail Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingSuperMail(ctx context.Context, site string, s *SettingSuperMail) (*SettingSuperMail, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingSuperMailKey, s)
Data []SettingSuperMail `json:"data"`
}
d.Key = "super_mail"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/super_mail", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingSuperMail), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingSuperMgmtKey = "super_mgmt"
type SettingSuperMgmt struct { type SettingSuperMgmt struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -111,42 +113,23 @@ func (dst *SettingSuperMgmt) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingSuperMgmt(ctx context.Context, site string) (*SettingSuperMgmt, error) { // Update SettingSuperMgmt Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingSuperMgmt(ctx context.Context, site string) (*SettingSuperMgmt, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingSuperMgmtKey)
Data []SettingSuperMgmt `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/super_mgmt", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingSuperMgmtKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingSuperMgmtKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingSuperMgmt), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingSuperMgmt(ctx context.Context, site string, d *SettingSuperMgmt) (*SettingSuperMgmt, error) { // Update SettingSuperMgmt Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingSuperMgmt(ctx context.Context, site string, s *SettingSuperMgmt) (*SettingSuperMgmt, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingSuperMgmtKey, s)
Data []SettingSuperMgmt `json:"data"`
}
d.Key = "super_mgmt"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/super_mgmt", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingSuperMgmt), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingSuperSdnKey = "super_sdn"
type SettingSuperSdn struct { type SettingSuperSdn struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -51,42 +53,23 @@ func (dst *SettingSuperSdn) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingSuperSdn(ctx context.Context, site string) (*SettingSuperSdn, error) { // Update SettingSuperSdn Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingSuperSdn(ctx context.Context, site string) (*SettingSuperSdn, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingSuperSdnKey)
Data []SettingSuperSdn `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/super_sdn", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingSuperSdnKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingSuperSdnKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingSuperSdn), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingSuperSdn(ctx context.Context, site string, d *SettingSuperSdn) (*SettingSuperSdn, error) { // Update SettingSuperSdn Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingSuperSdn(ctx context.Context, site string, s *SettingSuperSdn) (*SettingSuperSdn, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingSuperSdnKey, s)
Data []SettingSuperSdn `json:"data"`
}
d.Key = "super_sdn"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/super_sdn", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingSuperSdn), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingSuperSmtpKey = "super_smtp"
type SettingSuperSmtp struct { type SettingSuperSmtp struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -57,42 +59,23 @@ func (dst *SettingSuperSmtp) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingSuperSmtp(ctx context.Context, site string) (*SettingSuperSmtp, error) { // Update SettingSuperSmtp Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingSuperSmtp(ctx context.Context, site string) (*SettingSuperSmtp, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingSuperSmtpKey)
Data []SettingSuperSmtp `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/super_smtp", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingSuperSmtpKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingSuperSmtpKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingSuperSmtp), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingSuperSmtp(ctx context.Context, site string, d *SettingSuperSmtp) (*SettingSuperSmtp, error) { // Update SettingSuperSmtp Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingSuperSmtp(ctx context.Context, site string, s *SettingSuperSmtp) (*SettingSuperSmtp, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingSuperSmtpKey, s)
Data []SettingSuperSmtp `json:"data"`
}
d.Key = "super_smtp"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/super_smtp", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingSuperSmtp), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingTeleportKey = "teleport"
type SettingTeleport struct { type SettingTeleport struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -47,42 +49,23 @@ func (dst *SettingTeleport) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingTeleport(ctx context.Context, site string) (*SettingTeleport, error) { // Update SettingTeleport Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingTeleport(ctx context.Context, site string) (*SettingTeleport, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingTeleportKey)
Data []SettingTeleport `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/teleport", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingTeleportKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingTeleportKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingTeleport), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingTeleport(ctx context.Context, site string, d *SettingTeleport) (*SettingTeleport, error) { // Update SettingTeleport Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingTeleport(ctx context.Context, site string, s *SettingTeleport) (*SettingTeleport, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingTeleportKey, s)
Data []SettingTeleport `json:"data"`
}
d.Key = "teleport"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/teleport", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingTeleport), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingUsgKey = "usg"
type SettingUsg struct { type SettingUsg struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -158,42 +160,23 @@ func (dst *SettingUsgDNSVerification) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingUsg(ctx context.Context, site string) (*SettingUsg, error) { // Update SettingUsg Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingUsg(ctx context.Context, site string) (*SettingUsg, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingUsgKey)
Data []SettingUsg `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/usg", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingUsgKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingUsgKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingUsg), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingUsg(ctx context.Context, site string, d *SettingUsg) (*SettingUsg, error) { // Update SettingUsg Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingUsg(ctx context.Context, site string, s *SettingUsg) (*SettingUsg, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingUsgKey, s)
Data []SettingUsg `json:"data"`
}
d.Key = "usg"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/usg", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingUsg), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }

View File

@@ -1,13 +0,0 @@
package unifi
import (
"context"
)
func (c *client) GetSettingUsg(ctx context.Context, site string) (*SettingUsg, error) {
return c.getSettingUsg(ctx, site)
}
func (c *client) UpdateSettingUsg(ctx context.Context, site string, d *SettingUsg) (*SettingUsg, error) {
return c.updateSettingUsg(ctx, site, d)
}

View File

@@ -16,6 +16,8 @@ var (
_ json.Marshaler _ json.Marshaler
) )
const SettingUswKey = "usw"
type SettingUsw struct { type SettingUsw struct {
ID string `json:"_id,omitempty"` ID string `json:"_id,omitempty"`
SiteID string `json:"site_id,omitempty"` SiteID string `json:"site_id,omitempty"`
@@ -46,42 +48,23 @@ func (dst *SettingUsw) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *client) getSettingUsw(ctx context.Context, site string) (*SettingUsw, error) { // Update SettingUsw Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) GetSettingUsw(ctx context.Context, site string) (*SettingUsw, error) {
Meta Meta `json:"meta"` s, f, err := c.GetSetting(ctx, site, SettingUswKey)
Data []SettingUsw `json:"data"`
}
err := c.Get(ctx, fmt.Sprintf("s/%s/get/setting/usw", site), nil, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.Key != SettingUswKey {
if len(respBody.Data) != 1 { return nil, fmt.Errorf("unexpected setting key received. Requested: %q, received: %q", SettingUswKey, s.Key)
return nil, ErrNotFound
} }
return f.(*SettingUsw), nil
d := respBody.Data[0]
return &d, nil
} }
func (c *client) updateSettingUsw(ctx context.Context, site string, d *SettingUsw) (*SettingUsw, error) { // Update SettingUsw Experimental! This function is not yet stable and may change in the future.
var respBody struct { func (c *client) UpdateSettingUsw(ctx context.Context, site string, s *SettingUsw) (*SettingUsw, error) {
Meta Meta `json:"meta"` result, err := c.SetSetting(ctx, site, SettingUswKey, s)
Data []SettingUsw `json:"data"`
}
d.Key = "usw"
err := c.Put(ctx, fmt.Sprintf("s/%s/set/setting/usw", site), d, &respBody)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return result.(*SettingUsw), nil
if len(respBody.Data) != 1 {
return nil, ErrNotFound
}
new := respBody.Data[0]
return &new, nil
} }