Add support for IP on User
This commit is contained in:
@@ -204,6 +204,11 @@ type %s struct {
|
|||||||
code += fieldCode + "\n"
|
code += fieldCode + "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch structName {
|
||||||
|
case "User":
|
||||||
|
code += "\t// non-generated fields\n\tIP string `json:\"ip,omitempty\"`\n"
|
||||||
|
}
|
||||||
|
|
||||||
code = code + "}\n"
|
code = code + "}\n"
|
||||||
|
|
||||||
if strings.HasPrefix(structName, "Setting") {
|
if strings.HasPrefix(structName, "Setting") {
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ type User struct {
|
|||||||
Note string `json:"note,omitempty"`
|
Note string `json:"note,omitempty"`
|
||||||
UseFixedIP bool `json:"use_fixedip"`
|
UseFixedIP bool `json:"use_fixedip"`
|
||||||
UserGroupID string `json:"usergroup_id"`
|
UserGroupID string `json:"usergroup_id"`
|
||||||
|
// non-generated fields
|
||||||
|
IP string `json:"ip,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) listUser(site string) ([]User, error) {
|
func (c *Client) listUser(site string) ([]User, error) {
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ package unifi
|
|||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
|
// GetUserByMAC returns slightly different information than GetUser, as they
|
||||||
|
// use separate endpoints for their lookups. Specifically IP is only returned
|
||||||
|
// by this method.
|
||||||
func (c *Client) GetUserByMAC(site, mac string) (*User, error) {
|
func (c *Client) GetUserByMAC(site, mac string) (*User, error) {
|
||||||
var respBody struct {
|
var respBody struct {
|
||||||
Meta meta `json:"meta"`
|
Meta meta `json:"meta"`
|
||||||
@@ -129,6 +132,9 @@ func (c *Client) ListUser(site string) ([]User, error) {
|
|||||||
return c.listUser(site)
|
return c.listUser(site)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUser returns information about a user from the REST endpoint.
|
||||||
|
// The GetUserByMAC method returns slightly different information (for
|
||||||
|
// example the IP) as it uses a different endpoint.
|
||||||
func (c *Client) GetUser(site, id string) (*User, error) {
|
func (c *Client) GetUser(site, id string) (*User, error) {
|
||||||
return c.getUser(site, id)
|
return c.getUser(site, id)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user