|
23 | 23 | # IN THE SOFTWARE.
|
24 | 24 | #
|
25 | 25 | # --------------------------------------------------------------------------
|
26 |
| -from typing import Mapping, MutableMapping, Optional, Type, Union, cast |
| 26 | +from typing import Mapping, MutableMapping, Optional, Type, Union, cast, Dict, Any |
27 | 27 | import re
|
28 | 28 | import logging
|
| 29 | +from azure.core import AzureClouds |
29 | 30 |
|
30 | 31 |
|
31 | 32 | _LOGGER = logging.getLogger(__name__)
|
@@ -217,3 +218,29 @@ def is_valid_resource_name(rname: str, exception_type: Optional[Type[BaseExcepti
|
217 | 218 | if exception_type:
|
218 | 219 | raise exception_type()
|
219 | 220 | return False
|
| 221 | + |
| 222 | + |
| 223 | +def get_arm_endpoints(cloud_setting: AzureClouds) -> Dict[str, Any]: |
| 224 | + """Get the ARM endpoint and ARM credential scopes for the given cloud setting. |
| 225 | +
|
| 226 | + :param cloud_setting: The cloud setting for which to get the ARM endpoint. |
| 227 | + :type cloud_setting: AzureClouds |
| 228 | + :return: The ARM endpoint and ARM credential scopes. |
| 229 | + :rtype: dict[str, Any] |
| 230 | + """ |
| 231 | + if cloud_setting == AzureClouds.AZURE_CHINA_CLOUD: |
| 232 | + return { |
| 233 | + "resource_manager": "https://management.chinacloudapi.cn", |
| 234 | + "credential_scopes": ["https://management.chinacloudapi.cn/.default"], |
| 235 | + } |
| 236 | + if cloud_setting == AzureClouds.AZURE_US_GOVERNMENT: |
| 237 | + return { |
| 238 | + "resource_manager": "https://management.usgovcloudapi.net/", |
| 239 | + "credential_scopes": ["https://management.core.usgovcloudapi.net/.default"], |
| 240 | + } |
| 241 | + if cloud_setting == AzureClouds.AZURE_PUBLIC_CLOUD: |
| 242 | + return { |
| 243 | + "resource_manager": "https://management.azure.com/", |
| 244 | + "credential_scopes": ["https://management.azure.com/.default"], |
| 245 | + } |
| 246 | + raise ValueError("Unknown cloud setting: {}".format(cloud_setting)) |
0 commit comments