Skip to content
Open
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
8 changes: 8 additions & 0 deletions .chronus/changes/python-fix-nightly-2026-1-3-9-2-18.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: internal
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

Add test case
8 changes: 8 additions & 0 deletions .chronus/changes/python-fix-nightly-2026-1-4-6-52-8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: fix
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

Fix import for xml paging
4 changes: 2 additions & 2 deletions 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": "~0.26.3",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTgzNTk5NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.26.3.tgz",
"@autorest/system-requirements": "~1.0.2",
"fs-extra": "~11.2.0",
"tsx": "~4.19.1"
Expand All @@ -47,4 +47,4 @@
"requirements.txt",
"generator/"
]
}
}
8 changes: 4 additions & 4 deletions packages/typespec-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"js-yaml": "~4.1.0",
"semver": "~7.6.2",
"tsx": "~4.19.1",
"@typespec/http-client-python": "~0.26.3",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTgzNTk5NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.26.3.tgz",
"fs-extra": "~11.2.0"
},
"devDependencies": {
Expand All @@ -86,8 +86,8 @@
"@azure-tools/typespec-azure-rulesets": "~0.64.0",
"@azure-tools/typespec-autorest": "~0.64.1",
"@azure-tools/typespec-client-generator-core": "~0.64.5",
"@azure-tools/azure-http-specs": "0.1.0-alpha.36",
"@typespec/http-specs": "0.1.0-alpha.32-dev.1",
"@azure-tools/azure-http-specs": "0.1.0-alpha.37-dev.1",
"@typespec/http-specs": "0.1.0-alpha.32-dev.5",
"@typespec/spector": "0.1.0-alpha.22",
"@typespec/spec-api": "0.1.0-alpha.12",
"@types/js-yaml": "~4.0.5",
Expand All @@ -103,4 +103,4 @@
"chalk": "5.3.0",
"@types/fs-extra": "11.0.4"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
"azure.resourcemanager.operationtemplates.aio.operations.LroOperations.begin_export": "Azure.ResourceManager.OperationTemplates.Lro.export",
"azure.resourcemanager.operationtemplates.operations.LroOperations.begin_delete": "Azure.ResourceManager.OperationTemplates.Lro.delete",
"azure.resourcemanager.operationtemplates.aio.operations.LroOperations.begin_delete": "Azure.ResourceManager.OperationTemplates.Lro.delete",
"azure.resourcemanager.operationtemplates.operations.LroOperations.begin_export_array": "Azure.ResourceManager.OperationTemplates.Lro.exportArray",
"azure.resourcemanager.operationtemplates.aio.operations.LroOperations.begin_export_array": "Azure.ResourceManager.OperationTemplates.Lro.exportArray",
"azure.resourcemanager.operationtemplates.operations.LroPagingOperations.begin_post_paging_lro": "Azure.ResourceManager.OperationTemplates.LroPaging.postPagingLro",
"azure.resourcemanager.operationtemplates.aio.operations.LroPagingOperations.begin_post_paging_lro": "Azure.ResourceManager.OperationTemplates.LroPaging.postPagingLro",
"azure.resourcemanager.operationtemplates.operations.OptionalBodyOperations.get": "Azure.ResourceManager.OperationTemplates.OptionalBody.get",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
build_check_name_availability_check_local_request,
build_lro_create_or_replace_request,
build_lro_delete_request,
build_lro_export_array_request,
build_lro_export_request,
build_lro_paging_post_paging_lro_request,
build_operations_list_request,
Expand Down Expand Up @@ -1064,6 +1065,194 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-
)
return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore

async def _export_array_initial(
self, body: Union[_models.ExportRequest, JSON, IO[bytes]], **kwargs: Any
) -> AsyncIterator[bytes]:
error_map: MutableMapping = {
401: ClientAuthenticationError,
404: ResourceNotFoundError,
409: ResourceExistsError,
304: ResourceNotModifiedError,
}
error_map.update(kwargs.pop("error_map", {}) or {})

_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = kwargs.pop("params", {}) or {}

content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None)

content_type = content_type or "application/json"
_content = None
if isinstance(body, (IOBase, bytes)):
_content = body
else:
_content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore

_request = build_lro_export_array_request(
subscription_id=self._config.subscription_id,
content_type=content_type,
api_version=self._config.api_version,
content=_content,
headers=_headers,
params=_params,
)
path_format_arguments = {
"endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
}
_request.url = self._client.format_url(_request.url, **path_format_arguments)

_stream = True
pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
_request, stream=_stream, **kwargs
)

response = pipeline_response.http_response

if response.status_code not in [200, 202]:
try:
await response.read() # Load the body in memory and close the socket
except (StreamConsumedError, StreamClosedError):
pass
map_error(status_code=response.status_code, response=response, error_map=error_map)
error = _failsafe_deserialize(
_models.ErrorResponse,
response,
)
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

response_headers = {}
if response.status_code == 202:
response_headers["Azure-AsyncOperation"] = self._deserialize(
"str", response.headers.get("Azure-AsyncOperation")
)
response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))

deserialized = response.iter_bytes()

if cls:
return cls(pipeline_response, deserialized, response_headers) # type: ignore

return deserialized # type: ignore

@overload
async def begin_export_array(
self, body: _models.ExportRequest, *, content_type: str = "application/json", **kwargs: Any
) -> AsyncLROPoller[List[_models.ExportResult]]:
"""export_array.

:param body: The request body. Required.
:type body: ~azure.resourcemanager.operationtemplates.models.ExportRequest
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:return: An instance of AsyncLROPoller that returns list of ExportResult
:rtype:
~azure.core.polling.AsyncLROPoller[list[~azure.resourcemanager.operationtemplates.models.ExportResult]]
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
async def begin_export_array(
self, body: JSON, *, content_type: str = "application/json", **kwargs: Any
) -> AsyncLROPoller[List[_models.ExportResult]]:
"""export_array.

:param body: The request body. Required.
:type body: JSON
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
Default value is "application/json".
:paramtype content_type: str
:return: An instance of AsyncLROPoller that returns list of ExportResult
:rtype:
~azure.core.polling.AsyncLROPoller[list[~azure.resourcemanager.operationtemplates.models.ExportResult]]
:raises ~azure.core.exceptions.HttpResponseError:
"""

@overload
async def begin_export_array(
self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
) -> AsyncLROPoller[List[_models.ExportResult]]:
"""export_array.

:param body: The request body. Required.
:type body: IO[bytes]
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
Default value is "application/json".
:paramtype content_type: str
:return: An instance of AsyncLROPoller that returns list of ExportResult
:rtype:
~azure.core.polling.AsyncLROPoller[list[~azure.resourcemanager.operationtemplates.models.ExportResult]]
:raises ~azure.core.exceptions.HttpResponseError:
"""

@distributed_trace_async
async def begin_export_array(
self, body: Union[_models.ExportRequest, JSON, IO[bytes]], **kwargs: Any
) -> AsyncLROPoller[List[_models.ExportResult]]:
"""export_array.

:param body: The request body. Is one of the following types: ExportRequest, JSON, IO[bytes]
Required.
:type body: ~azure.resourcemanager.operationtemplates.models.ExportRequest or JSON or IO[bytes]
:return: An instance of AsyncLROPoller that returns list of ExportResult
:rtype:
~azure.core.polling.AsyncLROPoller[list[~azure.resourcemanager.operationtemplates.models.ExportResult]]
:raises ~azure.core.exceptions.HttpResponseError:
"""
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
_params = kwargs.pop("params", {}) or {}

content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
cls: ClsType[List[_models.ExportResult]] = kwargs.pop("cls", None)
polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True)
lro_delay = kwargs.pop("polling_interval", self._config.polling_interval)
cont_token: Optional[str] = kwargs.pop("continuation_token", None)
if cont_token is None:
raw_result = await self._export_array_initial(
body=body, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs
)
await raw_result.http_response.read() # type: ignore
kwargs.pop("error_map", None)

def get_long_running_output(pipeline_response):
response_headers = {}
response = pipeline_response.http_response
response_headers["Azure-AsyncOperation"] = self._deserialize(
"str", response.headers.get("Azure-AsyncOperation")
)
response_headers["Location"] = self._deserialize("str", response.headers.get("Location"))
response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After"))

deserialized = _deserialize(List[_models.ExportResult], response.json())
if cls:
return cls(pipeline_response, deserialized, response_headers) # type: ignore
return deserialized

path_format_arguments = {
"endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
}

if polling is True:
polling_method: AsyncPollingMethod = cast(
AsyncPollingMethod, AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs)
)
elif polling is False:
polling_method = cast(AsyncPollingMethod, AsyncNoPolling())
else:
polling_method = polling
if cont_token:
return AsyncLROPoller[List[_models.ExportResult]].from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller[List[_models.ExportResult]](
self._client, raw_result, get_long_running_output, polling_method # type: ignore
)


class LroPagingOperations:
"""
Expand Down
Loading
Loading