Skip to content

Commit

Permalink
Add support for IP on User
Browse files Browse the repository at this point in the history
  • Loading branch information
paultyng committed Feb 19, 2020
1 parent 3fb1d0b commit 19709df
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fields/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ type %s struct {
code += fieldCode + "\n"
}

switch structName {
case "User":
code += "\t// non-generated fields\n\tIP string `json:\"ip,omitempty\"`\n"
}

code = code + "}\n"

if strings.HasPrefix(structName, "Setting") {
Expand Down
2 changes: 2 additions & 0 deletions unifi/user.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions unifi/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package unifi

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) {
var respBody struct {
Meta meta `json:"meta"`
Expand Down Expand Up @@ -129,6 +132,9 @@ func (c *Client) ListUser(site string) ([]User, error) {
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) {
return c.getUser(site, id)
}
Expand Down

0 comments on commit 19709df

Please sign in to comment.