2025-02-01 17:38:29 +01:00
|
|
|
package omadaapi
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"git.tordarus.net/tordarus/ezhttp"
|
|
|
|
"git.tordarus.net/tordarus/omada-api/model"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (api *Api) GetApInfo(siteID model.SiteID, macAddress string) (*model.ApInfo, error) {
|
2025-02-02 10:54:39 +01:00
|
|
|
api.refreshMutex.RLock()
|
|
|
|
defer api.refreshMutex.RUnlock()
|
|
|
|
|
2025-02-01 17:38:29 +01:00
|
|
|
req := ezhttp.Request(
|
|
|
|
ezhttp.Template(api.tmpl),
|
|
|
|
ezhttp.Method("GET"),
|
|
|
|
ezhttp.AppendPath(
|
|
|
|
fmt.Sprintf("/openapi/v1/%s/sites/%s/aps/%s",
|
|
|
|
api.config.OmadaID,
|
|
|
|
siteID,
|
|
|
|
macAddress)),
|
|
|
|
)
|
|
|
|
|
|
|
|
resp, err := ezhttp.Do(req)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer resp.Body.Close()
|
|
|
|
|
|
|
|
response, err := ezhttp.ParseJsonResponse[model.Response[model.ApInfo]](resp.Body)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &response.Result, nil
|
|
|
|
}
|