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
5 changes: 3 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',
}

Expand All @@ -101,6 +101,7 @@ class _SwaggerGroup(str, Enum):
'CustomUrlPaging': 'custombaseurlpaging',
'AzureSpecials': 'azurespecialproperties',
'StorageManagementClient': 'storage',
'CustomUrlPaging': 'custombaseurlpaging',
}

_PACKAGES_WITH_CLIENT_SIDE_VALIDATION = [
Expand Down
11 changes: 6 additions & 5 deletions test/azure/AcceptanceTests/asynctests/test_paging.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@

@pytest.fixture
@async_generator
async def client(cookie_policy, credential):
async def client(cookie_policy):
policies = [
RequestIdPolicy(),
HeadersPolicy(),
ContentDecodePolicy(),
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):
Expand Down 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(polling=AsyncARMPolling(timeout=0))
pager = await poller.result()
items = []
async for item in pager:
Expand Down
4 changes: 2 additions & 2 deletions test/azure/AcceptanceTests/asynctests/test_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand All @@ -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)
assert has_tracing_decorator(client.group.get_sample_resource_group)
13 changes: 7 additions & 6 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:
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):
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
4 changes: 2 additions & 2 deletions test/azure/AcceptanceTests/test_tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand All @@ -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)
assert has_tracing_decorator(client.group.get_sample_resource_group)
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
Loading