-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccess_points.go
76 lines (65 loc) · 2.28 KB
/
access_points.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package dnas
import (
"context"
"fmt"
"net/http"
)
// AccessPointStatus represents the status passed to get the access point count for a given status
type AccessPointStatus string
// Fields for AccessPointStatus
const (
All AccessPointStatus = "all"
Active AccessPointStatus = "active"
Inactive AccessPointStatus = "inactive"
Missing AccessPointStatus = "missing"
)
// AccessPointsResponse provides a list of missing access points returned by ListAccessPoints
type AccessPointsResponse []struct {
// ap mac
ApMac string `json:"apMac,omitempty"`
// The message count received.
Count int64 `json:"count,omitempty"`
// The message rate in 15 min.
M15Rate float64 `json:"m15Rate,omitempty"`
// The message rate in 1 min.
M1Rate float64 `json:"m1Rate,omitempty"`
// The message rate in 5 min.
M5Rate float64 `json:"m5Rate,omitempty"`
}
// AccessPointsCountResponse provides the count for the active, inactive, missing or all the access points from GetCount()
type AccessPointsCountResponse struct {
// Count of access points for a given status
Count int64 `json:"count"`
}
// ListAccessPoints retrieves a list of missing access points.
// The only valid status is "missing" and is therefore not provided as an option.
func (s *AccessPointsService) ListAccessPoints(ctx context.Context) (AccessPointsResponse, error) {
apr := AccessPointsResponse{}
url := fmt.Sprintf("%s/accessPoints?status=missing", s.client.BaseURL)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return apr, err
}
if err := s.client.makeRequest(ctx, req, &apr); err != nil {
return apr, err
}
return apr, nil
}
// GetCount retrieves the count of the active, inactive, missing or all the access points.
// If no parameters are given, the count of all active access points is returned.
// Status may be missing, active, inactive or all
func (s *AccessPointsService) GetCount(ctx context.Context, status AccessPointStatus) (AccessPointsCountResponse, error) {
if status == "" {
status = "missing"
}
apcr := AccessPointsCountResponse{}
url := fmt.Sprintf("%s/accessPoints/count?status=%s", s.client.BaseURL, status)
req, err := http.NewRequest("GET", url, nil)
if err != nil {
return apcr, err
}
if err := s.client.makeRequest(ctx, req, &apcr); err != nil {
return apcr, err
}
return apcr, nil
}