diff --git a/tasks.py b/tasks.py index 3de7c3dc091..7cdcc25806a 100644 --- a/tasks.py +++ b/tasks.py @@ -73,6 +73,8 @@ class _SwaggerGroup(str, Enum): 'AzureParameterGrouping': 'azure-parameter-grouping.json', 'CustomBaseUri': 'custom-baseUrl.json', 'LroWithParameterizedEndpoints': 'lro-parameterized-endpoints.json', + 'Paging': 'paging.json', + 'CustomUrlPaging': 'custom-baseUrl-paging.json', } # The list is mostly built on Swaggers that uses CloudError feature @@ -83,8 +85,6 @@ class _SwaggerGroup(str, Enum): 'StorageManagementClient': 'storage.json', 'Lro': 'lro.json', 'SubscriptionIdApiVersion': 'subscriptionId-apiVersion.json', - 'Paging': 'paging.json', - 'CustomUrlPaging': 'custom-baseUrl-paging.json', 'AzureSpecials': 'azure-special-properties.json', } @@ -101,6 +101,7 @@ class _SwaggerGroup(str, Enum): 'CustomUrlPaging': 'custombaseurlpaging', 'AzureSpecials': 'azurespecialproperties', 'StorageManagementClient': 'storage', + 'CustomUrlPaging': 'custombaseurlpaging', } _PACKAGES_WITH_CLIENT_SIDE_VALIDATION = [ diff --git a/test/azure/AcceptanceTests/asynctests/test_paging.py b/test/azure/AcceptanceTests/asynctests/test_paging.py index 14b9987a216..f023a68bcb6 100644 --- a/test/azure/AcceptanceTests/asynctests/test_paging.py +++ b/test/azure/AcceptanceTests/asynctests/test_paging.py @@ -46,7 +46,7 @@ @pytest.fixture @async_generator -async def client(cookie_policy, credential): +async def client(cookie_policy): policies = [ RequestIdPolicy(), HeadersPolicy(), @@ -54,13 +54,13 @@ async def client(cookie_policy, credential): AsyncRetryPolicy(), cookie_policy ] - async with AutoRestPagingTestService(credential, base_url="http://localhost:3000", policies=policies) as client: + async with AutoRestPagingTestService(base_url="http://localhost:3000", policies=policies) as client: await yield_(client) @pytest.fixture @async_generator -async def custom_url_client(credential, authentication_policy): - async with AutoRestParameterizedHostTestPagingClient(credential, host="host:3000", authentication_policy=authentication_policy) as client: +async def custom_url_client(): + async with AutoRestParameterizedHostTestPagingClient(host="host:3000") as client: await yield_(client) class TestPaging(object): @@ -214,7 +214,8 @@ async def test_custom_url_get_pages_partial_url_operation(self, custom_url_clien async def test_get_multiple_pages_lro(self, client): """LRO + Paging at the same time. """ - poller = await client.paging.begin_get_multiple_pages_lro() + from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + poller = await client.paging.begin_get_multiple_pages_lro(polling=AsyncARMPolling(timeout=0)) pager = await poller.result() items = [] async for item in pager: diff --git a/test/azure/AcceptanceTests/asynctests/test_tracing.py b/test/azure/AcceptanceTests/asynctests/test_tracing.py index d6ae7daad31..a35b7b032aa 100644 --- a/test/azure/AcceptanceTests/asynctests/test_tracing.py +++ b/test/azure/AcceptanceTests/asynctests/test_tracing.py @@ -45,7 +45,7 @@ def has_tracing_decorator(function): @pytest.mark.asyncio async def test_paging(): - async with AutoRestPagingTestService("cred", base_url="dummy url") as client: + async with AutoRestPagingTestService(base_url="dummy url") as client: assert has_tracing_decorator(client.paging.get_single_pages) @@ -58,4 +58,4 @@ async def test_lro(): def test_azure_url(): client = MicrosoftAzureTestUrl("cred", "sub_id", base_url="dummy url") - assert has_tracing_decorator(client.group.get_sample_resource_group) \ No newline at end of file + assert has_tracing_decorator(client.group.get_sample_resource_group) diff --git a/test/azure/AcceptanceTests/test_paging.py b/test/azure/AcceptanceTests/test_paging.py index 79361c839f5..978e888965c 100644 --- a/test/azure/AcceptanceTests/test_paging.py +++ b/test/azure/AcceptanceTests/test_paging.py @@ -40,17 +40,18 @@ from azure.core.exceptions import HttpResponseError + import pytest @pytest.fixture -def client(credential, authentication_policy): - with AutoRestPagingTestService(credential, base_url="http://localhost:3000", authentication_policy=authentication_policy) as client: +def client(): + with AutoRestPagingTestService(base_url="http://localhost:3000") as client: yield client @pytest.fixture -def custom_url_client(credential, authentication_policy): - with AutoRestParameterizedHostTestPagingClient(credential, host="host:3000", authentication_policy=authentication_policy) as client: +def custom_url_client(): + with AutoRestParameterizedHostTestPagingClient(host="host:3000") as client: yield client class TestPaging(object): @@ -159,8 +160,8 @@ def test_custom_url_get_pages_partial_url_operation(self, custom_url_client): def test_get_multiple_pages_lro(self, client): """LRO + Paging at the same time. """ - - poller = client.paging.begin_get_multiple_pages_lro() + from azure.mgmt.core.polling.arm_polling import ARMPolling + poller = client.paging.begin_get_multiple_pages_lro(polling=ARMPolling(timeout=0)) pager = poller.result() items = list(pager) diff --git a/test/azure/AcceptanceTests/test_tracing.py b/test/azure/AcceptanceTests/test_tracing.py index 4e0a128c5dc..cf6e24c759b 100644 --- a/test/azure/AcceptanceTests/test_tracing.py +++ b/test/azure/AcceptanceTests/test_tracing.py @@ -40,7 +40,7 @@ def has_tracing_decorator(function): def test_paging(): - with AutoRestPagingTestService("cred", base_url="dummy url") as client: + with AutoRestPagingTestService(base_url="dummy url") as client: assert has_tracing_decorator(client.paging.get_single_pages) @@ -53,4 +53,4 @@ def test_lro(): def test_azure_url(): client = MicrosoftAzureTestUrl("cred", "sub_id", base_url="dummy url") - assert has_tracing_decorator(client.group.get_sample_resource_group) \ No newline at end of file + assert has_tracing_decorator(client.group.get_sample_resource_group) diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_auto_rest_parameterized_host_test_paging_client.py b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_auto_rest_parameterized_host_test_paging_client.py index 74def540332..8b1ce17ab6a 100644 --- a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_auto_rest_parameterized_host_test_paging_client.py +++ b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_auto_rest_parameterized_host_test_paging_client.py @@ -8,15 +8,13 @@ from typing import TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient +from azure.core import PipelineClient from msrest import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any - from azure.core.credentials import TokenCredential - from ._configuration import AutoRestParameterizedHostTestPagingClientConfiguration from .operations import PagingOperations from . import models @@ -27,22 +25,19 @@ class AutoRestParameterizedHostTestPagingClient(object): :ivar paging: PagingOperations operations :vartype paging: custombaseurlpaging.operations.PagingOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential :param host: A string value that is used as a global part of the parameterized host. :type host: str """ def __init__( self, - credential, # type: "TokenCredential" host="host", # type: str **kwargs # type: Any ): # type: (...) -> None base_url = 'http://{accountName}{host}' - self._config = AutoRestParameterizedHostTestPagingClientConfiguration(credential, host, **kwargs) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._config = AutoRestParameterizedHostTestPagingClientConfiguration(host, **kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_configuration.py b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_configuration.py index b6c7ebb631f..08a74a09ebb 100644 --- a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_configuration.py +++ b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/_configuration.py @@ -10,7 +10,6 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy from ._version import VERSION @@ -18,8 +17,6 @@ # pylint: disable=unused-import,ungrouped-imports from typing import Any - from azure.core.credentials import TokenCredential - class AutoRestParameterizedHostTestPagingClientConfiguration(Configuration): """Configuration for AutoRestParameterizedHostTestPagingClient. @@ -27,28 +24,21 @@ class AutoRestParameterizedHostTestPagingClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential :param host: A string value that is used as a global part of the parameterized host. :type host: str """ def __init__( self, - credential, # type: "TokenCredential" host="host", # type: str **kwargs # type: Any ): # type: (...) -> None - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") if host is None: raise ValueError("Parameter 'host' must not be None.") super(AutoRestParameterizedHostTestPagingClientConfiguration, self).__init__(**kwargs) - self.credential = credential self.host = host - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'autorestparameterizedhosttestpagingclient/{}'.format(VERSION)) self._configure(**kwargs) @@ -61,10 +51,8 @@ def _configure( self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') - if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_auto_rest_parameterized_host_test_paging_client.py b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_auto_rest_parameterized_host_test_paging_client.py index afe0992bca5..24b3ff1267b 100644 --- a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_auto_rest_parameterized_host_test_paging_client.py +++ b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_auto_rest_parameterized_host_test_paging_client.py @@ -6,15 +6,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any -from azure.mgmt.core import AsyncARMPipelineClient +from azure.core import AsyncPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - from ._configuration import AutoRestParameterizedHostTestPagingClientConfiguration from .operations import PagingOperations from .. import models @@ -25,21 +21,18 @@ class AutoRestParameterizedHostTestPagingClient(object): :ivar paging: PagingOperations operations :vartype paging: custombaseurlpaging.aio.operations.PagingOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param host: A string value that is used as a global part of the parameterized host. :type host: str """ def __init__( self, - credential: "AsyncTokenCredential", host: str = "host", **kwargs: Any ) -> None: base_url = 'http://{accountName}{host}' - self._config = AutoRestParameterizedHostTestPagingClientConfiguration(credential, host, **kwargs) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._config = AutoRestParameterizedHostTestPagingClientConfiguration(host, **kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_configuration.py b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_configuration.py index 1ed3a229543..cc2ac645f7f 100644 --- a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_configuration.py +++ b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/_configuration.py @@ -6,18 +6,13 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy from .._version import VERSION -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - class AutoRestParameterizedHostTestPagingClientConfiguration(Configuration): """Configuration for AutoRestParameterizedHostTestPagingClient. @@ -25,27 +20,20 @@ class AutoRestParameterizedHostTestPagingClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param host: A string value that is used as a global part of the parameterized host. :type host: str """ def __init__( self, - credential: "AsyncTokenCredential", host: str = "host", **kwargs: Any ) -> None: - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") if host is None: raise ValueError("Parameter 'host' must not be None.") super(AutoRestParameterizedHostTestPagingClientConfiguration, self).__init__(**kwargs) - self.credential = credential self.host = host - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'autorestparameterizedhosttestpagingclient/{}'.format(VERSION)) self._configure(**kwargs) @@ -57,10 +45,8 @@ def _configure( self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') - if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/operations/_paging_operations.py b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/operations/_paging_operations.py index d05555216a4..06d6beed710 100644 --- a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/operations/_paging_operations.py +++ b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/aio/operations/_paging_operations.py @@ -14,7 +14,6 @@ from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models @@ -109,7 +108,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -186,7 +185,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/operations/_paging_operations.py b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/operations/_paging_operations.py index 19a2434d393..a4e91f9f501 100644 --- a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/operations/_paging_operations.py +++ b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/custombaseurlpaging/operations/_paging_operations.py @@ -13,7 +13,6 @@ from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models @@ -113,7 +112,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -191,7 +190,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response diff --git a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/setup.py b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/setup.py index fc0c74036f0..15fb5dd8551 100644 --- a/test/azure/Expected/AcceptanceTests/CustomUrlPaging/setup.py +++ b/test/azure/Expected/AcceptanceTests/CustomUrlPaging/setup.py @@ -19,7 +19,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.2", "azure-mgmt-core<2.0.0,>=1.2.1"] +REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.2"] setup( name=NAME, diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/_auto_rest_paging_test_service.py b/test/azure/Expected/AcceptanceTests/Paging/paging/_auto_rest_paging_test_service.py index 8250b86dd64..54ed1133975 100644 --- a/test/azure/Expected/AcceptanceTests/Paging/paging/_auto_rest_paging_test_service.py +++ b/test/azure/Expected/AcceptanceTests/Paging/paging/_auto_rest_paging_test_service.py @@ -8,15 +8,13 @@ from typing import TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient +from azure.core import PipelineClient from msrest import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional - from azure.core.credentials import TokenCredential - from ._configuration import AutoRestPagingTestServiceConfiguration from .operations import PagingOperations from . import models @@ -27,23 +25,20 @@ class AutoRestPagingTestService(object): :ivar paging: PagingOperations operations :vartype paging: paging.operations.PagingOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential :param str base_url: Service URL :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" base_url=None, # type: Optional[str] **kwargs # type: Any ): # type: (...) -> None if not base_url: base_url = 'http://localhost:3000' - self._config = AutoRestPagingTestServiceConfiguration(credential, **kwargs) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._config = AutoRestPagingTestServiceConfiguration(**kwargs) + self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/_configuration.py b/test/azure/Expected/AcceptanceTests/Paging/paging/_configuration.py index 56bd87ee410..bbab1169947 100644 --- a/test/azure/Expected/AcceptanceTests/Paging/paging/_configuration.py +++ b/test/azure/Expected/AcceptanceTests/Paging/paging/_configuration.py @@ -10,7 +10,6 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy from ._version import VERSION @@ -18,31 +17,21 @@ # pylint: disable=unused-import,ungrouped-imports from typing import Any - from azure.core.credentials import TokenCredential - class AutoRestPagingTestServiceConfiguration(Configuration): """Configuration for AutoRestPagingTestService. Note that all parameters used to create this instance are saved as instance attributes. - - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials.TokenCredential """ def __init__( self, - credential, # type: "TokenCredential" **kwargs # type: Any ): # type: (...) -> None - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") super(AutoRestPagingTestServiceConfiguration, self).__init__(**kwargs) - self.credential = credential - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'autorestpagingtestservice/{}'.format(VERSION)) self._configure(**kwargs) @@ -55,10 +44,8 @@ def _configure( self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') - if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/aio/_auto_rest_paging_test_service.py b/test/azure/Expected/AcceptanceTests/Paging/paging/aio/_auto_rest_paging_test_service.py index 2feeaf2cfe1..a63f9edf43b 100644 --- a/test/azure/Expected/AcceptanceTests/Paging/paging/aio/_auto_rest_paging_test_service.py +++ b/test/azure/Expected/AcceptanceTests/Paging/paging/aio/_auto_rest_paging_test_service.py @@ -6,15 +6,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, Optional -from azure.mgmt.core import AsyncARMPipelineClient +from azure.core import AsyncPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - from ._configuration import AutoRestPagingTestServiceConfiguration from .operations import PagingOperations from .. import models @@ -25,22 +21,19 @@ class AutoRestPagingTestService(object): :ivar paging: PagingOperations operations :vartype paging: paging.aio.operations.PagingOperations - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param str base_url: Service URL :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ def __init__( self, - credential: "AsyncTokenCredential", base_url: Optional[str] = None, **kwargs: Any ) -> None: if not base_url: base_url = 'http://localhost:3000' - self._config = AutoRestPagingTestServiceConfiguration(credential, **kwargs) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._config = AutoRestPagingTestServiceConfiguration(**kwargs) + self._client = AsyncPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/aio/_configuration.py b/test/azure/Expected/AcceptanceTests/Paging/paging/aio/_configuration.py index 61134807822..619313dadf9 100644 --- a/test/azure/Expected/AcceptanceTests/Paging/paging/aio/_configuration.py +++ b/test/azure/Expected/AcceptanceTests/Paging/paging/aio/_configuration.py @@ -6,40 +6,27 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, TYPE_CHECKING +from typing import Any from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy from .._version import VERSION -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - class AutoRestPagingTestServiceConfiguration(Configuration): """Configuration for AutoRestPagingTestService. Note that all parameters used to create this instance are saved as instance attributes. - - :param credential: Credential needed for the client to connect to Azure. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential """ def __init__( self, - credential: "AsyncTokenCredential", **kwargs: Any ) -> None: - if credential is None: - raise ValueError("Parameter 'credential' must not be None.") super(AutoRestPagingTestServiceConfiguration, self).__init__(**kwargs) - self.credential = credential - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'autorestpagingtestservice/{}'.format(VERSION)) self._configure(**kwargs) @@ -51,10 +38,8 @@ def _configure( self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') - if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/aio/operations/_paging_operations.py b/test/azure/Expected/AcceptanceTests/Paging/paging/aio/operations/_paging_operations.py index e7d5cc4ec65..2b7032c2f97 100644 --- a/test/azure/Expected/AcceptanceTests/Paging/paging/aio/operations/_paging_operations.py +++ b/test/azure/Expected/AcceptanceTests/Paging/paging/aio/operations/_paging_operations.py @@ -13,10 +13,9 @@ from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.polling.async_base_polling import AsyncLROBasePolling from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models @@ -97,7 +96,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -158,7 +157,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -219,7 +218,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -281,7 +280,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -360,7 +359,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -432,7 +431,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -511,7 +510,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -596,7 +595,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -658,7 +657,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -720,7 +719,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -781,7 +780,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -842,7 +841,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -903,7 +902,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -983,7 +982,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -1066,7 +1065,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -1116,7 +1115,7 @@ async def _get_multiple_pages_lro_initial( if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) deserialized = self._deserialize('ProductResult', pipeline_response) @@ -1201,11 +1200,11 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', False) # type: Union[bool, AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1232,7 +1231,7 @@ async def internal_get_next(next_link=None): return AsyncItemPaged( internal_get_next, extract_data ) - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + if polling is True: polling_method = AsyncLROBasePolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -1299,7 +1298,7 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/operations/_paging_operations.py b/test/azure/Expected/AcceptanceTests/Paging/paging/operations/_paging_operations.py index 59c1a29f338..da476d5e21e 100644 --- a/test/azure/Expected/AcceptanceTests/Paging/paging/operations/_paging_operations.py +++ b/test/azure/Expected/AcceptanceTests/Paging/paging/operations/_paging_operations.py @@ -13,9 +13,8 @@ from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpRequest, HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.polling.base_polling import LROBasePolling from azure.core.tracing.decorator import distributed_trace -from azure.mgmt.core.exceptions import ARMErrorFormat -from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models @@ -101,7 +100,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -163,7 +162,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -225,7 +224,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -288,7 +287,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -368,7 +367,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -441,7 +440,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -521,7 +520,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -607,7 +606,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -670,7 +669,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -733,7 +732,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -795,7 +794,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -857,7 +856,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -919,7 +918,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -1000,7 +999,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -1084,7 +1083,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response @@ -1135,7 +1134,7 @@ def _get_multiple_pages_lro_initial( if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) deserialized = self._deserialize('ProductResult', pipeline_response) @@ -1221,11 +1220,11 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', False) # type: Union[bool, PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ProductResult"] lro_delay = kwargs.pop( 'polling_interval', @@ -1252,7 +1251,7 @@ def internal_get_next(next_link=None): return ItemPaged( internal_get_next, extract_data ) - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + if polling is True: polling_method = LROBasePolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -1320,7 +1319,7 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response diff --git a/test/azure/Expected/AcceptanceTests/Paging/setup.py b/test/azure/Expected/AcceptanceTests/Paging/setup.py index 4ad99b28940..e7ab7f924f8 100644 --- a/test/azure/Expected/AcceptanceTests/Paging/setup.py +++ b/test/azure/Expected/AcceptanceTests/Paging/setup.py @@ -19,7 +19,7 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.2", "azure-mgmt-core<2.0.0,>=1.2.1"] +REQUIRES = ["msrest>=0.6.18", "azure-core<2.0.0,>=1.8.2"] setup( name=NAME,