Skip to content

Commit

Permalink
Add dev_id_override to user
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaspence authored and paultyng committed Jun 18, 2021
1 parent dd685c0 commit 2f7eee3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
1 change: 1 addition & 0 deletions fields/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func NewResource(structName string, resourcePath string) *Resource {
baseType.Fields[" MAC"] = NewFieldInfo("MAC", "mac", "string", "", true, false)
case resource.StructName == "User":
baseType.Fields[" IP"] = NewFieldInfo("IP", "ip", "string", "non-generated field", true, false)
baseType.Fields[" DevIdOverride"] = NewFieldInfo("DevIdOverride", "dev_id_override", "int", "non-generated field", true, false)
case resource.StructName == "WLAN":
// this field removed in v6, retaining for backwards compatibility
baseType.Fields["WLANGroupID"] = NewFieldInfo("WLANGroupID", "wlangroup_id", "string", "", false, false)
Expand Down
21 changes: 11 additions & 10 deletions unifi/user.generated.go

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

28 changes: 28 additions & 0 deletions unifi/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,34 @@ func (c *Client) DeleteUserByMAC(ctx context.Context, site, mac string) error {
return nil
}

func (c *Client) OverrideUserFingerprint(ctx context.Context, site, mac string, devIdOveride int) error {
reqBody := map[string]interface{}{
"mac": mac,
"dev_id_override": devIdOveride,
"search_query": "",
}

var reqMethod string
if devIdOveride == 0 {
reqMethod = "DELETE"
} else {
reqMethod = "PUT"
}

var respBody struct {
Mac string `json:"mac"`
DevIdOverride int `json:"dev_id_override"`
SearchQuery string `json:"search_query"`
}

err := c.do(ctx, reqMethod, fmt.Sprintf("%s/site/%s/station/%s/fingerprint_override", c.apiV2Path, site, mac), reqBody, &respBody)
if err != nil {
return err
}

return nil
}

func (c *Client) ListUser(ctx context.Context, site string) ([]User, error) {
return c.listUser(ctx, site)
}
Expand Down

0 comments on commit 2f7eee3

Please sign in to comment.