diff --git a/core/unifi/clients_type.go b/core/unifi/clients_type.go index d0a21c04..820e4b48 100644 --- a/core/unifi/clients_type.go +++ b/core/unifi/clients_type.go @@ -1,5 +1,10 @@ package unifi +// Clients contains a list that contains all of the unifi clients from a controller. +type Clients struct { + UCLs []UCL +} + // UCL defines all the data a connected-network client contains. type UCL struct { ID string `json:"_id"` diff --git a/core/unifi/site_influx.go b/core/unifi/site_influx.go index f78b3c3e..a0ad2c77 100644 --- a/core/unifi/site_influx.go +++ b/core/unifi/site_influx.go @@ -10,7 +10,7 @@ import ( // Points generates Unifi Sites' datapoints for InfluxDB. // These points can be passed directly to influx. func (u Site) Points() ([]*influx.Point, error) { - points := make([]*influx.Point, 1) + var points []*influx.Point for _, s := range u.Health { tags := map[string]string{ "id": u.ID, diff --git a/core/unifi/site_type.go b/core/unifi/site_type.go index b215363f..23eba62c 100644 --- a/core/unifi/site_type.go +++ b/core/unifi/site_type.go @@ -1,5 +1,8 @@ package unifi +// Sites is a struct to match Devices and Clients. +type Sites []Site + // Site represents a site's data. type Site struct { ID string `json:"_id"` diff --git a/core/unifi/types.go b/core/unifi/types.go index 63530eec..a2795ade 100644 --- a/core/unifi/types.go +++ b/core/unifi/types.go @@ -54,11 +54,6 @@ type Devices struct { USWs []USW } -// Clients contains a list that contains all of the unifi clients from a controller. -type Clients struct { - UCLs []UCL -} - // Unifi is what you get in return for providing a password! Unifi represents // a controller that you can make authenticated requests to. Use this to make // additional requests for devices, clients or other custom data. diff --git a/core/unifi/unifi.go b/core/unifi/unifi.go index 7afb2af2..0676b3e1 100644 --- a/core/unifi/unifi.go +++ b/core/unifi/unifi.go @@ -125,7 +125,7 @@ func (u *Unifi) GetDevices(sites []Site) (*Devices, error) { } // GetSites returns a list of configured sites on the Unifi controller. -func (u *Unifi) GetSites() ([]Site, error) { +func (u *Unifi) GetSites() (Sites, error) { var response struct { Data []Site `json:"data"` }