From b0f7ec85112a8c69e15685d2ddc6da7892810e8d Mon Sep 17 00:00:00 2001 From: appkins Date: Wed, 19 Feb 2025 00:37:21 -0600 Subject: [PATCH] Add Execute CMD --- unifi/cmd.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 unifi/cmd.go diff --git a/unifi/cmd.go b/unifi/cmd.go new file mode 100644 index 0000000..2852962 --- /dev/null +++ b/unifi/cmd.go @@ -0,0 +1,30 @@ +package unifi + +import ( + "context" + "fmt" +) + +// just to fix compile issues with the import. +var ( + _ fmt.Formatter + _ context.Context +) + +type Cmd struct { + MAC string `json:"mac,omitempty"` + PortIDX *int `json:"port_idx,omitempty"` + FileName string `json:"filename,omitempty"` + SiteID string `json:"site_id,omitempty"` +} + +func (c *Client) ExecuteCmd(ctx context.Context, site string, mgr string, cmd Cmd) (any, error) { + var respBody struct{} + + err := c.do(ctx, "POST", fmt.Sprintf("%s/site/%s/cmd/%s", c.apiV2Path, site, mgr), &cmd, &respBody) + if err != nil { + return nil, err + } + + return respBody, nil +}