Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added get_arm_info #38018

Merged
merged 6 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
)
Loading