Expose Device API

This commit is contained in:
James Stephenson
2020-08-21 14:47:02 -04:00
committed by Paul Tyng
parent 14e88eece9
commit e93f92a066
3 changed files with 43 additions and 2 deletions

View File

@@ -23,7 +23,7 @@ type Device struct {
NoDelete bool `json:"attr_no_delete,omitempty"`
NoEdit bool `json:"attr_no_edit,omitempty"`
MAC string `json:"mac"`
MAC string `json:"mac,omitempty"`
AtfEnabled bool `json:"atf_enabled,omitempty"`
BandsteeringMode string `json:"bandsteering_mode,omitempty"` // off|equal|prefer_5g

41
unifi/device.go Normal file
View File

@@ -0,0 +1,41 @@
package unifi
import (
"context"
)
func (c *Client) ListDevice(ctx context.Context, site string) ([]Device, error) {
return c.listDevice(ctx, site)
}
func (c *Client) GetDevice(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 {
return c.deleteDevice(ctx, site, id)
}
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) {
return c.updateDevice(ctx, site, d)
}
func (c *Client) GetDeviceById(ctx context.Context, site, id string) (*Device, error) {
devices, err := c.ListDevice(ctx, site)
if err != nil {
return nil, err
}
for _, d := range devices {
if d.ID == id {
return &d, nil
}
}
return nil, &NotFoundError{}
}