Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
'AcceptanceTests/AzureParameterGrouping': 'azure-parameter-grouping.json',
'AcceptanceTests/CustomBaseUri': ['custom-baseUrl.json', 'custombaseurl'],
'AcceptanceTests/LroWithParameterizedEndpoints': 'lro-parameterized-endpoints.json',
'AcceptanceTests/Paging': 'paging.json',
'AcceptanceTests/CustomUrlPaging': ['custom-baseUrl-paging.json', 'custombaseurlpaging'],
}

# The list is mostly built on Swaggers that uses CloudError feature
Expand All @@ -79,8 +81,6 @@
'AcceptanceTests/StorageManagementClient': ['storage.json', 'storage'],
'AcceptanceTests/Lro': 'lro.json',
'AcceptanceTests/SubscriptionIdApiVersion': 'subscriptionId-apiVersion.json',
'AcceptanceTests/Paging': 'paging.json',
'AcceptanceTests/CustomUrlPaging': ['custom-baseUrl-paging.json', 'custombaseurlpaging'],
'AcceptanceTests/AzureSpecials': ['azure-special-properties.json', 'azurespecialproperties'],
}

Expand Down
3 changes: 2 additions & 1 deletion test/azure/AcceptanceTests/asynctests/test_paging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(AsyncARMPolling(timeout=0))
pager = await poller.result()
items = []
async for item in pager:
Expand Down
9 changes: 5 additions & 4 deletions test/azure/AcceptanceTests/test_paging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
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:
with AutoRestParameterizedHostTestPagingClient(host="host:3000") as client:
yield client

class TestPaging(object):
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,35 @@

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 typing import Any

from azure.core.credentials import TokenCredential


class AutoRestParameterizedHostTestPagingClientConfiguration(Configuration):
"""Configuration for AutoRestParameterizedHostTestPagingClient.

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)

Expand All @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,34 @@
# 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.

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)

Expand All @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
Loading