huaweicloud-sdk-python-v3/huaweicloud-sdk-cdn/huaweicloudsdkcdn/v2/region/cdn_region.py

39 lines
1014 B
Python
Executable File

# coding: utf-8
import types
import six
from huaweicloudsdkcore.region.region import Region
from huaweicloudsdkcore.region.provider import RegionProviderChain
class CdnRegion:
_PROVIDER = RegionProviderChain.get_default_region_provider_chain("CDN")
CN_NORTH_1 = Region(id="cn-north-1", endpoint="https://cdn.myhuaweicloud.com")
AP_SOUTHEAST_1 = Region(id="ap-southeast-1", endpoint="https://cdn.myhuaweicloud.com")
static_fields = {
"cn-north-1": CN_NORTH_1,
"ap-southeast-1": AP_SOUTHEAST_1,
}
@classmethod
def value_of(cls, region_id, static_fields=None):
if not region_id:
raise KeyError("Unexpected empty parameter: region_id.")
fields = static_fields if static_fields else cls.static_fields
region = cls._PROVIDER.get_region(region_id)
if region:
return region
if region_id in fields:
return fields.get(region_id)
raise KeyError("Unexpected region_id: " + region_id)