feat: add Version method to client to provide system version information (#32)
This commit is contained in:
committed by
GitHub
parent
d3a3d5a342
commit
16f71e7fe9
@@ -16,6 +16,10 @@ customizations:
|
||||
comment: "BaseURL returns the base URL of the controller."
|
||||
returns:
|
||||
- "string"
|
||||
- name: "Version"
|
||||
comment: "Version returns the version of the UniFi Controller API."
|
||||
returns:
|
||||
- "string"
|
||||
- name: "Do"
|
||||
comment: "Do sends a request to the controller."
|
||||
params:
|
||||
|
||||
3
unifi/client.generated.go
generated
3
unifi/client.generated.go
generated
@@ -33,6 +33,9 @@ type Client interface {
|
||||
// Put sends a PUT request to the controller.
|
||||
Put(ctx context.Context, apiPath string, reqBody interface{}, respBody interface{}) error
|
||||
|
||||
// Version returns the version of the UniFi Controller API.
|
||||
Version() string
|
||||
|
||||
// ==== client methods for APGroup resource ====
|
||||
|
||||
// CreateAPGroup creates a resource
|
||||
|
||||
@@ -153,6 +153,20 @@ func parseBaseURL(base string) (*url.URL, error) {
|
||||
return baseURL, nil
|
||||
}
|
||||
|
||||
func (c *client) Version() string {
|
||||
if c.sysInfo != nil {
|
||||
return c.sysInfo.Version
|
||||
}
|
||||
c.lock.Lock()
|
||||
defer c.lock.Unlock()
|
||||
i, err := c.GetSystemInformation()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
c.sysInfo = i
|
||||
return c.sysInfo.Version
|
||||
}
|
||||
|
||||
func newClientFromConfig(config *ClientConfig, v *validator) (*client, error) {
|
||||
var rt http.RoundTripper
|
||||
var err error
|
||||
|
||||
Reference in New Issue
Block a user