-
Notifications
You must be signed in to change notification settings - Fork 3
/
locations.go
50 lines (44 loc) · 1.37 KB
/
locations.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
package wpt
// LocationsResponse is the response wraper for a location list request.
type LocationsResponse struct {
StatusCode int `json:"statusCode"`
StatusText string `json:"statusText"`
Data map[string]Location `json:"data"`
}
// Location is a single location.
type Location struct {
Label string `json:"Label"`
Location string `json:"location"`
Browser string `json:"Browser"`
RelayServer string `json:"relayServer"`
RelayLocation string `json:"relayLocation"`
LabelShort string `json:"labelShort"`
Default bool `json:"default"`
PendingTests struct {
Total int `json:"Total"`
HighPriority int `json:"HighPriority"`
LowPriority int `json:"LowPriority"`
Testing int `json:"Testing"`
Idle int `json:"Idle"`
} `json:"PendingTests"`
}
// Locations is a list of Location
type Locations []Location
// GetDefault returns the default location if your API Key runs a test.
func (locations Locations) GetDefault() (defaultLocation Location) {
for _, location := range locations {
if location.Default {
defaultLocation = location
}
}
return defaultLocation
}
// Valid checks to see if name exists in this list of locations.
func (locations Locations) Valid(name string) bool {
for _, location := range locations {
if location.Location == name {
return true
}
}
return false
}