Files
go-unifi/unifi/device.go
James Stephenson e93f92a066 Expose Device API
2020-10-09 08:56:24 -04:00

42 lines
938 B
Go

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{}
}