2022-03-25 08:53:59 +00:00
|
|
|
# coding: utf-8
|
|
|
|
|
|
|
|
from huaweicloudsdkcore.region.region import Region
|
2022-06-23 11:11:56 +00:00
|
|
|
from huaweicloudsdkcore.region.provider import RegionProviderChain
|
2022-03-25 08:53:59 +00:00
|
|
|
|
|
|
|
class CdnRegion:
|
2022-06-23 11:11:56 +00:00
|
|
|
_PROVIDER = RegionProviderChain.get_default_region_provider_chain("CDN")
|
|
|
|
|
2023-02-16 10:11:56 +00:00
|
|
|
CN_NORTH_1 = Region("cn-north-1",
|
|
|
|
"https://cdn.myhuaweicloud.com")
|
|
|
|
AP_SOUTHEAST_1 = Region("ap-southeast-1",
|
|
|
|
"https://cdn.myhuaweicloud.com")
|
2024-01-18 09:04:41 +00:00
|
|
|
EU_WEST_101 = Region("eu-west-101",
|
|
|
|
"https://cdn.myhuaweicloud.eu")
|
2022-03-25 08:53:59 +00:00
|
|
|
|
|
|
|
static_fields = {
|
|
|
|
"cn-north-1": CN_NORTH_1,
|
|
|
|
"ap-southeast-1": AP_SOUTHEAST_1,
|
2024-01-18 09:04:41 +00:00
|
|
|
"eu-west-101": EU_WEST_101,
|
2022-03-25 08:53:59 +00:00
|
|
|
}
|
|
|
|
|
2022-06-23 11:11:56 +00:00
|
|
|
@classmethod
|
|
|
|
def value_of(cls, region_id, static_fields=None):
|
|
|
|
if not region_id:
|
2024-01-18 09:04:41 +00:00
|
|
|
raise KeyError("Unexpected empty parameter: region_id")
|
2022-06-23 11:11:56 +00:00
|
|
|
|
2024-01-18 09:04:41 +00:00
|
|
|
fields = static_fields or cls.static_fields
|
2022-06-23 11:11:56 +00:00
|
|
|
|
|
|
|
region = cls._PROVIDER.get_region(region_id)
|
|
|
|
if region:
|
|
|
|
return region
|
|
|
|
|
|
|
|
if region_id in fields:
|
|
|
|
return fields.get(region_id)
|
|
|
|
|
2024-01-18 09:04:41 +00:00
|
|
|
raise KeyError("region_id '%s' is not in the following supported regions of service 'Cdn': [%s]" % (
|
|
|
|
region_id, ", ".join(sorted(fields.keys()))))
|