42 lines
939 B
Go
42 lines
939 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) 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 {
|
|
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) GetDevice(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{}
|
|
}
|