Renaming PortConf to PortProfile; cleanup Device API func names
This commit is contained in:
committed by
Paul Tyng
parent
4b8ec1e2f8
commit
6203ee9620
@@ -55,6 +55,7 @@ var fieldReps = []replacement{
|
|||||||
{"Networkgroup", "NetworkGroup"},
|
{"Networkgroup", "NetworkGroup"},
|
||||||
{"Pd", "PD"},
|
{"Pd", "PD"},
|
||||||
{"Pmf", "PMF"},
|
{"Pmf", "PMF"},
|
||||||
|
{"Portconf", "PortProfile"},
|
||||||
{"Qos", "QOS"},
|
{"Qos", "QOS"},
|
||||||
{"Radiusprofile", "RADIUSProfile"},
|
{"Radiusprofile", "RADIUSProfile"},
|
||||||
{"Radius", "RADIUS"},
|
{"Radius", "RADIUS"},
|
||||||
@@ -80,6 +81,7 @@ var fileReps = []replacement{
|
|||||||
{"Dhcp", "DHCP"},
|
{"Dhcp", "DHCP"},
|
||||||
{"Wlan", "WLAN"},
|
{"Wlan", "WLAN"},
|
||||||
{"NetworkConf", "Network"},
|
{"NetworkConf", "Network"},
|
||||||
|
{"PortConf", "PortProfile"},
|
||||||
{"RadiusProfile", "RADIUSProfile"},
|
{"RadiusProfile", "RADIUSProfile"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -120,9 +120,9 @@ type DevicePortOverrides struct {
|
|||||||
OpMode string `json:"op_mode,omitempty"` // switch|mirror|aggregate
|
OpMode string `json:"op_mode,omitempty"` // switch|mirror|aggregate
|
||||||
PoeMode string `json:"poe_mode,omitempty"` // auto|pasv24|passthrough|off
|
PoeMode string `json:"poe_mode,omitempty"` // auto|pasv24|passthrough|off
|
||||||
PortIDX int `json:"port_idx,omitempty"` // [1-9]|[1-4][0-9]|5[0-2]
|
PortIDX int `json:"port_idx,omitempty"` // [1-9]|[1-4][0-9]|5[0-2]
|
||||||
|
PortProfileID string `json:"portconf_id,omitempty"` // [\d\w]+
|
||||||
PortSecurityEnabled bool `json:"port_security_enabled,omitempty"`
|
PortSecurityEnabled bool `json:"port_security_enabled,omitempty"`
|
||||||
PortSecurityMACAddress []string `json:"port_security_mac_address,omitempty"` // ^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$
|
PortSecurityMACAddress []string `json:"port_security_mac_address,omitempty"` // ^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$
|
||||||
PortconfID string `json:"portconf_id,omitempty"` // [\d\w]+
|
|
||||||
PriorityQueue1Level int `json:"priority_queue1_level,omitempty"` // [0-9]|[1-9][0-9]|100
|
PriorityQueue1Level int `json:"priority_queue1_level,omitempty"` // [0-9]|[1-9][0-9]|100
|
||||||
PriorityQueue2Level int `json:"priority_queue2_level,omitempty"` // [0-9]|[1-9][0-9]|100
|
PriorityQueue2Level int `json:"priority_queue2_level,omitempty"` // [0-9]|[1-9][0-9]|100
|
||||||
PriorityQueue3Level int `json:"priority_queue3_level,omitempty"` // [0-9]|[1-9][0-9]|100
|
PriorityQueue3Level int `json:"priority_queue3_level,omitempty"` // [0-9]|[1-9][0-9]|100
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ func (c *Client) ListDevice(ctx context.Context, site string) ([]Device, error)
|
|||||||
return c.listDevice(ctx, site)
|
return c.listDevice(ctx, site)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetDevice(ctx context.Context, site, mac string) (*Device, error) {
|
func (c *Client) GetDeviceByMAC(ctx context.Context, site, mac string) (*Device, error) {
|
||||||
return c.getDevice(ctx, site, mac)
|
return c.getDevice(ctx, site, mac)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ func (c *Client) UpdateDevice(ctx context.Context, site string, d *Device) (*Dev
|
|||||||
return c.updateDevice(ctx, site, d)
|
return c.updateDevice(ctx, site, d)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) GetDeviceById(ctx context.Context, site, id string) (*Device, error) {
|
func (c *Client) GetDevice(ctx context.Context, site, id string) (*Device, error) {
|
||||||
devices, err := c.ListDevice(ctx, site)
|
devices, err := c.ListDevice(ctx, site)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
package unifi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (c *Client) ListPortConf(ctx context.Context, site string) ([]PortConf, error) {
|
|
||||||
return c.listPortConf(ctx, site)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) GetPortConf(ctx context.Context, site, id string) (*PortConf, error) {
|
|
||||||
return c.getPortConf(ctx, site, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) DeletePortConf(ctx context.Context, site, id string) error {
|
|
||||||
return c.deletePortConf(ctx, site, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) CreatePortConf(ctx context.Context, site string, d *PortConf) (*PortConf, error) {
|
|
||||||
return c.createPortConf(ctx, site, d)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) UpdatePortConf(ctx context.Context, site string, d *PortConf) (*PortConf, error) {
|
|
||||||
return c.updatePortConf(ctx, site, d)
|
|
||||||
}
|
|
||||||
@@ -14,7 +14,7 @@ var (
|
|||||||
_ context.Context
|
_ context.Context
|
||||||
)
|
)
|
||||||
|
|
||||||
type PortConf struct {
|
type PortProfile struct {
|
||||||
ID string `json:"_id,omitempty"`
|
ID string `json:"_id,omitempty"`
|
||||||
SiteID string `json:"site_id,omitempty"`
|
SiteID string `json:"site_id,omitempty"`
|
||||||
|
|
||||||
@@ -59,10 +59,10 @@ type PortConf struct {
|
|||||||
VoiceNetworkID string `json:"voice_networkconf_id"`
|
VoiceNetworkID string `json:"voice_networkconf_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) listPortConf(ctx context.Context, site string) ([]PortConf, error) {
|
func (c *Client) listPortProfile(ctx context.Context, site string) ([]PortProfile, error) {
|
||||||
var respBody struct {
|
var respBody struct {
|
||||||
Meta meta `json:"meta"`
|
Meta meta `json:"meta"`
|
||||||
Data []PortConf `json:"data"`
|
Data []PortProfile `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/portconf", site), nil, &respBody)
|
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/portconf", site), nil, &respBody)
|
||||||
@@ -73,10 +73,10 @@ func (c *Client) listPortConf(ctx context.Context, site string) ([]PortConf, err
|
|||||||
return respBody.Data, nil
|
return respBody.Data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) getPortConf(ctx context.Context, site, id string) (*PortConf, error) {
|
func (c *Client) getPortProfile(ctx context.Context, site, id string) (*PortProfile, error) {
|
||||||
var respBody struct {
|
var respBody struct {
|
||||||
Meta meta `json:"meta"`
|
Meta meta `json:"meta"`
|
||||||
Data []PortConf `json:"data"`
|
Data []PortProfile `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/portconf/%s", site, id), nil, &respBody)
|
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/rest/portconf/%s", site, id), nil, &respBody)
|
||||||
@@ -92,7 +92,7 @@ func (c *Client) getPortConf(ctx context.Context, site, id string) (*PortConf, e
|
|||||||
return &d, nil
|
return &d, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) deletePortConf(ctx context.Context, site, id string) error {
|
func (c *Client) deletePortProfile(ctx context.Context, site, id string) error {
|
||||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/portconf/%s", site, id), struct{}{}, nil)
|
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/portconf/%s", site, id), struct{}{}, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -100,10 +100,10 @@ func (c *Client) deletePortConf(ctx context.Context, site, id string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) createPortConf(ctx context.Context, site string, d *PortConf) (*PortConf, error) {
|
func (c *Client) createPortProfile(ctx context.Context, site string, d *PortProfile) (*PortProfile, error) {
|
||||||
var respBody struct {
|
var respBody struct {
|
||||||
Meta meta `json:"meta"`
|
Meta meta `json:"meta"`
|
||||||
Data []PortConf `json:"data"`
|
Data []PortProfile `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/portconf", site), d, &respBody)
|
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/portconf", site), d, &respBody)
|
||||||
@@ -120,10 +120,10 @@ func (c *Client) createPortConf(ctx context.Context, site string, d *PortConf) (
|
|||||||
return &new, nil
|
return &new, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) updatePortConf(ctx context.Context, site string, d *PortConf) (*PortConf, error) {
|
func (c *Client) updatePortProfile(ctx context.Context, site string, d *PortProfile) (*PortProfile, error) {
|
||||||
var respBody struct {
|
var respBody struct {
|
||||||
Meta meta `json:"meta"`
|
Meta meta `json:"meta"`
|
||||||
Data []PortConf `json:"data"`
|
Data []PortProfile `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/portconf/%s", site, d.ID), d, &respBody)
|
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/portconf/%s", site, d.ID), d, &respBody)
|
||||||
25
unifi/port_profile.go
Normal file
25
unifi/port_profile.go
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package unifi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
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) {
|
||||||
|
return c.getPortProfile(ctx, site, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
return c.createPortProfile(ctx, site, d)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) UpdatePortProfile(ctx context.Context, site string, d *PortProfile) (*PortProfile, error) {
|
||||||
|
return c.updatePortProfile(ctx, site, d)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user