forked from huaweicloud/huaweicloud-sdk-go-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
region.go
54 lines (47 loc) · 1.58 KB
/
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
package region
import (
"fmt"
"github.com/dysodeng/huaweicloud-sdk-go-v3/core/region"
)
var (
AP_SOUTHEAST_3 = region.NewRegion("ap-southeast-3",
"https://codearts-deploy.ap-southeast-3.myhuaweicloud.com")
CN_SOUTH_1 = region.NewRegion("cn-south-1",
"https://codearts-deploy.cn-south-1.myhuaweicloud.com")
CN_EAST_3 = region.NewRegion("cn-east-3",
"https://codearts-deploy.cn-east-3.myhuaweicloud.com")
CN_EAST_2 = region.NewRegion("cn-east-2",
"https://codearts-deploy.cn-east-2.myhuaweicloud.com")
CN_NORTH_1 = region.NewRegion("cn-north-1",
"https://codearts-deploy.cn-north-1.myhuaweicloud.com")
CN_NORTH_4 = region.NewRegion("cn-north-4",
"https://codearts-deploy.cn-north-4.myhuaweicloud.com")
SA_BRAZIL_1 = region.NewRegion("sa-brazil-1",
"https://codearts-deploy.sa-brazil-1.myhuaweicloud.com")
LA_NORTH_2 = region.NewRegion("la-north-2",
"https://codearts-deploy.la-north-2.myhuaweicloud.com")
)
var staticFields = map[string]*region.Region{
"ap-southeast-3": AP_SOUTHEAST_3,
"cn-south-1": CN_SOUTH_1,
"cn-east-3": CN_EAST_3,
"cn-east-2": CN_EAST_2,
"cn-north-1": CN_NORTH_1,
"cn-north-4": CN_NORTH_4,
"sa-brazil-1": SA_BRAZIL_1,
"la-north-2": LA_NORTH_2,
}
var provider = region.DefaultProviderChain("CODEARTSDEPLOY")
func ValueOf(regionId string) *region.Region {
if regionId == "" {
panic("unexpected empty parameter: regionId")
}
reg := provider.GetRegion(regionId)
if reg != nil {
return reg
}
if _, ok := staticFields[regionId]; ok {
return staticFields[regionId]
}
panic(fmt.Sprintf("unexpected regionId: %s", regionId))
}