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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"devDependencies": {
"@autorest/autorest": "^3.0.0",
"@azure-tools/extension": "^3.0.249",
"@microsoft.azure/autorest.testserver": "^2.10.38"
"@microsoft.azure/autorest.testserver": "^2.10.40"
},
"files": [
"autorest/**/*.py",
Expand Down
8 changes: 8 additions & 0 deletions test/azure/AcceptanceTests/asynctests/test_paging.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,11 @@ async def test_get_multiple_pages_lro(client):
assert len(page1.values) == 1
assert page1.values[0].properties.id == 1
assert page1.next_link.endswith("paging/multiple/page/2")

@pytest.mark.asyncio
async def test_item_name_with_xms_client_name(client):
pages = client.paging.get_paging_model_with_item_name_with_xms_client_name()
items = []
async for item in pages:
items.append(item)
assert len(items) == 1
5 changes: 5 additions & 0 deletions test/azure/AcceptanceTests/test_paging.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,8 @@ def test_get_multiple_pages_lro(client):
assert len(page1.values) == 1
assert page1.values[0].properties.id == 1
assert page1.next_link.endswith("paging/multiple/page/2")

def test_item_name_with_xms_client_name(client):
pages = client.paging.get_paging_model_with_item_name_with_xms_client_name()
items = [i for i in pages]
assert len(items) == 1
Original file line number Diff line number Diff line change
Expand Up @@ -1070,3 +1070,62 @@ def get_long_running_output(pipeline_response):
else: polling_method = polling
return await async_poller(self._client, raw_result, get_long_running_output, polling_method)
get_multiple_pages_lro.metadata = {'url': '/paging/multiple/lro'} # type: ignore

@distributed_trace
def get_paging_model_with_item_name_with_xms_client_name(
self,
**kwargs
) -> AsyncIterable["models.ProductResultValueWithXMSClientName"]:
"""A paging operation that returns a paging model whose item name is is overriden by x-ms-client-
name 'indexes'.

:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either ProductResultValueWithXMSClientName or the result of cls(response)
:rtype: ~azure.core.async_paging.AsyncItemPaged[~paging.models.ProductResultValueWithXMSClientName]
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["models.ProductResultValueWithXMSClientName"]
error_map = {404: ResourceNotFoundError, 409: ResourceExistsError}
error_map.update(kwargs.pop('error_map', {}))

def prepare_request(next_link=None):
if not next_link:
# Construct URL
url = self.get_paging_model_with_item_name_with_xms_client_name.metadata['url'] # type: ignore
# Construct parameters
query_parameters = {} # type: Dict[str, Any]

else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = 'application/json'

# Construct and send request
request = self._client.get(url, query_parameters, header_parameters)
return request

async def extract_data(pipeline_response):
deserialized = self._deserialize('ProductResultValueWithXMSClientName', pipeline_response)
list_of_elem = deserialized.indexes
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link or None, AsyncList(list_of_elem)

async def get_next(next_link=None):
request = prepare_request(next_link)

pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

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)

return pipeline_response

return AsyncItemPaged(
get_next, extract_data
)
get_paging_model_with_item_name_with_xms_client_name.metadata = {'url': '/paging/itemNameWithXMSClientName'} # type: ignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from ._models_py3 import ProductProperties
from ._models_py3 import ProductResult
from ._models_py3 import ProductResultValue
from ._models_py3 import ProductResultValueWithXMSClientName
except (SyntaxError, ImportError):
from ._models import CustomParameterGroup # type: ignore
from ._models import OdataProductResult # type: ignore
Expand All @@ -30,6 +31,7 @@
from ._models import ProductProperties # type: ignore
from ._models import ProductResult # type: ignore
from ._models import ProductResultValue # type: ignore
from ._models import ProductResultValueWithXMSClientName # type: ignore

from ._auto_rest_paging_test_service_enums import (
OperationResultStatus,
Expand All @@ -47,5 +49,6 @@
'ProductProperties',
'ProductResult',
'ProductResultValue',
'ProductResultValueWithXMSClientName',
'OperationResultStatus',
]
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,26 @@ def __init__(
super(ProductResultValue, self).__init__(**kwargs)
self.value = kwargs.get('value', None)
self.next_link = kwargs.get('next_link', None)


class ProductResultValueWithXMSClientName(msrest.serialization.Model):
"""ProductResultValueWithXMSClientName.

:param indexes:
:type indexes: list[~paging.models.Product]
:param next_link:
:type next_link: str
"""

_attribute_map = {
'indexes': {'key': 'values', 'type': '[Product]'},
'next_link': {'key': 'nextLink', 'type': 'str'},
}

def __init__(
self,
**kwargs
):
super(ProductResultValueWithXMSClientName, self).__init__(**kwargs)
self.indexes = kwargs.get('indexes', None)
self.next_link = kwargs.get('next_link', None)
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,29 @@ def __init__(
super(ProductResultValue, self).__init__(**kwargs)
self.value = value
self.next_link = next_link


class ProductResultValueWithXMSClientName(msrest.serialization.Model):
"""ProductResultValueWithXMSClientName.

:param indexes:
:type indexes: list[~paging.models.Product]
:param next_link:
:type next_link: str
"""

_attribute_map = {
'indexes': {'key': 'values', 'type': '[Product]'},
'next_link': {'key': 'nextLink', 'type': 'str'},
}

def __init__(
self,
*,
indexes: Optional[List["Product"]] = None,
next_link: Optional[str] = None,
**kwargs
):
super(ProductResultValueWithXMSClientName, self).__init__(**kwargs)
self.indexes = indexes
self.next_link = next_link
Original file line number Diff line number Diff line change
Expand Up @@ -1089,3 +1089,63 @@ def get_long_running_output(pipeline_response):
else: polling_method = polling
return LROPoller(self._client, raw_result, get_long_running_output, polling_method)
begin_get_multiple_pages_lro.metadata = {'url': '/paging/multiple/lro'} # type: ignore

@distributed_trace
def get_paging_model_with_item_name_with_xms_client_name(
self,
**kwargs # type: Any
):
# type: (...) -> Iterable["models.ProductResultValueWithXMSClientName"]
"""A paging operation that returns a paging model whose item name is is overriden by x-ms-client-
name 'indexes'.

:keyword callable cls: A custom type or function that will be passed the direct response
:return: An iterator like instance of either ProductResultValueWithXMSClientName or the result of cls(response)
:rtype: ~azure.core.paging.ItemPaged[~paging.models.ProductResultValueWithXMSClientName]
:raises: ~azure.core.exceptions.HttpResponseError
"""
cls = kwargs.pop('cls', None) # type: ClsType["models.ProductResultValueWithXMSClientName"]
error_map = {404: ResourceNotFoundError, 409: ResourceExistsError}
error_map.update(kwargs.pop('error_map', {}))

def prepare_request(next_link=None):
if not next_link:
# Construct URL
url = self.get_paging_model_with_item_name_with_xms_client_name.metadata['url'] # type: ignore
# Construct parameters
query_parameters = {} # type: Dict[str, Any]

else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = 'application/json'

# Construct and send request
request = self._client.get(url, query_parameters, header_parameters)
return request

def extract_data(pipeline_response):
deserialized = self._deserialize('ProductResultValueWithXMSClientName', pipeline_response)
list_of_elem = deserialized.indexes
if cls:
list_of_elem = cls(list_of_elem)
return deserialized.next_link or None, iter(list_of_elem)

def get_next(next_link=None):
request = prepare_request(next_link)

pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
response = pipeline_response.http_response

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)

return pipeline_response

return ItemPaged(
get_next, extract_data
)
get_paging_model_with_item_name_with_xms_client_name.metadata = {'url': '/paging/itemNameWithXMSClientName'} # type: ignore