feat: use Client interface instead of client struct when interacting with UniFi SDK (#21)

* feat: use Client interface instead of client struct when interacting with UniFi SDK

Breaking change!

* chore: linting

* chore: linting
This commit is contained in:
Mateusz Filipowicz
2025-02-17 09:38:41 +01:00
committed by GitHub
parent fadc5ada8b
commit dca894e8e7
104 changed files with 1048 additions and 419 deletions

View File

@@ -65,7 +65,7 @@ func (dst *{{ $k }}) UnmarshalJSON(b []byte) error {
{{ end }} {{ end }}
{{ if not .IsSetting }} {{ if not .IsSetting }}
func (c *Client) list{{ .StructName }}(ctx context.Context, site string) ([]{{ .StructName }}, error) { func (c *client) list{{ .StructName }}(ctx context.Context, site 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"`
@@ -80,7 +80,7 @@ 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) { func (c *client) get{{ .StructName }}(ctx context.Context, site{{ if not .IsSetting }}, id{{ end }} 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"`
@@ -103,7 +103,7 @@ func (c *Client) get{{ .StructName }}(ctx context.Context, site{{ if not .IsSett
} }
{{ 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 {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/{{ .ResourcePath }}/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/{{ .ResourcePath }}/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -111,7 +111,7 @@ func (c *Client) delete{{ .StructName }}(ctx context.Context, site, id string) e
return nil return nil
} }
func (c *Client) create{{ .StructName }}(ctx context.Context, site string, d *{{ .StructName }}) (*{{ .StructName }}, error) { func (c *client) create{{ .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"`
@@ -132,7 +132,7 @@ func (c *Client) create{{ .StructName }}(ctx context.Context, site string, d *{{
} }
{{- end }} {{- end }}
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"`

View File

@@ -143,17 +143,18 @@ func singlePointerParam(name string) []FunctionParam {
} }
func (c *ClientInfoBuilder) AddResource(r *Resource) *ClientInfoBuilder { func (c *ClientInfoBuilder) AddResource(r *Resource) *ClientInfoBuilder {
c.AddFunction(&Comment{comment: fmt.Sprintf("client methods for %s resource", r.Name()), resourceName: r.Name()}) c.AddFunction(&Comment{comment: fmt.Sprintf("==== client methods for %s resource ====", r.Name()), resourceName: r.Name()})
if r.IsSetting() { if r.IsSetting() {
c.addResourceFunction("Get", r.Name(), "retrieves the settings for a resource", nil, singlePointerReturn(r.Name())) c.addResourceFunction("Get", r.Name(), "retrieves the settings for a resource", nil, singlePointerReturn(r.Name()))
c.addResourceFunction("Update", r.Name(), "updates a resource", singlePointerParam(r.Name()), singlePointerReturn(r.Name())) c.addResourceFunction("Update", r.Name(), "updates a resource", singlePointerParam(r.Name()), singlePointerReturn(r.Name()))
return c return c
} }
c.addResourceFunction("Get", r.Name(), "retrieves a resource", []FunctionParam{{"id", "string"}}, singlePointerReturn(r.Name())) c.addResourceFunction("Get", r.Name(), "retrieves a resource", []FunctionParam{{"id", "string"}}, singlePointerReturn(r.Name()))
c.addResourceFunction("List", r.Name(), "lists the resources", nil, []string{"[]*" + r.Name()}) c.addResourceFunction("List", r.Name(), "lists the resources", nil, []string{"[]" + r.Name()})
c.addResourceFunction("Create", r.Name(), "creates a resource", singlePointerParam(r.Name()), singlePointerReturn(r.Name())) c.addResourceFunction("Create", r.Name(), "creates a resource", singlePointerParam(r.Name()), singlePointerReturn(r.Name()))
c.addResourceFunction("Update", r.Name(), "updates a resource", singlePointerParam(r.Name()), singlePointerReturn(r.Name())) c.addResourceFunction("Update", r.Name(), "updates a resource", singlePointerParam(r.Name()), singlePointerReturn(r.Name()))
c.addResourceFunction("Delete", r.Name(), "deletes a resource", []FunctionParam{{"id", "string"}}, nil) c.addResourceFunction("Delete", r.Name(), "deletes a resource", []FunctionParam{{"id", "string"}}, nil)
c.AddFunction(&Comment{comment: fmt.Sprintf("==== end of client methods for %s resource ====", r.Name()), resourceName: r.Name() + "_end"})
return c return c
} }
@@ -198,5 +199,5 @@ func (c *ClientInfo) GenerateCode() (string, error) {
// Name returns the name of the client. // Name returns the name of the client.
func (c *ClientInfo) Name() string { func (c *ClientInfo) Name() string {
return "client" return "Client"
} }

View File

@@ -2,7 +2,20 @@
customizations: customizations:
client: client:
excludeResources: excludeResources:
- "BroadcastGroup"
- "ChannelPlan"
- "Dashboard"
- "DHCPOption"
- "Dpi*"
- "HeatMap*"
- "Hotspot*"
- "Map"
- "MediaFile"
- "ScheduleTask"
- "Setting*" # Exclude all resources that start with "Setting" - "Setting*" # Exclude all resources that start with "Setting"
- "SpatialRecord"
- "Tag"
- "VirtualDevice"
functions: functions:
- name: "Login" - name: "Login"
comment: "Login logs in to the controller. Useful only for user/password authentication." comment: "Login logs in to the controller. Useful only for user/password authentication."
@@ -16,6 +29,75 @@ customizations:
comment: "BaseURL returns the base URL of the controller." comment: "BaseURL returns the base URL of the controller."
returns: returns:
- "string" - "string"
- name: "Do"
comment: "Do sends a request to the controller."
params:
- name: "ctx"
type: "context.Context"
- name: "method"
type: "string"
- name: "apiPath"
type: "string"
- name: "reqBody"
type: "interface{}"
- name: "respBody"
type: "interface{}"
returns:
- "error"
- name: "Get"
comment: "Get sends a GET request to the controller."
params:
- name: "ctx"
type: "context.Context"
- name: "apiPath"
type: "string"
- name: "reqBody"
type: "interface{}"
- name: "respBody"
type: "interface{}"
returns:
- "error"
- name: "Post"
comment: "Post sends a POST request to the controller."
params:
- name: "ctx"
type: "context.Context"
- name: "apiPath"
type: "string"
- name: "reqBody"
type: "interface{}"
- name: "respBody"
type: "interface{}"
returns:
- "error"
- name: "Put"
comment: "Put sends a PUT request to the controller."
params:
- name: "ctx"
type: "context.Context"
- name: "apiPath"
type: "string"
- name: "reqBody"
type: "interface{}"
- name: "respBody"
type: "interface{}"
returns:
- "error"
- name: "Delete"
comment: "Delete sends a DELETE request to the controller."
params:
- name: "ctx"
type: "context.Context"
- name: "apiPath"
type: "string"
- name: "reqBody"
type: "interface{}"
- name: "respBody"
type: "interface{}"
returns:
- "error"
- name: "AdoptDevice" - name: "AdoptDevice"
comment: "AdoptDevice adopts a device by MAC address." comment: "AdoptDevice adopts a device by MAC address."
resourceName: "Device" resourceName: "Device"
@@ -28,6 +110,190 @@ customizations:
type: "string" type: "string"
returns: returns:
- "error" - "error"
- name: "ForgetDevice"
comment: "ForgetDevice forgets a device by MAC address."
resourceName: "Device"
params:
- name: "ctx"
type: "context.Context"
- name: "site"
type: "string"
- name: "mac"
type: "string"
returns:
- "error"
- name: "GetDeviceByMAC"
resourceName: "Device"
params:
- name: "ctx"
type: "context.Context"
- name: "site"
type: "string"
- name: "mac"
type: "string"
returns:
- "*Device"
- "error"
- name: "ReorderFirewallRules"
resourceName: "FirewallRule"
params:
- name: "ctx"
type: "context.Context"
- name: "site"
type: "string"
- name: "ruleset"
type: "string"
- name: "reorder"
type: "[]FirewallRuleIndexUpdate"
returns:
- "error"
- name: "GetSetting"
resourceName: "Setting"
params:
- name: "ctx"
type: "context.Context"
- name: "site"
type: "string"
- name: "key"
type: "string"
returns:
- "*Setting"
- "interface{}"
- "error"
- name: "ListSites"
resourceName: "Site"
params:
- name: "ctx"
type: "context.Context"
returns:
- "[]Site"
- "error"
- name: "GetSite"
resourceName: "Site"
params:
- name: "ctx"
type: "context.Context"
- name: "id"
type: "string"
returns:
- "*Site"
- "error"
- name: "CreateSite"
resourceName: "Site"
params:
- name: "ctx"
type: "context.Context"
- name: "description"
type: "string"
returns:
- "[]Site"
- "error"
- name: "DeleteSite"
resourceName: "Site"
params:
- name: "ctx"
type: "context.Context"
- name: "id"
type: "string"
returns:
- "[]Site"
- "error"
- name: "UpdateSite"
resourceName: "Site"
params:
- name: "ctx"
type: "context.Context"
- name: "name"
type: "string"
- name: "description"
type: "string"
returns:
- "[]Site"
- "error"
- name: "GetSystemInfo"
resourceName: "SysInfo"
params:
- name: "ctx"
type: "context.Context"
- name: "id"
type: "string"
returns:
- "*SysInfo"
- "error"
- name: "GetSystemInformation"
resourceName: "SysInfo"
returns:
- "*SysInfo"
- "error"
- name: "GetUserByMAC"
resourceName: "User"
params:
- name: "ctx"
type: "context.Context"
- name: "site"
type: "string"
- name: "mac"
type: "string"
returns:
- "*User"
- "error"
- name: "BlockUserByMAC"
resourceName: "User"
params:
- name: "ctx"
type: "context.Context"
- name: "site"
type: "string"
- name: "mac"
type: "string"
returns:
- "error"
- name: "UnblockUserByMAC"
resourceName: "User"
params:
- name: "ctx"
type: "context.Context"
- name: "site"
type: "string"
- name: "mac"
type: "string"
returns:
- "error"
- name: "DeleteUserByMAC"
resourceName: "User"
params:
- name: "ctx"
type: "context.Context"
- name: "site"
type: "string"
- name: "mac"
type: "string"
returns:
- "error"
- name: "KickUserByMAC"
resourceName: "User"
params:
- name: "ctx"
type: "context.Context"
- name: "site"
type: "string"
- name: "mac"
type: "string"
returns:
- "error"
- name: "OverrideUserFingerprint"
resourceName: "User"
params:
- name: "ctx"
type: "context.Context"
- name: "site"
type: "string"
- name: "mac"
type: "string"
- name: "devIdOverride"
type: "int"
returns:
- "error"
resources: resources:
Account: Account:
fields: fields:

View File

@@ -60,7 +60,7 @@ func (dst *Account) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listAccount(ctx context.Context, site string) ([]Account, error) { func (c *client) listAccount(ctx context.Context, site string) ([]Account, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Account `json:"data"` Data []Account `json:"data"`
@@ -74,7 +74,7 @@ func (c *Client) listAccount(ctx context.Context, site string) ([]Account, error
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getAccount(ctx context.Context, site, id string) (*Account, error) { func (c *client) getAccount(ctx context.Context, site, id string) (*Account, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Account `json:"data"` Data []Account `json:"data"`
@@ -93,7 +93,7 @@ func (c *Client) getAccount(ctx context.Context, site, id string) (*Account, err
return &d, nil return &d, nil
} }
func (c *Client) deleteAccount(ctx context.Context, site, id string) error { func (c *client) deleteAccount(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/account/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/account/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -101,7 +101,7 @@ func (c *Client) deleteAccount(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createAccount(ctx context.Context, site string, d *Account) (*Account, error) { func (c *client) createAccount(ctx context.Context, site string, d *Account) (*Account, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Account `json:"data"` Data []Account `json:"data"`
@@ -121,7 +121,7 @@ func (c *Client) createAccount(ctx context.Context, site string, d *Account) (*A
return &new, nil return &new, nil
} }
func (c *Client) updateAccount(ctx context.Context, site string, d *Account) (*Account, error) { func (c *client) updateAccount(ctx context.Context, site string, d *Account) (*Account, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Account `json:"data"` Data []Account `json:"data"`

View File

@@ -25,22 +25,22 @@ func (dst *Account) MarshalJSON() ([]byte, error) {
return b, err return b, err
} }
func (c *Client) ListAccount(ctx context.Context, site string) ([]Account, error) { func (c *client) ListAccount(ctx context.Context, site string) ([]Account, error) {
return c.listAccount(ctx, site) return c.listAccount(ctx, site)
} }
func (c *Client) GetAccount(ctx context.Context, site, id string) (*Account, error) { func (c *client) GetAccount(ctx context.Context, site, id string) (*Account, error) {
return c.getAccount(ctx, site, id) return c.getAccount(ctx, site, id)
} }
func (c *Client) DeleteAccount(ctx context.Context, site, id string) error { func (c *client) DeleteAccount(ctx context.Context, site, id string) error {
return c.deleteAccount(ctx, site, id) return c.deleteAccount(ctx, site, id)
} }
func (c *Client) CreateAccount(ctx context.Context, site string, d *Account) (*Account, error) { func (c *client) CreateAccount(ctx context.Context, site string, d *Account) (*Account, error) {
return c.createAccount(ctx, site, d) return c.createAccount(ctx, site, d)
} }
func (c *Client) UpdateAccount(ctx context.Context, site string, d *Account) (*Account, error) { func (c *client) UpdateAccount(ctx context.Context, site string, d *Account) (*Account, error) {
return c.updateAccount(ctx, site, d) return c.updateAccount(ctx, site, d)
} }

View File

@@ -25,7 +25,7 @@ type APGroup struct {
DeviceMACs []string `json:"device_macs"` DeviceMACs []string `json:"device_macs"`
} }
func (c *Client) ListAPGroup(ctx context.Context, site string) ([]APGroup, error) { func (c *client) ListAPGroup(ctx context.Context, site string) ([]APGroup, error) {
var respBody []APGroup var respBody []APGroup
err := c.Get(ctx, fmt.Sprintf("%s/site/%s/apgroups", c.apiPaths.ApiV2Path, site), nil, &respBody) err := c.Get(ctx, fmt.Sprintf("%s/site/%s/apgroups", c.apiPaths.ApiV2Path, site), nil, &respBody)
@@ -36,7 +36,7 @@ func (c *Client) ListAPGroup(ctx context.Context, site string) ([]APGroup, error
return respBody, nil return respBody, nil
} }
// func (c *Client) getWLANGroup(ctx context.Context, site, id string) (*WLANGroup, error) { // func (c *client) getWLANGroup(ctx context.Context, site, id string) (*WLANGroup, error) {
// var respBody struct { // var respBody struct {
// Meta `json:"Meta"` // Meta `json:"Meta"`
// Data []WLANGroup `json:"data"` // Data []WLANGroup `json:"data"`
@@ -55,7 +55,7 @@ func (c *Client) ListAPGroup(ctx context.Context, site string) ([]APGroup, error
// return &d, nil // return &d, nil
// } // }
// func (c *Client) deleteWLANGroup(ctx context.Context, site, id string) error { // func (c *client) deleteWLANGroup(ctx context.Context, site, id string) error {
// err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/wlangroup/%s", site, id), struct{}{}, nil) // err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/wlangroup/%s", site, id), struct{}{}, nil)
// if err != nil { // if err != nil {
// return err // return err
@@ -63,7 +63,7 @@ func (c *Client) ListAPGroup(ctx context.Context, site string) ([]APGroup, error
// return nil // return nil
// } // }
func (c *Client) CreateAPGroup(ctx context.Context, site string, d *APGroup) (*APGroup, error) { func (c *client) CreateAPGroup(ctx context.Context, site string, d *APGroup) (*APGroup, error) {
var respBody APGroup var respBody APGroup
err := c.Post(ctx, fmt.Sprintf("%s/site/%s/apgroups", c.apiPaths.ApiV2Path, site), d, &respBody) err := c.Post(ctx, fmt.Sprintf("%s/site/%s/apgroups", c.apiPaths.ApiV2Path, site), d, &respBody)
@@ -74,7 +74,7 @@ func (c *Client) CreateAPGroup(ctx context.Context, site string, d *APGroup) (*A
return &respBody, nil return &respBody, nil
} }
// func (c *Client) updateWLANGroup(ctx context.Context, site string, d *WLANGroup) (*WLANGroup, error) { // func (c *client) updateWLANGroup(ctx context.Context, site string, d *WLANGroup) (*WLANGroup, error) {
// var respBody struct { // var respBody struct {
// Meta `json:"Meta"` // Meta `json:"Meta"`
// Data []WLANGroup `json:"data"` // Data []WLANGroup `json:"data"`

View File

@@ -58,11 +58,11 @@ var (
) )
// determineApiStyle checks the base URL to decide which API style to use and sets the apiPaths accordingly. // determineApiStyle checks the base URL to decide which API style to use and sets the apiPaths accordingly.
func (c *Client) determineApiStyle() error { func (c *client) determineApiStyle() error {
ctx, cancel := c.newRequestContext() ctx, cancel := c.newRequestContext()
defer cancel() defer cancel()
req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.BaseURL.String(), nil) req, err := http.NewRequestWithContext(ctx, http.MethodGet, c.baseURL.String(), nil)
if err != nil { if err != nil {
return err return err
} }

View File

@@ -45,7 +45,7 @@ func (dst *BroadcastGroup) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listBroadcastGroup(ctx context.Context, site string) ([]BroadcastGroup, error) { func (c *client) listBroadcastGroup(ctx context.Context, site string) ([]BroadcastGroup, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []BroadcastGroup `json:"data"` Data []BroadcastGroup `json:"data"`
@@ -59,7 +59,7 @@ func (c *Client) listBroadcastGroup(ctx context.Context, site string) ([]Broadca
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getBroadcastGroup(ctx context.Context, site, id string) (*BroadcastGroup, error) { func (c *client) getBroadcastGroup(ctx context.Context, site, id string) (*BroadcastGroup, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []BroadcastGroup `json:"data"` Data []BroadcastGroup `json:"data"`
@@ -78,7 +78,7 @@ func (c *Client) getBroadcastGroup(ctx context.Context, site, id string) (*Broad
return &d, nil return &d, nil
} }
func (c *Client) deleteBroadcastGroup(ctx context.Context, site, id string) error { func (c *client) deleteBroadcastGroup(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/broadcastgroup/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/broadcastgroup/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -86,7 +86,7 @@ func (c *Client) deleteBroadcastGroup(ctx context.Context, site, id string) erro
return nil return nil
} }
func (c *Client) createBroadcastGroup(ctx context.Context, site string, d *BroadcastGroup) (*BroadcastGroup, error) { func (c *client) createBroadcastGroup(ctx context.Context, site string, d *BroadcastGroup) (*BroadcastGroup, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []BroadcastGroup `json:"data"` Data []BroadcastGroup `json:"data"`
@@ -106,7 +106,7 @@ func (c *Client) createBroadcastGroup(ctx context.Context, site string, d *Broad
return &new, nil return &new, nil
} }
func (c *Client) updateBroadcastGroup(ctx context.Context, site string, d *BroadcastGroup) (*BroadcastGroup, error) { func (c *client) updateBroadcastGroup(ctx context.Context, site string, d *BroadcastGroup) (*BroadcastGroup, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []BroadcastGroup `json:"data"` Data []BroadcastGroup `json:"data"`

View File

@@ -188,7 +188,7 @@ func (dst *ChannelPlanSiteBlacklistedChannels) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listChannelPlan(ctx context.Context, site string) ([]ChannelPlan, error) { func (c *client) listChannelPlan(ctx context.Context, site string) ([]ChannelPlan, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []ChannelPlan `json:"data"` Data []ChannelPlan `json:"data"`
@@ -202,7 +202,7 @@ func (c *Client) listChannelPlan(ctx context.Context, site string) ([]ChannelPla
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getChannelPlan(ctx context.Context, site, id string) (*ChannelPlan, error) { func (c *client) getChannelPlan(ctx context.Context, site, id string) (*ChannelPlan, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []ChannelPlan `json:"data"` Data []ChannelPlan `json:"data"`
@@ -221,7 +221,7 @@ func (c *Client) getChannelPlan(ctx context.Context, site, id string) (*ChannelP
return &d, nil return &d, nil
} }
func (c *Client) deleteChannelPlan(ctx context.Context, site, id string) error { func (c *client) deleteChannelPlan(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/channelplan/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/channelplan/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -229,7 +229,7 @@ func (c *Client) deleteChannelPlan(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createChannelPlan(ctx context.Context, site string, d *ChannelPlan) (*ChannelPlan, error) { func (c *client) createChannelPlan(ctx context.Context, site string, d *ChannelPlan) (*ChannelPlan, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []ChannelPlan `json:"data"` Data []ChannelPlan `json:"data"`
@@ -249,7 +249,7 @@ func (c *Client) createChannelPlan(ctx context.Context, site string, d *ChannelP
return &new, nil return &new, nil
} }
func (c *Client) updateChannelPlan(ctx context.Context, site string, d *ChannelPlan) (*ChannelPlan, error) { func (c *client) updateChannelPlan(ctx context.Context, site string, d *ChannelPlan) (*ChannelPlan, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []ChannelPlan `json:"data"` Data []ChannelPlan `json:"data"`

340
unifi/client.generated.go generated Normal file
View File

@@ -0,0 +1,340 @@
// Code generated from ace.jar fields *.json files
// DO NOT EDIT.
package unifi
import (
"context"
)
type Client interface {
// BaseURL returns the base URL of the controller.
BaseURL() string
// Delete sends a DELETE request to the controller.
Delete(ctx context.Context, apiPath string, reqBody interface{}, respBody interface{}) error
// Do sends a request to the controller.
Do(ctx context.Context, method string, apiPath string, reqBody interface{}, respBody interface{}) error
// Get sends a GET request to the controller.
Get(ctx context.Context, apiPath string, reqBody interface{}, respBody interface{}) error
// Login logs in to the controller. Useful only for user/password authentication.
Login() error
// Logout logs out from the controller.
Logout() error
// Post sends a POST request to the controller.
Post(ctx context.Context, apiPath string, reqBody interface{}, respBody interface{}) error
// Put sends a PUT request to the controller.
Put(ctx context.Context, apiPath string, reqBody interface{}, respBody interface{}) error
// ==== client methods for Account resource ====
// CreateAccount creates a resource
CreateAccount(ctx context.Context, site string, a *Account) (*Account, error)
// DeleteAccount deletes a resource
DeleteAccount(ctx context.Context, site string, id string) error
// GetAccount retrieves a resource
GetAccount(ctx context.Context, site string, id string) (*Account, error)
// ListAccount lists the resources
ListAccount(ctx context.Context, site string) ([]Account, error)
// UpdateAccount updates a resource
UpdateAccount(ctx context.Context, site string, a *Account) (*Account, error)
// ==== end of client methods for Account resource ====
// ==== client methods for Device resource ====
// AdoptDevice adopts a device by MAC address.
AdoptDevice(ctx context.Context, site string, mac string) error
// CreateDevice creates a resource
CreateDevice(ctx context.Context, site string, d *Device) (*Device, error)
// DeleteDevice deletes a resource
DeleteDevice(ctx context.Context, site string, id string) error
// ForgetDevice forgets a device by MAC address.
ForgetDevice(ctx context.Context, site string, mac string) error
// GetDevice retrieves a resource
GetDevice(ctx context.Context, site string, id string) (*Device, error)
GetDeviceByMAC(ctx context.Context, site string, mac string) (*Device, error)
// ListDevice lists the resources
ListDevice(ctx context.Context, site string) ([]Device, error)
// UpdateDevice updates a resource
UpdateDevice(ctx context.Context, site string, d *Device) (*Device, error)
// ==== end of client methods for Device resource ====
// ==== client methods for DynamicDNS resource ====
// CreateDynamicDNS creates a resource
CreateDynamicDNS(ctx context.Context, site string, d *DynamicDNS) (*DynamicDNS, error)
// DeleteDynamicDNS deletes a resource
DeleteDynamicDNS(ctx context.Context, site string, id string) error
// GetDynamicDNS retrieves a resource
GetDynamicDNS(ctx context.Context, site string, id string) (*DynamicDNS, error)
// ListDynamicDNS lists the resources
ListDynamicDNS(ctx context.Context, site string) ([]DynamicDNS, error)
// UpdateDynamicDNS updates a resource
UpdateDynamicDNS(ctx context.Context, site string, d *DynamicDNS) (*DynamicDNS, error)
// ==== end of client methods for DynamicDNS resource ====
// ==== client methods for FirewallGroup resource ====
// CreateFirewallGroup creates a resource
CreateFirewallGroup(ctx context.Context, site string, f *FirewallGroup) (*FirewallGroup, error)
// DeleteFirewallGroup deletes a resource
DeleteFirewallGroup(ctx context.Context, site string, id string) error
// GetFirewallGroup retrieves a resource
GetFirewallGroup(ctx context.Context, site string, id string) (*FirewallGroup, error)
// ListFirewallGroup lists the resources
ListFirewallGroup(ctx context.Context, site string) ([]FirewallGroup, error)
// UpdateFirewallGroup updates a resource
UpdateFirewallGroup(ctx context.Context, site string, f *FirewallGroup) (*FirewallGroup, error)
// ==== end of client methods for FirewallGroup resource ====
// ==== client methods for FirewallRule resource ====
// CreateFirewallRule creates a resource
CreateFirewallRule(ctx context.Context, site string, f *FirewallRule) (*FirewallRule, error)
// DeleteFirewallRule deletes a resource
DeleteFirewallRule(ctx context.Context, site string, id string) error
// GetFirewallRule retrieves a resource
GetFirewallRule(ctx context.Context, site string, id string) (*FirewallRule, error)
// ListFirewallRule lists the resources
ListFirewallRule(ctx context.Context, site string) ([]FirewallRule, error)
ReorderFirewallRules(ctx context.Context, site string, ruleset string, reorder []FirewallRuleIndexUpdate) error
// UpdateFirewallRule updates a resource
UpdateFirewallRule(ctx context.Context, site string, f *FirewallRule) (*FirewallRule, error)
// ==== end of client methods for FirewallRule resource ====
// ==== client methods for Network resource ====
// CreateNetwork creates a resource
CreateNetwork(ctx context.Context, site string, n *Network) (*Network, error)
// DeleteNetwork deletes a resource
DeleteNetwork(ctx context.Context, site string, id string) error
// GetNetwork retrieves a resource
GetNetwork(ctx context.Context, site string, id string) (*Network, error)
// ListNetwork lists the resources
ListNetwork(ctx context.Context, site string) ([]Network, error)
// UpdateNetwork updates a resource
UpdateNetwork(ctx context.Context, site string, n *Network) (*Network, error)
// ==== end of client methods for Network resource ====
// ==== client methods for PortForward resource ====
// CreatePortForward creates a resource
CreatePortForward(ctx context.Context, site string, p *PortForward) (*PortForward, error)
// DeletePortForward deletes a resource
DeletePortForward(ctx context.Context, site string, id string) error
// GetPortForward retrieves a resource
GetPortForward(ctx context.Context, site string, id string) (*PortForward, error)
// ListPortForward lists the resources
ListPortForward(ctx context.Context, site string) ([]PortForward, error)
// UpdatePortForward updates a resource
UpdatePortForward(ctx context.Context, site string, p *PortForward) (*PortForward, error)
// ==== end of client methods for PortForward resource ====
// ==== client methods for PortProfile resource ====
// CreatePortProfile creates a resource
CreatePortProfile(ctx context.Context, site string, p *PortProfile) (*PortProfile, error)
// DeletePortProfile deletes a resource
DeletePortProfile(ctx context.Context, site string, id string) error
// GetPortProfile retrieves a resource
GetPortProfile(ctx context.Context, site string, id string) (*PortProfile, error)
// ListPortProfile lists the resources
ListPortProfile(ctx context.Context, site string) ([]PortProfile, error)
// UpdatePortProfile updates a resource
UpdatePortProfile(ctx context.Context, site string, p *PortProfile) (*PortProfile, error)
// ==== end of client methods for PortProfile resource ====
// ==== client methods for RADIUSProfile resource ====
// CreateRADIUSProfile creates a resource
CreateRADIUSProfile(ctx context.Context, site string, r *RADIUSProfile) (*RADIUSProfile, error)
// DeleteRADIUSProfile deletes a resource
DeleteRADIUSProfile(ctx context.Context, site string, id string) error
// GetRADIUSProfile retrieves a resource
GetRADIUSProfile(ctx context.Context, site string, id string) (*RADIUSProfile, error)
// ListRADIUSProfile lists the resources
ListRADIUSProfile(ctx context.Context, site string) ([]RADIUSProfile, error)
// UpdateRADIUSProfile updates a resource
UpdateRADIUSProfile(ctx context.Context, site string, r *RADIUSProfile) (*RADIUSProfile, error)
// ==== end of client methods for RADIUSProfile resource ====
// ==== client methods for Routing resource ====
// CreateRouting creates a resource
CreateRouting(ctx context.Context, site string, r *Routing) (*Routing, error)
// DeleteRouting deletes a resource
DeleteRouting(ctx context.Context, site string, id string) error
// GetRouting retrieves a resource
GetRouting(ctx context.Context, site string, id string) (*Routing, error)
// ListRouting lists the resources
ListRouting(ctx context.Context, site string) ([]Routing, error)
// UpdateRouting updates a resource
UpdateRouting(ctx context.Context, site string, r *Routing) (*Routing, error)
// ==== end of client methods for Routing resource ====
GetSetting(ctx context.Context, site string, key string) (*Setting, interface{}, error)
CreateSite(ctx context.Context, description string) ([]Site, error)
DeleteSite(ctx context.Context, id string) ([]Site, error)
GetSite(ctx context.Context, id string) (*Site, error)
ListSites(ctx context.Context) ([]Site, error)
UpdateSite(ctx context.Context, name string, description string) ([]Site, error)
GetSystemInfo(ctx context.Context, id string) (*SysInfo, error)
GetSystemInformation() (*SysInfo, error)
// ==== client methods for User resource ====
BlockUserByMAC(ctx context.Context, site string, mac string) error
// CreateUser creates a resource
CreateUser(ctx context.Context, site string, u *User) (*User, error)
// DeleteUser deletes a resource
DeleteUser(ctx context.Context, site string, id string) error
DeleteUserByMAC(ctx context.Context, site string, mac string) error
// GetUser retrieves a resource
GetUser(ctx context.Context, site string, id string) (*User, error)
GetUserByMAC(ctx context.Context, site string, mac string) (*User, error)
KickUserByMAC(ctx context.Context, site string, mac string) error
// ListUser lists the resources
ListUser(ctx context.Context, site string) ([]User, error)
OverrideUserFingerprint(ctx context.Context, site string, mac string, devIdOverride int) error
UnblockUserByMAC(ctx context.Context, site string, mac string) error
// UpdateUser updates a resource
UpdateUser(ctx context.Context, site string, u *User) (*User, error)
// ==== client methods for UserGroup resource ====
// CreateUserGroup creates a resource
CreateUserGroup(ctx context.Context, site string, u *UserGroup) (*UserGroup, error)
// DeleteUserGroup deletes a resource
DeleteUserGroup(ctx context.Context, site string, id string) error
// GetUserGroup retrieves a resource
GetUserGroup(ctx context.Context, site string, id string) (*UserGroup, error)
// ListUserGroup lists the resources
ListUserGroup(ctx context.Context, site string) ([]UserGroup, error)
// UpdateUserGroup updates a resource
UpdateUserGroup(ctx context.Context, site string, u *UserGroup) (*UserGroup, error)
// ==== end of client methods for UserGroup resource ====
// ==== end of client methods for User resource ====
// ==== client methods for WLAN resource ====
// CreateWLAN creates a resource
CreateWLAN(ctx context.Context, site string, w *WLAN) (*WLAN, error)
// DeleteWLAN deletes a resource
DeleteWLAN(ctx context.Context, site string, id string) error
// GetWLAN retrieves a resource
GetWLAN(ctx context.Context, site string, id string) (*WLAN, error)
// ListWLAN lists the resources
ListWLAN(ctx context.Context, site string) ([]WLAN, error)
// UpdateWLAN updates a resource
UpdateWLAN(ctx context.Context, site string, w *WLAN) (*WLAN, error)
// ==== client methods for WLANGroup resource ====
// CreateWLANGroup creates a resource
CreateWLANGroup(ctx context.Context, site string, w *WLANGroup) (*WLANGroup, error)
// DeleteWLANGroup deletes a resource
DeleteWLANGroup(ctx context.Context, site string, id string) error
// GetWLANGroup retrieves a resource
GetWLANGroup(ctx context.Context, site string, id string) (*WLANGroup, error)
// ListWLANGroup lists the resources
ListWLANGroup(ctx context.Context, site string) ([]WLANGroup, error)
// UpdateWLANGroup updates a resource
UpdateWLANGroup(ctx context.Context, site string, w *WLANGroup) (*WLANGroup, error)
// ==== end of client methods for WLANGroup resource ====
// ==== end of client methods for WLAN resource ====
}

View File

@@ -42,7 +42,7 @@ type ResponseErrorHandler interface {
} }
/* /*
ClientConfig holds configuration parameters for creating a UniFi Client. ClientConfig holds configuration parameters for creating a UniFi client.
Fields: Fields:
@@ -108,10 +108,10 @@ func (u UserPassCredentials) GetAPIKey() string { return "" }
func (u UserPassCredentials) GetUser() string { return u.User } func (u UserPassCredentials) GetUser() string { return u.User }
func (u UserPassCredentials) GetPass() string { return u.Pass } func (u UserPassCredentials) GetPass() string { return u.Pass }
// Client represents a UniFi client. // client represents a UniFi client.
type Client struct { type client struct {
BaseURL *url.URL baseURL *url.URL
SysInfo *SysInfo sysInfo *SysInfo
apiPaths *APIPaths apiPaths *APIPaths
timeout time.Duration timeout time.Duration
credentials Credentials credentials Credentials
@@ -125,9 +125,15 @@ type Client struct {
validator *validator validator *validator
} }
var _ Client = &client{} // Ensure that client implements the Client interface. (compile-time check)
func (c *client) BaseURL() string {
return c.baseURL.String()
}
// AddInterceptor adds a ClientInterceptor to the client's interceptor list if it is not already present. // AddInterceptor adds a ClientInterceptor to the client's interceptor list if it is not already present.
// It appends the interceptor only if it is not already included in the list. // It appends the interceptor only if it is not already included in the list.
func (c *Client) AddInterceptor(interceptor *ClientInterceptor) { func (c *client) AddInterceptor(interceptor *ClientInterceptor) {
if !slices.Contains(c.interceptors, *interceptor) { if !slices.Contains(c.interceptors, *interceptor) {
c.interceptors = append(c.interceptors, *interceptor) c.interceptors = append(c.interceptors, *interceptor)
} }
@@ -145,7 +151,7 @@ func parseBaseURL(base string) (*url.URL, error) {
return baseURL, nil return baseURL, nil
} }
func newClientFromConfig(config *ClientConfig, v *validator) (*Client, error) { func newClientFromConfig(config *ClientConfig, v *validator) (*client, error) {
var err error var err error
config.URL = strings.TrimRight(config.URL, "/") config.URL = strings.TrimRight(config.URL, "/")
transport := &http.Transport{ transport := &http.Transport{
@@ -157,7 +163,7 @@ func newClientFromConfig(config *ClientConfig, v *validator) (*Client, error) {
return nil, fmt.Errorf("failed customizing HTTP transport: %w", err) return nil, fmt.Errorf("failed customizing HTTP transport: %w", err)
} }
} }
client := &http.Client{ httpClient := &http.Client{
Timeout: config.Timeout, Timeout: config.Timeout,
Transport: transport, Transport: transport,
} }
@@ -166,7 +172,7 @@ func newClientFromConfig(config *ClientConfig, v *validator) (*Client, error) {
if err != nil { if err != nil {
return nil, fmt.Errorf("failed creating cookiejar: %w", err) return nil, fmt.Errorf("failed creating cookiejar: %w", err)
} }
client.Jar = jar httpClient.Jar = jar
} }
baseURL, err := parseBaseURL(config.URL) baseURL, err := parseBaseURL(config.URL)
if err != nil { if err != nil {
@@ -199,13 +205,13 @@ func newClientFromConfig(config *ClientConfig, v *validator) (*Client, error) {
if config.ValidationMode == "" { if config.ValidationMode == "" {
config.ValidationMode = DefaultValidation config.ValidationMode = DefaultValidation
} }
u := &Client{ u := &client{
BaseURL: baseURL, baseURL: baseURL,
timeout: config.Timeout, timeout: config.Timeout,
credentials: credentials, credentials: credentials,
validationMode: config.ValidationMode, validationMode: config.ValidationMode,
useLocking: config.UseLocking, useLocking: config.UseLocking,
http: client, http: httpClient,
interceptors: interceptors, interceptors: interceptors,
errorHandler: errorHandler, errorHandler: errorHandler,
lock: sync.Mutex{}, lock: sync.Mutex{},
@@ -220,9 +226,9 @@ func newClientFromConfig(config *ClientConfig, v *validator) (*Client, error) {
// NewClient creates and initializes a new UniFi client based on the provided ClientConfig. // NewClient creates and initializes a new UniFi client based on the provided ClientConfig.
// It validates the configuration, determines the API style, performs login if necessary, // It validates the configuration, determines the API style, performs login if necessary,
// and retrieves system information from the UniFi controller. // and retrieves system information from the UniFi controller.
// On success, it returns a pointer to a Client; otherwise, it returns an error. // On success, it returns a pointer to a client; otherwise, it returns an error.
func NewClient(config *ClientConfig) (*Client, error) { func NewClient(config *ClientConfig) (Client, error) { //nolint: ireturn
c, err := NewBareClient(config) c, err := newBareClient(config)
if err != nil { if err != nil {
return c, err return c, err
} }
@@ -232,7 +238,7 @@ func NewClient(config *ClientConfig) (*Client, error) {
if sysInfo, err := c.GetSystemInformation(); err != nil { if sysInfo, err := c.GetSystemInformation(); err != nil {
return c, fmt.Errorf("failed getting server info: %w", err) return c, fmt.Errorf("failed getting server info: %w", err)
} else { } else {
c.SysInfo = sysInfo c.sysInfo = sysInfo
} }
return c, nil return c, nil
} }
@@ -240,7 +246,11 @@ func NewClient(config *ClientConfig) (*Client, error) {
// NewBareClient creates a new UniFi client without performing login or system information retrieval. // NewBareClient creates a new UniFi client without performing login or system information retrieval.
// When user/pass authentication is used, you must call Login before making requests. // When user/pass authentication is used, you must call Login before making requests.
// It validates the configuration, determines the API style, and returns a pointer to the client on success. // It validates the configuration, determines the API style, and returns a pointer to the client on success.
func NewBareClient(config *ClientConfig) (*Client, error) { func NewBareClient(config *ClientConfig) (Client, error) { //nolint: ireturn
return newBareClient(config)
}
func newBareClient(config *ClientConfig) (*client, error) {
v, err := newValidator() v, err := newValidator()
if err != nil { if err != nil {
return nil, fmt.Errorf("failed creating validator: %w", err) return nil, fmt.Errorf("failed creating validator: %w", err)
@@ -261,7 +271,7 @@ func NewBareClient(config *ClientConfig) (*Client, error) {
// Login authenticates the client using user/pass credentials. // Login authenticates the client using user/pass credentials.
// For API key authentication, Login does nothing. // For API key authentication, Login does nothing.
// It returns an error if the authentication process fails. // It returns an error if the authentication process fails.
func (c *Client) Login() error { func (c *client) Login() error {
if c.credentials.IsAPIKey() { if c.credentials.IsAPIKey() {
return nil return nil
} }
@@ -285,7 +295,7 @@ func (c *Client) Login() error {
// Logout terminates the client's session for user/pass authentication. // Logout terminates the client's session for user/pass authentication.
// For API key authentication, Logout does nothing. // For API key authentication, Logout does nothing.
// It returns an error if the logout process fails. // It returns an error if the logout process fails.
func (c *Client) Logout() error { func (c *client) Logout() error {
if c.credentials.IsAPIKey() { if c.credentials.IsAPIKey() {
return nil return nil
} }

View File

@@ -1,5 +1,5 @@
package unifi package unifi
// This will generate the *.generated.go files in this package for the specified // This will generate the *.generated.go files in this package for the specified
// Client controller version. // client controller version.
//go:generate go run ../codegen/ -version-base-dir=../codegen/ latest //go:generate go run ../codegen/ -version-base-dir=../codegen/ latest

View File

@@ -71,7 +71,7 @@ func (dst *DashboardModules) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listDashboard(ctx context.Context, site string) ([]Dashboard, error) { func (c *client) listDashboard(ctx context.Context, site string) ([]Dashboard, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Dashboard `json:"data"` Data []Dashboard `json:"data"`
@@ -85,7 +85,7 @@ func (c *Client) listDashboard(ctx context.Context, site string) ([]Dashboard, e
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getDashboard(ctx context.Context, site, id string) (*Dashboard, error) { func (c *client) getDashboard(ctx context.Context, site, id string) (*Dashboard, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Dashboard `json:"data"` Data []Dashboard `json:"data"`
@@ -104,7 +104,7 @@ func (c *Client) getDashboard(ctx context.Context, site, id string) (*Dashboard,
return &d, nil return &d, nil
} }
func (c *Client) deleteDashboard(ctx context.Context, site, id string) error { func (c *client) deleteDashboard(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/dashboard/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/dashboard/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -112,7 +112,7 @@ func (c *Client) deleteDashboard(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createDashboard(ctx context.Context, site string, d *Dashboard) (*Dashboard, error) { func (c *client) createDashboard(ctx context.Context, site string, d *Dashboard) (*Dashboard, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Dashboard `json:"data"` Data []Dashboard `json:"data"`
@@ -132,7 +132,7 @@ func (c *Client) createDashboard(ctx context.Context, site string, d *Dashboard)
return &new, nil return &new, nil
} }
func (c *Client) updateDashboard(ctx context.Context, site string, d *Dashboard) (*Dashboard, error) { func (c *client) updateDashboard(ctx context.Context, site string, d *Dashboard) (*Dashboard, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Dashboard `json:"data"` Data []Dashboard `json:"data"`

View File

@@ -584,7 +584,7 @@ func (dst *DeviceRpsPortTable) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listDevice(ctx context.Context, site string) ([]Device, error) { func (c *client) listDevice(ctx context.Context, site string) ([]Device, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Device `json:"data"` Data []Device `json:"data"`
@@ -598,7 +598,7 @@ func (c *Client) listDevice(ctx context.Context, site string) ([]Device, error)
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getDevice(ctx context.Context, site, id string) (*Device, error) { func (c *client) getDevice(ctx context.Context, site, id string) (*Device, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Device `json:"data"` Data []Device `json:"data"`
@@ -617,7 +617,7 @@ func (c *Client) getDevice(ctx context.Context, site, id string) (*Device, error
return &d, nil return &d, nil
} }
func (c *Client) deleteDevice(ctx context.Context, site, id string) error { func (c *client) deleteDevice(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/device/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/device/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -625,7 +625,7 @@ func (c *Client) deleteDevice(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createDevice(ctx context.Context, site string, d *Device) (*Device, error) { func (c *client) createDevice(ctx context.Context, site string, d *Device) (*Device, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Device `json:"data"` Data []Device `json:"data"`
@@ -645,7 +645,7 @@ func (c *Client) createDevice(ctx context.Context, site string, d *Device) (*Dev
return &new, nil return &new, nil
} }
func (c *Client) updateDevice(ctx context.Context, site string, d *Device) (*Device, error) { func (c *client) updateDevice(ctx context.Context, site string, d *Device) (*Device, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Device `json:"data"` Data []Device `json:"data"`

View File

@@ -23,27 +23,27 @@ const (
DeviceStateIsolated DeviceState = 11 DeviceStateIsolated DeviceState = 11
) )
func (c *Client) ListDevice(ctx context.Context, site string) ([]Device, error) { func (c *client) ListDevice(ctx context.Context, site string) ([]Device, error) {
return c.listDevice(ctx, site) return c.listDevice(ctx, site)
} }
func (c *Client) GetDeviceByMAC(ctx context.Context, site, mac string) (*Device, error) { func (c *client) GetDeviceByMAC(ctx context.Context, site, mac string) (*Device, error) {
return c.getDevice(ctx, site, mac) return c.getDevice(ctx, site, mac)
} }
func (c *Client) DeleteDevice(ctx context.Context, site, id string) error { func (c *client) DeleteDevice(ctx context.Context, site, id string) error {
return c.deleteDevice(ctx, site, id) return c.deleteDevice(ctx, site, id)
} }
func (c *Client) CreateDevice(ctx context.Context, site string, d *Device) (*Device, error) { func (c *client) CreateDevice(ctx context.Context, site string, d *Device) (*Device, error) {
return c.createDevice(ctx, site, d) return c.createDevice(ctx, site, d)
} }
func (c *Client) UpdateDevice(ctx context.Context, site string, d *Device) (*Device, error) { func (c *client) UpdateDevice(ctx context.Context, site string, d *Device) (*Device, error) {
return c.updateDevice(ctx, site, d) return c.updateDevice(ctx, site, d)
} }
func (c *Client) GetDevice(ctx context.Context, site, id string) (*Device, error) { func (c *client) GetDevice(ctx context.Context, site, id string) (*Device, error) {
devices, err := c.ListDevice(ctx, site) devices, err := c.ListDevice(ctx, site)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -58,7 +58,7 @@ func (c *Client) GetDevice(ctx context.Context, site, id string) (*Device, error
return nil, ErrNotFound return nil, ErrNotFound
} }
func (c *Client) AdoptDevice(ctx context.Context, site, mac string) error { func (c *client) AdoptDevice(ctx context.Context, site, mac string) error {
reqBody := struct { reqBody := struct {
Cmd string `json:"cmd"` Cmd string `json:"cmd"`
MAC string `json:"mac"` MAC string `json:"mac"`
@@ -79,7 +79,7 @@ func (c *Client) AdoptDevice(ctx context.Context, site, mac string) error {
return nil return nil
} }
func (c *Client) ForgetDevice(ctx context.Context, site, mac string) error { func (c *client) ForgetDevice(ctx context.Context, site, mac string) error {
reqBody := struct { reqBody := struct {
Cmd string `json:"cmd"` Cmd string `json:"cmd"`
MACs []string `json:"macs"` MACs []string `json:"macs"`

View File

@@ -51,7 +51,7 @@ func (dst *DHCPOption) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listDHCPOption(ctx context.Context, site string) ([]DHCPOption, error) { func (c *client) listDHCPOption(ctx context.Context, site string) ([]DHCPOption, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []DHCPOption `json:"data"` Data []DHCPOption `json:"data"`
@@ -65,7 +65,7 @@ func (c *Client) listDHCPOption(ctx context.Context, site string) ([]DHCPOption,
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getDHCPOption(ctx context.Context, site, id string) (*DHCPOption, error) { func (c *client) getDHCPOption(ctx context.Context, site, id string) (*DHCPOption, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []DHCPOption `json:"data"` Data []DHCPOption `json:"data"`
@@ -84,7 +84,7 @@ func (c *Client) getDHCPOption(ctx context.Context, site, id string) (*DHCPOptio
return &d, nil return &d, nil
} }
func (c *Client) deleteDHCPOption(ctx context.Context, site, id string) error { func (c *client) deleteDHCPOption(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/dhcpoption/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/dhcpoption/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -92,7 +92,7 @@ func (c *Client) deleteDHCPOption(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createDHCPOption(ctx context.Context, site string, d *DHCPOption) (*DHCPOption, error) { func (c *client) createDHCPOption(ctx context.Context, site string, d *DHCPOption) (*DHCPOption, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []DHCPOption `json:"data"` Data []DHCPOption `json:"data"`
@@ -112,7 +112,7 @@ func (c *Client) createDHCPOption(ctx context.Context, site string, d *DHCPOptio
return &new, nil return &new, nil
} }
func (c *Client) updateDHCPOption(ctx context.Context, site string, d *DHCPOption) (*DHCPOption, error) { func (c *client) updateDHCPOption(ctx context.Context, site string, d *DHCPOption) (*DHCPOption, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []DHCPOption `json:"data"` Data []DHCPOption `json:"data"`

View File

@@ -1,4 +1,4 @@
// Custom package for handling DNS records in Client Controller // Custom package for handling DNS records in client Controller
package unifi package unifi
@@ -51,7 +51,7 @@ func (dst *DNSRecord) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) ListDNSRecord(ctx context.Context, site string) ([]DNSRecord, error) { func (c *client) ListDNSRecord(ctx context.Context, site string) ([]DNSRecord, error) {
var respBody []DNSRecord var respBody []DNSRecord
err := c.Get(ctx, fmt.Sprintf("%s/site/%s/static-dns", c.apiPaths.ApiV2Path, site), nil, &respBody) err := c.Get(ctx, fmt.Sprintf("%s/site/%s/static-dns", c.apiPaths.ApiV2Path, site), nil, &respBody)
@@ -62,7 +62,7 @@ func (c *Client) ListDNSRecord(ctx context.Context, site string) ([]DNSRecord, e
return respBody, nil return respBody, nil
} }
func (c *Client) GetDNSRecord(ctx context.Context, site, id string) (*DNSRecord, error) { func (c *client) GetDNSRecord(ctx context.Context, site, id string) (*DNSRecord, error) {
var respBody DNSRecord var respBody DNSRecord
err := c.Get(ctx, fmt.Sprintf("%s/site/%s/static-dns/%s", c.apiPaths.ApiV2Path, site, id), nil, &respBody) err := c.Get(ctx, fmt.Sprintf("%s/site/%s/static-dns/%s", c.apiPaths.ApiV2Path, site, id), nil, &respBody)
@@ -77,7 +77,7 @@ func (c *Client) GetDNSRecord(ctx context.Context, site, id string) (*DNSRecord,
return &respBody, nil return &respBody, nil
} }
func (c *Client) DeleteDNSRecord(ctx context.Context, site, id string) error { func (c *client) DeleteDNSRecord(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("%s/site/%s/static-dns/%s", c.apiPaths.ApiV2Path, site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("%s/site/%s/static-dns/%s", c.apiPaths.ApiV2Path, site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -85,7 +85,7 @@ func (c *Client) DeleteDNSRecord(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) CreateDNSRecord(ctx context.Context, site string, d *DNSRecord) (*DNSRecord, error) { func (c *client) CreateDNSRecord(ctx context.Context, site string, d *DNSRecord) (*DNSRecord, error) {
var respBody DNSRecord var respBody DNSRecord
err := c.Post(ctx, fmt.Sprintf("%s/site/%s/static-dns", c.apiPaths.ApiV2Path, site), d, &respBody) err := c.Post(ctx, fmt.Sprintf("%s/site/%s/static-dns", c.apiPaths.ApiV2Path, site), d, &respBody)
if err != nil { if err != nil {
@@ -94,7 +94,7 @@ func (c *Client) CreateDNSRecord(ctx context.Context, site string, d *DNSRecord)
return &respBody, nil return &respBody, nil
} }
func (c *Client) UpdateDNSRecord(ctx context.Context, site string, d *DNSRecord) (*DNSRecord, error) { func (c *client) UpdateDNSRecord(ctx context.Context, site string, d *DNSRecord) (*DNSRecord, error) {
var respBody DNSRecord var respBody DNSRecord
err := c.Put(ctx, fmt.Sprintf("%s/site/%s/static-dns/%s", c.apiPaths.ApiV2Path, site, d.ID), d, &respBody) err := c.Put(ctx, fmt.Sprintf("%s/site/%s/static-dns/%s", c.apiPaths.ApiV2Path, site, d.ID), d, &respBody)

View File

@@ -66,7 +66,7 @@ func (dst *DpiApp) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listDpiApp(ctx context.Context, site string) ([]DpiApp, error) { func (c *client) listDpiApp(ctx context.Context, site string) ([]DpiApp, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []DpiApp `json:"data"` Data []DpiApp `json:"data"`
@@ -80,7 +80,7 @@ func (c *Client) listDpiApp(ctx context.Context, site string) ([]DpiApp, error)
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getDpiApp(ctx context.Context, site, id string) (*DpiApp, error) { func (c *client) getDpiApp(ctx context.Context, site, id string) (*DpiApp, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []DpiApp `json:"data"` Data []DpiApp `json:"data"`
@@ -99,7 +99,7 @@ func (c *Client) getDpiApp(ctx context.Context, site, id string) (*DpiApp, error
return &d, nil return &d, nil
} }
func (c *Client) deleteDpiApp(ctx context.Context, site, id string) error { func (c *client) deleteDpiApp(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/dpiapp/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/dpiapp/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -107,7 +107,7 @@ func (c *Client) deleteDpiApp(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createDpiApp(ctx context.Context, site string, d *DpiApp) (*DpiApp, error) { func (c *client) createDpiApp(ctx context.Context, site string, d *DpiApp) (*DpiApp, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []DpiApp `json:"data"` Data []DpiApp `json:"data"`
@@ -127,7 +127,7 @@ func (c *Client) createDpiApp(ctx context.Context, site string, d *DpiApp) (*Dpi
return &new, nil return &new, nil
} }
func (c *Client) updateDpiApp(ctx context.Context, site string, d *DpiApp) (*DpiApp, error) { func (c *client) updateDpiApp(ctx context.Context, site string, d *DpiApp) (*DpiApp, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []DpiApp `json:"data"` Data []DpiApp `json:"data"`

View File

@@ -46,7 +46,7 @@ func (dst *DpiGroup) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listDpiGroup(ctx context.Context, site string) ([]DpiGroup, error) { func (c *client) listDpiGroup(ctx context.Context, site string) ([]DpiGroup, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []DpiGroup `json:"data"` Data []DpiGroup `json:"data"`
@@ -60,7 +60,7 @@ func (c *Client) listDpiGroup(ctx context.Context, site string) ([]DpiGroup, err
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getDpiGroup(ctx context.Context, site, id string) (*DpiGroup, error) { func (c *client) getDpiGroup(ctx context.Context, site, id string) (*DpiGroup, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []DpiGroup `json:"data"` Data []DpiGroup `json:"data"`
@@ -79,7 +79,7 @@ func (c *Client) getDpiGroup(ctx context.Context, site, id string) (*DpiGroup, e
return &d, nil return &d, nil
} }
func (c *Client) deleteDpiGroup(ctx context.Context, site, id string) error { func (c *client) deleteDpiGroup(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/dpigroup/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/dpigroup/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -87,7 +87,7 @@ func (c *Client) deleteDpiGroup(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createDpiGroup(ctx context.Context, site string, d *DpiGroup) (*DpiGroup, error) { func (c *client) createDpiGroup(ctx context.Context, site string, d *DpiGroup) (*DpiGroup, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []DpiGroup `json:"data"` Data []DpiGroup `json:"data"`
@@ -107,7 +107,7 @@ func (c *Client) createDpiGroup(ctx context.Context, site string, d *DpiGroup) (
return &new, nil return &new, nil
} }
func (c *Client) updateDpiGroup(ctx context.Context, site string, d *DpiGroup) (*DpiGroup, error) { func (c *client) updateDpiGroup(ctx context.Context, site string, d *DpiGroup) (*DpiGroup, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []DpiGroup `json:"data"` Data []DpiGroup `json:"data"`

View File

@@ -51,7 +51,7 @@ func (dst *DynamicDNS) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listDynamicDNS(ctx context.Context, site string) ([]DynamicDNS, error) { func (c *client) listDynamicDNS(ctx context.Context, site string) ([]DynamicDNS, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []DynamicDNS `json:"data"` Data []DynamicDNS `json:"data"`
@@ -65,7 +65,7 @@ func (c *Client) listDynamicDNS(ctx context.Context, site string) ([]DynamicDNS,
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getDynamicDNS(ctx context.Context, site, id string) (*DynamicDNS, error) { func (c *client) getDynamicDNS(ctx context.Context, site, id string) (*DynamicDNS, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []DynamicDNS `json:"data"` Data []DynamicDNS `json:"data"`
@@ -84,7 +84,7 @@ func (c *Client) getDynamicDNS(ctx context.Context, site, id string) (*DynamicDN
return &d, nil return &d, nil
} }
func (c *Client) deleteDynamicDNS(ctx context.Context, site, id string) error { func (c *client) deleteDynamicDNS(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/dynamicdns/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/dynamicdns/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -92,7 +92,7 @@ func (c *Client) deleteDynamicDNS(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createDynamicDNS(ctx context.Context, site string, d *DynamicDNS) (*DynamicDNS, error) { func (c *client) createDynamicDNS(ctx context.Context, site string, d *DynamicDNS) (*DynamicDNS, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []DynamicDNS `json:"data"` Data []DynamicDNS `json:"data"`
@@ -112,7 +112,7 @@ func (c *Client) createDynamicDNS(ctx context.Context, site string, d *DynamicDN
return &new, nil return &new, nil
} }
func (c *Client) updateDynamicDNS(ctx context.Context, site string, d *DynamicDNS) (*DynamicDNS, error) { func (c *client) updateDynamicDNS(ctx context.Context, site string, d *DynamicDNS) (*DynamicDNS, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []DynamicDNS `json:"data"` Data []DynamicDNS `json:"data"`

View File

@@ -2,22 +2,22 @@ package unifi
import "context" import "context"
func (c *Client) ListDynamicDNS(ctx context.Context, site string) ([]DynamicDNS, error) { func (c *client) ListDynamicDNS(ctx context.Context, site string) ([]DynamicDNS, error) {
return c.listDynamicDNS(ctx, site) return c.listDynamicDNS(ctx, site)
} }
func (c *Client) GetDynamicDNS(ctx context.Context, site, id string) (*DynamicDNS, error) { func (c *client) GetDynamicDNS(ctx context.Context, site, id string) (*DynamicDNS, error) {
return c.getDynamicDNS(ctx, site, id) return c.getDynamicDNS(ctx, site, id)
} }
func (c *Client) DeleteDynamicDNS(ctx context.Context, site, id string) error { func (c *client) DeleteDynamicDNS(ctx context.Context, site, id string) error {
return c.deleteDynamicDNS(ctx, site, id) return c.deleteDynamicDNS(ctx, site, id)
} }
func (c *Client) CreateDynamicDNS(ctx context.Context, site string, d *DynamicDNS) (*DynamicDNS, error) { func (c *client) CreateDynamicDNS(ctx context.Context, site string, d *DynamicDNS) (*DynamicDNS, error) {
return c.createDynamicDNS(ctx, site, d) return c.createDynamicDNS(ctx, site, d)
} }
func (c *Client) UpdateDynamicDNS(ctx context.Context, site string, d *DynamicDNS) (*DynamicDNS, error) { func (c *client) UpdateDynamicDNS(ctx context.Context, site string, d *DynamicDNS) (*DynamicDNS, error) {
return c.updateDynamicDNS(ctx, site, d) return c.updateDynamicDNS(ctx, site, d)
} }

View File

@@ -46,7 +46,7 @@ func (dst *FirewallGroup) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listFirewallGroup(ctx context.Context, site string) ([]FirewallGroup, error) { func (c *client) listFirewallGroup(ctx context.Context, site string) ([]FirewallGroup, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []FirewallGroup `json:"data"` Data []FirewallGroup `json:"data"`
@@ -60,7 +60,7 @@ func (c *Client) listFirewallGroup(ctx context.Context, site string) ([]Firewall
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getFirewallGroup(ctx context.Context, site, id string) (*FirewallGroup, error) { func (c *client) getFirewallGroup(ctx context.Context, site, id string) (*FirewallGroup, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []FirewallGroup `json:"data"` Data []FirewallGroup `json:"data"`
@@ -79,7 +79,7 @@ func (c *Client) getFirewallGroup(ctx context.Context, site, id string) (*Firewa
return &d, nil return &d, nil
} }
func (c *Client) deleteFirewallGroup(ctx context.Context, site, id string) error { func (c *client) deleteFirewallGroup(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/firewallgroup/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/firewallgroup/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -87,7 +87,7 @@ func (c *Client) deleteFirewallGroup(ctx context.Context, site, id string) error
return nil return nil
} }
func (c *Client) createFirewallGroup(ctx context.Context, site string, d *FirewallGroup) (*FirewallGroup, error) { func (c *client) createFirewallGroup(ctx context.Context, site string, d *FirewallGroup) (*FirewallGroup, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []FirewallGroup `json:"data"` Data []FirewallGroup `json:"data"`
@@ -107,7 +107,7 @@ func (c *Client) createFirewallGroup(ctx context.Context, site string, d *Firewa
return &new, nil return &new, nil
} }
func (c *Client) updateFirewallGroup(ctx context.Context, site string, d *FirewallGroup) (*FirewallGroup, error) { func (c *client) updateFirewallGroup(ctx context.Context, site string, d *FirewallGroup) (*FirewallGroup, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []FirewallGroup `json:"data"` Data []FirewallGroup `json:"data"`

View File

@@ -2,22 +2,22 @@ package unifi
import "context" import "context"
func (c *Client) ListFirewallGroup(ctx context.Context, site string) ([]FirewallGroup, error) { func (c *client) ListFirewallGroup(ctx context.Context, site string) ([]FirewallGroup, error) {
return c.listFirewallGroup(ctx, site) return c.listFirewallGroup(ctx, site)
} }
func (c *Client) GetFirewallGroup(ctx context.Context, site, id string) (*FirewallGroup, error) { func (c *client) GetFirewallGroup(ctx context.Context, site, id string) (*FirewallGroup, error) {
return c.getFirewallGroup(ctx, site, id) return c.getFirewallGroup(ctx, site, id)
} }
func (c *Client) DeleteFirewallGroup(ctx context.Context, site, id string) error { func (c *client) DeleteFirewallGroup(ctx context.Context, site, id string) error {
return c.deleteFirewallGroup(ctx, site, id) return c.deleteFirewallGroup(ctx, site, id)
} }
func (c *Client) CreateFirewallGroup(ctx context.Context, site string, d *FirewallGroup) (*FirewallGroup, error) { func (c *client) CreateFirewallGroup(ctx context.Context, site string, d *FirewallGroup) (*FirewallGroup, error) {
return c.createFirewallGroup(ctx, site, d) return c.createFirewallGroup(ctx, site, d)
} }
func (c *Client) UpdateFirewallGroup(ctx context.Context, site string, d *FirewallGroup) (*FirewallGroup, error) { func (c *client) UpdateFirewallGroup(ctx context.Context, site string, d *FirewallGroup) (*FirewallGroup, error) {
return c.updateFirewallGroup(ctx, site, d) return c.updateFirewallGroup(ctx, site, d)
} }

View File

@@ -76,7 +76,7 @@ func (dst *FirewallRule) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listFirewallRule(ctx context.Context, site string) ([]FirewallRule, error) { func (c *client) listFirewallRule(ctx context.Context, site string) ([]FirewallRule, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []FirewallRule `json:"data"` Data []FirewallRule `json:"data"`
@@ -90,7 +90,7 @@ func (c *Client) listFirewallRule(ctx context.Context, site string) ([]FirewallR
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getFirewallRule(ctx context.Context, site, id string) (*FirewallRule, error) { func (c *client) getFirewallRule(ctx context.Context, site, id string) (*FirewallRule, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []FirewallRule `json:"data"` Data []FirewallRule `json:"data"`
@@ -109,7 +109,7 @@ func (c *Client) getFirewallRule(ctx context.Context, site, id string) (*Firewal
return &d, nil return &d, nil
} }
func (c *Client) deleteFirewallRule(ctx context.Context, site, id string) error { func (c *client) deleteFirewallRule(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/firewallrule/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/firewallrule/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -117,7 +117,7 @@ func (c *Client) deleteFirewallRule(ctx context.Context, site, id string) error
return nil return nil
} }
func (c *Client) createFirewallRule(ctx context.Context, site string, d *FirewallRule) (*FirewallRule, error) { func (c *client) createFirewallRule(ctx context.Context, site string, d *FirewallRule) (*FirewallRule, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []FirewallRule `json:"data"` Data []FirewallRule `json:"data"`
@@ -137,7 +137,7 @@ func (c *Client) createFirewallRule(ctx context.Context, site string, d *Firewal
return &new, nil return &new, nil
} }
func (c *Client) updateFirewallRule(ctx context.Context, site string, d *FirewallRule) (*FirewallRule, error) { func (c *client) updateFirewallRule(ctx context.Context, site string, d *FirewallRule) (*FirewallRule, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []FirewallRule `json:"data"` Data []FirewallRule `json:"data"`

View File

@@ -10,27 +10,27 @@ type FirewallRuleIndexUpdate struct {
RuleIndex int `json:"rule_index,string"` RuleIndex int `json:"rule_index,string"`
} }
func (c *Client) ListFirewallRule(ctx context.Context, site string) ([]FirewallRule, error) { func (c *client) ListFirewallRule(ctx context.Context, site string) ([]FirewallRule, error) {
return c.listFirewallRule(ctx, site) return c.listFirewallRule(ctx, site)
} }
func (c *Client) GetFirewallRule(ctx context.Context, site, id string) (*FirewallRule, error) { func (c *client) GetFirewallRule(ctx context.Context, site, id string) (*FirewallRule, error) {
return c.getFirewallRule(ctx, site, id) return c.getFirewallRule(ctx, site, id)
} }
func (c *Client) DeleteFirewallRule(ctx context.Context, site, id string) error { func (c *client) DeleteFirewallRule(ctx context.Context, site, id string) error {
return c.deleteFirewallRule(ctx, site, id) return c.deleteFirewallRule(ctx, site, id)
} }
func (c *Client) CreateFirewallRule(ctx context.Context, site string, d *FirewallRule) (*FirewallRule, error) { func (c *client) CreateFirewallRule(ctx context.Context, site string, d *FirewallRule) (*FirewallRule, error) {
return c.createFirewallRule(ctx, site, d) return c.createFirewallRule(ctx, site, d)
} }
func (c *Client) UpdateFirewallRule(ctx context.Context, site string, d *FirewallRule) (*FirewallRule, error) { func (c *client) UpdateFirewallRule(ctx context.Context, site string, d *FirewallRule) (*FirewallRule, error) {
return c.updateFirewallRule(ctx, site, d) return c.updateFirewallRule(ctx, site, d)
} }
func (c *Client) ReorderFirewallRules(ctx context.Context, site, ruleset string, reorder []FirewallRuleIndexUpdate) error { func (c *client) ReorderFirewallRules(ctx context.Context, site, ruleset string, reorder []FirewallRuleIndexUpdate) error {
reqBody := struct { reqBody := struct {
Cmd string `json:"cmd"` Cmd string `json:"cmd"`
Ruleset string `json:"ruleset"` Ruleset string `json:"ruleset"`

View File

@@ -47,7 +47,7 @@ func (dst *HeatMap) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listHeatMap(ctx context.Context, site string) ([]HeatMap, error) { func (c *client) listHeatMap(ctx context.Context, site string) ([]HeatMap, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []HeatMap `json:"data"` Data []HeatMap `json:"data"`
@@ -61,7 +61,7 @@ func (c *Client) listHeatMap(ctx context.Context, site string) ([]HeatMap, error
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getHeatMap(ctx context.Context, site, id string) (*HeatMap, error) { func (c *client) getHeatMap(ctx context.Context, site, id string) (*HeatMap, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []HeatMap `json:"data"` Data []HeatMap `json:"data"`
@@ -80,7 +80,7 @@ func (c *Client) getHeatMap(ctx context.Context, site, id string) (*HeatMap, err
return &d, nil return &d, nil
} }
func (c *Client) deleteHeatMap(ctx context.Context, site, id string) error { func (c *client) deleteHeatMap(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/heatmap/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/heatmap/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -88,7 +88,7 @@ func (c *Client) deleteHeatMap(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createHeatMap(ctx context.Context, site string, d *HeatMap) (*HeatMap, error) { func (c *client) createHeatMap(ctx context.Context, site string, d *HeatMap) (*HeatMap, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []HeatMap `json:"data"` Data []HeatMap `json:"data"`
@@ -108,7 +108,7 @@ func (c *Client) createHeatMap(ctx context.Context, site string, d *HeatMap) (*H
return &new, nil return &new, nil
} }
func (c *Client) updateHeatMap(ctx context.Context, site string, d *HeatMap) (*HeatMap, error) { func (c *client) updateHeatMap(ctx context.Context, site string, d *HeatMap) (*HeatMap, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []HeatMap `json:"data"` Data []HeatMap `json:"data"`

View File

@@ -48,7 +48,7 @@ func (dst *HeatMapPoint) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listHeatMapPoint(ctx context.Context, site string) ([]HeatMapPoint, error) { func (c *client) listHeatMapPoint(ctx context.Context, site string) ([]HeatMapPoint, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []HeatMapPoint `json:"data"` Data []HeatMapPoint `json:"data"`
@@ -62,7 +62,7 @@ func (c *Client) listHeatMapPoint(ctx context.Context, site string) ([]HeatMapPo
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getHeatMapPoint(ctx context.Context, site, id string) (*HeatMapPoint, error) { func (c *client) getHeatMapPoint(ctx context.Context, site, id string) (*HeatMapPoint, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []HeatMapPoint `json:"data"` Data []HeatMapPoint `json:"data"`
@@ -81,7 +81,7 @@ func (c *Client) getHeatMapPoint(ctx context.Context, site, id string) (*HeatMap
return &d, nil return &d, nil
} }
func (c *Client) deleteHeatMapPoint(ctx context.Context, site, id string) error { func (c *client) deleteHeatMapPoint(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/heatmappoint/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/heatmappoint/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -89,7 +89,7 @@ func (c *Client) deleteHeatMapPoint(ctx context.Context, site, id string) error
return nil return nil
} }
func (c *Client) createHeatMapPoint(ctx context.Context, site string, d *HeatMapPoint) (*HeatMapPoint, error) { func (c *client) createHeatMapPoint(ctx context.Context, site string, d *HeatMapPoint) (*HeatMapPoint, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []HeatMapPoint `json:"data"` Data []HeatMapPoint `json:"data"`
@@ -109,7 +109,7 @@ func (c *Client) createHeatMapPoint(ctx context.Context, site string, d *HeatMap
return &new, nil return &new, nil
} }
func (c *Client) updateHeatMapPoint(ctx context.Context, site string, d *HeatMapPoint) (*HeatMapPoint, error) { func (c *client) updateHeatMapPoint(ctx context.Context, site string, d *HeatMapPoint) (*HeatMapPoint, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []HeatMapPoint `json:"data"` Data []HeatMapPoint `json:"data"`

View File

@@ -427,7 +427,7 @@ func (dst *Hotspot2ConfVenueName) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listHotspot2Conf(ctx context.Context, site string) ([]Hotspot2Conf, error) { func (c *client) listHotspot2Conf(ctx context.Context, site string) ([]Hotspot2Conf, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Hotspot2Conf `json:"data"` Data []Hotspot2Conf `json:"data"`
@@ -441,7 +441,7 @@ func (c *Client) listHotspot2Conf(ctx context.Context, site string) ([]Hotspot2C
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getHotspot2Conf(ctx context.Context, site, id string) (*Hotspot2Conf, error) { func (c *client) getHotspot2Conf(ctx context.Context, site, id string) (*Hotspot2Conf, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Hotspot2Conf `json:"data"` Data []Hotspot2Conf `json:"data"`
@@ -460,7 +460,7 @@ func (c *Client) getHotspot2Conf(ctx context.Context, site, id string) (*Hotspot
return &d, nil return &d, nil
} }
func (c *Client) deleteHotspot2Conf(ctx context.Context, site, id string) error { func (c *client) deleteHotspot2Conf(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/hotspot2conf/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/hotspot2conf/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -468,7 +468,7 @@ func (c *Client) deleteHotspot2Conf(ctx context.Context, site, id string) error
return nil return nil
} }
func (c *Client) createHotspot2Conf(ctx context.Context, site string, d *Hotspot2Conf) (*Hotspot2Conf, error) { func (c *client) createHotspot2Conf(ctx context.Context, site string, d *Hotspot2Conf) (*Hotspot2Conf, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Hotspot2Conf `json:"data"` Data []Hotspot2Conf `json:"data"`
@@ -488,7 +488,7 @@ func (c *Client) createHotspot2Conf(ctx context.Context, site string, d *Hotspot
return &new, nil return &new, nil
} }
func (c *Client) updateHotspot2Conf(ctx context.Context, site string, d *Hotspot2Conf) (*Hotspot2Conf, error) { func (c *client) updateHotspot2Conf(ctx context.Context, site string, d *Hotspot2Conf) (*Hotspot2Conf, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Hotspot2Conf `json:"data"` Data []Hotspot2Conf `json:"data"`

View File

@@ -46,7 +46,7 @@ func (dst *HotspotOp) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listHotspotOp(ctx context.Context, site string) ([]HotspotOp, error) { func (c *client) listHotspotOp(ctx context.Context, site string) ([]HotspotOp, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []HotspotOp `json:"data"` Data []HotspotOp `json:"data"`
@@ -60,7 +60,7 @@ func (c *Client) listHotspotOp(ctx context.Context, site string) ([]HotspotOp, e
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getHotspotOp(ctx context.Context, site, id string) (*HotspotOp, error) { func (c *client) getHotspotOp(ctx context.Context, site, id string) (*HotspotOp, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []HotspotOp `json:"data"` Data []HotspotOp `json:"data"`
@@ -79,7 +79,7 @@ func (c *Client) getHotspotOp(ctx context.Context, site, id string) (*HotspotOp,
return &d, nil return &d, nil
} }
func (c *Client) deleteHotspotOp(ctx context.Context, site, id string) error { func (c *client) deleteHotspotOp(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/hotspotop/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/hotspotop/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -87,7 +87,7 @@ func (c *Client) deleteHotspotOp(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createHotspotOp(ctx context.Context, site string, d *HotspotOp) (*HotspotOp, error) { func (c *client) createHotspotOp(ctx context.Context, site string, d *HotspotOp) (*HotspotOp, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []HotspotOp `json:"data"` Data []HotspotOp `json:"data"`
@@ -107,7 +107,7 @@ func (c *Client) createHotspotOp(ctx context.Context, site string, d *HotspotOp)
return &new, nil return &new, nil
} }
func (c *Client) updateHotspotOp(ctx context.Context, site string, d *HotspotOp) (*HotspotOp, error) { func (c *client) updateHotspotOp(ctx context.Context, site string, d *HotspotOp) (*HotspotOp, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []HotspotOp `json:"data"` Data []HotspotOp `json:"data"`

View File

@@ -85,7 +85,7 @@ func (dst *HotspotPackage) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listHotspotPackage(ctx context.Context, site string) ([]HotspotPackage, error) { func (c *client) listHotspotPackage(ctx context.Context, site string) ([]HotspotPackage, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []HotspotPackage `json:"data"` Data []HotspotPackage `json:"data"`
@@ -99,7 +99,7 @@ func (c *Client) listHotspotPackage(ctx context.Context, site string) ([]Hotspot
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getHotspotPackage(ctx context.Context, site, id string) (*HotspotPackage, error) { func (c *client) getHotspotPackage(ctx context.Context, site, id string) (*HotspotPackage, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []HotspotPackage `json:"data"` Data []HotspotPackage `json:"data"`
@@ -118,7 +118,7 @@ func (c *Client) getHotspotPackage(ctx context.Context, site, id string) (*Hotsp
return &d, nil return &d, nil
} }
func (c *Client) deleteHotspotPackage(ctx context.Context, site, id string) error { func (c *client) deleteHotspotPackage(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/hotspotpackage/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/hotspotpackage/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -126,7 +126,7 @@ func (c *Client) deleteHotspotPackage(ctx context.Context, site, id string) erro
return nil return nil
} }
func (c *Client) createHotspotPackage(ctx context.Context, site string, d *HotspotPackage) (*HotspotPackage, error) { func (c *client) createHotspotPackage(ctx context.Context, site string, d *HotspotPackage) (*HotspotPackage, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []HotspotPackage `json:"data"` Data []HotspotPackage `json:"data"`
@@ -146,7 +146,7 @@ func (c *Client) createHotspotPackage(ctx context.Context, site string, d *Hotsp
return &new, nil return &new, nil
} }
func (c *Client) updateHotspotPackage(ctx context.Context, site string, d *HotspotPackage) (*HotspotPackage, error) { func (c *client) updateHotspotPackage(ctx context.Context, site string, d *HotspotPackage) (*HotspotPackage, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []HotspotPackage `json:"data"` Data []HotspotPackage `json:"data"`

10
unifi/map.generated.go generated
View File

@@ -61,7 +61,7 @@ func (dst *Map) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listMap(ctx context.Context, site string) ([]Map, error) { func (c *client) listMap(ctx context.Context, site string) ([]Map, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Map `json:"data"` Data []Map `json:"data"`
@@ -75,7 +75,7 @@ func (c *Client) listMap(ctx context.Context, site string) ([]Map, error) {
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getMap(ctx context.Context, site, id string) (*Map, error) { func (c *client) getMap(ctx context.Context, site, id string) (*Map, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Map `json:"data"` Data []Map `json:"data"`
@@ -94,7 +94,7 @@ func (c *Client) getMap(ctx context.Context, site, id string) (*Map, error) {
return &d, nil return &d, nil
} }
func (c *Client) deleteMap(ctx context.Context, site, id string) error { func (c *client) deleteMap(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/map/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/map/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -102,7 +102,7 @@ func (c *Client) deleteMap(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createMap(ctx context.Context, site string, d *Map) (*Map, error) { func (c *client) createMap(ctx context.Context, site string, d *Map) (*Map, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Map `json:"data"` Data []Map `json:"data"`
@@ -122,7 +122,7 @@ func (c *Client) createMap(ctx context.Context, site string, d *Map) (*Map, erro
return &new, nil return &new, nil
} }
func (c *Client) updateMap(ctx context.Context, site string, d *Map) (*Map, error) { func (c *client) updateMap(ctx context.Context, site string, d *Map) (*Map, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Map `json:"data"` Data []Map `json:"data"`

View File

@@ -44,7 +44,7 @@ func (dst *MediaFile) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listMediaFile(ctx context.Context, site string) ([]MediaFile, error) { func (c *client) listMediaFile(ctx context.Context, site string) ([]MediaFile, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []MediaFile `json:"data"` Data []MediaFile `json:"data"`
@@ -58,7 +58,7 @@ func (c *Client) listMediaFile(ctx context.Context, site string) ([]MediaFile, e
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getMediaFile(ctx context.Context, site, id string) (*MediaFile, error) { func (c *client) getMediaFile(ctx context.Context, site, id string) (*MediaFile, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []MediaFile `json:"data"` Data []MediaFile `json:"data"`
@@ -77,7 +77,7 @@ func (c *Client) getMediaFile(ctx context.Context, site, id string) (*MediaFile,
return &d, nil return &d, nil
} }
func (c *Client) deleteMediaFile(ctx context.Context, site, id string) error { func (c *client) deleteMediaFile(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/mediafile/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/mediafile/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -85,7 +85,7 @@ func (c *Client) deleteMediaFile(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createMediaFile(ctx context.Context, site string, d *MediaFile) (*MediaFile, error) { func (c *client) createMediaFile(ctx context.Context, site string, d *MediaFile) (*MediaFile, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []MediaFile `json:"data"` Data []MediaFile `json:"data"`
@@ -105,7 +105,7 @@ func (c *Client) createMediaFile(ctx context.Context, site string, d *MediaFile)
return &new, nil return &new, nil
} }
func (c *Client) updateMediaFile(ctx context.Context, site string, d *MediaFile) (*MediaFile, error) { func (c *client) updateMediaFile(ctx context.Context, site string, d *MediaFile) (*MediaFile, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []MediaFile `json:"data"` Data []MediaFile `json:"data"`

View File

@@ -436,7 +436,7 @@ func (dst *NetworkWANProviderCapabilities) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listNetwork(ctx context.Context, site string) ([]Network, error) { func (c *client) listNetwork(ctx context.Context, site string) ([]Network, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Network `json:"data"` Data []Network `json:"data"`
@@ -450,7 +450,7 @@ func (c *Client) listNetwork(ctx context.Context, site string) ([]Network, error
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getNetwork(ctx context.Context, site, id string) (*Network, error) { func (c *client) getNetwork(ctx context.Context, site, id string) (*Network, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Network `json:"data"` Data []Network `json:"data"`
@@ -469,7 +469,7 @@ func (c *Client) getNetwork(ctx context.Context, site, id string) (*Network, err
return &d, nil return &d, nil
} }
func (c *Client) deleteNetwork(ctx context.Context, site, id string) error { func (c *client) deleteNetwork(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/networkconf/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/networkconf/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -477,7 +477,7 @@ func (c *Client) deleteNetwork(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createNetwork(ctx context.Context, site string, d *Network) (*Network, error) { func (c *client) createNetwork(ctx context.Context, site string, d *Network) (*Network, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Network `json:"data"` Data []Network `json:"data"`
@@ -497,7 +497,7 @@ func (c *Client) createNetwork(ctx context.Context, site string, d *Network) (*N
return &new, nil return &new, nil
} }
func (c *Client) updateNetwork(ctx context.Context, site string, d *Network) (*Network, error) { func (c *client) updateNetwork(ctx context.Context, site string, d *Network) (*Network, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Network `json:"data"` Data []Network `json:"data"`

View File

@@ -26,30 +26,38 @@ func (dst *Network) MarshalJSON() ([]byte, error) {
return b, err return b, err
} }
func (c *Client) DeleteNetwork(ctx context.Context, site, id, name string) error { //func (c *client) DeleteNetwork(ctx context.Context, site, id, name string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/networkconf/%s", site, id), struct { // err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/networkconf/%s", site, id), struct {
Name string `json:"name"` // Name string `json:"name"`
}{ // }{
Name: name, // Name: name,
}, nil) // }, nil)
// if err != nil {
// return err
// }
// return nil
//}
func (c *client) DeleteNetwork(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/networkconf/%s", site, id), nil, nil)
if err != nil { if err != nil {
return err return err
} }
return nil return nil
} }
func (c *Client) ListNetwork(ctx context.Context, site string) ([]Network, error) { func (c *client) ListNetwork(ctx context.Context, site string) ([]Network, error) {
return c.listNetwork(ctx, site) return c.listNetwork(ctx, site)
} }
func (c *Client) GetNetwork(ctx context.Context, site, id string) (*Network, error) { func (c *client) GetNetwork(ctx context.Context, site, id string) (*Network, error) {
return c.getNetwork(ctx, site, id) return c.getNetwork(ctx, site, id)
} }
func (c *Client) CreateNetwork(ctx context.Context, site string, d *Network) (*Network, error) { func (c *client) CreateNetwork(ctx context.Context, site string, d *Network) (*Network, error) {
return c.createNetwork(ctx, site, d) return c.createNetwork(ctx, site, d)
} }
func (c *Client) UpdateNetwork(ctx context.Context, site string, d *Network) (*Network, error) { func (c *client) UpdateNetwork(ctx context.Context, site string, d *Network) (*Network, error) {
return c.updateNetwork(ctx, site, d) return c.updateNetwork(ctx, site, d)
} }

View File

@@ -78,7 +78,7 @@ func (dst *PortForwardDestinationIPs) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listPortForward(ctx context.Context, site string) ([]PortForward, error) { func (c *client) listPortForward(ctx context.Context, site string) ([]PortForward, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []PortForward `json:"data"` Data []PortForward `json:"data"`
@@ -92,7 +92,7 @@ func (c *Client) listPortForward(ctx context.Context, site string) ([]PortForwar
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getPortForward(ctx context.Context, site, id string) (*PortForward, error) { func (c *client) getPortForward(ctx context.Context, site, id string) (*PortForward, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []PortForward `json:"data"` Data []PortForward `json:"data"`
@@ -111,7 +111,7 @@ func (c *Client) getPortForward(ctx context.Context, site, id string) (*PortForw
return &d, nil return &d, nil
} }
func (c *Client) deletePortForward(ctx context.Context, site, id string) error { func (c *client) deletePortForward(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/portforward/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/portforward/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -119,7 +119,7 @@ func (c *Client) deletePortForward(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createPortForward(ctx context.Context, site string, d *PortForward) (*PortForward, error) { func (c *client) createPortForward(ctx context.Context, site string, d *PortForward) (*PortForward, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []PortForward `json:"data"` Data []PortForward `json:"data"`
@@ -139,7 +139,7 @@ func (c *Client) createPortForward(ctx context.Context, site string, d *PortForw
return &new, nil return &new, nil
} }
func (c *Client) updatePortForward(ctx context.Context, site string, d *PortForward) (*PortForward, error) { func (c *client) updatePortForward(ctx context.Context, site string, d *PortForward) (*PortForward, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []PortForward `json:"data"` Data []PortForward `json:"data"`

View File

@@ -2,22 +2,22 @@ package unifi
import "context" import "context"
func (c *Client) ListPortForward(ctx context.Context, site string) ([]PortForward, error) { func (c *client) ListPortForward(ctx context.Context, site string) ([]PortForward, error) {
return c.listPortForward(ctx, site) return c.listPortForward(ctx, site)
} }
func (c *Client) GetPortForward(ctx context.Context, site, id string) (*PortForward, error) { func (c *client) GetPortForward(ctx context.Context, site, id string) (*PortForward, error) {
return c.getPortForward(ctx, site, id) return c.getPortForward(ctx, site, id)
} }
func (c *Client) DeletePortForward(ctx context.Context, site, id string) error { func (c *client) DeletePortForward(ctx context.Context, site, id string) error {
return c.deletePortForward(ctx, site, id) return c.deletePortForward(ctx, site, id)
} }
func (c *Client) CreatePortForward(ctx context.Context, site string, d *PortForward) (*PortForward, error) { func (c *client) CreatePortForward(ctx context.Context, site string, d *PortForward) (*PortForward, error) {
return c.createPortForward(ctx, site, d) return c.createPortForward(ctx, site, d)
} }
func (c *Client) UpdatePortForward(ctx context.Context, site string, d *PortForward) (*PortForward, error) { func (c *client) UpdatePortForward(ctx context.Context, site string, d *PortForward) (*PortForward, error) {
return c.updatePortForward(ctx, site, d) return c.updatePortForward(ctx, site, d)
} }

View File

@@ -220,7 +220,7 @@ func (dst *PortProfileQOSProfile) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listPortProfile(ctx context.Context, site string) ([]PortProfile, error) { func (c *client) listPortProfile(ctx context.Context, site string) ([]PortProfile, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []PortProfile `json:"data"` Data []PortProfile `json:"data"`
@@ -234,7 +234,7 @@ func (c *Client) listPortProfile(ctx context.Context, site string) ([]PortProfil
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getPortProfile(ctx context.Context, site, id string) (*PortProfile, error) { func (c *client) getPortProfile(ctx context.Context, site, id string) (*PortProfile, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []PortProfile `json:"data"` Data []PortProfile `json:"data"`
@@ -253,7 +253,7 @@ func (c *Client) getPortProfile(ctx context.Context, site, id string) (*PortProf
return &d, nil return &d, nil
} }
func (c *Client) deletePortProfile(ctx context.Context, site, id string) error { func (c *client) deletePortProfile(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/portconf/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/portconf/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -261,7 +261,7 @@ func (c *Client) deletePortProfile(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createPortProfile(ctx context.Context, site string, d *PortProfile) (*PortProfile, error) { func (c *client) createPortProfile(ctx context.Context, site string, d *PortProfile) (*PortProfile, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []PortProfile `json:"data"` Data []PortProfile `json:"data"`
@@ -281,7 +281,7 @@ func (c *Client) createPortProfile(ctx context.Context, site string, d *PortProf
return &new, nil return &new, nil
} }
func (c *Client) updatePortProfile(ctx context.Context, site string, d *PortProfile) (*PortProfile, error) { func (c *client) updatePortProfile(ctx context.Context, site string, d *PortProfile) (*PortProfile, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []PortProfile `json:"data"` Data []PortProfile `json:"data"`

View File

@@ -4,22 +4,22 @@ import (
"context" "context"
) )
func (c *Client) ListPortProfile(ctx context.Context, site string) ([]PortProfile, error) { func (c *client) ListPortProfile(ctx context.Context, site string) ([]PortProfile, error) {
return c.listPortProfile(ctx, site) return c.listPortProfile(ctx, site)
} }
func (c *Client) GetPortProfile(ctx context.Context, site, id string) (*PortProfile, error) { func (c *client) GetPortProfile(ctx context.Context, site, id string) (*PortProfile, error) {
return c.getPortProfile(ctx, site, id) return c.getPortProfile(ctx, site, id)
} }
func (c *Client) DeletePortProfile(ctx context.Context, site, id string) error { func (c *client) DeletePortProfile(ctx context.Context, site, id string) error {
return c.deletePortProfile(ctx, site, id) return c.deletePortProfile(ctx, site, id)
} }
func (c *Client) CreatePortProfile(ctx context.Context, site string, d *PortProfile) (*PortProfile, error) { func (c *client) CreatePortProfile(ctx context.Context, site string, d *PortProfile) (*PortProfile, error) {
return c.createPortProfile(ctx, site, d) return c.createPortProfile(ctx, site, d)
} }
func (c *Client) UpdatePortProfile(ctx context.Context, site string, d *PortProfile) (*PortProfile, error) { func (c *client) UpdatePortProfile(ctx context.Context, site string, d *PortProfile) (*PortProfile, error) {
return c.updatePortProfile(ctx, site, d) return c.updatePortProfile(ctx, site, d)
} }

View File

@@ -134,7 +134,7 @@ func (dst *RADIUSProfileXCaCrts) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listRADIUSProfile(ctx context.Context, site string) ([]RADIUSProfile, error) { func (c *client) listRADIUSProfile(ctx context.Context, site string) ([]RADIUSProfile, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []RADIUSProfile `json:"data"` Data []RADIUSProfile `json:"data"`
@@ -148,7 +148,7 @@ func (c *Client) listRADIUSProfile(ctx context.Context, site string) ([]RADIUSPr
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getRADIUSProfile(ctx context.Context, site, id string) (*RADIUSProfile, error) { func (c *client) getRADIUSProfile(ctx context.Context, site, id string) (*RADIUSProfile, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []RADIUSProfile `json:"data"` Data []RADIUSProfile `json:"data"`
@@ -167,7 +167,7 @@ func (c *Client) getRADIUSProfile(ctx context.Context, site, id string) (*RADIUS
return &d, nil return &d, nil
} }
func (c *Client) deleteRADIUSProfile(ctx context.Context, site, id string) error { func (c *client) deleteRADIUSProfile(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/radiusprofile/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/radiusprofile/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -175,7 +175,7 @@ func (c *Client) deleteRADIUSProfile(ctx context.Context, site, id string) error
return nil return nil
} }
func (c *Client) createRADIUSProfile(ctx context.Context, site string, d *RADIUSProfile) (*RADIUSProfile, error) { func (c *client) createRADIUSProfile(ctx context.Context, site string, d *RADIUSProfile) (*RADIUSProfile, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []RADIUSProfile `json:"data"` Data []RADIUSProfile `json:"data"`
@@ -195,7 +195,7 @@ func (c *Client) createRADIUSProfile(ctx context.Context, site string, d *RADIUS
return &new, nil return &new, nil
} }
func (c *Client) updateRADIUSProfile(ctx context.Context, site string, d *RADIUSProfile) (*RADIUSProfile, error) { func (c *client) updateRADIUSProfile(ctx context.Context, site string, d *RADIUSProfile) (*RADIUSProfile, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []RADIUSProfile `json:"data"` Data []RADIUSProfile `json:"data"`

View File

@@ -4,22 +4,22 @@ import (
"context" "context"
) )
func (c *Client) ListRADIUSProfile(ctx context.Context, site string) ([]RADIUSProfile, error) { func (c *client) ListRADIUSProfile(ctx context.Context, site string) ([]RADIUSProfile, error) {
return c.listRADIUSProfile(ctx, site) return c.listRADIUSProfile(ctx, site)
} }
func (c *Client) GetRADIUSProfile(ctx context.Context, site, id string) (*RADIUSProfile, error) { func (c *client) GetRADIUSProfile(ctx context.Context, site, id string) (*RADIUSProfile, error) {
return c.getRADIUSProfile(ctx, site, id) return c.getRADIUSProfile(ctx, site, id)
} }
func (c *Client) DeleteRADIUSProfile(ctx context.Context, site, id string) error { func (c *client) DeleteRADIUSProfile(ctx context.Context, site, id string) error {
return c.deleteRADIUSProfile(ctx, site, id) return c.deleteRADIUSProfile(ctx, site, id)
} }
func (c *Client) CreateRADIUSProfile(ctx context.Context, site string, d *RADIUSProfile) (*RADIUSProfile, error) { func (c *client) CreateRADIUSProfile(ctx context.Context, site string, d *RADIUSProfile) (*RADIUSProfile, error) {
return c.createRADIUSProfile(ctx, site, d) return c.createRADIUSProfile(ctx, site, d)
} }
func (c *Client) UpdateRADIUSProfile(ctx context.Context, site string, d *RADIUSProfile) (*RADIUSProfile, error) { func (c *client) UpdateRADIUSProfile(ctx context.Context, site string, d *RADIUSProfile) (*RADIUSProfile, error) {
return c.updateRADIUSProfile(ctx, site, d) return c.updateRADIUSProfile(ctx, site, d)
} }

View File

@@ -24,8 +24,8 @@ func marshalRequest(reqBody interface{}) (io.Reader, error) {
return bytes.NewReader(reqBytes), nil return bytes.NewReader(reqBytes), nil
} }
// buildRequestURL constructs the full URL for a given apiPath using the client's BaseURL and apiPaths. // buildRequestURL constructs the full URL for a given apiPath using the client's baseURL and apiPaths.
func (c *Client) buildRequestURL(apiPath string) (*url.URL, error) { func (c *client) buildRequestURL(apiPath string) (*url.URL, error) {
reqURL, err := url.Parse(apiPath) reqURL, err := url.Parse(apiPath)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -33,11 +33,11 @@ func (c *Client) buildRequestURL(apiPath string) (*url.URL, error) {
if !strings.HasPrefix(apiPath, "/") && !reqURL.IsAbs() { if !strings.HasPrefix(apiPath, "/") && !reqURL.IsAbs() {
reqURL.Path = path.Join(c.apiPaths.ApiPath, reqURL.Path) reqURL.Path = path.Join(c.apiPaths.ApiPath, reqURL.Path)
} }
return c.BaseURL.ResolveReference(reqURL), nil return c.baseURL.ResolveReference(reqURL), nil
} }
// validateRequestBody validates the request body if validation is enabled. // validateRequestBody validates the request body if validation is enabled.
func (c *Client) validateRequestBody(reqBody interface{}) error { func (c *client) validateRequestBody(reqBody interface{}) error {
if reqBody != nil && c.validationMode != DisableValidation { if reqBody != nil && c.validationMode != DisableValidation {
if err := c.validator.Validate(reqBody); err != nil { if err := c.validator.Validate(reqBody); err != nil {
err = fmt.Errorf("failed validating request body: %w", err) err = fmt.Errorf("failed validating request body: %w", err)
@@ -52,7 +52,7 @@ func (c *Client) validateRequestBody(reqBody interface{}) error {
} }
// newRequestContext creates a new context for the request with a timeout if specified. // newRequestContext creates a new context for the request with a timeout if specified.
func (c *Client) newRequestContext() (context.Context, context.CancelFunc) { func (c *client) newRequestContext() (context.Context, context.CancelFunc) {
ctx := context.Background() ctx := context.Background()
if c.timeout != 0 { if c.timeout != 0 {
return context.WithTimeout(ctx, c.timeout) return context.WithTimeout(ctx, c.timeout)
@@ -63,7 +63,7 @@ func (c *Client) newRequestContext() (context.Context, context.CancelFunc) {
// Do performs an HTTP request using the given method, apiPath, request body, and decodes the response into respBody. // Do performs an HTTP request using the given method, apiPath, request body, and decodes the response into respBody.
// It validates the request body, applies interceptors, and decodes the HTTP response into respBody if provided. // It validates the request body, applies interceptors, and decodes the HTTP response into respBody if provided.
// It returns an error if the request or response handling fails. // It returns an error if the request or response handling fails.
func (c *Client) Do(ctx context.Context, method, apiPath string, reqBody interface{}, respBody interface{}) error { func (c *client) Do(ctx context.Context, method, apiPath string, reqBody interface{}, respBody interface{}) error {
if err := c.validateRequestBody(reqBody); err != nil { if err := c.validateRequestBody(reqBody); err != nil {
return err return err
} }
@@ -122,27 +122,27 @@ func (c *Client) Do(ctx context.Context, method, apiPath string, reqBody interfa
// Get sends an HTTP GET request to the specified API path with the provided request body, // Get sends an HTTP GET request to the specified API path with the provided request body,
// and decodes the HTTP response into respBody. // and decodes the HTTP response into respBody.
// It is a convenience wrapper around Do. // It is a convenience wrapper around Do.
func (c *Client) Get(ctx context.Context, apiPath string, reqBody interface{}, respBody interface{}) error { func (c *client) Get(ctx context.Context, apiPath string, reqBody interface{}, respBody interface{}) error {
return c.Do(ctx, http.MethodGet, apiPath, reqBody, respBody) return c.Do(ctx, http.MethodGet, apiPath, reqBody, respBody)
} }
// Post sends an HTTP POST request to the specified API path with the provided request body, // Post sends an HTTP POST request to the specified API path with the provided request body,
// and decodes the HTTP response into respBody. // and decodes the HTTP response into respBody.
// It is a convenience wrapper around Do. // It is a convenience wrapper around Do.
func (c *Client) Post(ctx context.Context, apiPath string, reqBody interface{}, respBody interface{}) error { func (c *client) Post(ctx context.Context, apiPath string, reqBody interface{}, respBody interface{}) error {
return c.Do(ctx, http.MethodPost, apiPath, reqBody, respBody) return c.Do(ctx, http.MethodPost, apiPath, reqBody, respBody)
} }
// Put sends an HTTP PUT request to the specified API path with the provided request body, // Put sends an HTTP PUT request to the specified API path with the provided request body,
// and decodes the HTTP response into respBody. // and decodes the HTTP response into respBody.
// It is a convenience wrapper around Do. // It is a convenience wrapper around Do.
func (c *Client) Put(ctx context.Context, apiPath string, reqBody interface{}, respBody interface{}) error { func (c *client) Put(ctx context.Context, apiPath string, reqBody interface{}, respBody interface{}) error {
return c.Do(ctx, http.MethodPut, apiPath, reqBody, respBody) return c.Do(ctx, http.MethodPut, apiPath, reqBody, respBody)
} }
// Delete sends an HTTP DELETE request to the specified API path with the provided request body, // Delete sends an HTTP DELETE request to the specified API path with the provided request body,
// and decodes the HTTP response into respBody. // and decodes the HTTP response into respBody.
// It is a convenience wrapper around Do. // It is a convenience wrapper around Do.
func (c *Client) Delete(ctx context.Context, apiPath string, reqBody interface{}, respBody interface{}) error { func (c *client) Delete(ctx context.Context, apiPath string, reqBody interface{}, respBody interface{}) error {
return c.Do(ctx, http.MethodDelete, apiPath, reqBody, respBody) return c.Do(ctx, http.MethodDelete, apiPath, reqBody, respBody)
} }

View File

@@ -56,7 +56,7 @@ func (dst *Routing) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listRouting(ctx context.Context, site string) ([]Routing, error) { func (c *client) listRouting(ctx context.Context, site string) ([]Routing, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Routing `json:"data"` Data []Routing `json:"data"`
@@ -70,7 +70,7 @@ func (c *Client) listRouting(ctx context.Context, site string) ([]Routing, error
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getRouting(ctx context.Context, site, id string) (*Routing, error) { func (c *client) getRouting(ctx context.Context, site, id string) (*Routing, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Routing `json:"data"` Data []Routing `json:"data"`
@@ -89,7 +89,7 @@ func (c *Client) getRouting(ctx context.Context, site, id string) (*Routing, err
return &d, nil return &d, nil
} }
func (c *Client) deleteRouting(ctx context.Context, site, id string) error { func (c *client) deleteRouting(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/routing/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/routing/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -97,7 +97,7 @@ func (c *Client) deleteRouting(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createRouting(ctx context.Context, site string, d *Routing) (*Routing, error) { func (c *client) createRouting(ctx context.Context, site string, d *Routing) (*Routing, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Routing `json:"data"` Data []Routing `json:"data"`
@@ -117,7 +117,7 @@ func (c *Client) createRouting(ctx context.Context, site string, d *Routing) (*R
return &new, nil return &new, nil
} }
func (c *Client) updateRouting(ctx context.Context, site string, d *Routing) (*Routing, error) { func (c *client) updateRouting(ctx context.Context, site string, d *Routing) (*Routing, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Routing `json:"data"` Data []Routing `json:"data"`

View File

@@ -16,22 +16,22 @@ import (
"context" "context"
) )
func (c *Client) ListRouting(ctx context.Context, site string) ([]Routing, error) { func (c *client) ListRouting(ctx context.Context, site string) ([]Routing, error) {
return c.listRouting(ctx, site) return c.listRouting(ctx, site)
} }
func (c *Client) GetRouting(ctx context.Context, site, id string) (*Routing, error) { func (c *client) GetRouting(ctx context.Context, site, id string) (*Routing, error) {
return c.getRouting(ctx, site, id) return c.getRouting(ctx, site, id)
} }
func (c *Client) DeleteRouting(ctx context.Context, site, id string) error { func (c *client) DeleteRouting(ctx context.Context, site, id string) error {
return c.deleteRouting(ctx, site, id) return c.deleteRouting(ctx, site, id)
} }
func (c *Client) CreateRouting(ctx context.Context, site string, d *Routing) (*Routing, error) { func (c *client) CreateRouting(ctx context.Context, site string, d *Routing) (*Routing, error) {
return c.createRouting(ctx, site, d) return c.createRouting(ctx, site, d)
} }
func (c *Client) UpdateRouting(ctx context.Context, site string, d *Routing) (*Routing, error) { func (c *client) UpdateRouting(ctx context.Context, site string, d *Routing) (*Routing, error) {
return c.updateRouting(ctx, site, d) return c.updateRouting(ctx, site, d)
} }

View File

@@ -68,7 +68,7 @@ func (dst *ScheduleTaskUpgradeTargets) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listScheduleTask(ctx context.Context, site string) ([]ScheduleTask, error) { func (c *client) listScheduleTask(ctx context.Context, site string) ([]ScheduleTask, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []ScheduleTask `json:"data"` Data []ScheduleTask `json:"data"`
@@ -82,7 +82,7 @@ func (c *Client) listScheduleTask(ctx context.Context, site string) ([]ScheduleT
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getScheduleTask(ctx context.Context, site, id string) (*ScheduleTask, error) { func (c *client) getScheduleTask(ctx context.Context, site, id string) (*ScheduleTask, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []ScheduleTask `json:"data"` Data []ScheduleTask `json:"data"`
@@ -101,7 +101,7 @@ func (c *Client) getScheduleTask(ctx context.Context, site, id string) (*Schedul
return &d, nil return &d, nil
} }
func (c *Client) deleteScheduleTask(ctx context.Context, site, id string) error { func (c *client) deleteScheduleTask(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/scheduletask/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/scheduletask/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -109,7 +109,7 @@ func (c *Client) deleteScheduleTask(ctx context.Context, site, id string) error
return nil return nil
} }
func (c *Client) createScheduleTask(ctx context.Context, site string, d *ScheduleTask) (*ScheduleTask, error) { func (c *client) createScheduleTask(ctx context.Context, site string, d *ScheduleTask) (*ScheduleTask, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []ScheduleTask `json:"data"` Data []ScheduleTask `json:"data"`
@@ -129,7 +129,7 @@ func (c *Client) createScheduleTask(ctx context.Context, site string, d *Schedul
return &new, nil return &new, nil
} }
func (c *Client) updateScheduleTask(ctx context.Context, site string, d *ScheduleTask) (*ScheduleTask, error) { func (c *client) updateScheduleTask(ctx context.Context, site string, d *ScheduleTask) (*ScheduleTask, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []ScheduleTask `json:"data"` Data []ScheduleTask `json:"data"`

View File

@@ -79,7 +79,7 @@ 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) 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"`
Data []json.RawMessage `json:"data"` Data []json.RawMessage `json:"data"`

View File

@@ -47,7 +47,7 @@ func (dst *SettingAutoSpeedtest) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingAutoSpeedtest(ctx context.Context, site string) (*SettingAutoSpeedtest, error) { func (c *client) getSettingAutoSpeedtest(ctx context.Context, site string) (*SettingAutoSpeedtest, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingAutoSpeedtest `json:"data"` Data []SettingAutoSpeedtest `json:"data"`
@@ -66,7 +66,7 @@ func (c *Client) getSettingAutoSpeedtest(ctx context.Context, site string) (*Set
return &d, nil return &d, nil
} }
func (c *Client) updateSettingAutoSpeedtest(ctx context.Context, site string, d *SettingAutoSpeedtest) (*SettingAutoSpeedtest, error) { func (c *client) updateSettingAutoSpeedtest(ctx context.Context, site string, d *SettingAutoSpeedtest) (*SettingAutoSpeedtest, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingAutoSpeedtest `json:"data"` Data []SettingAutoSpeedtest `json:"data"`

View File

@@ -49,7 +49,7 @@ func (dst *SettingBaresip) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingBaresip(ctx context.Context, site string) (*SettingBaresip, error) { func (c *client) getSettingBaresip(ctx context.Context, site string) (*SettingBaresip, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingBaresip `json:"data"` Data []SettingBaresip `json:"data"`
@@ -68,7 +68,7 @@ func (c *Client) getSettingBaresip(ctx context.Context, site string) (*SettingBa
return &d, nil return &d, nil
} }
func (c *Client) updateSettingBaresip(ctx context.Context, site string, d *SettingBaresip) (*SettingBaresip, error) { func (c *client) updateSettingBaresip(ctx context.Context, site string, d *SettingBaresip) (*SettingBaresip, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingBaresip `json:"data"` Data []SettingBaresip `json:"data"`

View File

@@ -51,7 +51,7 @@ func (dst *SettingBroadcast) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingBroadcast(ctx context.Context, site string) (*SettingBroadcast, error) { func (c *client) getSettingBroadcast(ctx context.Context, site string) (*SettingBroadcast, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingBroadcast `json:"data"` Data []SettingBroadcast `json:"data"`
@@ -70,7 +70,7 @@ func (c *Client) getSettingBroadcast(ctx context.Context, site string) (*Setting
return &d, nil return &d, nil
} }
func (c *Client) updateSettingBroadcast(ctx context.Context, site string, d *SettingBroadcast) (*SettingBroadcast, error) { func (c *client) updateSettingBroadcast(ctx context.Context, site string, d *SettingBroadcast) (*SettingBroadcast, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingBroadcast `json:"data"` Data []SettingBroadcast `json:"data"`

View File

@@ -51,7 +51,7 @@ func (dst *SettingConnectivity) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingConnectivity(ctx context.Context, site string) (*SettingConnectivity, error) { func (c *client) getSettingConnectivity(ctx context.Context, site string) (*SettingConnectivity, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingConnectivity `json:"data"` Data []SettingConnectivity `json:"data"`
@@ -70,7 +70,7 @@ func (c *Client) getSettingConnectivity(ctx context.Context, site string) (*Sett
return &d, nil return &d, nil
} }
func (c *Client) updateSettingConnectivity(ctx context.Context, site string, d *SettingConnectivity) (*SettingConnectivity, error) { func (c *client) updateSettingConnectivity(ctx context.Context, site string, d *SettingConnectivity) (*SettingConnectivity, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingConnectivity `json:"data"` Data []SettingConnectivity `json:"data"`

View File

@@ -49,7 +49,7 @@ func (dst *SettingCountry) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingCountry(ctx context.Context, site string) (*SettingCountry, error) { func (c *client) getSettingCountry(ctx context.Context, site string) (*SettingCountry, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingCountry `json:"data"` Data []SettingCountry `json:"data"`
@@ -68,7 +68,7 @@ func (c *Client) getSettingCountry(ctx context.Context, site string) (*SettingCo
return &d, nil return &d, nil
} }
func (c *Client) updateSettingCountry(ctx context.Context, site string, d *SettingCountry) (*SettingCountry, error) { func (c *client) updateSettingCountry(ctx context.Context, site string, d *SettingCountry) (*SettingCountry, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingCountry `json:"data"` Data []SettingCountry `json:"data"`

View File

@@ -68,7 +68,7 @@ func (dst *SettingDashboardWidgets) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingDashboard(ctx context.Context, site string) (*SettingDashboard, error) { func (c *client) getSettingDashboard(ctx context.Context, site string) (*SettingDashboard, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingDashboard `json:"data"` Data []SettingDashboard `json:"data"`
@@ -87,7 +87,7 @@ func (c *Client) getSettingDashboard(ctx context.Context, site string) (*Setting
return &d, nil return &d, nil
} }
func (c *Client) updateSettingDashboard(ctx context.Context, site string, d *SettingDashboard) (*SettingDashboard, error) { func (c *client) updateSettingDashboard(ctx context.Context, site string, d *SettingDashboard) (*SettingDashboard, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingDashboard `json:"data"` Data []SettingDashboard `json:"data"`

View File

@@ -70,7 +70,7 @@ func (dst *SettingDohCustomServers) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingDoh(ctx context.Context, site string) (*SettingDoh, error) { func (c *client) getSettingDoh(ctx context.Context, site string) (*SettingDoh, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingDoh `json:"data"` Data []SettingDoh `json:"data"`
@@ -89,7 +89,7 @@ func (c *Client) getSettingDoh(ctx context.Context, site string) (*SettingDoh, e
return &d, nil return &d, nil
} }
func (c *Client) updateSettingDoh(ctx context.Context, site string, d *SettingDoh) (*SettingDoh, error) { func (c *client) updateSettingDoh(ctx context.Context, site string, d *SettingDoh) (*SettingDoh, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingDoh `json:"data"` Data []SettingDoh `json:"data"`

View File

@@ -47,7 +47,7 @@ func (dst *SettingDpi) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingDpi(ctx context.Context, site string) (*SettingDpi, error) { func (c *client) getSettingDpi(ctx context.Context, site string) (*SettingDpi, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingDpi `json:"data"` Data []SettingDpi `json:"data"`
@@ -66,7 +66,7 @@ func (c *Client) getSettingDpi(ctx context.Context, site string) (*SettingDpi, e
return &d, nil return &d, nil
} }
func (c *Client) updateSettingDpi(ctx context.Context, site string, d *SettingDpi) (*SettingDpi, error) { func (c *client) updateSettingDpi(ctx context.Context, site string, d *SettingDpi) (*SettingDpi, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingDpi `json:"data"` Data []SettingDpi `json:"data"`

View File

@@ -48,7 +48,7 @@ func (dst *SettingElementAdopt) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingElementAdopt(ctx context.Context, site string) (*SettingElementAdopt, error) { func (c *client) getSettingElementAdopt(ctx context.Context, site string) (*SettingElementAdopt, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingElementAdopt `json:"data"` Data []SettingElementAdopt `json:"data"`
@@ -67,7 +67,7 @@ func (c *Client) getSettingElementAdopt(ctx context.Context, site string) (*Sett
return &d, nil return &d, nil
} }
func (c *Client) updateSettingElementAdopt(ctx context.Context, site string, d *SettingElementAdopt) (*SettingElementAdopt, error) { func (c *client) updateSettingElementAdopt(ctx context.Context, site string, d *SettingElementAdopt) (*SettingElementAdopt, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingElementAdopt `json:"data"` Data []SettingElementAdopt `json:"data"`

View File

@@ -89,7 +89,7 @@ func (dst *SettingEtherLightingSpeedOverrides) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingEtherLighting(ctx context.Context, site string) (*SettingEtherLighting, error) { func (c *client) getSettingEtherLighting(ctx context.Context, site string) (*SettingEtherLighting, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingEtherLighting `json:"data"` Data []SettingEtherLighting `json:"data"`
@@ -108,7 +108,7 @@ func (c *Client) getSettingEtherLighting(ctx context.Context, site string) (*Set
return &d, nil return &d, nil
} }
func (c *Client) updateSettingEtherLighting(ctx context.Context, site string, d *SettingEtherLighting) (*SettingEtherLighting, error) { func (c *client) updateSettingEtherLighting(ctx context.Context, site string, d *SettingEtherLighting) (*SettingEtherLighting, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingEtherLighting `json:"data"` Data []SettingEtherLighting `json:"data"`

View File

@@ -46,7 +46,7 @@ func (dst *SettingEvaluationScore) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingEvaluationScore(ctx context.Context, site string) (*SettingEvaluationScore, error) { func (c *client) getSettingEvaluationScore(ctx context.Context, site string) (*SettingEvaluationScore, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingEvaluationScore `json:"data"` Data []SettingEvaluationScore `json:"data"`
@@ -65,7 +65,7 @@ func (c *Client) getSettingEvaluationScore(ctx context.Context, site string) (*S
return &d, nil return &d, nil
} }
func (c *Client) updateSettingEvaluationScore(ctx context.Context, site string, d *SettingEvaluationScore) (*SettingEvaluationScore, error) { func (c *client) updateSettingEvaluationScore(ctx context.Context, site string, d *SettingEvaluationScore) (*SettingEvaluationScore, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingEvaluationScore `json:"data"` Data []SettingEvaluationScore `json:"data"`

View File

@@ -68,7 +68,7 @@ func (dst *SettingGlobalAp) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingGlobalAp(ctx context.Context, site string) (*SettingGlobalAp, error) { func (c *client) getSettingGlobalAp(ctx context.Context, site string) (*SettingGlobalAp, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingGlobalAp `json:"data"` Data []SettingGlobalAp `json:"data"`
@@ -87,7 +87,7 @@ func (c *Client) getSettingGlobalAp(ctx context.Context, site string) (*SettingG
return &d, nil return &d, nil
} }
func (c *Client) updateSettingGlobalAp(ctx context.Context, site string, d *SettingGlobalAp) (*SettingGlobalAp, error) { func (c *client) updateSettingGlobalAp(ctx context.Context, site string, d *SettingGlobalAp) (*SettingGlobalAp, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingGlobalAp `json:"data"` Data []SettingGlobalAp `json:"data"`

View File

@@ -47,7 +47,7 @@ func (dst *SettingGlobalNat) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingGlobalNat(ctx context.Context, site string) (*SettingGlobalNat, error) { func (c *client) getSettingGlobalNat(ctx context.Context, site string) (*SettingGlobalNat, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingGlobalNat `json:"data"` Data []SettingGlobalNat `json:"data"`
@@ -66,7 +66,7 @@ func (c *Client) getSettingGlobalNat(ctx context.Context, site string) (*Setting
return &d, nil return &d, nil
} }
func (c *Client) updateSettingGlobalNat(ctx context.Context, site string, d *SettingGlobalNat) (*SettingGlobalNat, error) { func (c *client) updateSettingGlobalNat(ctx context.Context, site string, d *SettingGlobalNat) (*SettingGlobalNat, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingGlobalNat `json:"data"` Data []SettingGlobalNat `json:"data"`

View File

@@ -76,7 +76,7 @@ func (dst *SettingGlobalSwitchAclL3Isolation) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingGlobalSwitch(ctx context.Context, site string) (*SettingGlobalSwitch, error) { func (c *client) getSettingGlobalSwitch(ctx context.Context, site string) (*SettingGlobalSwitch, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingGlobalSwitch `json:"data"` Data []SettingGlobalSwitch `json:"data"`
@@ -95,7 +95,7 @@ func (c *Client) getSettingGlobalSwitch(ctx context.Context, site string) (*Sett
return &d, nil return &d, nil
} }
func (c *Client) updateSettingGlobalSwitch(ctx context.Context, site string, d *SettingGlobalSwitch) (*SettingGlobalSwitch, error) { func (c *client) updateSettingGlobalSwitch(ctx context.Context, site string, d *SettingGlobalSwitch) (*SettingGlobalSwitch, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingGlobalSwitch `json:"data"` Data []SettingGlobalSwitch `json:"data"`

View File

@@ -155,7 +155,7 @@ func (dst *SettingGuestAccess) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingGuestAccess(ctx context.Context, site string) (*SettingGuestAccess, error) { func (c *client) getSettingGuestAccess(ctx context.Context, site string) (*SettingGuestAccess, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingGuestAccess `json:"data"` Data []SettingGuestAccess `json:"data"`
@@ -174,7 +174,7 @@ func (c *Client) getSettingGuestAccess(ctx context.Context, site string) (*Setti
return &d, nil return &d, nil
} }
func (c *Client) updateSettingGuestAccess(ctx context.Context, site string, d *SettingGuestAccess) (*SettingGuestAccess, error) { func (c *client) updateSettingGuestAccess(ctx context.Context, site string, d *SettingGuestAccess) (*SettingGuestAccess, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingGuestAccess `json:"data"` Data []SettingGuestAccess `json:"data"`

View File

@@ -222,7 +222,7 @@ func (dst *SettingIpsWhitelist) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingIps(ctx context.Context, site string) (*SettingIps, error) { func (c *client) getSettingIps(ctx context.Context, site string) (*SettingIps, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingIps `json:"data"` Data []SettingIps `json:"data"`
@@ -241,7 +241,7 @@ func (c *Client) getSettingIps(ctx context.Context, site string) (*SettingIps, e
return &d, nil return &d, nil
} }
func (c *Client) updateSettingIps(ctx context.Context, site string, d *SettingIps) (*SettingIps, error) { func (c *client) updateSettingIps(ctx context.Context, site string, d *SettingIps) (*SettingIps, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingIps `json:"data"` Data []SettingIps `json:"data"`

View File

@@ -55,7 +55,7 @@ func (dst *SettingLcm) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingLcm(ctx context.Context, site string) (*SettingLcm, error) { func (c *client) getSettingLcm(ctx context.Context, site string) (*SettingLcm, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingLcm `json:"data"` Data []SettingLcm `json:"data"`
@@ -74,7 +74,7 @@ func (c *Client) getSettingLcm(ctx context.Context, site string) (*SettingLcm, e
return &d, nil return &d, nil
} }
func (c *Client) updateSettingLcm(ctx context.Context, site string, d *SettingLcm) (*SettingLcm, error) { func (c *client) updateSettingLcm(ctx context.Context, site string, d *SettingLcm) (*SettingLcm, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingLcm `json:"data"` Data []SettingLcm `json:"data"`

View File

@@ -46,7 +46,7 @@ func (dst *SettingLocale) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingLocale(ctx context.Context, site string) (*SettingLocale, error) { func (c *client) getSettingLocale(ctx context.Context, site string) (*SettingLocale, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingLocale `json:"data"` Data []SettingLocale `json:"data"`
@@ -65,7 +65,7 @@ func (c *Client) getSettingLocale(ctx context.Context, site string) (*SettingLoc
return &d, nil return &d, nil
} }
func (c *Client) updateSettingLocale(ctx context.Context, site string, d *SettingLocale) (*SettingLocale, error) { func (c *client) updateSettingLocale(ctx context.Context, site string, d *SettingLocale) (*SettingLocale, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingLocale `json:"data"` Data []SettingLocale `json:"data"`

View File

@@ -46,7 +46,7 @@ func (dst *SettingMagicSiteToSiteVpn) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingMagicSiteToSiteVpn(ctx context.Context, site string) (*SettingMagicSiteToSiteVpn, error) { func (c *client) getSettingMagicSiteToSiteVpn(ctx context.Context, site string) (*SettingMagicSiteToSiteVpn, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingMagicSiteToSiteVpn `json:"data"` Data []SettingMagicSiteToSiteVpn `json:"data"`
@@ -65,7 +65,7 @@ func (c *Client) getSettingMagicSiteToSiteVpn(ctx context.Context, site string)
return &d, nil return &d, nil
} }
func (c *Client) updateSettingMagicSiteToSiteVpn(ctx context.Context, site string, d *SettingMagicSiteToSiteVpn) (*SettingMagicSiteToSiteVpn, error) { func (c *client) updateSettingMagicSiteToSiteVpn(ctx context.Context, site string, d *SettingMagicSiteToSiteVpn) (*SettingMagicSiteToSiteVpn, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingMagicSiteToSiteVpn `json:"data"` Data []SettingMagicSiteToSiteVpn `json:"data"`

View File

@@ -93,7 +93,7 @@ func (dst *SettingMgmtXSshKeys) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingMgmt(ctx context.Context, site string) (*SettingMgmt, error) { func (c *client) getSettingMgmt(ctx context.Context, site string) (*SettingMgmt, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingMgmt `json:"data"` Data []SettingMgmt `json:"data"`
@@ -112,7 +112,7 @@ func (c *Client) getSettingMgmt(ctx context.Context, site string) (*SettingMgmt,
return &d, nil return &d, nil
} }
func (c *Client) updateSettingMgmt(ctx context.Context, site string, d *SettingMgmt) (*SettingMgmt, error) { func (c *client) updateSettingMgmt(ctx context.Context, site string, d *SettingMgmt) (*SettingMgmt, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingMgmt `json:"data"` Data []SettingMgmt `json:"data"`

View File

@@ -4,11 +4,11 @@ import (
"context" "context"
) )
func (c *Client) GetSettingMgmt(ctx context.Context, site string) (*SettingMgmt, error) { func (c *client) GetSettingMgmt(ctx context.Context, site string) (*SettingMgmt, error) {
return c.getSettingMgmt(ctx, site) return c.getSettingMgmt(ctx, site)
} }
func (c *Client) UpdateSettingMgmt(ctx context.Context, site string, d *SettingMgmt) (*SettingMgmt, error) { func (c *client) UpdateSettingMgmt(ctx context.Context, site string, d *SettingMgmt) (*SettingMgmt, error) {
d.Key = "mgmt" d.Key = "mgmt"
return c.updateSettingMgmt(ctx, site, d) return c.updateSettingMgmt(ctx, site, d)
} }

View File

@@ -69,7 +69,7 @@ func (dst *SettingNetflow) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingNetflow(ctx context.Context, site string) (*SettingNetflow, error) { func (c *client) getSettingNetflow(ctx context.Context, site string) (*SettingNetflow, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingNetflow `json:"data"` Data []SettingNetflow `json:"data"`
@@ -88,7 +88,7 @@ func (c *Client) getSettingNetflow(ctx context.Context, site string) (*SettingNe
return &d, nil return &d, nil
} }
func (c *Client) updateSettingNetflow(ctx context.Context, site string, d *SettingNetflow) (*SettingNetflow, error) { func (c *client) updateSettingNetflow(ctx context.Context, site string, d *SettingNetflow) (*SettingNetflow, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingNetflow `json:"data"` Data []SettingNetflow `json:"data"`

View File

@@ -46,7 +46,7 @@ func (dst *SettingNetworkOptimization) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingNetworkOptimization(ctx context.Context, site string) (*SettingNetworkOptimization, error) { func (c *client) getSettingNetworkOptimization(ctx context.Context, site string) (*SettingNetworkOptimization, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingNetworkOptimization `json:"data"` Data []SettingNetworkOptimization `json:"data"`
@@ -65,7 +65,7 @@ func (c *Client) getSettingNetworkOptimization(ctx context.Context, site string)
return &d, nil return &d, nil
} }
func (c *Client) updateSettingNetworkOptimization(ctx context.Context, site string, d *SettingNetworkOptimization) (*SettingNetworkOptimization, error) { func (c *client) updateSettingNetworkOptimization(ctx context.Context, site string, d *SettingNetworkOptimization) (*SettingNetworkOptimization, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingNetworkOptimization `json:"data"` Data []SettingNetworkOptimization `json:"data"`

View File

@@ -50,7 +50,7 @@ func (dst *SettingNtp) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingNtp(ctx context.Context, site string) (*SettingNtp, error) { func (c *client) getSettingNtp(ctx context.Context, site string) (*SettingNtp, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingNtp `json:"data"` Data []SettingNtp `json:"data"`
@@ -69,7 +69,7 @@ func (c *Client) getSettingNtp(ctx context.Context, site string) (*SettingNtp, e
return &d, nil return &d, nil
} }
func (c *Client) updateSettingNtp(ctx context.Context, site string, d *SettingNtp) (*SettingNtp, error) { func (c *client) updateSettingNtp(ctx context.Context, site string, d *SettingNtp) (*SettingNtp, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingNtp `json:"data"` Data []SettingNtp `json:"data"`

View File

@@ -46,7 +46,7 @@ func (dst *SettingPorta) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingPorta(ctx context.Context, site string) (*SettingPorta, error) { func (c *client) getSettingPorta(ctx context.Context, site string) (*SettingPorta, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingPorta `json:"data"` Data []SettingPorta `json:"data"`
@@ -65,7 +65,7 @@ func (c *Client) getSettingPorta(ctx context.Context, site string) (*SettingPort
return &d, nil return &d, nil
} }
func (c *Client) updateSettingPorta(ctx context.Context, site string, d *SettingPorta) (*SettingPorta, error) { func (c *client) updateSettingPorta(ctx context.Context, site string, d *SettingPorta) (*SettingPorta, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingPorta `json:"data"` Data []SettingPorta `json:"data"`

View File

@@ -53,7 +53,7 @@ func (dst *SettingProviderCapabilities) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingProviderCapabilities(ctx context.Context, site string) (*SettingProviderCapabilities, error) { func (c *client) getSettingProviderCapabilities(ctx context.Context, site string) (*SettingProviderCapabilities, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"Meta"` Meta Meta `json:"Meta"`
Data []SettingProviderCapabilities `json:"data"` Data []SettingProviderCapabilities `json:"data"`
@@ -72,7 +72,7 @@ func (c *Client) getSettingProviderCapabilities(ctx context.Context, site string
return &d, nil return &d, nil
} }
func (c *Client) updateSettingProviderCapabilities(ctx context.Context, site string, d *SettingProviderCapabilities) (*SettingProviderCapabilities, error) { func (c *client) updateSettingProviderCapabilities(ctx context.Context, site string, d *SettingProviderCapabilities) (*SettingProviderCapabilities, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"Meta"` Meta Meta `json:"Meta"`
Data []SettingProviderCapabilities `json:"data"` Data []SettingProviderCapabilities `json:"data"`

View File

@@ -113,7 +113,7 @@ func (dst *SettingRadioAiChannelsBlacklist) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingRadioAi(ctx context.Context, site string) (*SettingRadioAi, error) { func (c *client) getSettingRadioAi(ctx context.Context, site string) (*SettingRadioAi, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingRadioAi `json:"data"` Data []SettingRadioAi `json:"data"`
@@ -132,7 +132,7 @@ func (c *Client) getSettingRadioAi(ctx context.Context, site string) (*SettingRa
return &d, nil return &d, nil
} }
func (c *Client) updateSettingRadioAi(ctx context.Context, site string, d *SettingRadioAi) (*SettingRadioAi, error) { func (c *client) updateSettingRadioAi(ctx context.Context, site string, d *SettingRadioAi) (*SettingRadioAi, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingRadioAi `json:"data"` Data []SettingRadioAi `json:"data"`

View File

@@ -60,7 +60,7 @@ func (dst *SettingRadius) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingRadius(ctx context.Context, site string) (*SettingRadius, error) { func (c *client) getSettingRadius(ctx context.Context, site string) (*SettingRadius, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingRadius `json:"data"` Data []SettingRadius `json:"data"`
@@ -79,7 +79,7 @@ func (c *Client) getSettingRadius(ctx context.Context, site string) (*SettingRad
return &d, nil return &d, nil
} }
func (c *Client) updateSettingRadius(ctx context.Context, site string, d *SettingRadius) (*SettingRadius, error) { func (c *client) updateSettingRadius(ctx context.Context, site string, d *SettingRadius) (*SettingRadius, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingRadius `json:"data"` Data []SettingRadius `json:"data"`

View File

@@ -4,10 +4,10 @@ import (
"context" "context"
) )
func (c *Client) GetSettingRadius(ctx context.Context, site string) (*SettingRadius, error) { func (c *client) GetSettingRadius(ctx context.Context, site string) (*SettingRadius, error) {
return c.getSettingRadius(ctx, site) return c.getSettingRadius(ctx, site)
} }
func (c *Client) UpdateSettingRadius(ctx context.Context, site string, d *SettingRadius) (*SettingRadius, error) { func (c *client) UpdateSettingRadius(ctx context.Context, site string, d *SettingRadius) (*SettingRadius, error) {
return c.updateSettingRadius(ctx, site, d) return c.updateSettingRadius(ctx, site, d)
} }

View File

@@ -61,7 +61,7 @@ func (dst *SettingRsyslogd) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingRsyslogd(ctx context.Context, site string) (*SettingRsyslogd, error) { func (c *client) getSettingRsyslogd(ctx context.Context, site string) (*SettingRsyslogd, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingRsyslogd `json:"data"` Data []SettingRsyslogd `json:"data"`
@@ -80,7 +80,7 @@ func (c *Client) getSettingRsyslogd(ctx context.Context, site string) (*SettingR
return &d, nil return &d, nil
} }
func (c *Client) updateSettingRsyslogd(ctx context.Context, site string, d *SettingRsyslogd) (*SettingRsyslogd, error) { func (c *client) updateSettingRsyslogd(ctx context.Context, site string, d *SettingRsyslogd) (*SettingRsyslogd, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingRsyslogd `json:"data"` Data []SettingRsyslogd `json:"data"`

View File

@@ -50,7 +50,7 @@ func (dst *SettingSnmp) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingSnmp(ctx context.Context, site string) (*SettingSnmp, error) { func (c *client) getSettingSnmp(ctx context.Context, site string) (*SettingSnmp, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSnmp `json:"data"` Data []SettingSnmp `json:"data"`
@@ -69,7 +69,7 @@ func (c *Client) getSettingSnmp(ctx context.Context, site string) (*SettingSnmp,
return &d, nil return &d, nil
} }
func (c *Client) updateSettingSnmp(ctx context.Context, site string, d *SettingSnmp) (*SettingSnmp, error) { func (c *client) updateSettingSnmp(ctx context.Context, site string, d *SettingSnmp) (*SettingSnmp, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSnmp `json:"data"` Data []SettingSnmp `json:"data"`

View File

@@ -46,7 +46,7 @@ func (dst *SettingSslInspection) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingSslInspection(ctx context.Context, site string) (*SettingSslInspection, error) { func (c *client) getSettingSslInspection(ctx context.Context, site string) (*SettingSslInspection, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSslInspection `json:"data"` Data []SettingSslInspection `json:"data"`
@@ -65,7 +65,7 @@ func (c *Client) getSettingSslInspection(ctx context.Context, site string) (*Set
return &d, nil return &d, nil
} }
func (c *Client) updateSettingSslInspection(ctx context.Context, site string, d *SettingSslInspection) (*SettingSslInspection, error) { func (c *client) updateSettingSslInspection(ctx context.Context, site string, d *SettingSslInspection) (*SettingSslInspection, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSslInspection `json:"data"` Data []SettingSslInspection `json:"data"`

View File

@@ -52,7 +52,7 @@ func (dst *SettingSuperCloudaccess) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingSuperCloudaccess(ctx context.Context, site string) (*SettingSuperCloudaccess, error) { func (c *client) getSettingSuperCloudaccess(ctx context.Context, site string) (*SettingSuperCloudaccess, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSuperCloudaccess `json:"data"` Data []SettingSuperCloudaccess `json:"data"`
@@ -71,7 +71,7 @@ func (c *Client) getSettingSuperCloudaccess(ctx context.Context, site string) (*
return &d, nil return &d, nil
} }
func (c *Client) updateSettingSuperCloudaccess(ctx context.Context, site string, d *SettingSuperCloudaccess) (*SettingSuperCloudaccess, error) { func (c *client) updateSettingSuperCloudaccess(ctx context.Context, site string, d *SettingSuperCloudaccess) (*SettingSuperCloudaccess, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSuperCloudaccess `json:"data"` Data []SettingSuperCloudaccess `json:"data"`

View File

@@ -46,7 +46,7 @@ func (dst *SettingSuperEvents) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingSuperEvents(ctx context.Context, site string) (*SettingSuperEvents, error) { func (c *client) getSettingSuperEvents(ctx context.Context, site string) (*SettingSuperEvents, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSuperEvents `json:"data"` Data []SettingSuperEvents `json:"data"`
@@ -65,7 +65,7 @@ func (c *Client) getSettingSuperEvents(ctx context.Context, site string) (*Setti
return &d, nil return &d, nil
} }
func (c *Client) updateSettingSuperEvents(ctx context.Context, site string, d *SettingSuperEvents) (*SettingSuperEvents, error) { func (c *client) updateSettingSuperEvents(ctx context.Context, site string, d *SettingSuperEvents) (*SettingSuperEvents, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSuperEvents `json:"data"` Data []SettingSuperEvents `json:"data"`

View File

@@ -48,7 +48,7 @@ func (dst *SettingSuperFwupdate) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingSuperFwupdate(ctx context.Context, site string) (*SettingSuperFwupdate, error) { func (c *client) getSettingSuperFwupdate(ctx context.Context, site string) (*SettingSuperFwupdate, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSuperFwupdate `json:"data"` Data []SettingSuperFwupdate `json:"data"`
@@ -67,7 +67,7 @@ func (c *Client) getSettingSuperFwupdate(ctx context.Context, site string) (*Set
return &d, nil return &d, nil
} }
func (c *Client) updateSettingSuperFwupdate(ctx context.Context, site string, d *SettingSuperFwupdate) (*SettingSuperFwupdate, error) { func (c *client) updateSettingSuperFwupdate(ctx context.Context, site string, d *SettingSuperFwupdate) (*SettingSuperFwupdate, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSuperFwupdate `json:"data"` Data []SettingSuperFwupdate `json:"data"`

View File

@@ -47,7 +47,7 @@ func (dst *SettingSuperIdentity) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingSuperIdentity(ctx context.Context, site string) (*SettingSuperIdentity, error) { func (c *client) getSettingSuperIdentity(ctx context.Context, site string) (*SettingSuperIdentity, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSuperIdentity `json:"data"` Data []SettingSuperIdentity `json:"data"`
@@ -66,7 +66,7 @@ func (c *Client) getSettingSuperIdentity(ctx context.Context, site string) (*Set
return &d, nil return &d, nil
} }
func (c *Client) updateSettingSuperIdentity(ctx context.Context, site string, d *SettingSuperIdentity) (*SettingSuperIdentity, error) { func (c *client) updateSettingSuperIdentity(ctx context.Context, site string, d *SettingSuperIdentity) (*SettingSuperIdentity, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSuperIdentity `json:"data"` Data []SettingSuperIdentity `json:"data"`

View File

@@ -46,7 +46,7 @@ func (dst *SettingSuperMail) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingSuperMail(ctx context.Context, site string) (*SettingSuperMail, error) { func (c *client) getSettingSuperMail(ctx context.Context, site string) (*SettingSuperMail, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSuperMail `json:"data"` Data []SettingSuperMail `json:"data"`
@@ -65,7 +65,7 @@ func (c *Client) getSettingSuperMail(ctx context.Context, site string) (*Setting
return &d, nil return &d, nil
} }
func (c *Client) updateSettingSuperMail(ctx context.Context, site string, d *SettingSuperMail) (*SettingSuperMail, error) { func (c *client) updateSettingSuperMail(ctx context.Context, site string, d *SettingSuperMail) (*SettingSuperMail, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSuperMail `json:"data"` Data []SettingSuperMail `json:"data"`

View File

@@ -111,7 +111,7 @@ func (dst *SettingSuperMgmt) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingSuperMgmt(ctx context.Context, site string) (*SettingSuperMgmt, error) { func (c *client) getSettingSuperMgmt(ctx context.Context, site string) (*SettingSuperMgmt, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSuperMgmt `json:"data"` Data []SettingSuperMgmt `json:"data"`
@@ -130,7 +130,7 @@ func (c *Client) getSettingSuperMgmt(ctx context.Context, site string) (*Setting
return &d, nil return &d, nil
} }
func (c *Client) updateSettingSuperMgmt(ctx context.Context, site string, d *SettingSuperMgmt) (*SettingSuperMgmt, error) { func (c *client) updateSettingSuperMgmt(ctx context.Context, site string, d *SettingSuperMgmt) (*SettingSuperMgmt, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSuperMgmt `json:"data"` Data []SettingSuperMgmt `json:"data"`

View File

@@ -51,7 +51,7 @@ func (dst *SettingSuperSdn) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingSuperSdn(ctx context.Context, site string) (*SettingSuperSdn, error) { func (c *client) getSettingSuperSdn(ctx context.Context, site string) (*SettingSuperSdn, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSuperSdn `json:"data"` Data []SettingSuperSdn `json:"data"`
@@ -70,7 +70,7 @@ func (c *Client) getSettingSuperSdn(ctx context.Context, site string) (*SettingS
return &d, nil return &d, nil
} }
func (c *Client) updateSettingSuperSdn(ctx context.Context, site string, d *SettingSuperSdn) (*SettingSuperSdn, error) { func (c *client) updateSettingSuperSdn(ctx context.Context, site string, d *SettingSuperSdn) (*SettingSuperSdn, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSuperSdn `json:"data"` Data []SettingSuperSdn `json:"data"`

View File

@@ -57,7 +57,7 @@ func (dst *SettingSuperSmtp) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingSuperSmtp(ctx context.Context, site string) (*SettingSuperSmtp, error) { func (c *client) getSettingSuperSmtp(ctx context.Context, site string) (*SettingSuperSmtp, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSuperSmtp `json:"data"` Data []SettingSuperSmtp `json:"data"`
@@ -76,7 +76,7 @@ func (c *Client) getSettingSuperSmtp(ctx context.Context, site string) (*Setting
return &d, nil return &d, nil
} }
func (c *Client) updateSettingSuperSmtp(ctx context.Context, site string, d *SettingSuperSmtp) (*SettingSuperSmtp, error) { func (c *client) updateSettingSuperSmtp(ctx context.Context, site string, d *SettingSuperSmtp) (*SettingSuperSmtp, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingSuperSmtp `json:"data"` Data []SettingSuperSmtp `json:"data"`

View File

@@ -47,7 +47,7 @@ func (dst *SettingTeleport) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingTeleport(ctx context.Context, site string) (*SettingTeleport, error) { func (c *client) getSettingTeleport(ctx context.Context, site string) (*SettingTeleport, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingTeleport `json:"data"` Data []SettingTeleport `json:"data"`
@@ -66,7 +66,7 @@ func (c *Client) getSettingTeleport(ctx context.Context, site string) (*SettingT
return &d, nil return &d, nil
} }
func (c *Client) updateSettingTeleport(ctx context.Context, site string, d *SettingTeleport) (*SettingTeleport, error) { func (c *client) updateSettingTeleport(ctx context.Context, site string, d *SettingTeleport) (*SettingTeleport, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingTeleport `json:"data"` Data []SettingTeleport `json:"data"`

View File

@@ -158,7 +158,7 @@ func (dst *SettingUsgDNSVerification) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingUsg(ctx context.Context, site string) (*SettingUsg, error) { func (c *client) getSettingUsg(ctx context.Context, site string) (*SettingUsg, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingUsg `json:"data"` Data []SettingUsg `json:"data"`
@@ -177,7 +177,7 @@ func (c *Client) getSettingUsg(ctx context.Context, site string) (*SettingUsg, e
return &d, nil return &d, nil
} }
func (c *Client) updateSettingUsg(ctx context.Context, site string, d *SettingUsg) (*SettingUsg, error) { func (c *client) updateSettingUsg(ctx context.Context, site string, d *SettingUsg) (*SettingUsg, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingUsg `json:"data"` Data []SettingUsg `json:"data"`

View File

@@ -4,10 +4,10 @@ import (
"context" "context"
) )
func (c *Client) GetSettingUsg(ctx context.Context, site string) (*SettingUsg, error) { func (c *client) GetSettingUsg(ctx context.Context, site string) (*SettingUsg, error) {
return c.getSettingUsg(ctx, site) return c.getSettingUsg(ctx, site)
} }
func (c *Client) UpdateSettingUsg(ctx context.Context, site string, d *SettingUsg) (*SettingUsg, error) { func (c *client) UpdateSettingUsg(ctx context.Context, site string, d *SettingUsg) (*SettingUsg, error) {
return c.updateSettingUsg(ctx, site, d) return c.updateSettingUsg(ctx, site, d)
} }

View File

@@ -46,7 +46,7 @@ func (dst *SettingUsw) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) getSettingUsw(ctx context.Context, site string) (*SettingUsw, error) { func (c *client) getSettingUsw(ctx context.Context, site string) (*SettingUsw, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingUsw `json:"data"` Data []SettingUsw `json:"data"`
@@ -65,7 +65,7 @@ func (c *Client) getSettingUsw(ctx context.Context, site string) (*SettingUsw, e
return &d, nil return &d, nil
} }
func (c *Client) updateSettingUsw(ctx context.Context, site string, d *SettingUsw) (*SettingUsw, error) { func (c *client) updateSettingUsw(ctx context.Context, site string, d *SettingUsw) (*SettingUsw, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SettingUsw `json:"data"` Data []SettingUsw `json:"data"`

View File

@@ -19,7 +19,7 @@ type Site struct {
// Role string `json:"role"` // Role string `json:"role"`
} }
func (c *Client) ListSites(ctx context.Context) ([]Site, error) { func (c *client) ListSites(ctx context.Context) ([]Site, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"Meta"` Meta Meta `json:"Meta"`
Data []Site `json:"data"` Data []Site `json:"data"`
@@ -33,7 +33,7 @@ func (c *Client) ListSites(ctx context.Context) ([]Site, error) {
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) GetSite(ctx context.Context, id string) (*Site, error) { func (c *client) GetSite(ctx context.Context, id string) (*Site, error) {
sites, err := c.ListSites(ctx) sites, err := c.ListSites(ctx)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -48,7 +48,7 @@ func (c *Client) GetSite(ctx context.Context, id string) (*Site, error) {
return nil, ErrNotFound return nil, ErrNotFound
} }
func (c *Client) CreateSite(ctx context.Context, description string) ([]Site, error) { func (c *client) CreateSite(ctx context.Context, description string) ([]Site, error) {
reqBody := struct { reqBody := struct {
Cmd string `json:"cmd"` Cmd string `json:"cmd"`
Desc string `json:"desc"` Desc string `json:"desc"`
@@ -70,7 +70,7 @@ func (c *Client) CreateSite(ctx context.Context, description string) ([]Site, er
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) DeleteSite(ctx context.Context, id string) ([]Site, error) { func (c *client) DeleteSite(ctx context.Context, id string) ([]Site, error) {
reqBody := struct { reqBody := struct {
Cmd string `json:"cmd"` Cmd string `json:"cmd"`
Site string `json:"site"` Site string `json:"site"`
@@ -92,7 +92,7 @@ func (c *Client) DeleteSite(ctx context.Context, id string) ([]Site, error) {
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) UpdateSite(ctx context.Context, name, description string) ([]Site, error) { func (c *client) UpdateSite(ctx context.Context, name, description string) ([]Site, error) {
reqBody := struct { reqBody := struct {
Cmd string `json:"cmd"` Cmd string `json:"cmd"`
Desc string `json:"desc"` Desc string `json:"desc"`

View File

@@ -88,7 +88,7 @@ func (dst *SpatialRecordPosition) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listSpatialRecord(ctx context.Context, site string) ([]SpatialRecord, error) { func (c *client) listSpatialRecord(ctx context.Context, site string) ([]SpatialRecord, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SpatialRecord `json:"data"` Data []SpatialRecord `json:"data"`
@@ -102,7 +102,7 @@ func (c *Client) listSpatialRecord(ctx context.Context, site string) ([]SpatialR
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getSpatialRecord(ctx context.Context, site, id string) (*SpatialRecord, error) { func (c *client) getSpatialRecord(ctx context.Context, site, id string) (*SpatialRecord, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SpatialRecord `json:"data"` Data []SpatialRecord `json:"data"`
@@ -121,7 +121,7 @@ func (c *Client) getSpatialRecord(ctx context.Context, site, id string) (*Spatia
return &d, nil return &d, nil
} }
func (c *Client) deleteSpatialRecord(ctx context.Context, site, id string) error { func (c *client) deleteSpatialRecord(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/spatialrecord/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/spatialrecord/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -129,7 +129,7 @@ func (c *Client) deleteSpatialRecord(ctx context.Context, site, id string) error
return nil return nil
} }
func (c *Client) createSpatialRecord(ctx context.Context, site string, d *SpatialRecord) (*SpatialRecord, error) { func (c *client) createSpatialRecord(ctx context.Context, site string, d *SpatialRecord) (*SpatialRecord, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SpatialRecord `json:"data"` Data []SpatialRecord `json:"data"`
@@ -149,7 +149,7 @@ func (c *Client) createSpatialRecord(ctx context.Context, site string, d *Spatia
return &new, nil return &new, nil
} }
func (c *Client) updateSpatialRecord(ctx context.Context, site string, d *SpatialRecord) (*SpatialRecord, error) { func (c *client) updateSpatialRecord(ctx context.Context, site string, d *SpatialRecord) (*SpatialRecord, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []SpatialRecord `json:"data"` Data []SpatialRecord `json:"data"`

View File

@@ -74,7 +74,7 @@ type SysInfo struct {
} }
// GetSystemInfo retrieves system info using the new API. // GetSystemInfo retrieves system info using the new API.
func (c *Client) GetSystemInfo(ctx context.Context, id string) (*SysInfo, error) { func (c *client) GetSystemInfo(ctx context.Context, id string) (*SysInfo, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"Meta"` Meta Meta `json:"Meta"`
Data []SysInfo `json:"data"` Data []SysInfo `json:"data"`
@@ -100,7 +100,7 @@ type serverInfo struct {
} }
// getOldSysInfo retrieves system information using the old API style. // getOldSysInfo retrieves system information using the old API style.
func (c *Client) getOldSysInfo(ctx context.Context) (*SysInfo, error) { func (c *client) getOldSysInfo(ctx context.Context) (*SysInfo, error) {
var response struct { var response struct {
Data serverInfo `json:"Meta"` Data serverInfo `json:"Meta"`
} }
@@ -116,7 +116,7 @@ func (c *Client) getOldSysInfo(ctx context.Context) (*SysInfo, error) {
} }
// GetSystemInformation retrieves system information, trying the new API first and falling back to the old API if necessary. // GetSystemInformation retrieves system information, trying the new API first and falling back to the old API if necessary.
func (c *Client) GetSystemInformation() (*SysInfo, error) { func (c *client) GetSystemInformation() (*SysInfo, error) {
ctx, cancel := c.newRequestContext() ctx, cancel := c.newRequestContext()
defer cancel() defer cancel()

10
unifi/tag.generated.go generated
View File

@@ -45,7 +45,7 @@ func (dst *Tag) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listTag(ctx context.Context, site string) ([]Tag, error) { func (c *client) listTag(ctx context.Context, site string) ([]Tag, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Tag `json:"data"` Data []Tag `json:"data"`
@@ -59,7 +59,7 @@ func (c *Client) listTag(ctx context.Context, site string) ([]Tag, error) {
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getTag(ctx context.Context, site, id string) (*Tag, error) { func (c *client) getTag(ctx context.Context, site, id string) (*Tag, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Tag `json:"data"` Data []Tag `json:"data"`
@@ -78,7 +78,7 @@ func (c *Client) getTag(ctx context.Context, site, id string) (*Tag, error) {
return &d, nil return &d, nil
} }
func (c *Client) deleteTag(ctx context.Context, site, id string) error { func (c *client) deleteTag(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/tag/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/tag/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -86,7 +86,7 @@ func (c *Client) deleteTag(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createTag(ctx context.Context, site string, d *Tag) (*Tag, error) { func (c *client) createTag(ctx context.Context, site string, d *Tag) (*Tag, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Tag `json:"data"` Data []Tag `json:"data"`
@@ -106,7 +106,7 @@ func (c *Client) createTag(ctx context.Context, site string, d *Tag) (*Tag, erro
return &new, nil return &new, nil
} }
func (c *Client) updateTag(ctx context.Context, site string, d *Tag) (*Tag, error) { func (c *client) updateTag(ctx context.Context, site string, d *Tag) (*Tag, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []Tag `json:"data"` Data []Tag `json:"data"`

View File

@@ -2,7 +2,7 @@ package unifi
// DEPRECATED: The content of this file has been refactored and split into separate files to improve maintainability and readability. // DEPRECATED: The content of this file has been refactored and split into separate files to improve maintainability and readability.
// Please refer to the following files for the actual implementation: // Please refer to the following files for the actual implementation:
// - client.go: contains Client, ClientConfig, Credentials, newClientInternal, NewClient, NewBareClient etc. // - client.go: contains client, ClientConfig, Credentials, newClientInternal, NewClient, NewBareClient etc.
// - api_paths.go: contains API path constants and ApiPaths struct definitions. // - api_paths.go: contains API path constants and ApiPaths struct definitions.
// - interceptors.go: contains interceptor interface and implementations (ApiKeyAuthInterceptor, CsrfInterceptor, DefaultHeadersInterceptor). // - interceptors.go: contains interceptor interface and implementations (ApiKeyAuthInterceptor, CsrfInterceptor, DefaultHeadersInterceptor).
// - requests.go: contains request handling functions (marshalRequest, createRequestURL, Do, Get, Post, Put, Delete, etc.). // - requests.go: contains request handling functions (marshalRequest, createRequestURL, Do, Get, Post, Put, Delete, etc.).

View File

@@ -24,7 +24,7 @@ const (
) )
// verifyInterceptorPresence checks each expected interceptor type for presence or absence in the client. // verifyInterceptorPresence checks each expected interceptor type for presence or absence in the client.
func verifyInterceptorPresence(a *assert.Assertions, c *Client, interceptors []interface{}, shouldExist bool) { func verifyInterceptorPresence(a *assert.Assertions, c *client, interceptors []interface{}, shouldExist bool) {
expectedTypes := make([]reflect.Type, 0, len(interceptors)) expectedTypes := make([]reflect.Type, 0, len(interceptors))
for _, i := range interceptors { for _, i := range interceptors {
expectedTypes = append(expectedTypes, reflect.TypeOf(i)) expectedTypes = append(expectedTypes, reflect.TypeOf(i))
@@ -49,14 +49,14 @@ func verifyInterceptorPresence(a *assert.Assertions, c *Client, interceptors []i
func TestNewBareClient(t *testing.T) { func TestNewBareClient(t *testing.T) {
t.Parallel() t.Parallel()
a := assert.New(t) a := assert.New(t)
c, err := NewBareClient(&ClientConfig{ c, err := newBareClient(&ClientConfig{
URL: localUrl, URL: localUrl,
User: "admin", User: "admin",
Pass: "password", Pass: "password",
VerifySSL: false, VerifySSL: false,
}) })
require.Error(t, err) require.Error(t, err)
a.EqualValues(localUrl, c.BaseURL.String()) a.EqualValues(localUrl, c.BaseURL())
a.Contains(err.Error(), "connection refused", "an invalid destination should produce a connection error.") a.Contains(err.Error(), "connection refused", "an invalid destination should produce a connection error.")
verifyInterceptorPresence(a, c, []interface{}{&CSRFInterceptor{}, &DefaultHeadersInterceptor{}}, true) verifyInterceptorPresence(a, c, []interface{}{&CSRFInterceptor{}, &DefaultHeadersInterceptor{}}, true)
verifyInterceptorPresence(a, c, []interface{}{&APIKeyAuthInterceptor{}}, false) verifyInterceptorPresence(a, c, []interface{}{&APIKeyAuthInterceptor{}}, false)
@@ -66,7 +66,7 @@ func TestNewClientWithApiKey(t *testing.T) {
t.Parallel() t.Parallel()
a := assert.New(t) a := assert.New(t)
// when // when
c, err := NewClient(&ClientConfig{ c, err := newBareClient(&ClientConfig{
URL: localUrl, URL: localUrl,
APIKey: "test", APIKey: "test",
VerifySSL: false, VerifySSL: false,
@@ -74,7 +74,7 @@ func TestNewClientWithApiKey(t *testing.T) {
// then // then
require.Error(t, err) require.Error(t, err)
a.EqualValues(localUrl, c.BaseURL.String()) a.EqualValues(localUrl, c.BaseURL())
a.Contains(err.Error(), "connection refused", "an invalid destination should produce a connection error.") a.Contains(err.Error(), "connection refused", "an invalid destination should produce a connection error.")
verifyInterceptorPresence(a, c, []interface{}{&APIKeyAuthInterceptor{}, &DefaultHeadersInterceptor{}}, true) verifyInterceptorPresence(a, c, []interface{}{&APIKeyAuthInterceptor{}, &DefaultHeadersInterceptor{}}, true)
verifyInterceptorPresence(a, c, []interface{}{&CSRFInterceptor{}}, false) verifyInterceptorPresence(a, c, []interface{}{&CSRFInterceptor{}}, false)
@@ -148,9 +148,9 @@ func (i *TestInterceptor) AsList() []ClientInterceptor {
return []ClientInterceptor{i} return []ClientInterceptor{i}
} }
func NewTestClientWithInterceptor() (*Client, *TestInterceptor) { func newTestClientWithInterceptor() (*client, *TestInterceptor) {
interceptor := NewTestInterceptor() interceptor := NewTestInterceptor()
c, _ := NewClient(&ClientConfig{ c, _ := newBareClient(&ClientConfig{
URL: testUrl, URL: testUrl,
APIKey: "test-key", APIKey: "test-key",
Interceptors: interceptor.AsList(), Interceptors: interceptor.AsList(),
@@ -161,9 +161,9 @@ func NewTestClientWithInterceptor() (*Client, *TestInterceptor) {
// runClientGetRequest creates a new test client, performs a GET request, // runClientGetRequest creates a new test client, performs a GET request,
// asserts that an error occurred, and returns the client and its interceptor. // asserts that an error occurred, and returns the client and its interceptor.
func runClientGetRequest(t *testing.T, path string, data interface{}) (*Client, *TestInterceptor) { func runClientGetRequest(t *testing.T, path string, data interface{}) (*client, *TestInterceptor) {
t.Helper() t.Helper()
c, interceptor := NewTestClientWithInterceptor() c, interceptor := newTestClientWithInterceptor()
err := c.Get(context.Background(), path, data, nil) err := c.Get(context.Background(), path, data, nil)
require.Error(t, err) require.Error(t, err)
return c, interceptor return c, interceptor
@@ -171,9 +171,9 @@ func runClientGetRequest(t *testing.T, path string, data interface{}) (*Client,
// runClientRequest creates a new test client, performs a request with the given method, // runClientRequest creates a new test client, performs a request with the given method,
// asserts that an error occurred, and returns the client and its interceptor. // asserts that an error occurred, and returns the client and its interceptor.
func runClientRequest(t *testing.T, method, path string, body interface{}) (*Client, *TestInterceptor) { func runClientRequest(t *testing.T, method, path string, body interface{}) (*client, *TestInterceptor) {
t.Helper() t.Helper()
c, interceptor := NewTestClientWithInterceptor() c, interceptor := newTestClientWithInterceptor()
err := c.Do(context.Background(), method, path, body, nil) err := c.Do(context.Background(), method, path, body, nil)
require.Error(t, err) require.Error(t, err)
return c, interceptor return c, interceptor
@@ -196,7 +196,7 @@ func TestRequestInterceptorBehavior(t *testing.T) {
for _, tc := range tests { for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
c, interceptor := NewTestClientWithInterceptor() c, interceptor := newTestClientWithInterceptor()
interceptor.failOnRequest = tc.failOnRequest interceptor.failOnRequest = tc.failOnRequest
err := c.Get(context.Background(), "/", nil, nil) err := c.Get(context.Background(), "/", nil, nil)
require.Error(t, err) require.Error(t, err)
@@ -311,7 +311,7 @@ func TestUnifiIntegrationUserPassInjected(t *testing.T) {
// given // given
srv := runTestServer(NewStyleAPI.LoginPath) srv := runTestServer(NewStyleAPI.LoginPath)
interceptor := NewTestInterceptor() interceptor := NewTestInterceptor()
c, _ := NewClient(&ClientConfig{ c, _ := newBareClient(&ClientConfig{
URL: srv.URL, URL: srv.URL,
User: "test-user", User: "test-user",
Pass: "test-pass", Pass: "test-pass",
@@ -336,7 +336,7 @@ func TestResponseDataHandling(t *testing.T) {
Data: "request", Data: "request",
} }
srv := runTestServer(NewStyleAPI.ApiPath + "/test") srv := runTestServer(NewStyleAPI.ApiPath + "/test")
c, _ := NewClient(&ClientConfig{ c, _ := newBareClient(&ClientConfig{
URL: srv.URL, URL: srv.URL,
APIKey: "test-key", APIKey: "test-key",
}) })
@@ -357,7 +357,7 @@ func TestCsrfHandling(t *testing.T) {
// given // given
srv := runTestServer("") srv := runTestServer("")
interceptor := NewTestInterceptor() interceptor := NewTestInterceptor()
c, _ := NewClient(&ClientConfig{ c, _ := newBareClient(&ClientConfig{
URL: srv.URL, URL: srv.URL,
User: "test-user", User: "test-user",
Pass: "test-pass", Pass: "test-pass",
@@ -386,7 +386,7 @@ func TestOverrideUserAgent(t *testing.T) {
a := assert.New(t) a := assert.New(t)
// given // given
interceptor := NewTestInterceptor() interceptor := NewTestInterceptor()
c, _ := NewClient(&ClientConfig{ c, _ := newBareClient(&ClientConfig{
URL: testUrl, URL: testUrl,
APIKey: "test-key", APIKey: "test-key",
Interceptors: interceptor.AsList(), Interceptors: interceptor.AsList(),
@@ -556,7 +556,7 @@ func TestValidationModes(t *testing.T) {
a := assert.New(t) a := assert.New(t)
// given // given
interceptor := NewTestInterceptor() interceptor := NewTestInterceptor()
c, _ := NewClient(&ClientConfig{ c, _ := newBareClient(&ClientConfig{
URL: testUrl, URL: testUrl,
APIKey: "test-key", APIKey: "test-key",
Interceptors: []ClientInterceptor{interceptor}, Interceptors: []ClientInterceptor{interceptor},
@@ -693,7 +693,7 @@ func TestDetermineApiStyle_InvalidStatus(t *testing.T) {
func TestRegisterInterceptor(t *testing.T) { func TestRegisterInterceptor(t *testing.T) {
t.Parallel() t.Parallel()
// Create a manual client with an empty interceptor slice. // Create a manual client with an empty interceptor slice.
client := &Client{ client := &client{
interceptors: []ClientInterceptor{}, interceptors: []ClientInterceptor{},
} }
// Create a dummy interceptor (using TestInterceptor already defined in the file). // Create a dummy interceptor (using TestInterceptor already defined in the file).
@@ -727,12 +727,12 @@ func TestDoInvalidJsonResponse(t *testing.T) {
})) }))
defer ts.Close() defer ts.Close()
c, err := NewClient(&ClientConfig{ c, err := newBareClient(&ClientConfig{
URL: ts.URL, URL: ts.URL,
APIKey: "test-key", APIKey: "test-key",
VerifySSL: false, VerifySSL: false,
}) })
require.Error(t, err) require.NoError(t, err)
var result map[string]interface{} var result map[string]interface{}
err = c.Get(context.Background(), "any", nil, &result) err = c.Get(context.Background(), "any", nil, &result)
@@ -767,13 +767,13 @@ func TestErrorHandlerCustom(t *testing.T) {
defer ts.Close() defer ts.Close()
customErrorHandler := &failingErrorHandler{} customErrorHandler := &failingErrorHandler{}
c, err := NewClient(&ClientConfig{ c, err := newBareClient(&ClientConfig{
URL: ts.URL, URL: ts.URL,
APIKey: "test-key", APIKey: "test-key",
VerifySSL: false, VerifySSL: false,
ErrorHandler: customErrorHandler, ErrorHandler: customErrorHandler,
}) })
require.Error(t, err) require.NoError(t, err)
var result map[string]interface{} var result map[string]interface{}
err = c.Get(context.Background(), "error", nil, &result) err = c.Get(context.Background(), "error", nil, &result)
@@ -783,8 +783,8 @@ func TestErrorHandlerCustom(t *testing.T) {
func TestCreateRequestURLInvalid(t *testing.T) { func TestCreateRequestURLInvalid(t *testing.T) {
t.Parallel() t.Parallel()
c := &Client{ c := &client{
BaseURL: &url.URL{Scheme: "http", Host: "localhost"}, baseURL: &url.URL{Scheme: "http", Host: "localhost"},
apiPaths: &NewStyleAPI, apiPaths: &NewStyleAPI,
} }
_, err := c.buildRequestURL("://bad-url") _, err := c.buildRequestURL("://bad-url")
@@ -794,8 +794,8 @@ func TestCreateRequestURLInvalid(t *testing.T) {
func TestCreateRequestURLAbsolute(t *testing.T) { func TestCreateRequestURLAbsolute(t *testing.T) {
t.Parallel() t.Parallel()
c := &Client{ c := &client{
BaseURL: &url.URL{Scheme: "http", Host: "localhost"}, baseURL: &url.URL{Scheme: "http", Host: "localhost"},
apiPaths: &NewStyleAPI, apiPaths: &NewStyleAPI,
} }
reqURL, err := c.buildRequestURL("http://example.com/test") reqURL, err := c.buildRequestURL("http://example.com/test")
@@ -805,7 +805,7 @@ func TestCreateRequestURLAbsolute(t *testing.T) {
func TestCreateRequestContextTimeout(t *testing.T) { func TestCreateRequestContextTimeout(t *testing.T) {
t.Parallel() t.Parallel()
c := &Client{ c := &client{
timeout: 100 * time.Millisecond, timeout: 100 * time.Millisecond,
} }
ctx, cancel := c.newRequestContext() ctx, cancel := c.newRequestContext()
@@ -843,7 +843,7 @@ func TestMarshalRequestValid(t *testing.T) {
func TestLoginWithAPIKeyDirect(t *testing.T) { func TestLoginWithAPIKeyDirect(t *testing.T) {
t.Parallel() t.Parallel()
// Create a client manually with the APIKey set. // Create a client manually with the APIKey set.
c := &Client{ c := &client{
credentials: APIKeyCredentials{APIKey: "abc"}, credentials: APIKeyCredentials{APIKey: "abc"},
} }
err := c.Login() err := c.Login()

View File

@@ -65,7 +65,7 @@ func (dst *User) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listUser(ctx context.Context, site string) ([]User, error) { func (c *client) listUser(ctx context.Context, site string) ([]User, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []User `json:"data"` Data []User `json:"data"`
@@ -79,7 +79,7 @@ func (c *Client) listUser(ctx context.Context, site string) ([]User, error) {
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getUser(ctx context.Context, site, id string) (*User, error) { func (c *client) getUser(ctx context.Context, site, id string) (*User, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []User `json:"data"` Data []User `json:"data"`
@@ -98,7 +98,7 @@ func (c *Client) getUser(ctx context.Context, site, id string) (*User, error) {
return &d, nil return &d, nil
} }
func (c *Client) deleteUser(ctx context.Context, site, id string) error { func (c *client) deleteUser(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/user/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/user/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -106,7 +106,7 @@ func (c *Client) deleteUser(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createUser(ctx context.Context, site string, d *User) (*User, error) { func (c *client) createUser(ctx context.Context, site string, d *User) (*User, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []User `json:"data"` Data []User `json:"data"`
@@ -126,7 +126,7 @@ func (c *Client) createUser(ctx context.Context, site string, d *User) (*User, e
return &new, nil return &new, nil
} }
func (c *Client) updateUser(ctx context.Context, site string, d *User) (*User, error) { func (c *client) updateUser(ctx context.Context, site string, d *User) (*User, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []User `json:"data"` Data []User `json:"data"`

View File

@@ -9,7 +9,7 @@ import (
// GetUserByMAC returns slightly different information than GetUser, as they // GetUserByMAC returns slightly different information than GetUser, as they
// use separate endpoints for their lookups. Specifically IP is only returned // use separate endpoints for their lookups. Specifically IP is only returned
// by this method. // by this method.
func (c *Client) GetUserByMAC(ctx context.Context, site, mac string) (*User, error) { func (c *client) GetUserByMAC(ctx context.Context, site, mac string) (*User, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"Meta"` Meta Meta `json:"Meta"`
Data []User `json:"data"` Data []User `json:"data"`
@@ -28,7 +28,7 @@ func (c *Client) GetUserByMAC(ctx context.Context, site, mac string) (*User, err
return &d, nil return &d, nil
} }
func (c *Client) CreateUser(ctx context.Context, site string, d *User) (*User, error) { func (c *client) CreateUser(ctx context.Context, site string, d *User) (*User, error) {
reqBody := struct { reqBody := struct {
Objects []struct { Objects []struct {
Data *User `json:"data"` Data *User `json:"data"`
@@ -72,7 +72,7 @@ func (c *Client) CreateUser(ctx context.Context, site string, d *User) (*User, e
return &user, nil return &user, nil
} }
func (c *Client) stamgr(ctx context.Context, site, cmd string, data map[string]interface{}) ([]User, error) { func (c *client) stamgr(ctx context.Context, site, cmd string, data map[string]interface{}) ([]User, error) {
reqBody := map[string]interface{}{} reqBody := map[string]interface{}{}
for k, v := range data { for k, v := range data {
@@ -94,7 +94,7 @@ func (c *Client) stamgr(ctx context.Context, site, cmd string, data map[string]i
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) BlockUserByMAC(ctx context.Context, site, mac string) error { func (c *client) BlockUserByMAC(ctx context.Context, site, mac string) error {
users, err := c.stamgr(ctx, site, "block-sta", map[string]interface{}{ users, err := c.stamgr(ctx, site, "block-sta", map[string]interface{}{
"mac": mac, "mac": mac,
}) })
@@ -107,7 +107,7 @@ func (c *Client) BlockUserByMAC(ctx context.Context, site, mac string) error {
return nil return nil
} }
func (c *Client) UnblockUserByMAC(ctx context.Context, site, mac string) error { func (c *client) UnblockUserByMAC(ctx context.Context, site, mac string) error {
users, err := c.stamgr(ctx, site, "unblock-sta", map[string]interface{}{ users, err := c.stamgr(ctx, site, "unblock-sta", map[string]interface{}{
"mac": mac, "mac": mac,
}) })
@@ -120,7 +120,7 @@ func (c *Client) UnblockUserByMAC(ctx context.Context, site, mac string) error {
return nil return nil
} }
func (c *Client) DeleteUserByMAC(ctx context.Context, site, mac string) error { func (c *client) DeleteUserByMAC(ctx context.Context, site, mac string) error {
users, err := c.stamgr(ctx, site, "forget-sta", map[string]interface{}{ users, err := c.stamgr(ctx, site, "forget-sta", map[string]interface{}{
"macs": []string{mac}, "macs": []string{mac},
}) })
@@ -133,7 +133,7 @@ func (c *Client) DeleteUserByMAC(ctx context.Context, site, mac string) error {
return nil return nil
} }
func (c *Client) KickUserByMAC(ctx context.Context, site, mac string) error { func (c *client) KickUserByMAC(ctx context.Context, site, mac string) error {
users, err := c.stamgr(ctx, site, "kick-sta", map[string]interface{}{ users, err := c.stamgr(ctx, site, "kick-sta", map[string]interface{}{
"mac": mac, "mac": mac,
}) })
@@ -146,15 +146,15 @@ func (c *Client) KickUserByMAC(ctx context.Context, site, mac string) error {
return nil return nil
} }
func (c *Client) OverrideUserFingerprint(ctx context.Context, site, mac string, devIdOveride int) error { func (c *client) OverrideUserFingerprint(ctx context.Context, site, mac string, devIdOverride int) error {
reqBody := map[string]interface{}{ reqBody := map[string]interface{}{
"mac": mac, "mac": mac,
"dev_id_override": devIdOveride, "dev_id_override": devIdOverride,
"search_query": "", "search_query": "",
} }
var reqMethod string var reqMethod string
if devIdOveride == 0 { if devIdOverride == 0 {
reqMethod = "DELETE" reqMethod = "DELETE"
} else { } else {
reqMethod = "PUT" reqMethod = "PUT"
@@ -174,17 +174,21 @@ func (c *Client) OverrideUserFingerprint(ctx context.Context, site, mac string,
return nil return nil
} }
func (c *Client) ListUser(ctx context.Context, site string) ([]User, error) { func (c *client) ListUser(ctx context.Context, site string) ([]User, error) {
return c.listUser(ctx, site) return c.listUser(ctx, site)
} }
// GetUser returns information about a user from the REST endpoint. // GetUser returns information about a user from the REST endpoint.
// The GetUserByMAC method returns slightly different information (for // The GetUserByMAC method returns slightly different information (for
// example the IP) as it uses a different endpoint. // example the IP) as it uses a different endpoint.
func (c *Client) GetUser(ctx context.Context, site, id string) (*User, error) { func (c *client) GetUser(ctx context.Context, site, id string) (*User, error) {
return c.getUser(ctx, site, id) return c.getUser(ctx, site, id)
} }
func (c *Client) UpdateUser(ctx context.Context, site string, d *User) (*User, error) { func (c *client) UpdateUser(ctx context.Context, site string, d *User) (*User, error) {
return c.updateUser(ctx, site, d) return c.updateUser(ctx, site, d)
} }
func (c *client) DeleteUser(ctx context.Context, site, id string) error {
return c.deleteUser(ctx, site, id)
}

View File

@@ -51,7 +51,7 @@ func (dst *UserGroup) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listUserGroup(ctx context.Context, site string) ([]UserGroup, error) { func (c *client) listUserGroup(ctx context.Context, site string) ([]UserGroup, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []UserGroup `json:"data"` Data []UserGroup `json:"data"`
@@ -65,7 +65,7 @@ func (c *Client) listUserGroup(ctx context.Context, site string) ([]UserGroup, e
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getUserGroup(ctx context.Context, site, id string) (*UserGroup, error) { func (c *client) getUserGroup(ctx context.Context, site, id string) (*UserGroup, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []UserGroup `json:"data"` Data []UserGroup `json:"data"`
@@ -84,7 +84,7 @@ func (c *Client) getUserGroup(ctx context.Context, site, id string) (*UserGroup,
return &d, nil return &d, nil
} }
func (c *Client) deleteUserGroup(ctx context.Context, site, id string) error { func (c *client) deleteUserGroup(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/usergroup/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/usergroup/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -92,7 +92,7 @@ func (c *Client) deleteUserGroup(ctx context.Context, site, id string) error {
return nil return nil
} }
func (c *Client) createUserGroup(ctx context.Context, site string, d *UserGroup) (*UserGroup, error) { func (c *client) createUserGroup(ctx context.Context, site string, d *UserGroup) (*UserGroup, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []UserGroup `json:"data"` Data []UserGroup `json:"data"`
@@ -112,7 +112,7 @@ func (c *Client) createUserGroup(ctx context.Context, site string, d *UserGroup)
return &new, nil return &new, nil
} }
func (c *Client) updateUserGroup(ctx context.Context, site string, d *UserGroup) (*UserGroup, error) { func (c *client) updateUserGroup(ctx context.Context, site string, d *UserGroup) (*UserGroup, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []UserGroup `json:"data"` Data []UserGroup `json:"data"`

View File

@@ -2,22 +2,22 @@ package unifi
import "context" import "context"
func (c *Client) ListUserGroup(ctx context.Context, site string) ([]UserGroup, error) { func (c *client) ListUserGroup(ctx context.Context, site string) ([]UserGroup, error) {
return c.listUserGroup(ctx, site) return c.listUserGroup(ctx, site)
} }
func (c *Client) GetUserGroup(ctx context.Context, site, id string) (*UserGroup, error) { func (c *client) GetUserGroup(ctx context.Context, site, id string) (*UserGroup, error) {
return c.getUserGroup(ctx, site, id) return c.getUserGroup(ctx, site, id)
} }
func (c *Client) DeleteUserGroup(ctx context.Context, site, id string) error { func (c *client) DeleteUserGroup(ctx context.Context, site, id string) error {
return c.deleteUserGroup(ctx, site, id) return c.deleteUserGroup(ctx, site, id)
} }
func (c *Client) CreateUserGroup(ctx context.Context, site string, d *UserGroup) (*UserGroup, error) { func (c *client) CreateUserGroup(ctx context.Context, site string, d *UserGroup) (*UserGroup, error) {
return c.createUserGroup(ctx, site, d) return c.createUserGroup(ctx, site, d)
} }
func (c *Client) UpdateUserGroup(ctx context.Context, site string, d *UserGroup) (*UserGroup, error) { func (c *client) UpdateUserGroup(ctx context.Context, site string, d *UserGroup) (*UserGroup, error) {
return c.updateUserGroup(ctx, site, d) return c.updateUserGroup(ctx, site, d)
} }

View File

@@ -49,7 +49,7 @@ func (dst *VirtualDevice) UnmarshalJSON(b []byte) error {
return nil return nil
} }
func (c *Client) listVirtualDevice(ctx context.Context, site string) ([]VirtualDevice, error) { func (c *client) listVirtualDevice(ctx context.Context, site string) ([]VirtualDevice, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []VirtualDevice `json:"data"` Data []VirtualDevice `json:"data"`
@@ -63,7 +63,7 @@ func (c *Client) listVirtualDevice(ctx context.Context, site string) ([]VirtualD
return respBody.Data, nil return respBody.Data, nil
} }
func (c *Client) getVirtualDevice(ctx context.Context, site, id string) (*VirtualDevice, error) { func (c *client) getVirtualDevice(ctx context.Context, site, id string) (*VirtualDevice, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []VirtualDevice `json:"data"` Data []VirtualDevice `json:"data"`
@@ -82,7 +82,7 @@ func (c *Client) getVirtualDevice(ctx context.Context, site, id string) (*Virtua
return &d, nil return &d, nil
} }
func (c *Client) deleteVirtualDevice(ctx context.Context, site, id string) error { func (c *client) deleteVirtualDevice(ctx context.Context, site, id string) error {
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/virtualdevice/%s", site, id), struct{}{}, nil) err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/virtualdevice/%s", site, id), struct{}{}, nil)
if err != nil { if err != nil {
return err return err
@@ -90,7 +90,7 @@ func (c *Client) deleteVirtualDevice(ctx context.Context, site, id string) error
return nil return nil
} }
func (c *Client) createVirtualDevice(ctx context.Context, site string, d *VirtualDevice) (*VirtualDevice, error) { func (c *client) createVirtualDevice(ctx context.Context, site string, d *VirtualDevice) (*VirtualDevice, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []VirtualDevice `json:"data"` Data []VirtualDevice `json:"data"`
@@ -110,7 +110,7 @@ func (c *Client) createVirtualDevice(ctx context.Context, site string, d *Virtua
return &new, nil return &new, nil
} }
func (c *Client) updateVirtualDevice(ctx context.Context, site string, d *VirtualDevice) (*VirtualDevice, error) { func (c *client) updateVirtualDevice(ctx context.Context, site string, d *VirtualDevice) (*VirtualDevice, error) {
var respBody struct { var respBody struct {
Meta Meta `json:"meta"` Meta Meta `json:"meta"`
Data []VirtualDevice `json:"data"` Data []VirtualDevice `json:"data"`

Some files were not shown because too many files have changed in this diff Show More