diff --git a/codegen/api.go.tmpl b/codegen/api.go.tmpl index 91dbe33..899bd0d 100644 --- a/codegen/api.go.tmpl +++ b/codegen/api.go.tmpl @@ -65,7 +65,7 @@ func (dst *{{ $k }}) UnmarshalJSON(b []byte) error { {{ end }} {{ 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 { Meta Meta `json:"meta"` Data []{{ .StructName }} `json:"data"` @@ -80,7 +80,7 @@ func (c *Client) list{{ .StructName }}(ctx context.Context, site string) ([]{{ . } {{- 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 { Meta Meta `json:"meta"` Data []{{ .StructName }} `json:"data"` @@ -103,7 +103,7 @@ func (c *Client) get{{ .StructName }}(ctx context.Context, site{{ if not .IsSett } {{ 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) if err != nil { return err @@ -111,7 +111,7 @@ func (c *Client) delete{{ .StructName }}(ctx context.Context, site, id string) e 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 { Meta Meta `json:"meta"` Data []{{ .StructName }} `json:"data"` @@ -132,7 +132,7 @@ func (c *Client) create{{ .StructName }}(ctx context.Context, site string, d *{{ } {{- 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 { Meta Meta `json:"meta"` Data []{{ .StructName }} `json:"data"` diff --git a/codegen/clients.go b/codegen/clients.go index 350f179..7168edd 100644 --- a/codegen/clients.go +++ b/codegen/clients.go @@ -143,17 +143,18 @@ func singlePointerParam(name string) []FunctionParam { } 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() { 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())) return c } 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("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.AddFunction(&Comment{comment: fmt.Sprintf("==== end of client methods for %s resource ====", r.Name()), resourceName: r.Name() + "_end"}) return c } @@ -198,5 +199,5 @@ func (c *ClientInfo) GenerateCode() (string, error) { // Name returns the name of the client. func (c *ClientInfo) Name() string { - return "client" + return "Client" } diff --git a/codegen/customizations.yml b/codegen/customizations.yml index 26c0c2d..d2ca473 100644 --- a/codegen/customizations.yml +++ b/codegen/customizations.yml @@ -2,7 +2,20 @@ customizations: client: excludeResources: + - "BroadcastGroup" + - "ChannelPlan" + - "Dashboard" + - "DHCPOption" + - "Dpi*" + - "HeatMap*" + - "Hotspot*" + - "Map" + - "MediaFile" + - "ScheduleTask" - "Setting*" # Exclude all resources that start with "Setting" + - "SpatialRecord" + - "Tag" + - "VirtualDevice" functions: - name: "Login" 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." returns: - "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" comment: "AdoptDevice adopts a device by MAC address." resourceName: "Device" @@ -28,6 +110,190 @@ customizations: type: "string" returns: - "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: Account: fields: diff --git a/unifi/account.generated.go b/unifi/account.generated.go index c951c2f..c522218 100644 --- a/unifi/account.generated.go +++ b/unifi/account.generated.go @@ -60,7 +60,7 @@ func (dst *Account) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []Account `json:"data"` @@ -74,7 +74,7 @@ func (c *Client) listAccount(ctx context.Context, site string) ([]Account, error 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 { Meta Meta `json:"meta"` Data []Account `json:"data"` @@ -93,7 +93,7 @@ func (c *Client) getAccount(ctx context.Context, site, id string) (*Account, err 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) if err != nil { return err @@ -101,7 +101,7 @@ func (c *Client) deleteAccount(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []Account `json:"data"` @@ -121,7 +121,7 @@ func (c *Client) createAccount(ctx context.Context, site string, d *Account) (*A 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 { Meta Meta `json:"meta"` Data []Account `json:"data"` diff --git a/unifi/account.go b/unifi/account.go index d955e2b..ce3e8d2 100644 --- a/unifi/account.go +++ b/unifi/account.go @@ -25,22 +25,22 @@ func (dst *Account) MarshalJSON() ([]byte, error) { 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) } -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) } -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) } -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) } -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) } diff --git a/unifi/ap_group.go b/unifi/ap_group.go index 66a1214..3931d04 100644 --- a/unifi/ap_group.go +++ b/unifi/ap_group.go @@ -25,7 +25,7 @@ type APGroup struct { 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 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 } -// 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 { // Meta `json:"Meta"` // Data []WLANGroup `json:"data"` @@ -55,7 +55,7 @@ func (c *Client) ListAPGroup(ctx context.Context, site string) ([]APGroup, error // 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) // if err != nil { // return err @@ -63,7 +63,7 @@ func (c *Client) ListAPGroup(ctx context.Context, site string) ([]APGroup, error // 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 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 } -// 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 { // Meta `json:"Meta"` // Data []WLANGroup `json:"data"` diff --git a/unifi/api_paths.go b/unifi/api_paths.go index 2e94ee2..32d923f 100644 --- a/unifi/api_paths.go +++ b/unifi/api_paths.go @@ -58,11 +58,11 @@ var ( ) // 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() 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 { return err } diff --git a/unifi/broadcast_group.generated.go b/unifi/broadcast_group.generated.go index 78a5bc7..b24ef42 100644 --- a/unifi/broadcast_group.generated.go +++ b/unifi/broadcast_group.generated.go @@ -45,7 +45,7 @@ func (dst *BroadcastGroup) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []BroadcastGroup `json:"data"` @@ -59,7 +59,7 @@ func (c *Client) listBroadcastGroup(ctx context.Context, site string) ([]Broadca 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 { Meta Meta `json:"meta"` Data []BroadcastGroup `json:"data"` @@ -78,7 +78,7 @@ func (c *Client) getBroadcastGroup(ctx context.Context, site, id string) (*Broad 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) if err != nil { return err @@ -86,7 +86,7 @@ func (c *Client) deleteBroadcastGroup(ctx context.Context, site, id string) erro 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 { Meta Meta `json:"meta"` Data []BroadcastGroup `json:"data"` @@ -106,7 +106,7 @@ func (c *Client) createBroadcastGroup(ctx context.Context, site string, d *Broad 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 { Meta Meta `json:"meta"` Data []BroadcastGroup `json:"data"` diff --git a/unifi/channel_plan.generated.go b/unifi/channel_plan.generated.go index 371e52c..bcfd33e 100644 --- a/unifi/channel_plan.generated.go +++ b/unifi/channel_plan.generated.go @@ -188,7 +188,7 @@ func (dst *ChannelPlanSiteBlacklistedChannels) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []ChannelPlan `json:"data"` @@ -202,7 +202,7 @@ func (c *Client) listChannelPlan(ctx context.Context, site string) ([]ChannelPla 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 { Meta Meta `json:"meta"` Data []ChannelPlan `json:"data"` @@ -221,7 +221,7 @@ func (c *Client) getChannelPlan(ctx context.Context, site, id string) (*ChannelP 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) if err != nil { return err @@ -229,7 +229,7 @@ func (c *Client) deleteChannelPlan(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []ChannelPlan `json:"data"` @@ -249,7 +249,7 @@ func (c *Client) createChannelPlan(ctx context.Context, site string, d *ChannelP 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 { Meta Meta `json:"meta"` Data []ChannelPlan `json:"data"` diff --git a/unifi/client.generated.go b/unifi/client.generated.go new file mode 100644 index 0000000..2bc4865 --- /dev/null +++ b/unifi/client.generated.go @@ -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 ==== + +} diff --git a/unifi/client.go b/unifi/client.go index 2f2aea2..be2cf70 100644 --- a/unifi/client.go +++ b/unifi/client.go @@ -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: @@ -108,10 +108,10 @@ func (u UserPassCredentials) GetAPIKey() string { return "" } func (u UserPassCredentials) GetUser() string { return u.User } func (u UserPassCredentials) GetPass() string { return u.Pass } -// Client represents a UniFi client. -type Client struct { - BaseURL *url.URL - SysInfo *SysInfo +// client represents a UniFi client. +type client struct { + baseURL *url.URL + sysInfo *SysInfo apiPaths *APIPaths timeout time.Duration credentials Credentials @@ -125,9 +125,15 @@ type Client struct { 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. // 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) { c.interceptors = append(c.interceptors, *interceptor) } @@ -145,7 +151,7 @@ func parseBaseURL(base string) (*url.URL, error) { return baseURL, nil } -func newClientFromConfig(config *ClientConfig, v *validator) (*Client, error) { +func newClientFromConfig(config *ClientConfig, v *validator) (*client, error) { var err error config.URL = strings.TrimRight(config.URL, "/") 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) } } - client := &http.Client{ + httpClient := &http.Client{ Timeout: config.Timeout, Transport: transport, } @@ -166,7 +172,7 @@ func newClientFromConfig(config *ClientConfig, v *validator) (*Client, error) { if err != nil { return nil, fmt.Errorf("failed creating cookiejar: %w", err) } - client.Jar = jar + httpClient.Jar = jar } baseURL, err := parseBaseURL(config.URL) if err != nil { @@ -199,13 +205,13 @@ func newClientFromConfig(config *ClientConfig, v *validator) (*Client, error) { if config.ValidationMode == "" { config.ValidationMode = DefaultValidation } - u := &Client{ - BaseURL: baseURL, + u := &client{ + baseURL: baseURL, timeout: config.Timeout, credentials: credentials, validationMode: config.ValidationMode, useLocking: config.UseLocking, - http: client, + http: httpClient, interceptors: interceptors, errorHandler: errorHandler, 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. // It validates the configuration, determines the API style, performs login if necessary, // and retrieves system information from the UniFi controller. -// On success, it returns a pointer to a Client; otherwise, it returns an error. -func NewClient(config *ClientConfig) (*Client, error) { - c, err := NewBareClient(config) +// On success, it returns a pointer to a client; otherwise, it returns an error. +func NewClient(config *ClientConfig) (Client, error) { //nolint: ireturn + c, err := newBareClient(config) if err != nil { return c, err } @@ -232,7 +238,7 @@ func NewClient(config *ClientConfig) (*Client, error) { if sysInfo, err := c.GetSystemInformation(); err != nil { return c, fmt.Errorf("failed getting server info: %w", err) } else { - c.SysInfo = sysInfo + c.sysInfo = sysInfo } 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. // 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. -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() if err != nil { 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. // For API key authentication, Login does nothing. // It returns an error if the authentication process fails. -func (c *Client) Login() error { +func (c *client) Login() error { if c.credentials.IsAPIKey() { return nil } @@ -285,7 +295,7 @@ func (c *Client) Login() error { // Logout terminates the client's session for user/pass authentication. // For API key authentication, Logout does nothing. // It returns an error if the logout process fails. -func (c *Client) Logout() error { +func (c *client) Logout() error { if c.credentials.IsAPIKey() { return nil } diff --git a/unifi/codegen.go b/unifi/codegen.go index d70f653..dcbd746 100644 --- a/unifi/codegen.go +++ b/unifi/codegen.go @@ -1,5 +1,5 @@ package unifi // 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 diff --git a/unifi/dashboard.generated.go b/unifi/dashboard.generated.go index 1c7966b..0c6a710 100644 --- a/unifi/dashboard.generated.go +++ b/unifi/dashboard.generated.go @@ -71,7 +71,7 @@ func (dst *DashboardModules) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []Dashboard `json:"data"` @@ -85,7 +85,7 @@ func (c *Client) listDashboard(ctx context.Context, site string) ([]Dashboard, e 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 { Meta Meta `json:"meta"` Data []Dashboard `json:"data"` @@ -104,7 +104,7 @@ func (c *Client) getDashboard(ctx context.Context, site, id string) (*Dashboard, 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) if err != nil { return err @@ -112,7 +112,7 @@ func (c *Client) deleteDashboard(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []Dashboard `json:"data"` @@ -132,7 +132,7 @@ func (c *Client) createDashboard(ctx context.Context, site string, d *Dashboard) 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 { Meta Meta `json:"meta"` Data []Dashboard `json:"data"` diff --git a/unifi/device.generated.go b/unifi/device.generated.go index 3bf901d..a63e446 100644 --- a/unifi/device.generated.go +++ b/unifi/device.generated.go @@ -584,7 +584,7 @@ func (dst *DeviceRpsPortTable) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []Device `json:"data"` @@ -598,7 +598,7 @@ func (c *Client) listDevice(ctx context.Context, site string) ([]Device, error) 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 { Meta Meta `json:"meta"` Data []Device `json:"data"` @@ -617,7 +617,7 @@ func (c *Client) getDevice(ctx context.Context, site, id string) (*Device, error 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) if err != nil { return err @@ -625,7 +625,7 @@ func (c *Client) deleteDevice(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []Device `json:"data"` @@ -645,7 +645,7 @@ func (c *Client) createDevice(ctx context.Context, site string, d *Device) (*Dev 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 { Meta Meta `json:"meta"` Data []Device `json:"data"` diff --git a/unifi/device.go b/unifi/device.go index a221e36..1932ce3 100644 --- a/unifi/device.go +++ b/unifi/device.go @@ -23,27 +23,27 @@ const ( 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) } -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) } -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) } -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) } -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) } -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) if err != nil { return nil, err @@ -58,7 +58,7 @@ func (c *Client) GetDevice(ctx context.Context, site, id string) (*Device, error 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 { Cmd string `json:"cmd"` MAC string `json:"mac"` @@ -79,7 +79,7 @@ func (c *Client) AdoptDevice(ctx context.Context, site, mac string) error { 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 { Cmd string `json:"cmd"` MACs []string `json:"macs"` diff --git a/unifi/dhcp_option.generated.go b/unifi/dhcp_option.generated.go index baa92bf..7a01a52 100644 --- a/unifi/dhcp_option.generated.go +++ b/unifi/dhcp_option.generated.go @@ -51,7 +51,7 @@ func (dst *DHCPOption) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []DHCPOption `json:"data"` @@ -65,7 +65,7 @@ func (c *Client) listDHCPOption(ctx context.Context, site string) ([]DHCPOption, 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 { Meta Meta `json:"meta"` Data []DHCPOption `json:"data"` @@ -84,7 +84,7 @@ func (c *Client) getDHCPOption(ctx context.Context, site, id string) (*DHCPOptio 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) if err != nil { return err @@ -92,7 +92,7 @@ func (c *Client) deleteDHCPOption(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []DHCPOption `json:"data"` @@ -112,7 +112,7 @@ func (c *Client) createDHCPOption(ctx context.Context, site string, d *DHCPOptio 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 { Meta Meta `json:"meta"` Data []DHCPOption `json:"data"` diff --git a/unifi/dns_record.go b/unifi/dns_record.go index 43c10fe..7c4c2e0 100644 --- a/unifi/dns_record.go +++ b/unifi/dns_record.go @@ -1,4 +1,4 @@ -// Custom package for handling DNS records in Client Controller +// Custom package for handling DNS records in client Controller package unifi @@ -51,7 +51,7 @@ func (dst *DNSRecord) UnmarshalJSON(b []byte) error { 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 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 } -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 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 } -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) if err != nil { return err @@ -85,7 +85,7 @@ func (c *Client) DeleteDNSRecord(ctx context.Context, site, id string) error { 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 err := c.Post(ctx, fmt.Sprintf("%s/site/%s/static-dns", c.apiPaths.ApiV2Path, site), d, &respBody) if err != nil { @@ -94,7 +94,7 @@ func (c *Client) CreateDNSRecord(ctx context.Context, site string, d *DNSRecord) 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 err := c.Put(ctx, fmt.Sprintf("%s/site/%s/static-dns/%s", c.apiPaths.ApiV2Path, site, d.ID), d, &respBody) diff --git a/unifi/dpi_app.generated.go b/unifi/dpi_app.generated.go index df13c77..e5162d8 100644 --- a/unifi/dpi_app.generated.go +++ b/unifi/dpi_app.generated.go @@ -66,7 +66,7 @@ func (dst *DpiApp) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []DpiApp `json:"data"` @@ -80,7 +80,7 @@ func (c *Client) listDpiApp(ctx context.Context, site string) ([]DpiApp, error) 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 { Meta Meta `json:"meta"` Data []DpiApp `json:"data"` @@ -99,7 +99,7 @@ func (c *Client) getDpiApp(ctx context.Context, site, id string) (*DpiApp, error 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) if err != nil { return err @@ -107,7 +107,7 @@ func (c *Client) deleteDpiApp(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []DpiApp `json:"data"` @@ -127,7 +127,7 @@ func (c *Client) createDpiApp(ctx context.Context, site string, d *DpiApp) (*Dpi 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 { Meta Meta `json:"meta"` Data []DpiApp `json:"data"` diff --git a/unifi/dpi_group.generated.go b/unifi/dpi_group.generated.go index 242ea8f..ae96d75 100644 --- a/unifi/dpi_group.generated.go +++ b/unifi/dpi_group.generated.go @@ -46,7 +46,7 @@ func (dst *DpiGroup) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []DpiGroup `json:"data"` @@ -60,7 +60,7 @@ func (c *Client) listDpiGroup(ctx context.Context, site string) ([]DpiGroup, err 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 { Meta Meta `json:"meta"` Data []DpiGroup `json:"data"` @@ -79,7 +79,7 @@ func (c *Client) getDpiGroup(ctx context.Context, site, id string) (*DpiGroup, e 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) if err != nil { return err @@ -87,7 +87,7 @@ func (c *Client) deleteDpiGroup(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []DpiGroup `json:"data"` @@ -107,7 +107,7 @@ func (c *Client) createDpiGroup(ctx context.Context, site string, d *DpiGroup) ( 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 { Meta Meta `json:"meta"` Data []DpiGroup `json:"data"` diff --git a/unifi/dynamic_dns.generated.go b/unifi/dynamic_dns.generated.go index 1cdcc4d..050275e 100644 --- a/unifi/dynamic_dns.generated.go +++ b/unifi/dynamic_dns.generated.go @@ -51,7 +51,7 @@ func (dst *DynamicDNS) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []DynamicDNS `json:"data"` @@ -65,7 +65,7 @@ func (c *Client) listDynamicDNS(ctx context.Context, site string) ([]DynamicDNS, 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 { Meta Meta `json:"meta"` Data []DynamicDNS `json:"data"` @@ -84,7 +84,7 @@ func (c *Client) getDynamicDNS(ctx context.Context, site, id string) (*DynamicDN 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) if err != nil { return err @@ -92,7 +92,7 @@ func (c *Client) deleteDynamicDNS(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []DynamicDNS `json:"data"` @@ -112,7 +112,7 @@ func (c *Client) createDynamicDNS(ctx context.Context, site string, d *DynamicDN 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 { Meta Meta `json:"meta"` Data []DynamicDNS `json:"data"` diff --git a/unifi/dynamic_dns.go b/unifi/dynamic_dns.go index b86079e..f00965f 100644 --- a/unifi/dynamic_dns.go +++ b/unifi/dynamic_dns.go @@ -2,22 +2,22 @@ package unifi 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) } -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) } -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) } -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) } -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) } diff --git a/unifi/firewall_group.generated.go b/unifi/firewall_group.generated.go index ec888cd..fdf8ba2 100644 --- a/unifi/firewall_group.generated.go +++ b/unifi/firewall_group.generated.go @@ -46,7 +46,7 @@ func (dst *FirewallGroup) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []FirewallGroup `json:"data"` @@ -60,7 +60,7 @@ func (c *Client) listFirewallGroup(ctx context.Context, site string) ([]Firewall 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 { Meta Meta `json:"meta"` Data []FirewallGroup `json:"data"` @@ -79,7 +79,7 @@ func (c *Client) getFirewallGroup(ctx context.Context, site, id string) (*Firewa 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) if err != nil { return err @@ -87,7 +87,7 @@ func (c *Client) deleteFirewallGroup(ctx context.Context, site, id string) error 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 { Meta Meta `json:"meta"` Data []FirewallGroup `json:"data"` @@ -107,7 +107,7 @@ func (c *Client) createFirewallGroup(ctx context.Context, site string, d *Firewa 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 { Meta Meta `json:"meta"` Data []FirewallGroup `json:"data"` diff --git a/unifi/firewall_group.go b/unifi/firewall_group.go index 92459a8..f5d16de 100644 --- a/unifi/firewall_group.go +++ b/unifi/firewall_group.go @@ -2,22 +2,22 @@ package unifi 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) } -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) } -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) } -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) } -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) } diff --git a/unifi/firewall_rule.generated.go b/unifi/firewall_rule.generated.go index d2e4924..27597fb 100644 --- a/unifi/firewall_rule.generated.go +++ b/unifi/firewall_rule.generated.go @@ -76,7 +76,7 @@ func (dst *FirewallRule) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []FirewallRule `json:"data"` @@ -90,7 +90,7 @@ func (c *Client) listFirewallRule(ctx context.Context, site string) ([]FirewallR 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 { Meta Meta `json:"meta"` Data []FirewallRule `json:"data"` @@ -109,7 +109,7 @@ func (c *Client) getFirewallRule(ctx context.Context, site, id string) (*Firewal 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) if err != nil { return err @@ -117,7 +117,7 @@ func (c *Client) deleteFirewallRule(ctx context.Context, site, id string) error 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 { Meta Meta `json:"meta"` Data []FirewallRule `json:"data"` @@ -137,7 +137,7 @@ func (c *Client) createFirewallRule(ctx context.Context, site string, d *Firewal 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 { Meta Meta `json:"meta"` Data []FirewallRule `json:"data"` diff --git a/unifi/firewall_rule.go b/unifi/firewall_rule.go index a603440..74f700f 100644 --- a/unifi/firewall_rule.go +++ b/unifi/firewall_rule.go @@ -10,27 +10,27 @@ type FirewallRuleIndexUpdate struct { 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) } -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) } -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) } -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) } -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) } -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 { Cmd string `json:"cmd"` Ruleset string `json:"ruleset"` diff --git a/unifi/heat_map.generated.go b/unifi/heat_map.generated.go index e69d923..fd248fc 100644 --- a/unifi/heat_map.generated.go +++ b/unifi/heat_map.generated.go @@ -47,7 +47,7 @@ func (dst *HeatMap) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []HeatMap `json:"data"` @@ -61,7 +61,7 @@ func (c *Client) listHeatMap(ctx context.Context, site string) ([]HeatMap, error 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 { Meta Meta `json:"meta"` Data []HeatMap `json:"data"` @@ -80,7 +80,7 @@ func (c *Client) getHeatMap(ctx context.Context, site, id string) (*HeatMap, err 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) if err != nil { return err @@ -88,7 +88,7 @@ func (c *Client) deleteHeatMap(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []HeatMap `json:"data"` @@ -108,7 +108,7 @@ func (c *Client) createHeatMap(ctx context.Context, site string, d *HeatMap) (*H 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 { Meta Meta `json:"meta"` Data []HeatMap `json:"data"` diff --git a/unifi/heat_map_point.generated.go b/unifi/heat_map_point.generated.go index 23b8fab..74d2ee7 100644 --- a/unifi/heat_map_point.generated.go +++ b/unifi/heat_map_point.generated.go @@ -48,7 +48,7 @@ func (dst *HeatMapPoint) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []HeatMapPoint `json:"data"` @@ -62,7 +62,7 @@ func (c *Client) listHeatMapPoint(ctx context.Context, site string) ([]HeatMapPo 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 { Meta Meta `json:"meta"` Data []HeatMapPoint `json:"data"` @@ -81,7 +81,7 @@ func (c *Client) getHeatMapPoint(ctx context.Context, site, id string) (*HeatMap 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) if err != nil { return err @@ -89,7 +89,7 @@ func (c *Client) deleteHeatMapPoint(ctx context.Context, site, id string) error 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 { Meta Meta `json:"meta"` Data []HeatMapPoint `json:"data"` @@ -109,7 +109,7 @@ func (c *Client) createHeatMapPoint(ctx context.Context, site string, d *HeatMap 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 { Meta Meta `json:"meta"` Data []HeatMapPoint `json:"data"` diff --git a/unifi/hotspot_2_conf.generated.go b/unifi/hotspot_2_conf.generated.go index 2bed80d..3b00ea6 100644 --- a/unifi/hotspot_2_conf.generated.go +++ b/unifi/hotspot_2_conf.generated.go @@ -427,7 +427,7 @@ func (dst *Hotspot2ConfVenueName) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []Hotspot2Conf `json:"data"` @@ -441,7 +441,7 @@ func (c *Client) listHotspot2Conf(ctx context.Context, site string) ([]Hotspot2C 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 { Meta Meta `json:"meta"` Data []Hotspot2Conf `json:"data"` @@ -460,7 +460,7 @@ func (c *Client) getHotspot2Conf(ctx context.Context, site, id string) (*Hotspot 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) if err != nil { return err @@ -468,7 +468,7 @@ func (c *Client) deleteHotspot2Conf(ctx context.Context, site, id string) error 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 { Meta Meta `json:"meta"` Data []Hotspot2Conf `json:"data"` @@ -488,7 +488,7 @@ func (c *Client) createHotspot2Conf(ctx context.Context, site string, d *Hotspot 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 { Meta Meta `json:"meta"` Data []Hotspot2Conf `json:"data"` diff --git a/unifi/hotspot_op.generated.go b/unifi/hotspot_op.generated.go index 506c523..e9a4000 100644 --- a/unifi/hotspot_op.generated.go +++ b/unifi/hotspot_op.generated.go @@ -46,7 +46,7 @@ func (dst *HotspotOp) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []HotspotOp `json:"data"` @@ -60,7 +60,7 @@ func (c *Client) listHotspotOp(ctx context.Context, site string) ([]HotspotOp, e 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 { Meta Meta `json:"meta"` Data []HotspotOp `json:"data"` @@ -79,7 +79,7 @@ func (c *Client) getHotspotOp(ctx context.Context, site, id string) (*HotspotOp, 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) if err != nil { return err @@ -87,7 +87,7 @@ func (c *Client) deleteHotspotOp(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []HotspotOp `json:"data"` @@ -107,7 +107,7 @@ func (c *Client) createHotspotOp(ctx context.Context, site string, d *HotspotOp) 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 { Meta Meta `json:"meta"` Data []HotspotOp `json:"data"` diff --git a/unifi/hotspot_package.generated.go b/unifi/hotspot_package.generated.go index 1b3b584..c604cdf 100644 --- a/unifi/hotspot_package.generated.go +++ b/unifi/hotspot_package.generated.go @@ -85,7 +85,7 @@ func (dst *HotspotPackage) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []HotspotPackage `json:"data"` @@ -99,7 +99,7 @@ func (c *Client) listHotspotPackage(ctx context.Context, site string) ([]Hotspot 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 { Meta Meta `json:"meta"` Data []HotspotPackage `json:"data"` @@ -118,7 +118,7 @@ func (c *Client) getHotspotPackage(ctx context.Context, site, id string) (*Hotsp 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) if err != nil { return err @@ -126,7 +126,7 @@ func (c *Client) deleteHotspotPackage(ctx context.Context, site, id string) erro 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 { Meta Meta `json:"meta"` Data []HotspotPackage `json:"data"` @@ -146,7 +146,7 @@ func (c *Client) createHotspotPackage(ctx context.Context, site string, d *Hotsp 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 { Meta Meta `json:"meta"` Data []HotspotPackage `json:"data"` diff --git a/unifi/map.generated.go b/unifi/map.generated.go index e86dc03..13e4313 100644 --- a/unifi/map.generated.go +++ b/unifi/map.generated.go @@ -61,7 +61,7 @@ func (dst *Map) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []Map `json:"data"` @@ -75,7 +75,7 @@ func (c *Client) listMap(ctx context.Context, site string) ([]Map, error) { 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 { Meta Meta `json:"meta"` Data []Map `json:"data"` @@ -94,7 +94,7 @@ func (c *Client) getMap(ctx context.Context, site, id string) (*Map, error) { 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) if err != nil { return err @@ -102,7 +102,7 @@ func (c *Client) deleteMap(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []Map `json:"data"` @@ -122,7 +122,7 @@ func (c *Client) createMap(ctx context.Context, site string, d *Map) (*Map, erro 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 { Meta Meta `json:"meta"` Data []Map `json:"data"` diff --git a/unifi/media_file.generated.go b/unifi/media_file.generated.go index 8e7a4ab..be5d689 100644 --- a/unifi/media_file.generated.go +++ b/unifi/media_file.generated.go @@ -44,7 +44,7 @@ func (dst *MediaFile) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []MediaFile `json:"data"` @@ -58,7 +58,7 @@ func (c *Client) listMediaFile(ctx context.Context, site string) ([]MediaFile, e 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 { Meta Meta `json:"meta"` Data []MediaFile `json:"data"` @@ -77,7 +77,7 @@ func (c *Client) getMediaFile(ctx context.Context, site, id string) (*MediaFile, 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) if err != nil { return err @@ -85,7 +85,7 @@ func (c *Client) deleteMediaFile(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []MediaFile `json:"data"` @@ -105,7 +105,7 @@ func (c *Client) createMediaFile(ctx context.Context, site string, d *MediaFile) 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 { Meta Meta `json:"meta"` Data []MediaFile `json:"data"` diff --git a/unifi/network.generated.go b/unifi/network.generated.go index c5eaa45..736ee78 100644 --- a/unifi/network.generated.go +++ b/unifi/network.generated.go @@ -436,7 +436,7 @@ func (dst *NetworkWANProviderCapabilities) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []Network `json:"data"` @@ -450,7 +450,7 @@ func (c *Client) listNetwork(ctx context.Context, site string) ([]Network, error 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 { Meta Meta `json:"meta"` Data []Network `json:"data"` @@ -469,7 +469,7 @@ func (c *Client) getNetwork(ctx context.Context, site, id string) (*Network, err 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) if err != nil { return err @@ -477,7 +477,7 @@ func (c *Client) deleteNetwork(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []Network `json:"data"` @@ -497,7 +497,7 @@ func (c *Client) createNetwork(ctx context.Context, site string, d *Network) (*N 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 { Meta Meta `json:"meta"` Data []Network `json:"data"` diff --git a/unifi/network.go b/unifi/network.go index 196ecd1..9fd4fe2 100644 --- a/unifi/network.go +++ b/unifi/network.go @@ -26,30 +26,38 @@ func (dst *Network) MarshalJSON() ([]byte, error) { return b, err } -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 { - Name string `json:"name"` - }{ - Name: name, - }, nil) +//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 { +// Name string `json:"name"` +// }{ +// Name: name, +// }, 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 { return err } 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) } -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) } -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) } -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) } diff --git a/unifi/port_forward.generated.go b/unifi/port_forward.generated.go index ca29f23..6d803a1 100644 --- a/unifi/port_forward.generated.go +++ b/unifi/port_forward.generated.go @@ -78,7 +78,7 @@ func (dst *PortForwardDestinationIPs) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []PortForward `json:"data"` @@ -92,7 +92,7 @@ func (c *Client) listPortForward(ctx context.Context, site string) ([]PortForwar 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 { Meta Meta `json:"meta"` Data []PortForward `json:"data"` @@ -111,7 +111,7 @@ func (c *Client) getPortForward(ctx context.Context, site, id string) (*PortForw 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) if err != nil { return err @@ -119,7 +119,7 @@ func (c *Client) deletePortForward(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []PortForward `json:"data"` @@ -139,7 +139,7 @@ func (c *Client) createPortForward(ctx context.Context, site string, d *PortForw 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 { Meta Meta `json:"meta"` Data []PortForward `json:"data"` diff --git a/unifi/port_forward.go b/unifi/port_forward.go index 05144e0..a5449e1 100644 --- a/unifi/port_forward.go +++ b/unifi/port_forward.go @@ -2,22 +2,22 @@ package unifi 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) } -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) } -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) } -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) } -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) } diff --git a/unifi/port_profile.generated.go b/unifi/port_profile.generated.go index 7405b22..499a84a 100644 --- a/unifi/port_profile.generated.go +++ b/unifi/port_profile.generated.go @@ -220,7 +220,7 @@ func (dst *PortProfileQOSProfile) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []PortProfile `json:"data"` @@ -234,7 +234,7 @@ func (c *Client) listPortProfile(ctx context.Context, site string) ([]PortProfil 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 { Meta Meta `json:"meta"` Data []PortProfile `json:"data"` @@ -253,7 +253,7 @@ func (c *Client) getPortProfile(ctx context.Context, site, id string) (*PortProf 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) if err != nil { return err @@ -261,7 +261,7 @@ func (c *Client) deletePortProfile(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []PortProfile `json:"data"` @@ -281,7 +281,7 @@ func (c *Client) createPortProfile(ctx context.Context, site string, d *PortProf 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 { Meta Meta `json:"meta"` Data []PortProfile `json:"data"` diff --git a/unifi/port_profile.go b/unifi/port_profile.go index fc68243..4f74a2e 100644 --- a/unifi/port_profile.go +++ b/unifi/port_profile.go @@ -4,22 +4,22 @@ import ( "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) } -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) } -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) } -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) } -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) } diff --git a/unifi/radius_profile.generated.go b/unifi/radius_profile.generated.go index fe37b72..d76ad6d 100644 --- a/unifi/radius_profile.generated.go +++ b/unifi/radius_profile.generated.go @@ -134,7 +134,7 @@ func (dst *RADIUSProfileXCaCrts) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []RADIUSProfile `json:"data"` @@ -148,7 +148,7 @@ func (c *Client) listRADIUSProfile(ctx context.Context, site string) ([]RADIUSPr 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 { Meta Meta `json:"meta"` Data []RADIUSProfile `json:"data"` @@ -167,7 +167,7 @@ func (c *Client) getRADIUSProfile(ctx context.Context, site, id string) (*RADIUS 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) if err != nil { return err @@ -175,7 +175,7 @@ func (c *Client) deleteRADIUSProfile(ctx context.Context, site, id string) error 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 { Meta Meta `json:"meta"` Data []RADIUSProfile `json:"data"` @@ -195,7 +195,7 @@ func (c *Client) createRADIUSProfile(ctx context.Context, site string, d *RADIUS 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 { Meta Meta `json:"meta"` Data []RADIUSProfile `json:"data"` diff --git a/unifi/radius_profile.go b/unifi/radius_profile.go index 20387ed..d85fc28 100644 --- a/unifi/radius_profile.go +++ b/unifi/radius_profile.go @@ -4,22 +4,22 @@ import ( "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) } -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) } -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) } -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) } -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) } diff --git a/unifi/requests.go b/unifi/requests.go index f019a4a..6931427 100644 --- a/unifi/requests.go +++ b/unifi/requests.go @@ -24,8 +24,8 @@ func marshalRequest(reqBody interface{}) (io.Reader, error) { return bytes.NewReader(reqBytes), nil } -// 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) { +// 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) { reqURL, err := url.Parse(apiPath) if err != nil { return nil, err @@ -33,11 +33,11 @@ func (c *Client) buildRequestURL(apiPath string) (*url.URL, error) { if !strings.HasPrefix(apiPath, "/") && !reqURL.IsAbs() { 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. -func (c *Client) validateRequestBody(reqBody interface{}) error { +func (c *client) validateRequestBody(reqBody interface{}) error { if reqBody != nil && c.validationMode != DisableValidation { if err := c.validator.Validate(reqBody); err != nil { 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. -func (c *Client) newRequestContext() (context.Context, context.CancelFunc) { +func (c *client) newRequestContext() (context.Context, context.CancelFunc) { ctx := context.Background() if c.timeout != 0 { 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. // 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. -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 { 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, // and decodes the HTTP response into respBody. // 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) } // Post sends an HTTP POST request to the specified API path with the provided request body, // and decodes the HTTP response into respBody. // 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) } // Put sends an HTTP PUT request to the specified API path with the provided request body, // and decodes the HTTP response into respBody. // 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) } // Delete sends an HTTP DELETE request to the specified API path with the provided request body, // and decodes the HTTP response into respBody. // 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) } diff --git a/unifi/routing.generated.go b/unifi/routing.generated.go index f2a7510..004e6f3 100644 --- a/unifi/routing.generated.go +++ b/unifi/routing.generated.go @@ -56,7 +56,7 @@ func (dst *Routing) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []Routing `json:"data"` @@ -70,7 +70,7 @@ func (c *Client) listRouting(ctx context.Context, site string) ([]Routing, error 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 { Meta Meta `json:"meta"` Data []Routing `json:"data"` @@ -89,7 +89,7 @@ func (c *Client) getRouting(ctx context.Context, site, id string) (*Routing, err 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) if err != nil { return err @@ -97,7 +97,7 @@ func (c *Client) deleteRouting(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []Routing `json:"data"` @@ -117,7 +117,7 @@ func (c *Client) createRouting(ctx context.Context, site string, d *Routing) (*R 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 { Meta Meta `json:"meta"` Data []Routing `json:"data"` diff --git a/unifi/routing.go b/unifi/routing.go index 838857a..4fd1da2 100644 --- a/unifi/routing.go +++ b/unifi/routing.go @@ -16,22 +16,22 @@ import ( "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) } -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) } -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) } -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) } -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) } diff --git a/unifi/schedule_task.generated.go b/unifi/schedule_task.generated.go index e6fae13..f5281eb 100644 --- a/unifi/schedule_task.generated.go +++ b/unifi/schedule_task.generated.go @@ -68,7 +68,7 @@ func (dst *ScheduleTaskUpgradeTargets) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []ScheduleTask `json:"data"` @@ -82,7 +82,7 @@ func (c *Client) listScheduleTask(ctx context.Context, site string) ([]ScheduleT 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 { Meta Meta `json:"meta"` Data []ScheduleTask `json:"data"` @@ -101,7 +101,7 @@ func (c *Client) getScheduleTask(ctx context.Context, site, id string) (*Schedul 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) if err != nil { return err @@ -109,7 +109,7 @@ func (c *Client) deleteScheduleTask(ctx context.Context, site, id string) error 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 { Meta Meta `json:"meta"` Data []ScheduleTask `json:"data"` @@ -129,7 +129,7 @@ func (c *Client) createScheduleTask(ctx context.Context, site string, d *Schedul 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 { Meta Meta `json:"meta"` Data []ScheduleTask `json:"data"` diff --git a/unifi/setting.go b/unifi/setting.go index 8daa62d..6dca1e4 100644 --- a/unifi/setting.go +++ b/unifi/setting.go @@ -79,7 +79,7 @@ func (s *Setting) newFields() (interface{}, error) { 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 { Meta Meta `json:"Meta"` Data []json.RawMessage `json:"data"` diff --git a/unifi/setting_auto_speedtest.generated.go b/unifi/setting_auto_speedtest.generated.go index 7ba0492..07bcab3 100644 --- a/unifi/setting_auto_speedtest.generated.go +++ b/unifi/setting_auto_speedtest.generated.go @@ -47,7 +47,7 @@ func (dst *SettingAutoSpeedtest) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingAutoSpeedtest `json:"data"` @@ -66,7 +66,7 @@ func (c *Client) getSettingAutoSpeedtest(ctx context.Context, site string) (*Set 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 { Meta Meta `json:"meta"` Data []SettingAutoSpeedtest `json:"data"` diff --git a/unifi/setting_baresip.generated.go b/unifi/setting_baresip.generated.go index 1cee34d..62159d8 100644 --- a/unifi/setting_baresip.generated.go +++ b/unifi/setting_baresip.generated.go @@ -49,7 +49,7 @@ func (dst *SettingBaresip) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingBaresip `json:"data"` @@ -68,7 +68,7 @@ func (c *Client) getSettingBaresip(ctx context.Context, site string) (*SettingBa 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 { Meta Meta `json:"meta"` Data []SettingBaresip `json:"data"` diff --git a/unifi/setting_broadcast.generated.go b/unifi/setting_broadcast.generated.go index 7a7135f..c0ba104 100644 --- a/unifi/setting_broadcast.generated.go +++ b/unifi/setting_broadcast.generated.go @@ -51,7 +51,7 @@ func (dst *SettingBroadcast) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingBroadcast `json:"data"` @@ -70,7 +70,7 @@ func (c *Client) getSettingBroadcast(ctx context.Context, site string) (*Setting 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 { Meta Meta `json:"meta"` Data []SettingBroadcast `json:"data"` diff --git a/unifi/setting_connectivity.generated.go b/unifi/setting_connectivity.generated.go index 5aa712e..fa49bfe 100644 --- a/unifi/setting_connectivity.generated.go +++ b/unifi/setting_connectivity.generated.go @@ -51,7 +51,7 @@ func (dst *SettingConnectivity) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingConnectivity `json:"data"` @@ -70,7 +70,7 @@ func (c *Client) getSettingConnectivity(ctx context.Context, site string) (*Sett 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 { Meta Meta `json:"meta"` Data []SettingConnectivity `json:"data"` diff --git a/unifi/setting_country.generated.go b/unifi/setting_country.generated.go index 3dd65ef..d975c26 100644 --- a/unifi/setting_country.generated.go +++ b/unifi/setting_country.generated.go @@ -49,7 +49,7 @@ func (dst *SettingCountry) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingCountry `json:"data"` @@ -68,7 +68,7 @@ func (c *Client) getSettingCountry(ctx context.Context, site string) (*SettingCo 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 { Meta Meta `json:"meta"` Data []SettingCountry `json:"data"` diff --git a/unifi/setting_dashboard.generated.go b/unifi/setting_dashboard.generated.go index 37e7d52..1c106e5 100644 --- a/unifi/setting_dashboard.generated.go +++ b/unifi/setting_dashboard.generated.go @@ -68,7 +68,7 @@ func (dst *SettingDashboardWidgets) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingDashboard `json:"data"` @@ -87,7 +87,7 @@ func (c *Client) getSettingDashboard(ctx context.Context, site string) (*Setting 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 { Meta Meta `json:"meta"` Data []SettingDashboard `json:"data"` diff --git a/unifi/setting_doh.generated.go b/unifi/setting_doh.generated.go index 6f7d69e..fc8de3e 100644 --- a/unifi/setting_doh.generated.go +++ b/unifi/setting_doh.generated.go @@ -70,7 +70,7 @@ func (dst *SettingDohCustomServers) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingDoh `json:"data"` @@ -89,7 +89,7 @@ func (c *Client) getSettingDoh(ctx context.Context, site string) (*SettingDoh, e 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 { Meta Meta `json:"meta"` Data []SettingDoh `json:"data"` diff --git a/unifi/setting_dpi.generated.go b/unifi/setting_dpi.generated.go index d1acf01..6e7adb5 100644 --- a/unifi/setting_dpi.generated.go +++ b/unifi/setting_dpi.generated.go @@ -47,7 +47,7 @@ func (dst *SettingDpi) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingDpi `json:"data"` @@ -66,7 +66,7 @@ func (c *Client) getSettingDpi(ctx context.Context, site string) (*SettingDpi, e 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 { Meta Meta `json:"meta"` Data []SettingDpi `json:"data"` diff --git a/unifi/setting_element_adopt.generated.go b/unifi/setting_element_adopt.generated.go index 5ba5bfd..a5ff9eb 100644 --- a/unifi/setting_element_adopt.generated.go +++ b/unifi/setting_element_adopt.generated.go @@ -48,7 +48,7 @@ func (dst *SettingElementAdopt) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingElementAdopt `json:"data"` @@ -67,7 +67,7 @@ func (c *Client) getSettingElementAdopt(ctx context.Context, site string) (*Sett 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 { Meta Meta `json:"meta"` Data []SettingElementAdopt `json:"data"` diff --git a/unifi/setting_ether_lighting.generated.go b/unifi/setting_ether_lighting.generated.go index 81bc39c..5192e7f 100644 --- a/unifi/setting_ether_lighting.generated.go +++ b/unifi/setting_ether_lighting.generated.go @@ -89,7 +89,7 @@ func (dst *SettingEtherLightingSpeedOverrides) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingEtherLighting `json:"data"` @@ -108,7 +108,7 @@ func (c *Client) getSettingEtherLighting(ctx context.Context, site string) (*Set 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 { Meta Meta `json:"meta"` Data []SettingEtherLighting `json:"data"` diff --git a/unifi/setting_evaluation_score.generated.go b/unifi/setting_evaluation_score.generated.go index 3bcad96..fd95e51 100644 --- a/unifi/setting_evaluation_score.generated.go +++ b/unifi/setting_evaluation_score.generated.go @@ -46,7 +46,7 @@ func (dst *SettingEvaluationScore) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingEvaluationScore `json:"data"` @@ -65,7 +65,7 @@ func (c *Client) getSettingEvaluationScore(ctx context.Context, site string) (*S 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 { Meta Meta `json:"meta"` Data []SettingEvaluationScore `json:"data"` diff --git a/unifi/setting_global_ap.generated.go b/unifi/setting_global_ap.generated.go index 9043ac0..ef41bc8 100644 --- a/unifi/setting_global_ap.generated.go +++ b/unifi/setting_global_ap.generated.go @@ -68,7 +68,7 @@ func (dst *SettingGlobalAp) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingGlobalAp `json:"data"` @@ -87,7 +87,7 @@ func (c *Client) getSettingGlobalAp(ctx context.Context, site string) (*SettingG 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 { Meta Meta `json:"meta"` Data []SettingGlobalAp `json:"data"` diff --git a/unifi/setting_global_nat.generated.go b/unifi/setting_global_nat.generated.go index 41b5b89..ca98e6d 100644 --- a/unifi/setting_global_nat.generated.go +++ b/unifi/setting_global_nat.generated.go @@ -47,7 +47,7 @@ func (dst *SettingGlobalNat) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingGlobalNat `json:"data"` @@ -66,7 +66,7 @@ func (c *Client) getSettingGlobalNat(ctx context.Context, site string) (*Setting 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 { Meta Meta `json:"meta"` Data []SettingGlobalNat `json:"data"` diff --git a/unifi/setting_global_switch.generated.go b/unifi/setting_global_switch.generated.go index 8cabe4e..e484a60 100644 --- a/unifi/setting_global_switch.generated.go +++ b/unifi/setting_global_switch.generated.go @@ -76,7 +76,7 @@ func (dst *SettingGlobalSwitchAclL3Isolation) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingGlobalSwitch `json:"data"` @@ -95,7 +95,7 @@ func (c *Client) getSettingGlobalSwitch(ctx context.Context, site string) (*Sett 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 { Meta Meta `json:"meta"` Data []SettingGlobalSwitch `json:"data"` diff --git a/unifi/setting_guest_access.generated.go b/unifi/setting_guest_access.generated.go index f0df234..40191d5 100644 --- a/unifi/setting_guest_access.generated.go +++ b/unifi/setting_guest_access.generated.go @@ -155,7 +155,7 @@ func (dst *SettingGuestAccess) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingGuestAccess `json:"data"` @@ -174,7 +174,7 @@ func (c *Client) getSettingGuestAccess(ctx context.Context, site string) (*Setti 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 { Meta Meta `json:"meta"` Data []SettingGuestAccess `json:"data"` diff --git a/unifi/setting_ips.generated.go b/unifi/setting_ips.generated.go index 1c3e762..caa5558 100644 --- a/unifi/setting_ips.generated.go +++ b/unifi/setting_ips.generated.go @@ -222,7 +222,7 @@ func (dst *SettingIpsWhitelist) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingIps `json:"data"` @@ -241,7 +241,7 @@ func (c *Client) getSettingIps(ctx context.Context, site string) (*SettingIps, e 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 { Meta Meta `json:"meta"` Data []SettingIps `json:"data"` diff --git a/unifi/setting_lcm.generated.go b/unifi/setting_lcm.generated.go index 68699d5..f75b070 100644 --- a/unifi/setting_lcm.generated.go +++ b/unifi/setting_lcm.generated.go @@ -55,7 +55,7 @@ func (dst *SettingLcm) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingLcm `json:"data"` @@ -74,7 +74,7 @@ func (c *Client) getSettingLcm(ctx context.Context, site string) (*SettingLcm, e 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 { Meta Meta `json:"meta"` Data []SettingLcm `json:"data"` diff --git a/unifi/setting_locale.generated.go b/unifi/setting_locale.generated.go index 4232de2..48e6789 100644 --- a/unifi/setting_locale.generated.go +++ b/unifi/setting_locale.generated.go @@ -46,7 +46,7 @@ func (dst *SettingLocale) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingLocale `json:"data"` @@ -65,7 +65,7 @@ func (c *Client) getSettingLocale(ctx context.Context, site string) (*SettingLoc 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 { Meta Meta `json:"meta"` Data []SettingLocale `json:"data"` diff --git a/unifi/setting_magic_site_to_site_vpn.generated.go b/unifi/setting_magic_site_to_site_vpn.generated.go index 7cfcb0c..a9d071b 100644 --- a/unifi/setting_magic_site_to_site_vpn.generated.go +++ b/unifi/setting_magic_site_to_site_vpn.generated.go @@ -46,7 +46,7 @@ func (dst *SettingMagicSiteToSiteVpn) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingMagicSiteToSiteVpn `json:"data"` @@ -65,7 +65,7 @@ func (c *Client) getSettingMagicSiteToSiteVpn(ctx context.Context, site string) 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 { Meta Meta `json:"meta"` Data []SettingMagicSiteToSiteVpn `json:"data"` diff --git a/unifi/setting_mgmt.generated.go b/unifi/setting_mgmt.generated.go index 12380cc..ce86469 100644 --- a/unifi/setting_mgmt.generated.go +++ b/unifi/setting_mgmt.generated.go @@ -93,7 +93,7 @@ func (dst *SettingMgmtXSshKeys) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingMgmt `json:"data"` @@ -112,7 +112,7 @@ func (c *Client) getSettingMgmt(ctx context.Context, site string) (*SettingMgmt, 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 { Meta Meta `json:"meta"` Data []SettingMgmt `json:"data"` diff --git a/unifi/setting_mgmt.go b/unifi/setting_mgmt.go index f93ff52..c5612ff 100644 --- a/unifi/setting_mgmt.go +++ b/unifi/setting_mgmt.go @@ -4,11 +4,11 @@ import ( "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) } -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" return c.updateSettingMgmt(ctx, site, d) } diff --git a/unifi/setting_netflow.generated.go b/unifi/setting_netflow.generated.go index aba21fe..6d8768e 100644 --- a/unifi/setting_netflow.generated.go +++ b/unifi/setting_netflow.generated.go @@ -69,7 +69,7 @@ func (dst *SettingNetflow) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingNetflow `json:"data"` @@ -88,7 +88,7 @@ func (c *Client) getSettingNetflow(ctx context.Context, site string) (*SettingNe 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 { Meta Meta `json:"meta"` Data []SettingNetflow `json:"data"` diff --git a/unifi/setting_network_optimization.generated.go b/unifi/setting_network_optimization.generated.go index 30b5f8c..9e09214 100644 --- a/unifi/setting_network_optimization.generated.go +++ b/unifi/setting_network_optimization.generated.go @@ -46,7 +46,7 @@ func (dst *SettingNetworkOptimization) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingNetworkOptimization `json:"data"` @@ -65,7 +65,7 @@ func (c *Client) getSettingNetworkOptimization(ctx context.Context, site string) 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 { Meta Meta `json:"meta"` Data []SettingNetworkOptimization `json:"data"` diff --git a/unifi/setting_ntp.generated.go b/unifi/setting_ntp.generated.go index 55d20ca..0fd4196 100644 --- a/unifi/setting_ntp.generated.go +++ b/unifi/setting_ntp.generated.go @@ -50,7 +50,7 @@ func (dst *SettingNtp) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingNtp `json:"data"` @@ -69,7 +69,7 @@ func (c *Client) getSettingNtp(ctx context.Context, site string) (*SettingNtp, e 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 { Meta Meta `json:"meta"` Data []SettingNtp `json:"data"` diff --git a/unifi/setting_porta.generated.go b/unifi/setting_porta.generated.go index 718732c..a8195cf 100644 --- a/unifi/setting_porta.generated.go +++ b/unifi/setting_porta.generated.go @@ -46,7 +46,7 @@ func (dst *SettingPorta) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingPorta `json:"data"` @@ -65,7 +65,7 @@ func (c *Client) getSettingPorta(ctx context.Context, site string) (*SettingPort 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 { Meta Meta `json:"meta"` Data []SettingPorta `json:"data"` diff --git a/unifi/setting_provider_capabilities.generated.go b/unifi/setting_provider_capabilities.generated.go index 28bf0f5..a7a2a85 100644 --- a/unifi/setting_provider_capabilities.generated.go +++ b/unifi/setting_provider_capabilities.generated.go @@ -53,7 +53,7 @@ func (dst *SettingProviderCapabilities) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"Meta"` Data []SettingProviderCapabilities `json:"data"` @@ -72,7 +72,7 @@ func (c *Client) getSettingProviderCapabilities(ctx context.Context, site string 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 { Meta Meta `json:"Meta"` Data []SettingProviderCapabilities `json:"data"` diff --git a/unifi/setting_radio_ai.generated.go b/unifi/setting_radio_ai.generated.go index a4353aa..26d7520 100644 --- a/unifi/setting_radio_ai.generated.go +++ b/unifi/setting_radio_ai.generated.go @@ -113,7 +113,7 @@ func (dst *SettingRadioAiChannelsBlacklist) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingRadioAi `json:"data"` @@ -132,7 +132,7 @@ func (c *Client) getSettingRadioAi(ctx context.Context, site string) (*SettingRa 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 { Meta Meta `json:"meta"` Data []SettingRadioAi `json:"data"` diff --git a/unifi/setting_radius.generated.go b/unifi/setting_radius.generated.go index 73847d2..5780952 100644 --- a/unifi/setting_radius.generated.go +++ b/unifi/setting_radius.generated.go @@ -60,7 +60,7 @@ func (dst *SettingRadius) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingRadius `json:"data"` @@ -79,7 +79,7 @@ func (c *Client) getSettingRadius(ctx context.Context, site string) (*SettingRad 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 { Meta Meta `json:"meta"` Data []SettingRadius `json:"data"` diff --git a/unifi/setting_radius.go b/unifi/setting_radius.go index f026681..7eb6958 100644 --- a/unifi/setting_radius.go +++ b/unifi/setting_radius.go @@ -4,10 +4,10 @@ import ( "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) } -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) } diff --git a/unifi/setting_rsyslogd.generated.go b/unifi/setting_rsyslogd.generated.go index dcbbbff..96f6960 100644 --- a/unifi/setting_rsyslogd.generated.go +++ b/unifi/setting_rsyslogd.generated.go @@ -61,7 +61,7 @@ func (dst *SettingRsyslogd) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingRsyslogd `json:"data"` @@ -80,7 +80,7 @@ func (c *Client) getSettingRsyslogd(ctx context.Context, site string) (*SettingR 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 { Meta Meta `json:"meta"` Data []SettingRsyslogd `json:"data"` diff --git a/unifi/setting_snmp.generated.go b/unifi/setting_snmp.generated.go index 031063a..6086fe2 100644 --- a/unifi/setting_snmp.generated.go +++ b/unifi/setting_snmp.generated.go @@ -50,7 +50,7 @@ func (dst *SettingSnmp) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingSnmp `json:"data"` @@ -69,7 +69,7 @@ func (c *Client) getSettingSnmp(ctx context.Context, site string) (*SettingSnmp, 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 { Meta Meta `json:"meta"` Data []SettingSnmp `json:"data"` diff --git a/unifi/setting_ssl_inspection.generated.go b/unifi/setting_ssl_inspection.generated.go index 005c9b8..6722317 100644 --- a/unifi/setting_ssl_inspection.generated.go +++ b/unifi/setting_ssl_inspection.generated.go @@ -46,7 +46,7 @@ func (dst *SettingSslInspection) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingSslInspection `json:"data"` @@ -65,7 +65,7 @@ func (c *Client) getSettingSslInspection(ctx context.Context, site string) (*Set 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 { Meta Meta `json:"meta"` Data []SettingSslInspection `json:"data"` diff --git a/unifi/setting_super_cloudaccess.generated.go b/unifi/setting_super_cloudaccess.generated.go index 91d2294..a132b98 100644 --- a/unifi/setting_super_cloudaccess.generated.go +++ b/unifi/setting_super_cloudaccess.generated.go @@ -52,7 +52,7 @@ func (dst *SettingSuperCloudaccess) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingSuperCloudaccess `json:"data"` @@ -71,7 +71,7 @@ func (c *Client) getSettingSuperCloudaccess(ctx context.Context, site string) (* 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 { Meta Meta `json:"meta"` Data []SettingSuperCloudaccess `json:"data"` diff --git a/unifi/setting_super_events.generated.go b/unifi/setting_super_events.generated.go index aa076f8..beeb83b 100644 --- a/unifi/setting_super_events.generated.go +++ b/unifi/setting_super_events.generated.go @@ -46,7 +46,7 @@ func (dst *SettingSuperEvents) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingSuperEvents `json:"data"` @@ -65,7 +65,7 @@ func (c *Client) getSettingSuperEvents(ctx context.Context, site string) (*Setti 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 { Meta Meta `json:"meta"` Data []SettingSuperEvents `json:"data"` diff --git a/unifi/setting_super_fwupdate.generated.go b/unifi/setting_super_fwupdate.generated.go index fc9bbb6..e76d280 100644 --- a/unifi/setting_super_fwupdate.generated.go +++ b/unifi/setting_super_fwupdate.generated.go @@ -48,7 +48,7 @@ func (dst *SettingSuperFwupdate) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingSuperFwupdate `json:"data"` @@ -67,7 +67,7 @@ func (c *Client) getSettingSuperFwupdate(ctx context.Context, site string) (*Set 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 { Meta Meta `json:"meta"` Data []SettingSuperFwupdate `json:"data"` diff --git a/unifi/setting_super_identity.generated.go b/unifi/setting_super_identity.generated.go index 26407ef..80278f8 100644 --- a/unifi/setting_super_identity.generated.go +++ b/unifi/setting_super_identity.generated.go @@ -47,7 +47,7 @@ func (dst *SettingSuperIdentity) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingSuperIdentity `json:"data"` @@ -66,7 +66,7 @@ func (c *Client) getSettingSuperIdentity(ctx context.Context, site string) (*Set 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 { Meta Meta `json:"meta"` Data []SettingSuperIdentity `json:"data"` diff --git a/unifi/setting_super_mail.generated.go b/unifi/setting_super_mail.generated.go index cb1fec5..9b41163 100644 --- a/unifi/setting_super_mail.generated.go +++ b/unifi/setting_super_mail.generated.go @@ -46,7 +46,7 @@ func (dst *SettingSuperMail) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingSuperMail `json:"data"` @@ -65,7 +65,7 @@ func (c *Client) getSettingSuperMail(ctx context.Context, site string) (*Setting 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 { Meta Meta `json:"meta"` Data []SettingSuperMail `json:"data"` diff --git a/unifi/setting_super_mgmt.generated.go b/unifi/setting_super_mgmt.generated.go index 865b412..448708f 100644 --- a/unifi/setting_super_mgmt.generated.go +++ b/unifi/setting_super_mgmt.generated.go @@ -111,7 +111,7 @@ func (dst *SettingSuperMgmt) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingSuperMgmt `json:"data"` @@ -130,7 +130,7 @@ func (c *Client) getSettingSuperMgmt(ctx context.Context, site string) (*Setting 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 { Meta Meta `json:"meta"` Data []SettingSuperMgmt `json:"data"` diff --git a/unifi/setting_super_sdn.generated.go b/unifi/setting_super_sdn.generated.go index ebbfd2f..27673b5 100644 --- a/unifi/setting_super_sdn.generated.go +++ b/unifi/setting_super_sdn.generated.go @@ -51,7 +51,7 @@ func (dst *SettingSuperSdn) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingSuperSdn `json:"data"` @@ -70,7 +70,7 @@ func (c *Client) getSettingSuperSdn(ctx context.Context, site string) (*SettingS 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 { Meta Meta `json:"meta"` Data []SettingSuperSdn `json:"data"` diff --git a/unifi/setting_super_smtp.generated.go b/unifi/setting_super_smtp.generated.go index a27aac6..55b6439 100644 --- a/unifi/setting_super_smtp.generated.go +++ b/unifi/setting_super_smtp.generated.go @@ -57,7 +57,7 @@ func (dst *SettingSuperSmtp) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingSuperSmtp `json:"data"` @@ -76,7 +76,7 @@ func (c *Client) getSettingSuperSmtp(ctx context.Context, site string) (*Setting 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 { Meta Meta `json:"meta"` Data []SettingSuperSmtp `json:"data"` diff --git a/unifi/setting_teleport.generated.go b/unifi/setting_teleport.generated.go index 12c40c9..cb6b4a9 100644 --- a/unifi/setting_teleport.generated.go +++ b/unifi/setting_teleport.generated.go @@ -47,7 +47,7 @@ func (dst *SettingTeleport) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingTeleport `json:"data"` @@ -66,7 +66,7 @@ func (c *Client) getSettingTeleport(ctx context.Context, site string) (*SettingT 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 { Meta Meta `json:"meta"` Data []SettingTeleport `json:"data"` diff --git a/unifi/setting_usg.generated.go b/unifi/setting_usg.generated.go index 83d105d..b7ac829 100644 --- a/unifi/setting_usg.generated.go +++ b/unifi/setting_usg.generated.go @@ -158,7 +158,7 @@ func (dst *SettingUsgDNSVerification) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingUsg `json:"data"` @@ -177,7 +177,7 @@ func (c *Client) getSettingUsg(ctx context.Context, site string) (*SettingUsg, e 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 { Meta Meta `json:"meta"` Data []SettingUsg `json:"data"` diff --git a/unifi/setting_usg.go b/unifi/setting_usg.go index 99caed1..a75f957 100644 --- a/unifi/setting_usg.go +++ b/unifi/setting_usg.go @@ -4,10 +4,10 @@ import ( "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) } -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) } diff --git a/unifi/setting_usw.generated.go b/unifi/setting_usw.generated.go index 1971ec9..f0fa07f 100644 --- a/unifi/setting_usw.generated.go +++ b/unifi/setting_usw.generated.go @@ -46,7 +46,7 @@ func (dst *SettingUsw) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SettingUsw `json:"data"` @@ -65,7 +65,7 @@ func (c *Client) getSettingUsw(ctx context.Context, site string) (*SettingUsw, e 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 { Meta Meta `json:"meta"` Data []SettingUsw `json:"data"` diff --git a/unifi/sites.go b/unifi/sites.go index 41a450e..aa32eca 100644 --- a/unifi/sites.go +++ b/unifi/sites.go @@ -19,7 +19,7 @@ type Site struct { // 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 { Meta Meta `json:"Meta"` Data []Site `json:"data"` @@ -33,7 +33,7 @@ func (c *Client) ListSites(ctx context.Context) ([]Site, error) { 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) if err != nil { return nil, err @@ -48,7 +48,7 @@ func (c *Client) GetSite(ctx context.Context, id string) (*Site, error) { 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 { Cmd string `json:"cmd"` Desc string `json:"desc"` @@ -70,7 +70,7 @@ func (c *Client) CreateSite(ctx context.Context, description string) ([]Site, er 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 { Cmd string `json:"cmd"` Site string `json:"site"` @@ -92,7 +92,7 @@ func (c *Client) DeleteSite(ctx context.Context, id string) ([]Site, error) { 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 { Cmd string `json:"cmd"` Desc string `json:"desc"` diff --git a/unifi/spatial_record.generated.go b/unifi/spatial_record.generated.go index 2dfb873..d444b76 100644 --- a/unifi/spatial_record.generated.go +++ b/unifi/spatial_record.generated.go @@ -88,7 +88,7 @@ func (dst *SpatialRecordPosition) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []SpatialRecord `json:"data"` @@ -102,7 +102,7 @@ func (c *Client) listSpatialRecord(ctx context.Context, site string) ([]SpatialR 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 { Meta Meta `json:"meta"` Data []SpatialRecord `json:"data"` @@ -121,7 +121,7 @@ func (c *Client) getSpatialRecord(ctx context.Context, site, id string) (*Spatia 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) if err != nil { return err @@ -129,7 +129,7 @@ func (c *Client) deleteSpatialRecord(ctx context.Context, site, id string) error 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 { Meta Meta `json:"meta"` Data []SpatialRecord `json:"data"` @@ -149,7 +149,7 @@ func (c *Client) createSpatialRecord(ctx context.Context, site string, d *Spatia 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 { Meta Meta `json:"meta"` Data []SpatialRecord `json:"data"` diff --git a/unifi/sysinfo.go b/unifi/sysinfo.go index 8cb1efe..59ec291 100644 --- a/unifi/sysinfo.go +++ b/unifi/sysinfo.go @@ -74,7 +74,7 @@ type SysInfo struct { } // 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 { Meta Meta `json:"Meta"` Data []SysInfo `json:"data"` @@ -100,7 +100,7 @@ type serverInfo struct { } // 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 { 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. -func (c *Client) GetSystemInformation() (*SysInfo, error) { +func (c *client) GetSystemInformation() (*SysInfo, error) { ctx, cancel := c.newRequestContext() defer cancel() diff --git a/unifi/tag.generated.go b/unifi/tag.generated.go index 299c54a..f3eb251 100644 --- a/unifi/tag.generated.go +++ b/unifi/tag.generated.go @@ -45,7 +45,7 @@ func (dst *Tag) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []Tag `json:"data"` @@ -59,7 +59,7 @@ func (c *Client) listTag(ctx context.Context, site string) ([]Tag, error) { 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 { Meta Meta `json:"meta"` Data []Tag `json:"data"` @@ -78,7 +78,7 @@ func (c *Client) getTag(ctx context.Context, site, id string) (*Tag, error) { 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) if err != nil { return err @@ -86,7 +86,7 @@ func (c *Client) deleteTag(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []Tag `json:"data"` @@ -106,7 +106,7 @@ func (c *Client) createTag(ctx context.Context, site string, d *Tag) (*Tag, erro 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 { Meta Meta `json:"meta"` Data []Tag `json:"data"` diff --git a/unifi/unifi.go b/unifi/unifi.go index 62ebe32..efe9330 100644 --- a/unifi/unifi.go +++ b/unifi/unifi.go @@ -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. // 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. // - interceptors.go: contains interceptor interface and implementations (ApiKeyAuthInterceptor, CsrfInterceptor, DefaultHeadersInterceptor). // - requests.go: contains request handling functions (marshalRequest, createRequestURL, Do, Get, Post, Put, Delete, etc.). diff --git a/unifi/unifi_test.go b/unifi/unifi_test.go index ecd62df..015f826 100644 --- a/unifi/unifi_test.go +++ b/unifi/unifi_test.go @@ -24,7 +24,7 @@ const ( ) // 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)) for _, i := range interceptors { expectedTypes = append(expectedTypes, reflect.TypeOf(i)) @@ -49,14 +49,14 @@ func verifyInterceptorPresence(a *assert.Assertions, c *Client, interceptors []i func TestNewBareClient(t *testing.T) { t.Parallel() a := assert.New(t) - c, err := NewBareClient(&ClientConfig{ + c, err := newBareClient(&ClientConfig{ URL: localUrl, User: "admin", Pass: "password", VerifySSL: false, }) 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.") verifyInterceptorPresence(a, c, []interface{}{&CSRFInterceptor{}, &DefaultHeadersInterceptor{}}, true) verifyInterceptorPresence(a, c, []interface{}{&APIKeyAuthInterceptor{}}, false) @@ -66,7 +66,7 @@ func TestNewClientWithApiKey(t *testing.T) { t.Parallel() a := assert.New(t) // when - c, err := NewClient(&ClientConfig{ + c, err := newBareClient(&ClientConfig{ URL: localUrl, APIKey: "test", VerifySSL: false, @@ -74,7 +74,7 @@ func TestNewClientWithApiKey(t *testing.T) { // then 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.") verifyInterceptorPresence(a, c, []interface{}{&APIKeyAuthInterceptor{}, &DefaultHeadersInterceptor{}}, true) verifyInterceptorPresence(a, c, []interface{}{&CSRFInterceptor{}}, false) @@ -148,9 +148,9 @@ func (i *TestInterceptor) AsList() []ClientInterceptor { return []ClientInterceptor{i} } -func NewTestClientWithInterceptor() (*Client, *TestInterceptor) { +func newTestClientWithInterceptor() (*client, *TestInterceptor) { interceptor := NewTestInterceptor() - c, _ := NewClient(&ClientConfig{ + c, _ := newBareClient(&ClientConfig{ URL: testUrl, APIKey: "test-key", Interceptors: interceptor.AsList(), @@ -161,9 +161,9 @@ func NewTestClientWithInterceptor() (*Client, *TestInterceptor) { // runClientGetRequest creates a new test client, performs a GET request, // 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() - c, interceptor := NewTestClientWithInterceptor() + c, interceptor := newTestClientWithInterceptor() err := c.Get(context.Background(), path, data, nil) require.Error(t, err) 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, // 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() - c, interceptor := NewTestClientWithInterceptor() + c, interceptor := newTestClientWithInterceptor() err := c.Do(context.Background(), method, path, body, nil) require.Error(t, err) return c, interceptor @@ -196,7 +196,7 @@ func TestRequestInterceptorBehavior(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { t.Parallel() - c, interceptor := NewTestClientWithInterceptor() + c, interceptor := newTestClientWithInterceptor() interceptor.failOnRequest = tc.failOnRequest err := c.Get(context.Background(), "/", nil, nil) require.Error(t, err) @@ -311,7 +311,7 @@ func TestUnifiIntegrationUserPassInjected(t *testing.T) { // given srv := runTestServer(NewStyleAPI.LoginPath) interceptor := NewTestInterceptor() - c, _ := NewClient(&ClientConfig{ + c, _ := newBareClient(&ClientConfig{ URL: srv.URL, User: "test-user", Pass: "test-pass", @@ -336,7 +336,7 @@ func TestResponseDataHandling(t *testing.T) { Data: "request", } srv := runTestServer(NewStyleAPI.ApiPath + "/test") - c, _ := NewClient(&ClientConfig{ + c, _ := newBareClient(&ClientConfig{ URL: srv.URL, APIKey: "test-key", }) @@ -357,7 +357,7 @@ func TestCsrfHandling(t *testing.T) { // given srv := runTestServer("") interceptor := NewTestInterceptor() - c, _ := NewClient(&ClientConfig{ + c, _ := newBareClient(&ClientConfig{ URL: srv.URL, User: "test-user", Pass: "test-pass", @@ -386,7 +386,7 @@ func TestOverrideUserAgent(t *testing.T) { a := assert.New(t) // given interceptor := NewTestInterceptor() - c, _ := NewClient(&ClientConfig{ + c, _ := newBareClient(&ClientConfig{ URL: testUrl, APIKey: "test-key", Interceptors: interceptor.AsList(), @@ -556,7 +556,7 @@ func TestValidationModes(t *testing.T) { a := assert.New(t) // given interceptor := NewTestInterceptor() - c, _ := NewClient(&ClientConfig{ + c, _ := newBareClient(&ClientConfig{ URL: testUrl, APIKey: "test-key", Interceptors: []ClientInterceptor{interceptor}, @@ -693,7 +693,7 @@ func TestDetermineApiStyle_InvalidStatus(t *testing.T) { func TestRegisterInterceptor(t *testing.T) { t.Parallel() // Create a manual client with an empty interceptor slice. - client := &Client{ + client := &client{ interceptors: []ClientInterceptor{}, } // Create a dummy interceptor (using TestInterceptor already defined in the file). @@ -727,12 +727,12 @@ func TestDoInvalidJsonResponse(t *testing.T) { })) defer ts.Close() - c, err := NewClient(&ClientConfig{ + c, err := newBareClient(&ClientConfig{ URL: ts.URL, APIKey: "test-key", VerifySSL: false, }) - require.Error(t, err) + require.NoError(t, err) var result map[string]interface{} err = c.Get(context.Background(), "any", nil, &result) @@ -767,13 +767,13 @@ func TestErrorHandlerCustom(t *testing.T) { defer ts.Close() customErrorHandler := &failingErrorHandler{} - c, err := NewClient(&ClientConfig{ + c, err := newBareClient(&ClientConfig{ URL: ts.URL, APIKey: "test-key", VerifySSL: false, ErrorHandler: customErrorHandler, }) - require.Error(t, err) + require.NoError(t, err) var result map[string]interface{} err = c.Get(context.Background(), "error", nil, &result) @@ -783,8 +783,8 @@ func TestErrorHandlerCustom(t *testing.T) { func TestCreateRequestURLInvalid(t *testing.T) { t.Parallel() - c := &Client{ - BaseURL: &url.URL{Scheme: "http", Host: "localhost"}, + c := &client{ + baseURL: &url.URL{Scheme: "http", Host: "localhost"}, apiPaths: &NewStyleAPI, } _, err := c.buildRequestURL("://bad-url") @@ -794,8 +794,8 @@ func TestCreateRequestURLInvalid(t *testing.T) { func TestCreateRequestURLAbsolute(t *testing.T) { t.Parallel() - c := &Client{ - BaseURL: &url.URL{Scheme: "http", Host: "localhost"}, + c := &client{ + baseURL: &url.URL{Scheme: "http", Host: "localhost"}, apiPaths: &NewStyleAPI, } reqURL, err := c.buildRequestURL("http://example.com/test") @@ -805,7 +805,7 @@ func TestCreateRequestURLAbsolute(t *testing.T) { func TestCreateRequestContextTimeout(t *testing.T) { t.Parallel() - c := &Client{ + c := &client{ timeout: 100 * time.Millisecond, } ctx, cancel := c.newRequestContext() @@ -843,7 +843,7 @@ func TestMarshalRequestValid(t *testing.T) { func TestLoginWithAPIKeyDirect(t *testing.T) { t.Parallel() // Create a client manually with the APIKey set. - c := &Client{ + c := &client{ credentials: APIKeyCredentials{APIKey: "abc"}, } err := c.Login() diff --git a/unifi/user.generated.go b/unifi/user.generated.go index 67f667c..46da607 100644 --- a/unifi/user.generated.go +++ b/unifi/user.generated.go @@ -65,7 +65,7 @@ func (dst *User) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []User `json:"data"` @@ -79,7 +79,7 @@ func (c *Client) listUser(ctx context.Context, site string) ([]User, error) { 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 { Meta Meta `json:"meta"` Data []User `json:"data"` @@ -98,7 +98,7 @@ func (c *Client) getUser(ctx context.Context, site, id string) (*User, error) { 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) if err != nil { return err @@ -106,7 +106,7 @@ func (c *Client) deleteUser(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []User `json:"data"` @@ -126,7 +126,7 @@ func (c *Client) createUser(ctx context.Context, site string, d *User) (*User, e 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 { Meta Meta `json:"meta"` Data []User `json:"data"` diff --git a/unifi/user.go b/unifi/user.go index c5a609a..bfc5b8f 100644 --- a/unifi/user.go +++ b/unifi/user.go @@ -9,7 +9,7 @@ import ( // GetUserByMAC returns slightly different information than GetUser, as they // use separate endpoints for their lookups. Specifically IP is only returned // 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 { Meta Meta `json:"Meta"` Data []User `json:"data"` @@ -28,7 +28,7 @@ func (c *Client) GetUserByMAC(ctx context.Context, site, mac string) (*User, err 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 { Objects []struct { Data *User `json:"data"` @@ -72,7 +72,7 @@ func (c *Client) CreateUser(ctx context.Context, site string, d *User) (*User, e 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{}{} 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 } -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{}{ "mac": mac, }) @@ -107,7 +107,7 @@ func (c *Client) BlockUserByMAC(ctx context.Context, site, mac string) error { 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{}{ "mac": mac, }) @@ -120,7 +120,7 @@ func (c *Client) UnblockUserByMAC(ctx context.Context, site, mac string) error { 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{}{ "macs": []string{mac}, }) @@ -133,7 +133,7 @@ func (c *Client) DeleteUserByMAC(ctx context.Context, site, mac string) error { 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{}{ "mac": mac, }) @@ -146,15 +146,15 @@ func (c *Client) KickUserByMAC(ctx context.Context, site, mac string) error { 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{}{ "mac": mac, - "dev_id_override": devIdOveride, + "dev_id_override": devIdOverride, "search_query": "", } var reqMethod string - if devIdOveride == 0 { + if devIdOverride == 0 { reqMethod = "DELETE" } else { reqMethod = "PUT" @@ -174,17 +174,21 @@ func (c *Client) OverrideUserFingerprint(ctx context.Context, site, mac string, 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) } // GetUser returns information about a user from the REST endpoint. // The GetUserByMAC method returns slightly different information (for // 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) } -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) } + +func (c *client) DeleteUser(ctx context.Context, site, id string) error { + return c.deleteUser(ctx, site, id) +} diff --git a/unifi/user_group.generated.go b/unifi/user_group.generated.go index b40fa51..690aab0 100644 --- a/unifi/user_group.generated.go +++ b/unifi/user_group.generated.go @@ -51,7 +51,7 @@ func (dst *UserGroup) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []UserGroup `json:"data"` @@ -65,7 +65,7 @@ func (c *Client) listUserGroup(ctx context.Context, site string) ([]UserGroup, e 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 { Meta Meta `json:"meta"` Data []UserGroup `json:"data"` @@ -84,7 +84,7 @@ func (c *Client) getUserGroup(ctx context.Context, site, id string) (*UserGroup, 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) if err != nil { return err @@ -92,7 +92,7 @@ func (c *Client) deleteUserGroup(ctx context.Context, site, id string) error { 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 { Meta Meta `json:"meta"` Data []UserGroup `json:"data"` @@ -112,7 +112,7 @@ func (c *Client) createUserGroup(ctx context.Context, site string, d *UserGroup) 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 { Meta Meta `json:"meta"` Data []UserGroup `json:"data"` diff --git a/unifi/user_group.go b/unifi/user_group.go index 54ef065..b8bfdca 100644 --- a/unifi/user_group.go +++ b/unifi/user_group.go @@ -2,22 +2,22 @@ package unifi 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) } -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) } -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) } -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) } -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) } diff --git a/unifi/virtual_device.generated.go b/unifi/virtual_device.generated.go index 7ac2620..6d90be0 100644 --- a/unifi/virtual_device.generated.go +++ b/unifi/virtual_device.generated.go @@ -49,7 +49,7 @@ func (dst *VirtualDevice) UnmarshalJSON(b []byte) error { 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 { Meta Meta `json:"meta"` Data []VirtualDevice `json:"data"` @@ -63,7 +63,7 @@ func (c *Client) listVirtualDevice(ctx context.Context, site string) ([]VirtualD 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 { Meta Meta `json:"meta"` Data []VirtualDevice `json:"data"` @@ -82,7 +82,7 @@ func (c *Client) getVirtualDevice(ctx context.Context, site, id string) (*Virtua 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) if err != nil { return err @@ -90,7 +90,7 @@ func (c *Client) deleteVirtualDevice(ctx context.Context, site, id string) error 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 { Meta Meta `json:"meta"` Data []VirtualDevice `json:"data"` @@ -110,7 +110,7 @@ func (c *Client) createVirtualDevice(ctx context.Context, site string, d *Virtua 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 { Meta Meta `json:"meta"` Data []VirtualDevice `json:"data"` diff --git a/unifi/wlan.generated.go b/unifi/wlan.generated.go index 0c881dd..d0c745e 100644 --- a/unifi/wlan.generated.go +++ b/unifi/wlan.generated.go @@ -466,7 +466,7 @@ func (dst *WLANVenueName) UnmarshalJSON(b []byte) error { return nil } -func (c *Client) listWLAN(ctx context.Context, site string) ([]WLAN, error) { +func (c *client) listWLAN(ctx context.Context, site string) ([]WLAN, error) { var respBody struct { Meta Meta `json:"meta"` Data []WLAN `json:"data"` @@ -480,7 +480,7 @@ func (c *Client) listWLAN(ctx context.Context, site string) ([]WLAN, error) { return respBody.Data, nil } -func (c *Client) getWLAN(ctx context.Context, site, id string) (*WLAN, error) { +func (c *client) getWLAN(ctx context.Context, site, id string) (*WLAN, error) { var respBody struct { Meta Meta `json:"meta"` Data []WLAN `json:"data"` @@ -499,7 +499,7 @@ func (c *Client) getWLAN(ctx context.Context, site, id string) (*WLAN, error) { return &d, nil } -func (c *Client) deleteWLAN(ctx context.Context, site, id string) error { +func (c *client) deleteWLAN(ctx context.Context, site, id string) error { err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/wlanconf/%s", site, id), struct{}{}, nil) if err != nil { return err @@ -507,7 +507,7 @@ func (c *Client) deleteWLAN(ctx context.Context, site, id string) error { return nil } -func (c *Client) createWLAN(ctx context.Context, site string, d *WLAN) (*WLAN, error) { +func (c *client) createWLAN(ctx context.Context, site string, d *WLAN) (*WLAN, error) { var respBody struct { Meta Meta `json:"meta"` Data []WLAN `json:"data"` @@ -527,7 +527,7 @@ func (c *Client) createWLAN(ctx context.Context, site string, d *WLAN) (*WLAN, e return &new, nil } -func (c *Client) updateWLAN(ctx context.Context, site string, d *WLAN) (*WLAN, error) { +func (c *client) updateWLAN(ctx context.Context, site string, d *WLAN) (*WLAN, error) { var respBody struct { Meta Meta `json:"meta"` Data []WLAN `json:"data"` diff --git a/unifi/wlan.go b/unifi/wlan.go index 1afca38..ed1c281 100644 --- a/unifi/wlan.go +++ b/unifi/wlan.go @@ -4,7 +4,7 @@ import ( "context" ) -func (c *Client) CreateWLAN(ctx context.Context, site string, d *WLAN) (*WLAN, error) { +func (c *client) CreateWLAN(ctx context.Context, site string, d *WLAN) (*WLAN, error) { if d.Schedule == nil { d.Schedule = []string{} } @@ -12,18 +12,18 @@ func (c *Client) CreateWLAN(ctx context.Context, site string, d *WLAN) (*WLAN, e return c.createWLAN(ctx, site, d) } -func (c *Client) ListWLAN(ctx context.Context, site string) ([]WLAN, error) { +func (c *client) ListWLAN(ctx context.Context, site string) ([]WLAN, error) { return c.listWLAN(ctx, site) } -func (c *Client) GetWLAN(ctx context.Context, site, id string) (*WLAN, error) { +func (c *client) GetWLAN(ctx context.Context, site, id string) (*WLAN, error) { return c.getWLAN(ctx, site, id) } -func (c *Client) DeleteWLAN(ctx context.Context, site, id string) error { +func (c *client) DeleteWLAN(ctx context.Context, site, id string) error { return c.deleteWLAN(ctx, site, id) } -func (c *Client) UpdateWLAN(ctx context.Context, site string, d *WLAN) (*WLAN, error) { +func (c *client) UpdateWLAN(ctx context.Context, site string, d *WLAN) (*WLAN, error) { return c.updateWLAN(ctx, site, d) } diff --git a/unifi/wlan_group.generated.go b/unifi/wlan_group.generated.go index 53ef1e3..8b73ce2 100644 --- a/unifi/wlan_group.generated.go +++ b/unifi/wlan_group.generated.go @@ -44,7 +44,7 @@ func (dst *WLANGroup) UnmarshalJSON(b []byte) error { return nil } -func (c *Client) listWLANGroup(ctx context.Context, site string) ([]WLANGroup, error) { +func (c *client) listWLANGroup(ctx context.Context, site string) ([]WLANGroup, error) { var respBody struct { Meta Meta `json:"meta"` Data []WLANGroup `json:"data"` @@ -58,7 +58,7 @@ func (c *Client) listWLANGroup(ctx context.Context, site string) ([]WLANGroup, e return respBody.Data, 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 { Meta Meta `json:"meta"` Data []WLANGroup `json:"data"` @@ -77,7 +77,7 @@ func (c *Client) getWLANGroup(ctx context.Context, site, id string) (*WLANGroup, 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) if err != nil { return err @@ -85,7 +85,7 @@ func (c *Client) deleteWLANGroup(ctx context.Context, site, id string) error { return nil } -func (c *Client) createWLANGroup(ctx context.Context, site string, d *WLANGroup) (*WLANGroup, error) { +func (c *client) createWLANGroup(ctx context.Context, site string, d *WLANGroup) (*WLANGroup, error) { var respBody struct { Meta Meta `json:"meta"` Data []WLANGroup `json:"data"` @@ -105,7 +105,7 @@ func (c *Client) createWLANGroup(ctx context.Context, site string, d *WLANGroup) return &new, 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 { Meta Meta `json:"meta"` Data []WLANGroup `json:"data"` diff --git a/unifi/wlan_group.go b/unifi/wlan_group.go index 5ad3558..6cbcf2b 100644 --- a/unifi/wlan_group.go +++ b/unifi/wlan_group.go @@ -4,22 +4,22 @@ import ( "context" ) -func (c *Client) ListWLANGroup(ctx context.Context, site string) ([]WLANGroup, error) { +func (c *client) ListWLANGroup(ctx context.Context, site string) ([]WLANGroup, error) { return c.listWLANGroup(ctx, site) } -func (c *Client) GetWLANGroup(ctx context.Context, site, id string) (*WLANGroup, error) { +func (c *client) GetWLANGroup(ctx context.Context, site, id string) (*WLANGroup, error) { return c.getWLANGroup(ctx, site, id) } -func (c *Client) DeleteWLANGroup(ctx context.Context, site, id string) error { +func (c *client) DeleteWLANGroup(ctx context.Context, site, id string) error { return c.deleteWLANGroup(ctx, site, id) } -func (c *Client) CreateWLANGroup(ctx context.Context, site string, d *WLANGroup) (*WLANGroup, error) { +func (c *client) CreateWLANGroup(ctx context.Context, site string, d *WLANGroup) (*WLANGroup, error) { return c.createWLANGroup(ctx, site, d) } -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) { return c.updateWLANGroup(ctx, site, d) }