This commit changes the code generator to generate a `UnmarshalJSON` for each struct, so that if unmarshalled it properly handles UniFis varying integer values via the `emptyStringInt` type. Structs not including a field of `int` type will still have the function generated, but it will effectively do nothing. Fixes #18
35 lines
839 B
Go
35 lines
839 B
Go
package unifi
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
)
|
|
|
|
func (c *Client) DeleteNetwork(ctx context.Context, site, id, name string) error {
|
|
err := c.do(ctx, "DELETE", fmt.Sprintf("s/%s/rest/networkconf/%s", site, id), struct {
|
|
Name string `json:"name"`
|
|
}{
|
|
Name: name,
|
|
}, nil)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (c *Client) ListNetwork(ctx context.Context, site string) ([]Network, error) {
|
|
return c.listNetwork(ctx, site)
|
|
}
|
|
|
|
func (c *Client) GetNetwork(ctx context.Context, site, id string) (*Network, error) {
|
|
return c.getNetwork(ctx, site, id)
|
|
}
|
|
|
|
func (c *Client) CreateNetwork(ctx context.Context, site string, d *Network) (*Network, error) {
|
|
return c.createNetwork(ctx, site, d)
|
|
}
|
|
|
|
func (c *Client) UpdateNetwork(ctx context.Context, site string, d *Network) (*Network, error) {
|
|
return c.updateNetwork(ctx, site, d)
|
|
}
|