-
Notifications
You must be signed in to change notification settings - Fork 16
/
region.go
55 lines (48 loc) · 984 Bytes
/
region.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
package region
// Region represents the sauce labs region.
type Region uint
const (
// None is an undefined sauce labs region.
None Region = iota
// USWest1 is a sauce labs region in the US, aka us-west-1.
USWest1
// EUCentral1 is a sauce labs region in the EU, aka eu-central-1.
EUCentral1
)
var meta = []struct {
Name string
APIBaseURL string
}{
// None
{
"",
"",
},
// USWest1
{
"us-west-1",
"https://api.us-west-1.saucelabs.com",
},
// EUCentral1
{
"eu-central-1",
"https://api.eu-central-1.saucelabs.com",
},
}
func (r Region) String() string {
return meta[r].Name
}
// FromString converts the given string to the corresponding Region.
// Returns None if the string did not match any Region.
func FromString(s string) Region {
for i, m := range meta {
if m.Name == s {
return Region(i)
}
}
return None
}
// APIBaseURL returns the API base URL for the region.
func (r Region) APIBaseURL() string {
return meta[r].APIBaseURL
}