Expose Device API
This commit is contained in:
committed by
Paul Tyng
parent
14e88eece9
commit
e93f92a066
41
unifi/device.go
Normal file
41
unifi/device.go
Normal 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{}
|
||||
}
|
||||
Reference in New Issue
Block a user