huaweicloud-sdk-python-v3/huaweicloud-sdk-pangulargem.../huaweicloudsdkpangulargemodels/v1/region/pangulargemodels_region.py

32 lines
1022 B
Python
Raw Normal View History

2023-07-27 12:20:55 +00:00
# coding: utf-8
from huaweicloudsdkcore.region.region import Region
from huaweicloudsdkcore.region.provider import RegionProviderChain
class PanguLargeModelsRegion:
_PROVIDER = RegionProviderChain.get_default_region_provider_chain("PANGULARGEMODELS")
2023-11-02 08:35:25 +00:00
CN_SOUTHWEST_2 = Region("cn-southwest-2",
"https://pangu.cn-southwest-2.myhuaweicloud.com")
2023-07-27 12:20:55 +00:00
static_fields = {
2023-11-02 08:35:25 +00:00
"cn-southwest-2": CN_SOUTHWEST_2,
2023-07-27 12:20:55 +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")
2023-07-27 12:20:55 +00:00
2024-01-18 09:04:41 +00:00
fields = static_fields or cls.static_fields
2023-07-27 12:20:55 +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 'PanguLargeModels': [%s]" % (
region_id, ", ".join(sorted(fields.keys()))))