Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: feature
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

Add keyword only signature `cloud_setting` into ARM client
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class {{ code_model.client.name }}({% if code_model.operation_mixin_group.mixin_
if api_version:
kwargs.setdefault('api_version', api_version)
{% if credential_scopes %}
_cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore
_cloud = cloud_setting or settings.current.azure_cloud # type: ignore
_endpoints = get_arm_endpoints(_cloud)
if not base_url:
base_url = _endpoints["resource_manager"]
Expand Down
2 changes: 1 addition & 1 deletion packages/autorest.python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
"dependencies": {
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTIxOTc3Ny9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.15.2.tgz",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTIzMzU2Mi9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.15.2.tgz",
"@autorest/system-requirements": "~1.0.2",
"fs-extra": "~11.2.0",
"tsx": "~4.19.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any, TYPE_CHECKING
from typing import Any, Optional, TYPE_CHECKING

from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy

from ._version import VERSION

if TYPE_CHECKING:
from azure.core import AzureClouds
from azure.core.credentials import TokenCredential


Expand All @@ -25,13 +26,19 @@ class PyprojectMgmtClientConfiguration: # pylint: disable=too-many-instance-att

:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is
None.
:type cloud_setting: ~azure.core.AzureClouds
"""

def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None:
def __init__(
self, credential: "TokenCredential", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any
) -> None:
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")

self.credential = credential
self.cloud_setting = cloud_setting
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-pyproject/{}".format(VERSION))
self.polling_interval = kwargs.get("polling_interval", 30)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from .operations import HttpSuccessOperations

if TYPE_CHECKING:
from azure.core import AzureClouds
from azure.core.credentials import TokenCredential


Expand All @@ -34,16 +35,26 @@ class PyprojectMgmtClient: # pylint: disable=client-accepts-api-version-keyword
:type credential: ~azure.core.credentials.TokenCredential
:param base_url: Service URL. Default value is None.
:type base_url: str
:keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is
None.
:paramtype cloud_setting: ~azure.core.AzureClouds
"""

def __init__(self, credential: "TokenCredential", base_url: Optional[str] = None, **kwargs: Any) -> None:
_cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore
def __init__(
self,
credential: "TokenCredential",
base_url: Optional[str] = None,
*,
cloud_setting: Optional["AzureClouds"] = None,
**kwargs: Any
) -> None:
_cloud = cloud_setting or settings.current.azure_cloud # type: ignore
_endpoints = get_arm_endpoints(_cloud)
if not base_url:
base_url = _endpoints["resource_manager"]
credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"])
self._config = PyprojectMgmtClientConfiguration(
credential=credential, credential_scopes=credential_scopes, **kwargs
credential=credential, cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs
)

_policies = kwargs.pop("policies", None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any, TYPE_CHECKING
from typing import Any, Optional, TYPE_CHECKING

from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy

from .._version import VERSION

if TYPE_CHECKING:
from azure.core import AzureClouds
from azure.core.credentials_async import AsyncTokenCredential


Expand All @@ -25,13 +26,19 @@ class PyprojectMgmtClientConfiguration: # pylint: disable=too-many-instance-att

:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is
None.
:type cloud_setting: ~azure.core.AzureClouds
"""

def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None:
def __init__(
self, credential: "AsyncTokenCredential", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any
) -> None:
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")

self.credential = credential
self.cloud_setting = cloud_setting
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-pyproject/{}".format(VERSION))
self.polling_interval = kwargs.get("polling_interval", 30)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from .operations import HttpSuccessOperations

if TYPE_CHECKING:
from azure.core import AzureClouds
from azure.core.credentials_async import AsyncTokenCredential


Expand All @@ -34,16 +35,26 @@ class PyprojectMgmtClient: # pylint: disable=client-accepts-api-version-keyword
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param base_url: Service URL. Default value is None.
:type base_url: str
:keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is
None.
:paramtype cloud_setting: ~azure.core.AzureClouds
"""

def __init__(self, credential: "AsyncTokenCredential", base_url: Optional[str] = None, **kwargs: Any) -> None:
_cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore
def __init__(
self,
credential: "AsyncTokenCredential",
base_url: Optional[str] = None,
*,
cloud_setting: Optional["AzureClouds"] = None,
**kwargs: Any
) -> None:
_cloud = cloud_setting or settings.current.azure_cloud # type: ignore
_endpoints = get_arm_endpoints(_cloud)
if not base_url:
base_url = _endpoints["resource_manager"]
credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"])
self._config = PyprojectMgmtClientConfiguration(
credential=credential, credential_scopes=credential_scopes, **kwargs
credential=credential, cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs
)

_policies = kwargs.pop("policies", None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from .operations import HttpSuccessOperations

if TYPE_CHECKING:
from azure.core import AzureClouds
from azure.core.credentials import TokenCredential


Expand All @@ -34,16 +35,26 @@ class AutoRestHeadTestService: # pylint: disable=client-accepts-api-version-key
:type credential: ~azure.core.credentials.TokenCredential
:param base_url: Service URL. Default value is None.
:type base_url: str
:keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is
None.
:paramtype cloud_setting: ~azure.core.AzureClouds
"""

def __init__(self, credential: "TokenCredential", base_url: Optional[str] = None, **kwargs: Any) -> None:
_cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore
def __init__(
self,
credential: "TokenCredential",
base_url: Optional[str] = None,
*,
cloud_setting: Optional["AzureClouds"] = None,
**kwargs: Any
) -> None:
_cloud = cloud_setting or settings.current.azure_cloud # type: ignore
_endpoints = get_arm_endpoints(_cloud)
if not base_url:
base_url = _endpoints["resource_manager"]
credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"])
self._config = AutoRestHeadTestServiceConfiguration(
credential=credential, credential_scopes=credential_scopes, **kwargs
credential=credential, cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs
)

_policies = kwargs.pop("policies", None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any, TYPE_CHECKING
from typing import Any, Optional, TYPE_CHECKING

from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy

from ._version import VERSION

if TYPE_CHECKING:
from azure.core import AzureClouds
from azure.core.credentials import TokenCredential


Expand All @@ -25,13 +26,19 @@ class AutoRestHeadTestServiceConfiguration: # pylint: disable=too-many-instance

:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is
None.
:type cloud_setting: ~azure.core.AzureClouds
"""

def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None:
def __init__(
self, credential: "TokenCredential", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any
) -> None:
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")

self.credential = credential
self.cloud_setting = cloud_setting
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-test/{}".format(VERSION))
self.polling_interval = kwargs.get("polling_interval", 30)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from .operations import HttpSuccessOperations

if TYPE_CHECKING:
from azure.core import AzureClouds
from azure.core.credentials_async import AsyncTokenCredential


Expand All @@ -34,16 +35,26 @@ class AutoRestHeadTestService: # pylint: disable=client-accepts-api-version-key
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param base_url: Service URL. Default value is None.
:type base_url: str
:keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is
None.
:paramtype cloud_setting: ~azure.core.AzureClouds
"""

def __init__(self, credential: "AsyncTokenCredential", base_url: Optional[str] = None, **kwargs: Any) -> None:
_cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore
def __init__(
self,
credential: "AsyncTokenCredential",
base_url: Optional[str] = None,
*,
cloud_setting: Optional["AzureClouds"] = None,
**kwargs: Any
) -> None:
_cloud = cloud_setting or settings.current.azure_cloud # type: ignore
_endpoints = get_arm_endpoints(_cloud)
if not base_url:
base_url = _endpoints["resource_manager"]
credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"])
self._config = AutoRestHeadTestServiceConfiguration(
credential=credential, credential_scopes=credential_scopes, **kwargs
credential=credential, cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs
)

_policies = kwargs.pop("policies", None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any, TYPE_CHECKING
from typing import Any, Optional, TYPE_CHECKING

from azure.core.pipeline import policies
from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy

from .._version import VERSION

if TYPE_CHECKING:
from azure.core import AzureClouds
from azure.core.credentials_async import AsyncTokenCredential


Expand All @@ -25,13 +26,19 @@ class AutoRestHeadTestServiceConfiguration: # pylint: disable=too-many-instance

:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is
None.
:type cloud_setting: ~azure.core.AzureClouds
"""

def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None:
def __init__(
self, credential: "AsyncTokenCredential", cloud_setting: Optional["AzureClouds"] = None, **kwargs: Any
) -> None:
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")

self.credential = credential
self.cloud_setting = cloud_setting
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-test/{}".format(VERSION))
self.polling_interval = kwargs.get("polling_interval", 30)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from .operations import HttpSuccessOperations

if TYPE_CHECKING:
from azure.core import AzureClouds
from azure.core.credentials import TokenCredential


Expand All @@ -34,16 +35,26 @@ class AutoRestHeadTestService: # pylint: disable=client-accepts-api-version-key
:type credential: ~azure.core.credentials.TokenCredential
:param base_url: Service URL. Default value is None.
:type base_url: str
:keyword cloud_setting: The cloud setting for which to get the ARM endpoint. Default value is
None.
:paramtype cloud_setting: ~azure.core.AzureClouds
"""

def __init__(self, credential: "TokenCredential", base_url: Optional[str] = None, **kwargs: Any) -> None:
_cloud = kwargs.pop("cloud_setting", None) or settings.current.azure_cloud # type: ignore
def __init__(
self,
credential: "TokenCredential",
base_url: Optional[str] = None,
*,
cloud_setting: Optional["AzureClouds"] = None,
**kwargs: Any
) -> None:
_cloud = cloud_setting or settings.current.azure_cloud # type: ignore
_endpoints = get_arm_endpoints(_cloud)
if not base_url:
base_url = _endpoints["resource_manager"]
credential_scopes = kwargs.pop("credential_scopes", _endpoints["credential_scopes"])
self._config = AutoRestHeadTestServiceConfiguration(
credential=credential, credential_scopes=credential_scopes, **kwargs
credential=credential, cloud_setting=cloud_setting, credential_scopes=credential_scopes, **kwargs
)

_policies = kwargs.pop("policies", None)
Expand Down
Loading
Loading