feat: new, more customizable client supporting API Key and user/password authentication
This commit is contained in:
committed by
Mateusz Filipowicz
parent
8a0cf33e75
commit
f79f21c4ad
24
unifi/device.generated.go
generated
24
unifi/device.generated.go
generated
@@ -586,11 +586,11 @@ func (dst *DeviceRpsPortTable) UnmarshalJSON(b []byte) error {
|
||||
|
||||
func (c *Client) listDevice(ctx context.Context, site string) ([]Device, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Device `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/stat/device", site), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/stat/device", site), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -600,17 +600,17 @@ func (c *Client) listDevice(ctx context.Context, site string) ([]Device, error)
|
||||
|
||||
func (c *Client) getDevice(ctx context.Context, site, id string) (*Device, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Device `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "GET", fmt.Sprintf("s/%s/stat/device/%s", site, id), nil, &respBody)
|
||||
err := c.Get(ctx, fmt.Sprintf("s/%s/stat/device/%s", site, id), nil, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
d := respBody.Data[0]
|
||||
@@ -618,7 +618,7 @@ func (c *Client) getDevice(ctx context.Context, site, id string) (*Device, error
|
||||
}
|
||||
|
||||
func (c *Client) deleteDevice(ctx context.Context, site, id string) error {
|
||||
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/device/%s", site, id), struct{}{}, nil)
|
||||
err := c.Delete(ctx, fmt.Sprintf("s/%s/rest/device/%s", site, id), struct{}{}, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -627,17 +627,17 @@ func (c *Client) deleteDevice(ctx context.Context, site, id string) error {
|
||||
|
||||
func (c *Client) createDevice(ctx context.Context, site string, d *Device) (*Device, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Device `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "POST", fmt.Sprintf("s/%s/rest/device", site), d, &respBody)
|
||||
err := c.Post(ctx, fmt.Sprintf("s/%s/rest/device", site), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
@@ -647,17 +647,17 @@ func (c *Client) createDevice(ctx context.Context, site string, d *Device) (*Dev
|
||||
|
||||
func (c *Client) updateDevice(ctx context.Context, site string, d *Device) (*Device, error) {
|
||||
var respBody struct {
|
||||
Meta meta `json:"meta"`
|
||||
Meta Meta `json:"meta"`
|
||||
Data []Device `json:"data"`
|
||||
}
|
||||
|
||||
err := c.do(ctx, "PUT", fmt.Sprintf("s/%s/rest/device/%s", site, d.ID), d, &respBody)
|
||||
err := c.Put(ctx, fmt.Sprintf("s/%s/rest/device/%s", site, d.ID), d, &respBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(respBody.Data) != 1 {
|
||||
return nil, &NotFoundError{}
|
||||
return nil, NotFoundError
|
||||
}
|
||||
|
||||
new := respBody.Data[0]
|
||||
|
||||
Reference in New Issue
Block a user