From cd9a6c7079410b1c55e952c2c2ae3e9308a5f2f8 Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Mon, 21 Oct 2024 10:27:20 -0700 Subject: [PATCH 1/6] Added get_arm_info --- sdk/core/azure-mgmt-core/CHANGELOG.md | 6 +++++ .../azure/mgmt/core/_version.py | 2 +- .../azure-mgmt-core/azure/mgmt/core/tools.py | 27 +++++++++++++++++++ sdk/core/azure-mgmt-core/setup.py | 2 +- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/sdk/core/azure-mgmt-core/CHANGELOG.md b/sdk/core/azure-mgmt-core/CHANGELOG.md index 4ee21c3b8c89..6db51359d7c4 100644 --- a/sdk/core/azure-mgmt-core/CHANGELOG.md +++ b/sdk/core/azure-mgmt-core/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.5.0 (Unreleased) + +### Features + +- Added helper function `get_arm_info` to get the ARM endpoint and authentication scopes from the cloud setting. + ## 1.4.0 (2023-04-06) ### Features diff --git a/sdk/core/azure-mgmt-core/azure/mgmt/core/_version.py b/sdk/core/azure-mgmt-core/azure/mgmt/core/_version.py index 09b920aeeec0..1948e34ac9b0 100644 --- a/sdk/core/azure-mgmt-core/azure/mgmt/core/_version.py +++ b/sdk/core/azure-mgmt-core/azure/mgmt/core/_version.py @@ -9,4 +9,4 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "1.4.0" +VERSION = "1.5.0" diff --git a/sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py b/sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py index 06df8af9c168..7d0c17c3cbe2 100644 --- a/sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py +++ b/sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py @@ -26,6 +26,7 @@ from typing import Mapping, MutableMapping, Optional, Type, Union, cast import re import logging +from azure.core import AzureClouds _LOGGER = logging.getLogger(__name__) @@ -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_info(cloud_setting: AzureClouds) -> dict[str, str]: + """Get the ARM endpoint and ARM authentication endpoint 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 authentication scopes. + :rtype: dict[str, str] + """ + 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.chinacloudapi.cn/.default"], + } + if cloud_setting == AzureClouds.AZURE_PUBLIC_CLOUD: + return { + "resource_manager": "https://management.azure.com/", + "credential_scopes": ["https://management.chinacloudapi.cn/.default"], + } + raise ValueError("Unknown cloud setting: {}".format(cloud_setting)) diff --git a/sdk/core/azure-mgmt-core/setup.py b/sdk/core/azure-mgmt-core/setup.py index f89e829c6a42..5203a92c70ea 100644 --- a/sdk/core/azure-mgmt-core/setup.py +++ b/sdk/core/azure-mgmt-core/setup.py @@ -69,7 +69,7 @@ "pytyped": ["py.typed"], }, install_requires=[ - "azure-core>=1.29.0", + "azure-core>=1.31.0", ], python_requires=">=3.8", ) From 7b22d6dc1ce9be9c0852ef0a686d3cc75a5eae0b Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Mon, 28 Oct 2024 11:52:46 -0700 Subject: [PATCH 2/6] update --- sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py b/sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py index 7d0c17c3cbe2..3561169e50a0 100644 --- a/sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py +++ b/sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py @@ -23,7 +23,7 @@ # 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 @@ -220,7 +220,7 @@ def is_valid_resource_name(rname: str, exception_type: Optional[Type[BaseExcepti return False -def get_arm_info(cloud_setting: AzureClouds) -> dict[str, str]: +def get_arm_info(cloud_setting: AzureClouds) -> Dict[str, Any]: """Get the ARM endpoint and ARM authentication endpoint for the given cloud setting. :param cloud_setting: The cloud setting for which to get the ARM endpoint. From 1ff9478f2dc096e71dcbab84fe54bfadd6ca8a4b Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Tue, 29 Oct 2024 09:13:35 -0700 Subject: [PATCH 3/6] update --- sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py b/sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py index 3561169e50a0..5c52d3d6ee97 100644 --- a/sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py +++ b/sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py @@ -226,7 +226,7 @@ def get_arm_info(cloud_setting: AzureClouds) -> Dict[str, Any]: :param cloud_setting: The cloud setting for which to get the ARM endpoint. :type cloud_setting: AzureClouds :return: The ARM endpoint and ARM authentication scopes. - :rtype: dict[str, str] + :rtype: dict[str, Any] """ if cloud_setting == AzureClouds.AZURE_CHINA_CLOUD: return { @@ -236,11 +236,11 @@ def get_arm_info(cloud_setting: AzureClouds) -> Dict[str, Any]: if cloud_setting == AzureClouds.AZURE_US_GOVERNMENT: return { "resource_manager": "https://management.usgovcloudapi.net/", - "credential_scopes": ["https://management.chinacloudapi.cn/.default"], + "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.chinacloudapi.cn/.default"], + "credential_scopes": ["https://management.azure.com/.default"], } raise ValueError("Unknown cloud setting: {}".format(cloud_setting)) From 0b78cab907857559c800c6dc243b2f5d878c6efe Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Tue, 29 Oct 2024 15:24:50 -0700 Subject: [PATCH 4/6] Update --- sdk/core/azure-mgmt-core/CHANGELOG.md | 2 +- sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/core/azure-mgmt-core/CHANGELOG.md b/sdk/core/azure-mgmt-core/CHANGELOG.md index 6db51359d7c4..e7d2cc8ddba9 100644 --- a/sdk/core/azure-mgmt-core/CHANGELOG.md +++ b/sdk/core/azure-mgmt-core/CHANGELOG.md @@ -4,7 +4,7 @@ ### Features -- Added helper function `get_arm_info` to get the ARM endpoint and authentication scopes from the cloud setting. +- Added helper function `get_arm_endpoints` to get the ARM endpoint and credential scopes from the cloud setting. ## 1.4.0 (2023-04-06) diff --git a/sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py b/sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py index 5c52d3d6ee97..2143a5e516ae 100644 --- a/sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py +++ b/sdk/core/azure-mgmt-core/azure/mgmt/core/tools.py @@ -220,12 +220,12 @@ def is_valid_resource_name(rname: str, exception_type: Optional[Type[BaseExcepti return False -def get_arm_info(cloud_setting: AzureClouds) -> Dict[str, Any]: - """Get the ARM endpoint and ARM authentication endpoint for the given cloud setting. +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 authentication scopes. + :return: The ARM endpoint and ARM credential scopes. :rtype: dict[str, Any] """ if cloud_setting == AzureClouds.AZURE_CHINA_CLOUD: From dc876fe0f403dd2ced62d33452dc4dc2e6ab25b9 Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Tue, 29 Oct 2024 15:27:21 -0700 Subject: [PATCH 5/6] Update release date --- sdk/core/azure-core/CHANGELOG.md | 2 +- sdk/core/azure-mgmt-core/CHANGELOG.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/core/azure-core/CHANGELOG.md b/sdk/core/azure-core/CHANGELOG.md index 51c5c9641824..e8312e2c08bc 100644 --- a/sdk/core/azure-core/CHANGELOG.md +++ b/sdk/core/azure-core/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 1.32.0 (Unreleased) +## 1.32.0 (2024-10-31) ### Features Added diff --git a/sdk/core/azure-mgmt-core/CHANGELOG.md b/sdk/core/azure-mgmt-core/CHANGELOG.md index e7d2cc8ddba9..322f1b42b59a 100644 --- a/sdk/core/azure-mgmt-core/CHANGELOG.md +++ b/sdk/core/azure-mgmt-core/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 1.5.0 (Unreleased) +## 1.5.0 (2024-10-31) ### Features From 1c2d67f33eabc0d4efa5c8d142ef3658c615e7d5 Mon Sep 17 00:00:00 2001 From: Xiang Yan Date: Tue, 29 Oct 2024 16:13:26 -0700 Subject: [PATCH 6/6] update --- sdk/core/azure-mgmt-core/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/core/azure-mgmt-core/CHANGELOG.md b/sdk/core/azure-mgmt-core/CHANGELOG.md index 322f1b42b59a..f83890f3b1d8 100644 --- a/sdk/core/azure-mgmt-core/CHANGELOG.md +++ b/sdk/core/azure-mgmt-core/CHANGELOG.md @@ -2,7 +2,7 @@ ## 1.5.0 (2024-10-31) -### Features +### Features Added - Added helper function `get_arm_endpoints` to get the ARM endpoint and credential scopes from the cloud setting.