Skip to content

Commit

Permalink
Added get_arm_info (#38018)
Browse files Browse the repository at this point in the history
* Added get_arm_info

* update

* update

* Update

* Update release date

* update
  • Loading branch information
xiangyan99 authored Oct 30, 2024
1 parent f716a59 commit d0fcccd
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sdk/core/azure-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Release History

## 1.32.0 (Unreleased)
## 1.32.0 (2024-10-31)

### Features Added

Expand Down
6 changes: 6 additions & 0 deletions sdk/core/azure-mgmt-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release History

## 1.5.0 (2024-10-31)

### Features Added

- Added helper function `get_arm_endpoints` to get the ARM endpoint and credential scopes from the cloud setting.

## 1.4.0 (2023-04-06)

### Features
Expand Down
2 changes: 1 addition & 1 deletion sdk/core/azure-mgmt-core/azure/mgmt/core/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
# regenerated.
# --------------------------------------------------------------------------

VERSION = "1.4.0"
VERSION = "1.5.0"
29 changes: 28 additions & 1 deletion sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
# IN THE SOFTWARE.
#
# --------------------------------------------------------------------------
from typing import Mapping, MutableMapping, Optional, Type, Union, cast
from typing import Mapping, MutableMapping, Optional, Type, Union, cast, Dict, Any
import re
import logging
from azure.core import AzureClouds


_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -217,3 +218,29 @@ def is_valid_resource_name(rname: str, exception_type: Optional[Type[BaseExcepti
if exception_type:
raise exception_type()
return False


def get_arm_endpoints(cloud_setting: AzureClouds) -> Dict[str, Any]:
"""Get the ARM endpoint and ARM credential scopes for the given cloud setting.
:param cloud_setting: The cloud setting for which to get the ARM endpoint.
:type cloud_setting: AzureClouds
:return: The ARM endpoint and ARM credential scopes.
:rtype: dict[str, Any]
"""
if cloud_setting == AzureClouds.AZURE_CHINA_CLOUD:
return {
"resource_manager": "https://management.chinacloudapi.cn",
"credential_scopes": ["https://management.chinacloudapi.cn/.default"],
}
if cloud_setting == AzureClouds.AZURE_US_GOVERNMENT:
return {
"resource_manager": "https://management.usgovcloudapi.net/",
"credential_scopes": ["https://management.core.usgovcloudapi.net/.default"],
}
if cloud_setting == AzureClouds.AZURE_PUBLIC_CLOUD:
return {
"resource_manager": "https://management.azure.com/",
"credential_scopes": ["https://management.azure.com/.default"],
}
raise ValueError("Unknown cloud setting: {}".format(cloud_setting))
2 changes: 1 addition & 1 deletion sdk/core/azure-mgmt-core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"pytyped": ["py.typed"],
},
install_requires=[
"azure-core>=1.29.0",
"azure-core>=1.31.0",
],
python_requires=">=3.8",
)

0 comments on commit d0fcccd

Please sign in to comment.