2015-10-25 04:01:15 +01:00
|
|
|
package common
|
|
|
|
|
|
|
|
// Region represents ECS region
|
|
|
|
type Region string
|
|
|
|
|
|
|
|
// Constants of region definition
|
|
|
|
const (
|
2018-12-25 01:30:40 +01:00
|
|
|
Hangzhou = Region("cn-hangzhou")
|
|
|
|
Qingdao = Region("cn-qingdao")
|
|
|
|
Beijing = Region("cn-beijing")
|
|
|
|
Hongkong = Region("cn-hongkong")
|
|
|
|
Shenzhen = Region("cn-shenzhen")
|
|
|
|
Shanghai = Region("cn-shanghai")
|
|
|
|
Zhangjiakou = Region("cn-zhangjiakou")
|
|
|
|
Huhehaote = Region("cn-huhehaote")
|
|
|
|
|
2015-10-25 04:01:15 +01:00
|
|
|
APSouthEast1 = Region("ap-southeast-1")
|
2018-12-25 01:30:40 +01:00
|
|
|
APNorthEast1 = Region("ap-northeast-1")
|
|
|
|
APSouthEast2 = Region("ap-southeast-2")
|
|
|
|
APSouthEast3 = Region("ap-southeast-3")
|
|
|
|
APSouthEast5 = Region("ap-southeast-5")
|
|
|
|
|
|
|
|
APSouth1 = Region("ap-south-1")
|
|
|
|
|
|
|
|
USWest1 = Region("us-west-1")
|
|
|
|
USEast1 = Region("us-east-1")
|
|
|
|
|
|
|
|
MEEast1 = Region("me-east-1")
|
|
|
|
|
|
|
|
EUCentral1 = Region("eu-central-1")
|
|
|
|
EUWest1 = Region("eu-west-1")
|
|
|
|
|
|
|
|
ShenZhenFinance = Region("cn-shenzhen-finance-1")
|
|
|
|
ShanghaiFinance = Region("cn-shanghai-finance-1")
|
2015-10-25 04:01:15 +01:00
|
|
|
)
|
|
|
|
|
2018-12-25 01:30:40 +01:00
|
|
|
var ValidRegions = []Region{
|
|
|
|
Hangzhou, Qingdao, Beijing, Shenzhen, Hongkong, Shanghai, Zhangjiakou, Huhehaote,
|
|
|
|
USWest1, USEast1,
|
|
|
|
APNorthEast1, APSouthEast1, APSouthEast2, APSouthEast3, APSouthEast5,
|
|
|
|
APSouth1,
|
|
|
|
MEEast1,
|
|
|
|
EUCentral1, EUWest1,
|
|
|
|
ShenZhenFinance, ShanghaiFinance,
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsValidRegion checks if r is an Ali supported region.
|
|
|
|
func IsValidRegion(r string) bool {
|
|
|
|
for _, v := range ValidRegions {
|
|
|
|
if r == string(v) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|