diff --git a/.chronus/changes/python-fix-nightly-2026-1-3-9-2-18.md b/.chronus/changes/python-fix-nightly-2026-1-3-9-2-18.md new file mode 100644 index 00000000000..c2f9218c34e --- /dev/null +++ b/.chronus/changes/python-fix-nightly-2026-1-3-9-2-18.md @@ -0,0 +1,8 @@ +--- +changeKind: internal +packages: + - "@autorest/python" + - "@azure-tools/typespec-python" +--- + +Add test case \ No newline at end of file diff --git a/.chronus/changes/python-fix-nightly-2026-1-4-6-52-8.md b/.chronus/changes/python-fix-nightly-2026-1-4-6-52-8.md new file mode 100644 index 00000000000..9475e832907 --- /dev/null +++ b/.chronus/changes/python-fix-nightly-2026-1-4-6-52-8.md @@ -0,0 +1,8 @@ +--- +changeKind: fix +packages: + - "@autorest/python" + - "@azure-tools/typespec-python" +--- + +Fix import for xml paging \ No newline at end of file diff --git a/packages/autorest.python/package.json b/packages/autorest.python/package.json index e2a8987ace9..6d95fc9a4f2 100644 --- a/packages/autorest.python/package.json +++ b/packages/autorest.python/package.json @@ -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" @@ -47,4 +47,4 @@ "requirements.txt", "generator/" ] -} +} \ No newline at end of file diff --git a/packages/typespec-python/package.json b/packages/typespec-python/package.json index e4aea468376..4f799e1ae03 100644 --- a/packages/typespec-python/package.json +++ b/packages/typespec-python/package.json @@ -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": { @@ -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", @@ -103,4 +103,4 @@ "chalk": "5.3.0", "@types/fs-extra": "11.0.4" } -} +} \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/apiview-properties.json b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/apiview-properties.json index 1863d8dc13c..b7b5c0afd0b 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/apiview-properties.json +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/apiview-properties.json @@ -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", diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/aio/operations/_operations.py index 6b0b20ecbd6..e1659313c4c 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/aio/operations/_operations.py @@ -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, @@ -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: """ diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/operations/_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/operations/_operations.py index f73b66667a9..c6f9c024c01 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/azure/resourcemanager/operationtemplates/operations/_operations.py @@ -208,6 +208,33 @@ def build_lro_delete_request( return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) +def build_lro_export_array_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/subscriptions/{subscriptionId}/providers/Azure.ResourceManager.OperationTemplates/exportArray" + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + def build_lro_paging_post_paging_lro_request( resource_group_name: str, product_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: @@ -1358,6 +1385,194 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore + def _export_array_initial( + self, body: Union[_models.ExportRequest, JSON, IO[bytes]], **kwargs: Any + ) -> Iterator[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[Iterator[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 = 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: + 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 + def begin_export_array( + self, body: _models.ExportRequest, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[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 LROPoller that returns list of ExportResult + :rtype: + ~azure.core.polling.LROPoller[list[~azure.resourcemanager.operationtemplates.models.ExportResult]] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_export_array( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[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 LROPoller that returns list of ExportResult + :rtype: + ~azure.core.polling.LROPoller[list[~azure.resourcemanager.operationtemplates.models.ExportResult]] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_export_array( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[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 LROPoller that returns list of ExportResult + :rtype: + ~azure.core.polling.LROPoller[list[~azure.resourcemanager.operationtemplates.models.ExportResult]] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_export_array( + self, body: Union[_models.ExportRequest, JSON, IO[bytes]], **kwargs: Any + ) -> LROPoller[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 LROPoller that returns list of ExportResult + :rtype: + ~azure.core.polling.LROPoller[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, PollingMethod] = 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 = self._export_array_initial( + body=body, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs + ) + 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: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[List[_models.ExportResult]].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[List[_models.ExportResult]]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + class LroPagingOperations: """ diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/generated_tests/test_operation_templates_lro_operations.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/generated_tests/test_operation_templates_lro_operations.py index 4dd9bfcf656..52ea05874fc 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/generated_tests/test_operation_templates_lro_operations.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/generated_tests/test_operation_templates_lro_operations.py @@ -67,3 +67,13 @@ def test_lro_begin_delete(self, resource_group): # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_lro_begin_export_array(self, resource_group): + response = self.client.lro.begin_export_array( + body={"format": "str"}, + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/generated_tests/test_operation_templates_lro_operations_async.py b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/generated_tests/test_operation_templates_lro_operations_async.py index 4d27a056ccf..013cd6c9cc1 100644 --- a/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/generated_tests/test_operation_templates_lro_operations_async.py +++ b/packages/typespec-python/test/azure/generated/azure-resource-manager-operation-templates/generated_tests/test_operation_templates_lro_operations_async.py @@ -74,3 +74,15 @@ async def test_lro_begin_delete(self, resource_group): # please add some check logic here by yourself # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_lro_begin_export_array(self, resource_group): + response = await ( + await self.client.lro.begin_export_array( + body={"format": "str"}, + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/payload-pageable/apiview-properties.json b/packages/typespec-python/test/azure/generated/payload-pageable/apiview-properties.json index 6c445169040..4758f8b27f4 100644 --- a/packages/typespec-python/test/azure/generated/payload-pageable/apiview-properties.json +++ b/packages/typespec-python/test/azure/generated/payload-pageable/apiview-properties.json @@ -8,6 +8,7 @@ "payload.pageable.serverdrivenpagination.continuationtoken.models.RequestHeaderNestedResponseBodyResponseNestedNext": "Payload.Pageable.ServerDrivenPagination.ContinuationToken.requestHeaderNestedResponseBody.Response.nestedNext.anonymous", "payload.pageable.serverdrivenpagination.continuationtoken.models.RequestQueryNestedResponseBodyResponseNestedItems": "Payload.Pageable.ServerDrivenPagination.ContinuationToken.requestQueryNestedResponseBody.Response.nestedItems.anonymous", "payload.pageable.serverdrivenpagination.continuationtoken.models.RequestQueryNestedResponseBodyResponseNestedNext": "Payload.Pageable.ServerDrivenPagination.ContinuationToken.requestQueryNestedResponseBody.Response.nestedNext.anonymous", + "payload.pageable.models.XmlPet": "Payload.Pageable.XmlPet", "payload.pageable.operations.ServerDrivenPaginationOperations.link": "Payload.Pageable.ServerDrivenPagination.link", "payload.pageable.aio.operations.ServerDrivenPaginationOperations.link": "Payload.Pageable.ServerDrivenPagination.link", "payload.pageable.operations.ServerDrivenPaginationOperations.link_string": "Payload.Pageable.ServerDrivenPagination.linkString", @@ -17,6 +18,10 @@ "payload.pageable.operations.PageSizeOperations.list_without_continuation": "Payload.Pageable.PageSize.listWithoutContinuation", "payload.pageable.aio.operations.PageSizeOperations.list_without_continuation": "Payload.Pageable.PageSize.listWithoutContinuation", "payload.pageable.operations.PageSizeOperations.list_with_page_size": "Payload.Pageable.PageSize.listWithPageSize", - "payload.pageable.aio.operations.PageSizeOperations.list_with_page_size": "Payload.Pageable.PageSize.listWithPageSize" + "payload.pageable.aio.operations.PageSizeOperations.list_with_page_size": "Payload.Pageable.PageSize.listWithPageSize", + "payload.pageable.operations.XmlPaginationOperations.list_with_continuation": "Payload.Pageable.XmlPagination.listWithContinuation", + "payload.pageable.aio.operations.XmlPaginationOperations.list_with_continuation": "Payload.Pageable.XmlPagination.listWithContinuation", + "payload.pageable.operations.XmlPaginationOperations.list_with_next_link": "Payload.Pageable.XmlPagination.listWithNextLink", + "payload.pageable.aio.operations.XmlPaginationOperations.list_with_next_link": "Payload.Pageable.XmlPagination.listWithNextLink" } } \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/payload-pageable/generated_tests/test_pageable_xml_pagination_operations.py b/packages/typespec-python/test/azure/generated/payload-pageable/generated_tests/test_pageable_xml_pagination_operations.py new file mode 100644 index 00000000000..ddb909bfd85 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/payload-pageable/generated_tests/test_pageable_xml_pagination_operations.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils import recorded_by_proxy +from testpreparer import PageableClientTestBase, PageablePreparer + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPageableXmlPaginationOperations(PageableClientTestBase): + @PageablePreparer() + @recorded_by_proxy + def test_xml_pagination_list_with_continuation(self, pageable_endpoint): + client = self.create_client(endpoint=pageable_endpoint) + response = client.xml_pagination.list_with_continuation() + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @PageablePreparer() + @recorded_by_proxy + def test_xml_pagination_list_with_next_link(self, pageable_endpoint): + client = self.create_client(endpoint=pageable_endpoint) + response = client.xml_pagination.list_with_next_link() + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/payload-pageable/generated_tests/test_pageable_xml_pagination_operations_async.py b/packages/typespec-python/test/azure/generated/payload-pageable/generated_tests/test_pageable_xml_pagination_operations_async.py new file mode 100644 index 00000000000..200bdb41760 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/payload-pageable/generated_tests/test_pageable_xml_pagination_operations_async.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils.aio import recorded_by_proxy_async +from testpreparer import PageablePreparer +from testpreparer_async import PageableClientTestBaseAsync + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestPageableXmlPaginationOperationsAsync(PageableClientTestBaseAsync): + @PageablePreparer() + @recorded_by_proxy_async + async def test_xml_pagination_list_with_continuation(self, pageable_endpoint): + client = self.create_async_client(endpoint=pageable_endpoint) + response = client.xml_pagination.list_with_continuation() + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @PageablePreparer() + @recorded_by_proxy_async + async def test_xml_pagination_list_with_next_link(self, pageable_endpoint): + client = self.create_async_client(endpoint=pageable_endpoint) + response = client.xml_pagination.list_with_next_link() + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/_client.py b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/_client.py index 70f40869109..20b9cdc7b9e 100644 --- a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/_client.py +++ b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/_client.py @@ -18,6 +18,7 @@ from ._utils.serialization import Deserializer, Serializer from .pagesize.operations import PageSizeOperations from .serverdrivenpagination.operations import ServerDrivenPaginationOperations +from .xmlpagination.operations import XmlPaginationOperations class PageableClient: # pylint: disable=client-accepts-api-version-keyword @@ -27,6 +28,8 @@ class PageableClient: # pylint: disable=client-accepts-api-version-keyword :vartype server_driven_pagination: payload.pageable.operations.ServerDrivenPaginationOperations :ivar page_size: PageSizeOperations operations :vartype page_size: payload.pageable.operations.PageSizeOperations + :ivar xml_pagination: XmlPaginationOperations operations + :vartype xml_pagination: payload.pageable.operations.XmlPaginationOperations :keyword endpoint: Service host. Default value is "http://localhost:3000". :paramtype endpoint: str """ @@ -63,6 +66,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential self._client, self._config, self._serialize, self._deserialize ) self.page_size = PageSizeOperations(self._client, self._config, self._serialize, self._deserialize) + self.xml_pagination = XmlPaginationOperations(self._client, self._config, self._serialize, self._deserialize) def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/aio/_client.py b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/aio/_client.py index 9d29b3b03a8..c25cf8b3cc5 100644 --- a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/aio/_client.py @@ -17,6 +17,7 @@ from .._utils.serialization import Deserializer, Serializer from ..pagesize.aio.operations import PageSizeOperations from ..serverdrivenpagination.aio.operations import ServerDrivenPaginationOperations +from ..xmlpagination.aio.operations import XmlPaginationOperations from ._configuration import PageableClientConfiguration @@ -28,6 +29,8 @@ class PageableClient: # pylint: disable=client-accepts-api-version-keyword payload.pageable.aio.operations.ServerDrivenPaginationOperations :ivar page_size: PageSizeOperations operations :vartype page_size: payload.pageable.aio.operations.PageSizeOperations + :ivar xml_pagination: XmlPaginationOperations operations + :vartype xml_pagination: payload.pageable.aio.operations.XmlPaginationOperations :keyword endpoint: Service host. Default value is "http://localhost:3000". :paramtype endpoint: str """ @@ -64,6 +67,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential self._client, self._config, self._serialize, self._deserialize ) self.page_size = PageSizeOperations(self._client, self._config, self._serialize, self._deserialize) + self.xml_pagination = XmlPaginationOperations(self._client, self._config, self._serialize, self._deserialize) def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any diff --git a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/models/__init__.py b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/models/__init__.py index eda60593014..4044bea2cac 100644 --- a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/models/__init__.py +++ b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/models/__init__.py @@ -15,6 +15,7 @@ from ._models import ( # type: ignore Pet, + XmlPet, ) from ._patch import __all__ as _patch_all from ._patch import * @@ -22,6 +23,7 @@ __all__ = [ "Pet", + "XmlPet", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/models/_models.py b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/models/_models.py index 222a8739e63..72e24821194 100644 --- a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/models/_models.py +++ b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/models/_models.py @@ -43,3 +43,44 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) + + +class XmlPet(_Model): + """An XML pet item. + + :ivar id: Required. + :vartype id: str + :ivar name: Required. + :vartype name: str + """ + + id: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Id", "text": False, "unwrapped": False}, + ) + """Required.""" + name: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Name", "text": False, "unwrapped": False}, + ) + """Required.""" + + _xml = {"attribute": False, "name": "Pet", "text": False, "unwrapped": False} + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) diff --git a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/__init__.py b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/aio/__init__.py b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/aio/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/aio/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/aio/operations/__init__.py b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/aio/operations/__init__.py new file mode 100644 index 00000000000..32561ef802d --- /dev/null +++ b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/aio/operations/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import XmlPaginationOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "XmlPaginationOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/aio/operations/_operations.py new file mode 100644 index 00000000000..59150f4cc5a --- /dev/null +++ b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/aio/operations/_operations.py @@ -0,0 +1,184 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Optional, TypeVar +from xml.etree import ElementTree as ET + +from azure.core import AsyncPipelineClient +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.core.tracing.decorator import distributed_trace + +from .... import models as _models3 +from ...._utils.model_base import _deserialize +from ...._utils.serialization import Deserializer, Serializer +from ....aio._configuration import PageableClientConfiguration +from ...operations._operations import ( + build_xml_pagination_list_with_continuation_request, + build_xml_pagination_list_with_next_link_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] + + +class XmlPaginationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~payload.pageable.aio.PageableClient`'s + :attr:`xml_pagination` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PageableClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_with_continuation(self, **kwargs: Any) -> AsyncItemPaged["_models3.XmlPet"]: + """list_with_continuation. + + :return: An iterator like instance of XmlPet + :rtype: ~azure.core.async_paging.AsyncItemPaged[~payload.pageable.models.XmlPet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models3.XmlPet]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_xml_pagination_list_with_continuation_request( + marker=_continuation_token, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request + + async def extract_data(pipeline_response): + deserialized = ET.fromstring(pipeline_response.http_response.text()) + list_of_elem = _deserialize(list[_models3.XmlPet], deserialized.find("Pets")) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + _cont_token_elem = deserialized.find("NextMarker") + return _cont_token_elem.text if _cont_token_elem is not None else None, AsyncList(list_of_elem) + + async def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_with_next_link(self, **kwargs: Any) -> AsyncItemPaged["_models3.XmlPet"]: + """list_with_next_link. + + :return: An iterator like instance of XmlPet + :rtype: ~azure.core.async_paging.AsyncItemPaged[~payload.pageable.models.XmlPet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models3.XmlPet]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_xml_pagination_list_with_next_link_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = ET.fromstring(pipeline_response.http_response.text()) + list_of_elem = _deserialize(list[_models3.XmlPet], deserialized.find("Pets")) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + _cont_token_elem = deserialized.find("NextLink") + return _cont_token_elem.text if _cont_token_elem is not None else None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/aio/operations/_patch.py b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/aio/operations/_patch.py new file mode 100644 index 00000000000..87676c65a8f --- /dev/null +++ b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/aio/operations/_patch.py @@ -0,0 +1,21 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/operations/__init__.py b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/operations/__init__.py new file mode 100644 index 00000000000..32561ef802d --- /dev/null +++ b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/operations/__init__.py @@ -0,0 +1,25 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import XmlPaginationOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "XmlPaginationOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/operations/_operations.py b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/operations/_operations.py new file mode 100644 index 00000000000..962210a3b1c --- /dev/null +++ b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/operations/_operations.py @@ -0,0 +1,219 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from collections.abc import MutableMapping +from typing import Any, Callable, Optional, TypeVar +from xml.etree import ElementTree as ET + +from azure.core import PipelineClient +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict + +from ... import models as _models2 +from ..._configuration import PageableClientConfiguration +from ..._utils.model_base import _deserialize +from ..._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_xml_pagination_list_with_continuation_request( # pylint: disable=name-too-long + *, marker: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/xml") + + # Construct URL + _url = "/payload/pageable/xml/list-with-continuation" + + # Construct parameters + if marker is not None: + _params["marker"] = _SERIALIZER.query("marker", marker, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_xml_pagination_list_with_next_link_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/xml") + + # Construct URL + _url = "/payload/pageable/xml/list-with-next-link" + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +class XmlPaginationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~payload.pageable.PageableClient`'s + :attr:`xml_pagination` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PageableClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_with_continuation(self, **kwargs: Any) -> ItemPaged["_models2.XmlPet"]: + """list_with_continuation. + + :return: An iterator like instance of XmlPet + :rtype: ~azure.core.paging.ItemPaged[~payload.pageable.models.XmlPet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models2.XmlPet]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_xml_pagination_list_with_continuation_request( + marker=_continuation_token, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request + + def extract_data(pipeline_response): + deserialized = ET.fromstring(pipeline_response.http_response.text()) + list_of_elem = _deserialize(list[_models2.XmlPet], deserialized.find("Pets")) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + _cont_token_elem = deserialized.find("NextMarker") + return _cont_token_elem.text if _cont_token_elem is not None else None, iter(list_of_elem) + + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_with_next_link(self, **kwargs: Any) -> ItemPaged["_models2.XmlPet"]: + """list_with_next_link. + + :return: An iterator like instance of XmlPet + :rtype: ~azure.core.paging.ItemPaged[~payload.pageable.models.XmlPet] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models2.XmlPet]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_xml_pagination_list_with_next_link_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = ET.fromstring(pipeline_response.http_response.text()) + list_of_elem = _deserialize(list[_models2.XmlPet], deserialized.find("Pets")) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + _cont_token_elem = deserialized.find("NextLink") + return _cont_token_elem.text if _cont_token_elem is not None else None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/operations/_patch.py b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/operations/_patch.py new file mode 100644 index 00000000000..87676c65a8f --- /dev/null +++ b/packages/typespec-python/test/azure/generated/payload-pageable/payload/pageable/xmlpagination/operations/_patch.py @@ -0,0 +1,21 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/typespec-python/test/azure/generated/payload-xml/apiview-properties.json b/packages/typespec-python/test/azure/generated/payload-xml/apiview-properties.json index a5643eb1276..d460fbdfc94 100644 --- a/packages/typespec-python/test/azure/generated/payload-xml/apiview-properties.json +++ b/packages/typespec-python/test/azure/generated/payload-xml/apiview-properties.json @@ -13,6 +13,7 @@ "payload.xml.models.ModelWithText": "Payload.Xml.ModelWithText", "payload.xml.models.ModelWithUnwrappedArray": "Payload.Xml.ModelWithUnwrappedArray", "payload.xml.models.SimpleModel": "Payload.Xml.SimpleModel", + "payload.xml.models.XmlErrorBody": "Payload.Xml.XmlErrorBody", "payload.xml.operations.SimpleModelValueOperations.get": "Payload.Xml.SimpleModelValue.get", "payload.xml.aio.operations.SimpleModelValueOperations.get": "Payload.Xml.SimpleModelValue.get", "payload.xml.operations.SimpleModelValueOperations.put": "Payload.Xml.SimpleModelValue.put", @@ -60,6 +61,8 @@ "payload.xml.operations.ModelWithEncodedNamesValueOperations.get": "Payload.Xml.ModelWithEncodedNamesValue.get", "payload.xml.aio.operations.ModelWithEncodedNamesValueOperations.get": "Payload.Xml.ModelWithEncodedNamesValue.get", "payload.xml.operations.ModelWithEncodedNamesValueOperations.put": "Payload.Xml.ModelWithEncodedNamesValue.put", - "payload.xml.aio.operations.ModelWithEncodedNamesValueOperations.put": "Payload.Xml.ModelWithEncodedNamesValue.put" + "payload.xml.aio.operations.ModelWithEncodedNamesValueOperations.put": "Payload.Xml.ModelWithEncodedNamesValue.put", + "payload.xml.operations.XmlErrorValueOperations.get": "Payload.Xml.XmlErrorValue.get", + "payload.xml.aio.operations.XmlErrorValueOperations.get": "Payload.Xml.XmlErrorValue.get" } } \ No newline at end of file diff --git a/packages/typespec-python/test/azure/generated/payload-xml/generated_tests/test_xml_xml_error_value_operations.py b/packages/typespec-python/test/azure/generated/payload-xml/generated_tests/test_xml_xml_error_value_operations.py new file mode 100644 index 00000000000..f6f7e6721f4 --- /dev/null +++ b/packages/typespec-python/test/azure/generated/payload-xml/generated_tests/test_xml_xml_error_value_operations.py @@ -0,0 +1,22 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils import recorded_by_proxy +from testpreparer import XmlClientTestBase, XmlPreparer + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestXmlXmlErrorValueOperations(XmlClientTestBase): + @XmlPreparer() + @recorded_by_proxy + def test_xml_error_value_get(self, xml_endpoint): + client = self.create_client(endpoint=xml_endpoint) + response = client.xml_error_value.get() + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/payload-xml/generated_tests/test_xml_xml_error_value_operations_async.py b/packages/typespec-python/test/azure/generated/payload-xml/generated_tests/test_xml_xml_error_value_operations_async.py new file mode 100644 index 00000000000..52f7c4385aa --- /dev/null +++ b/packages/typespec-python/test/azure/generated/payload-xml/generated_tests/test_xml_xml_error_value_operations_async.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) Python Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from devtools_testutils.aio import recorded_by_proxy_async +from testpreparer import XmlPreparer +from testpreparer_async import XmlClientTestBaseAsync + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestXmlXmlErrorValueOperationsAsync(XmlClientTestBaseAsync): + @XmlPreparer() + @recorded_by_proxy_async + async def test_xml_error_value_get(self, xml_endpoint): + client = self.create_async_client(endpoint=xml_endpoint) + response = await client.xml_error_value.get() + + # please add some check logic here by yourself + # ... diff --git a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/_client.py b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/_client.py index 05d84532b37..49e70cf7fa1 100644 --- a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/_client.py +++ b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/_client.py @@ -29,6 +29,7 @@ ModelWithTextValueOperations, ModelWithUnwrappedArrayValueOperations, SimpleModelValueOperations, + XmlErrorValueOperations, ) @@ -67,6 +68,8 @@ class XmlClient: # pylint: disable=client-accepts-api-version-keyword,too-many- :ivar model_with_encoded_names_value: ModelWithEncodedNamesValueOperations operations :vartype model_with_encoded_names_value: payload.xml.operations.ModelWithEncodedNamesValueOperations + :ivar xml_error_value: XmlErrorValueOperations operations + :vartype xml_error_value: payload.xml.operations.XmlErrorValueOperations :keyword endpoint: Service host. Default value is "http://localhost:3000". :paramtype endpoint: str """ @@ -135,6 +138,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential self.model_with_encoded_names_value = ModelWithEncodedNamesValueOperations( self._client, self._config, self._serialize, self._deserialize ) + self.xml_error_value = XmlErrorValueOperations(self._client, self._config, self._serialize, self._deserialize) def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/aio/_client.py b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/aio/_client.py index 9bff62debf6..f39664ad7a5 100644 --- a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/aio/_client.py +++ b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/aio/_client.py @@ -29,6 +29,7 @@ ModelWithTextValueOperations, ModelWithUnwrappedArrayValueOperations, SimpleModelValueOperations, + XmlErrorValueOperations, ) @@ -69,6 +70,8 @@ class XmlClient: # pylint: disable=client-accepts-api-version-keyword,too-many- :ivar model_with_encoded_names_value: ModelWithEncodedNamesValueOperations operations :vartype model_with_encoded_names_value: payload.xml.aio.operations.ModelWithEncodedNamesValueOperations + :ivar xml_error_value: XmlErrorValueOperations operations + :vartype xml_error_value: payload.xml.aio.operations.XmlErrorValueOperations :keyword endpoint: Service host. Default value is "http://localhost:3000". :paramtype endpoint: str """ @@ -137,6 +140,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential self.model_with_encoded_names_value = ModelWithEncodedNamesValueOperations( self._client, self._config, self._serialize, self._deserialize ) + self.xml_error_value = XmlErrorValueOperations(self._client, self._config, self._serialize, self._deserialize) def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any diff --git a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/aio/operations/__init__.py b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/aio/operations/__init__.py index b4f8b77feaf..dea66a1abc1 100644 --- a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/aio/operations/__init__.py +++ b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/aio/operations/__init__.py @@ -24,6 +24,7 @@ from ._operations import ModelWithTextValueOperations # type: ignore from ._operations import ModelWithDictionaryValueOperations # type: ignore from ._operations import ModelWithEncodedNamesValueOperations # type: ignore +from ._operations import XmlErrorValueOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * @@ -42,6 +43,7 @@ "ModelWithTextValueOperations", "ModelWithDictionaryValueOperations", "ModelWithEncodedNamesValueOperations", + "XmlErrorValueOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/aio/operations/_operations.py b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/aio/operations/_operations.py index 768a0f03075..111130c7bf5 100644 --- a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/aio/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/aio/operations/_operations.py @@ -26,7 +26,7 @@ from azure.core.utils import case_insensitive_dict from ... import models as _models -from ..._utils.model_base import _deserialize_xml, _get_element +from ..._utils.model_base import _deserialize_xml, _failsafe_deserialize_xml, _get_element from ..._utils.serialization import Deserializer, Serializer from ...operations._operations import ( build_model_with_array_of_model_value_get_request, @@ -53,6 +53,7 @@ build_model_with_unwrapped_array_value_put_request, build_simple_model_value_get_request, build_simple_model_value_put_request, + build_xml_error_value_get_request, ) from .._configuration import XmlClientConfiguration @@ -1594,3 +1595,83 @@ async def put(self, input: _models.ModelWithEncodedNames, **kwargs: Any) -> None if cls: return cls(pipeline_response, None, {}) # type: ignore + + +class XmlErrorValueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~payload.xml.aio.XmlClient`'s + :attr:`xml_error_value` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: XmlClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, **kwargs: Any) -> _models.SimpleModel: + """get. + + :return: SimpleModel. The SimpleModel is compatible with MutableMapping + :rtype: ~payload.xml.models.SimpleModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SimpleModel] = kwargs.pop("cls", None) + + _request = build_xml_error_value_get_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + 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]: + if _stream: + 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 = None + if response.status_code == 400: + error = _failsafe_deserialize_xml(_models.XmlErrorBody, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize_xml(_models.SimpleModel, response.text()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/__init__.py b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/__init__.py index 5abef18076e..a85a751bf96 100644 --- a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/__init__.py +++ b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/__init__.py @@ -26,6 +26,7 @@ ModelWithText, ModelWithUnwrappedArray, SimpleModel, + XmlErrorBody, ) from ._patch import __all__ as _patch_all from ._patch import * @@ -44,6 +45,7 @@ "ModelWithText", "ModelWithUnwrappedArray", "SimpleModel", + "XmlErrorBody", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/_models.py b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/_models.py index 0fa323efbc5..d1b430a5462 100644 --- a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/_models.py +++ b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/models/_models.py @@ -496,3 +496,44 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) + + +class XmlErrorBody(_Model): + """The body of an XML error response. + + :ivar message: Required. + :vartype message: str + :ivar code: Required. + :vartype code: int + """ + + message: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "message", "text": False, "unwrapped": False}, + ) + """Required.""" + code: int = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "code", "text": False, "unwrapped": False}, + ) + """Required.""" + + _xml = {"attribute": False, "name": "XmlErrorBody", "text": False, "unwrapped": False} + + @overload + def __init__( + self, + *, + message: str, + code: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) diff --git a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/operations/__init__.py b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/operations/__init__.py index b4f8b77feaf..dea66a1abc1 100644 --- a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/operations/__init__.py +++ b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/operations/__init__.py @@ -24,6 +24,7 @@ from ._operations import ModelWithTextValueOperations # type: ignore from ._operations import ModelWithDictionaryValueOperations # type: ignore from ._operations import ModelWithEncodedNamesValueOperations # type: ignore +from ._operations import XmlErrorValueOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * @@ -42,6 +43,7 @@ "ModelWithTextValueOperations", "ModelWithDictionaryValueOperations", "ModelWithEncodedNamesValueOperations", + "XmlErrorValueOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/operations/_operations.py b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/operations/_operations.py index 7a655cf2758..840ff01e0dc 100644 --- a/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/operations/_operations.py +++ b/packages/typespec-python/test/azure/generated/payload-xml/payload/xml/operations/_operations.py @@ -27,7 +27,7 @@ from .. import models as _models from .._configuration import XmlClientConfiguration -from .._utils.model_base import _deserialize_xml, _get_element +from .._utils.model_base import _deserialize_xml, _failsafe_deserialize_xml, _get_element from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") @@ -361,6 +361,20 @@ def build_model_with_encoded_names_value_put_request(**kwargs: Any) -> HttpReque return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) +def build_xml_error_value_get_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/xml") + + # Construct URL + _url = "/payload/xml/error" + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + class SimpleModelValueOperations: """ .. warning:: @@ -1917,3 +1931,83 @@ def put( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore + + +class XmlErrorValueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~payload.xml.XmlClient`'s + :attr:`xml_error_value` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: XmlClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, **kwargs: Any) -> _models.SimpleModel: + """get. + + :return: SimpleModel. The SimpleModel is compatible with MutableMapping + :rtype: ~payload.xml.models.SimpleModel + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SimpleModel] = kwargs.pop("cls", None) + + _request = build_xml_error_value_get_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + 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 = None + if response.status_code == 400: + error = _failsafe_deserialize_xml(_models.XmlErrorBody, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize_xml(_models.SimpleModel, response.text()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_arm_operationtemplates_async.py b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_arm_operationtemplates_async.py index 21fc5d68738..2c1bc0fc4b6 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_arm_operationtemplates_async.py +++ b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_arm_operationtemplates_async.py @@ -176,6 +176,18 @@ async def test_optional_body_provider_post_with_body(client): assert result.status == "Changed to requested allowance" +@pytest.mark.asyncio +async def test_lro_begin_export_array(client): + result = await ( + await client.lro.begin_export_array( + body=models.ExportRequest(format="csv"), + ) + ).result() + assert len(result) == 2 + assert result[0].content == "order1,product1,1" + assert result[1].content == "order2,product2,2" + + @pytest.mark.asyncio async def test_lro_paging_begin_post_paging_lro(client): poller = await client.lro_paging.begin_post_paging_lro( diff --git a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_resource_manager_multi_service_older_versions_async.py b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_resource_manager_multi_service_older_versions_async.py new file mode 100644 index 00000000000..d9f36f938f3 --- /dev/null +++ b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_resource_manager_multi_service_older_versions_async.py @@ -0,0 +1,111 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +from azure.resourcemanager.multiserviceolderversions.combined.aio import CombinedClient +from azure.resourcemanager.multiserviceolderversions.combined.models import ( + VirtualMachine, + Disk, + VirtualMachineProperties, + DiskProperties, +) + + +@pytest.fixture +async def client(credential, authentication_policy): + """Create a Combined async client for testing.""" + return CombinedClient( + credential=credential, + subscription_id="00000000-0000-0000-0000-000000000000", + base_url="http://localhost:3000", + authentication_policy=authentication_policy, + polling_interval=0.1, + ) + + +@pytest.mark.asyncio +async def test_virtual_machines_get(client): + """Test getting a virtual machine.""" + resource_group_name = "test-rg" + vm_name = "vm-old1" + + result = await client.virtual_machines.get(resource_group_name=resource_group_name, vm_name=vm_name) + + assert result is not None + assert isinstance(result, VirtualMachine) + assert result.name == vm_name + assert result.location == "eastus" + assert result.properties is not None + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.size == "Standard_D2s_v3" + + +@pytest.mark.asyncio +async def test_virtual_machines_create_or_update(client): + """Test creating or updating a virtual machine.""" + resource_group_name = "test-rg" + vm_name = "vm-old1" + + vm_resource = VirtualMachine( + location="eastus", + properties=VirtualMachineProperties(size="Standard_D2s_v3"), + ) + + poller = await client.virtual_machines.begin_create_or_update( + resource_group_name=resource_group_name, + vm_name=vm_name, + resource=vm_resource, + ) + + result = await poller.result() + assert result is not None + assert isinstance(result, VirtualMachine) + assert result.location == "eastus" + assert result.properties is not None + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.size == "Standard_D2s_v3" + + +@pytest.mark.asyncio +async def test_disks_get(client): + """Test getting a disk.""" + resource_group_name = "test-rg" + disk_name = "disk-old1" + + result = await client.disks.get(resource_group_name=resource_group_name, disk_name=disk_name) + + assert result is not None + assert isinstance(result, Disk) + assert result.name == disk_name + assert result.location == "eastus" + assert result.properties is not None + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.disk_size_gb == 128 + + +@pytest.mark.asyncio +async def test_disks_create_or_update(client): + """Test creating or updating a disk.""" + resource_group_name = "test-rg" + disk_name = "disk-old1" + + disk_resource = Disk( + location="eastus", + properties=DiskProperties(disk_size_gb=128), + ) + + poller = await client.disks.begin_create_or_update( + resource_group_name=resource_group_name, + disk_name=disk_name, + resource=disk_resource, + ) + + result = await poller.result() + assert result is not None + assert isinstance(result, Disk) + assert result.location == "eastus" + assert result.properties is not None + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.disk_size_gb == 128 diff --git a/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_resource_manager_multi_service_shared_models_async.py b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_resource_manager_multi_service_shared_models_async.py new file mode 100644 index 00000000000..ee1c21bfbe1 --- /dev/null +++ b/packages/typespec-python/test/azure/mock_api_tests/asynctests/test_azure_resource_manager_multi_service_shared_models_async.py @@ -0,0 +1,132 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +from azure.resourcemanager.multiservicesharedmodels.combined.aio import CombinedClient +from azure.resourcemanager.multiservicesharedmodels.combined.models import ( + VirtualMachine, + VirtualMachineProperties, + StorageAccount, + StorageAccountProperties, + SharedMetadata, +) + + +@pytest.fixture +async def client(credential, authentication_policy): + """Create a Combined async client for testing.""" + return CombinedClient( + credential=credential, + subscription_id="00000000-0000-0000-0000-000000000000", + base_url="http://localhost:3000", + authentication_policy=authentication_policy, + polling_interval=0.1, + ) + + +@pytest.mark.asyncio +async def test_virtual_machines_get(client): + """Test getting a virtual machine with shared metadata.""" + resource_group_name = "test-rg" + vm_name = "vm-shared1" + + result = await client.virtual_machines.get(resource_group_name=resource_group_name, vm_name=vm_name) + + assert result is not None + assert isinstance(result, VirtualMachine) + assert result.name == vm_name + assert result.location == "eastus" + assert result.type == "Microsoft.Compute/virtualMachinesShared" + assert result.properties is not None + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.metadata is not None + assert result.properties.metadata.created_by == "user@example.com" + assert result.properties.metadata.tags == {"environment": "production"} + + +@pytest.mark.asyncio +async def test_virtual_machines_create_or_update(client): + """Test creating or updating a virtual machine with shared metadata.""" + resource_group_name = "test-rg" + vm_name = "vm-shared1" + + vm_resource = VirtualMachine( + location="eastus", + properties=VirtualMachineProperties( + metadata=SharedMetadata( + created_by="user@example.com", + tags={"environment": "production"}, + ), + ), + ) + + poller = await client.virtual_machines.begin_create_or_update( + resource_group_name=resource_group_name, + vm_name=vm_name, + resource=vm_resource, + ) + + result = await poller.result() + assert result is not None + assert isinstance(result, VirtualMachine) + assert result.location == "eastus" + assert result.properties is not None + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.metadata is not None + assert result.properties.metadata.created_by == "user@example.com" + assert result.properties.metadata.tags == {"environment": "production"} + + +@pytest.mark.asyncio +async def test_storage_accounts_get(client): + """Test getting a storage account with shared metadata.""" + resource_group_name = "test-rg" + account_name = "account1" + + result = await client.storage_accounts.get(resource_group_name=resource_group_name, account_name=account_name) + + assert result is not None + assert isinstance(result, StorageAccount) + assert result.name == account_name + assert result.location == "westus" + assert result.type == "Microsoft.Storage/storageAccounts" + assert result.properties is not None + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.metadata is not None + assert result.properties.metadata.created_by == "admin@example.com" + assert result.properties.metadata.tags == {"department": "engineering"} + + +@pytest.mark.asyncio +async def test_storage_accounts_create_or_update(client): + """Test creating or updating a storage account with shared metadata.""" + resource_group_name = "test-rg" + account_name = "account1" + + storage_resource = StorageAccount( + location="westus", + properties=StorageAccountProperties( + metadata=SharedMetadata( + created_by="admin@example.com", + tags={"department": "engineering"}, + ), + ), + ) + + poller = await client.storage_accounts.begin_create_or_update( + resource_group_name=resource_group_name, + account_name=account_name, + resource=storage_resource, + ) + + result = await poller.result() + assert result is not None + assert isinstance(result, StorageAccount) + assert result.location == "westus" + assert result.properties is not None + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.metadata is not None + assert result.properties.metadata.created_by == "admin@example.com" + assert result.properties.metadata.tags == {"department": "engineering"} diff --git a/packages/typespec-python/test/azure/mock_api_tests/test_azure_arm_operationtemplates.py b/packages/typespec-python/test/azure/mock_api_tests/test_azure_arm_operationtemplates.py index 9895d78d8cb..c86c95ef4a9 100644 --- a/packages/typespec-python/test/azure/mock_api_tests/test_azure_arm_operationtemplates.py +++ b/packages/typespec-python/test/azure/mock_api_tests/test_azure_arm_operationtemplates.py @@ -156,6 +156,15 @@ def test_optional_body_provider_post_with_body(client): assert result.status == "Changed to requested allowance" +def test_lro_begin_export_array(client): + result = client.lro.begin_export_array( + body=models.ExportRequest(format="csv"), + ).result() + assert len(result) == 2 + assert result[0].content == "order1,product1,1" + assert result[1].content == "order2,product2,2" + + def test_lro_paging_begin_post_paging_lro(client): result = client.lro_paging.begin_post_paging_lro( resource_group_name=RESOURCE_GROUP_NAME, diff --git a/packages/typespec-python/test/azure/mock_api_tests/test_azure_resource_manager_multi_service_older_versions.py b/packages/typespec-python/test/azure/mock_api_tests/test_azure_resource_manager_multi_service_older_versions.py new file mode 100644 index 00000000000..e98b0e07796 --- /dev/null +++ b/packages/typespec-python/test/azure/mock_api_tests/test_azure_resource_manager_multi_service_older_versions.py @@ -0,0 +1,107 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +from azure.resourcemanager.multiserviceolderversions.combined import CombinedClient +from azure.resourcemanager.multiserviceolderversions.combined.models import ( + VirtualMachine, + Disk, + VirtualMachineProperties, + DiskProperties, +) + + +@pytest.fixture +def client(credential, authentication_policy): + """Create a Combined client for testing.""" + return CombinedClient( + credential=credential, + subscription_id="00000000-0000-0000-0000-000000000000", + base_url="http://localhost:3000", + authentication_policy=authentication_policy, + polling_interval=0.1, + ) + + +def test_virtual_machines_get(client): + """Test getting a virtual machine.""" + resource_group_name = "test-rg" + vm_name = "vm-old1" + + result = client.virtual_machines.get(resource_group_name=resource_group_name, vm_name=vm_name) + + assert result is not None + assert isinstance(result, VirtualMachine) + assert result.name == vm_name + assert result.location == "eastus" + assert result.properties is not None + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.size == "Standard_D2s_v3" + + +def test_virtual_machines_create_or_update(client): + """Test creating or updating a virtual machine.""" + resource_group_name = "test-rg" + vm_name = "vm-old1" + + vm_resource = VirtualMachine( + location="eastus", + properties=VirtualMachineProperties(size="Standard_D2s_v3"), + ) + + poller = client.virtual_machines.begin_create_or_update( + resource_group_name=resource_group_name, + vm_name=vm_name, + resource=vm_resource, + ) + + result = poller.result() + assert result is not None + assert isinstance(result, VirtualMachine) + assert result.location == "eastus" + assert result.properties is not None + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.size == "Standard_D2s_v3" + + +def test_disks_get(client): + """Test getting a disk.""" + resource_group_name = "test-rg" + disk_name = "disk-old1" + + result = client.disks.get(resource_group_name=resource_group_name, disk_name=disk_name) + + assert result is not None + assert isinstance(result, Disk) + assert result.name == disk_name + assert result.location == "eastus" + assert result.properties is not None + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.disk_size_gb == 128 + + +def test_disks_create_or_update(client): + """Test creating or updating a disk.""" + resource_group_name = "test-rg" + disk_name = "disk-old1" + + disk_resource = Disk( + location="eastus", + properties=DiskProperties(disk_size_gb=128), + ) + + poller = client.disks.begin_create_or_update( + resource_group_name=resource_group_name, + disk_name=disk_name, + resource=disk_resource, + ) + + result = poller.result() + assert result is not None + assert isinstance(result, Disk) + assert result.location == "eastus" + assert result.properties is not None + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.disk_size_gb == 128 diff --git a/packages/typespec-python/test/azure/mock_api_tests/test_azure_resource_manager_multi_service_shared_models.py b/packages/typespec-python/test/azure/mock_api_tests/test_azure_resource_manager_multi_service_shared_models.py new file mode 100644 index 00000000000..0e3f67ebc10 --- /dev/null +++ b/packages/typespec-python/test/azure/mock_api_tests/test_azure_resource_manager_multi_service_shared_models.py @@ -0,0 +1,128 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- +import pytest +from azure.resourcemanager.multiservicesharedmodels.combined import CombinedClient +from azure.resourcemanager.multiservicesharedmodels.combined.models import ( + VirtualMachine, + VirtualMachineProperties, + StorageAccount, + StorageAccountProperties, + SharedMetadata, +) + + +@pytest.fixture +def client(credential, authentication_policy): + """Create a Combined client for testing.""" + return CombinedClient( + credential=credential, + subscription_id="00000000-0000-0000-0000-000000000000", + base_url="http://localhost:3000", + authentication_policy=authentication_policy, + polling_interval=0.1, + ) + + +def test_virtual_machines_get(client): + """Test getting a virtual machine with shared metadata.""" + resource_group_name = "test-rg" + vm_name = "vm-shared1" + + result = client.virtual_machines.get(resource_group_name=resource_group_name, vm_name=vm_name) + + assert result is not None + assert isinstance(result, VirtualMachine) + assert result.name == vm_name + assert result.location == "eastus" + assert result.type == "Microsoft.Compute/virtualMachinesShared" + assert result.properties is not None + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.metadata is not None + assert result.properties.metadata.created_by == "user@example.com" + assert result.properties.metadata.tags == {"environment": "production"} + + +def test_virtual_machines_create_or_update(client): + """Test creating or updating a virtual machine with shared metadata.""" + resource_group_name = "test-rg" + vm_name = "vm-shared1" + + vm_resource = VirtualMachine( + location="eastus", + properties=VirtualMachineProperties( + metadata=SharedMetadata( + created_by="user@example.com", + tags={"environment": "production"}, + ), + ), + ) + + poller = client.virtual_machines.begin_create_or_update( + resource_group_name=resource_group_name, + vm_name=vm_name, + resource=vm_resource, + ) + + result = poller.result() + assert result is not None + assert isinstance(result, VirtualMachine) + assert result.location == "eastus" + assert result.properties is not None + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.metadata is not None + assert result.properties.metadata.created_by == "user@example.com" + assert result.properties.metadata.tags == {"environment": "production"} + + +def test_storage_accounts_get(client): + """Test getting a storage account with shared metadata.""" + resource_group_name = "test-rg" + account_name = "account1" + + result = client.storage_accounts.get(resource_group_name=resource_group_name, account_name=account_name) + + assert result is not None + assert isinstance(result, StorageAccount) + assert result.name == account_name + assert result.location == "westus" + assert result.type == "Microsoft.Storage/storageAccounts" + assert result.properties is not None + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.metadata is not None + assert result.properties.metadata.created_by == "admin@example.com" + assert result.properties.metadata.tags == {"department": "engineering"} + + +def test_storage_accounts_create_or_update(client): + """Test creating or updating a storage account with shared metadata.""" + resource_group_name = "test-rg" + account_name = "account1" + + storage_resource = StorageAccount( + location="westus", + properties=StorageAccountProperties( + metadata=SharedMetadata( + created_by="admin@example.com", + tags={"department": "engineering"}, + ), + ), + ) + + poller = client.storage_accounts.begin_create_or_update( + resource_group_name=resource_group_name, + account_name=account_name, + resource=storage_resource, + ) + + result = poller.result() + assert result is not None + assert isinstance(result, StorageAccount) + assert result.location == "westus" + assert result.properties is not None + assert result.properties.provisioning_state == "Succeeded" + assert result.properties.metadata is not None + assert result.properties.metadata.created_by == "admin@example.com" + assert result.properties.metadata.tags == {"department": "engineering"} diff --git a/packages/typespec-python/test/azure/requirements.txt b/packages/typespec-python/test/azure/requirements.txt index 1933f2e79b2..647a9063488 100644 --- a/packages/typespec-python/test/azure/requirements.txt +++ b/packages/typespec-python/test/azure/requirements.txt @@ -38,6 +38,8 @@ azure-mgmt-core==1.6.0 -e ./generated/azure-resource-manager-resources -e ./generated/azure-resource-manager-method-subscription-id -e ./generated/azure-resource-manager-multi-service +-e ./generated/azure-resource-manager-multi-service-older-versions +-e ./generated/azure-resource-manager-multi-service-shared-models -e ./generated/azure-versioning-previewversion -e ./generated/azure-payload-pageable -e ./generated/client-namespace diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_payload_pageable_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_payload_pageable_async.py index e1ac8a4d655..c14800bb7d6 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_payload_pageable_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_payload_pageable_async.py @@ -113,3 +113,15 @@ async def test_request_header_nested_response_body(client: PageableClient): async def test_list_without_continuation(client: PageableClient): result = [p async for p in client.page_size.list_without_continuation()] assert_result(result) + + +@pytest.mark.asyncio +async def test_xml_pagination_list_with_continuation(client: PageableClient): + result = [p async for p in client.xml_pagination.list_with_continuation()] + assert_result(result) + + +@pytest.mark.asyncio +async def test_xml_pagination_list_with_next_link(client: PageableClient): + result = [p async for p in client.xml_pagination.list_with_next_link()] + assert_result(result) diff --git a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_payload_xml_async.py b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_payload_xml_async.py index 07905890cc3..28693b8c286 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_payload_xml_async.py +++ b/packages/typespec-python/test/generic_mock_api_tests/asynctests/test_payload_xml_async.py @@ -117,3 +117,12 @@ async def test_model_with_encoded_names(client: XmlClient): model = ModelWithEncodedNames(model_data=SimpleModel(name="foo", age=123), colors=["red", "green", "blue"]) assert await client.model_with_encoded_names_value.get() == model await client.model_with_encoded_names_value.put(model) + + +@pytest.mark.asyncio +async def test_xml_error_value(client: XmlClient, core_library): + with pytest.raises(core_library.exceptions.HttpResponseError) as ex: + await client.xml_error_value.get() + assert ex.value.status_code == 400 + assert ex.value.model.message == "Something went wrong" + assert ex.value.model.code == 400 diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_payload_pageable.py b/packages/typespec-python/test/generic_mock_api_tests/test_payload_pageable.py index d07bd3ac047..66cc77022d5 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_payload_pageable.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_payload_pageable.py @@ -81,3 +81,13 @@ def test_request_header_nested_response_body(client: PageableClient): def test_list_without_continuation(client: PageableClient): result = list(client.page_size.list_without_continuation()) assert_result(result) + + +def test_xml_pagination_list_with_continuation(client: PageableClient): + result = list(client.xml_pagination.list_with_continuation()) + assert_result(result) + + +def test_xml_pagination_list_with_next_link(client: PageableClient): + result = list(client.xml_pagination.list_with_next_link()) + assert_result(result) diff --git a/packages/typespec-python/test/generic_mock_api_tests/test_payload_xml.py b/packages/typespec-python/test/generic_mock_api_tests/test_payload_xml.py index 252b6abbd4d..f5e7a2da671 100644 --- a/packages/typespec-python/test/generic_mock_api_tests/test_payload_xml.py +++ b/packages/typespec-python/test/generic_mock_api_tests/test_payload_xml.py @@ -105,3 +105,11 @@ def test_model_with_encoded_names(client: XmlClient): model = ModelWithEncodedNames(model_data=SimpleModel(name="foo", age=123), colors=["red", "green", "blue"]) assert client.model_with_encoded_names_value.get() == model client.model_with_encoded_names_value.put(model) + + +def test_xml_error_value(client: XmlClient, core_library): + with pytest.raises(core_library.exceptions.HttpResponseError) as ex: + client.xml_error_value.get() + assert ex.value.status_code == 400 + assert ex.value.model.message == "Something went wrong" + assert ex.value.model.code == 400 diff --git a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/_client.py b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/_client.py index 0e55edb44e3..dc031a8f67d 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/_client.py +++ b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/_client.py @@ -11,6 +11,7 @@ from ._utils.serialization import Deserializer, Serializer from .pagesize.operations import PageSizeOperations from .serverdrivenpagination.operations import ServerDrivenPaginationOperations +from .xmlpagination.operations import XmlPaginationOperations class PageableClient: # pylint: disable=client-accepts-api-version-keyword @@ -20,6 +21,8 @@ class PageableClient: # pylint: disable=client-accepts-api-version-keyword :vartype server_driven_pagination: payload.pageable.operations.ServerDrivenPaginationOperations :ivar page_size: PageSizeOperations operations :vartype page_size: payload.pageable.operations.PageSizeOperations + :ivar xml_pagination: XmlPaginationOperations operations + :vartype xml_pagination: payload.pageable.operations.XmlPaginationOperations :keyword endpoint: Service host. Default value is "http://localhost:3000". :paramtype endpoint: str """ @@ -50,6 +53,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential self._client, self._config, self._serialize, self._deserialize ) self.page_size = PageSizeOperations(self._client, self._config, self._serialize, self._deserialize) + self.xml_pagination = XmlPaginationOperations(self._client, self._config, self._serialize, self._deserialize) def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/aio/_client.py b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/aio/_client.py index 2e506d18c19..ad05d7bcea2 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/aio/_client.py +++ b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/aio/_client.py @@ -10,6 +10,7 @@ from .._utils.serialization import Deserializer, Serializer from ..pagesize.aio.operations import PageSizeOperations from ..serverdrivenpagination.aio.operations import ServerDrivenPaginationOperations +from ..xmlpagination.aio.operations import XmlPaginationOperations from ._configuration import PageableClientConfiguration @@ -21,6 +22,8 @@ class PageableClient: # pylint: disable=client-accepts-api-version-keyword payload.pageable.aio.operations.ServerDrivenPaginationOperations :ivar page_size: PageSizeOperations operations :vartype page_size: payload.pageable.aio.operations.PageSizeOperations + :ivar xml_pagination: XmlPaginationOperations operations + :vartype xml_pagination: payload.pageable.aio.operations.XmlPaginationOperations :keyword endpoint: Service host. Default value is "http://localhost:3000". :paramtype endpoint: str """ @@ -51,6 +54,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential self._client, self._config, self._serialize, self._deserialize ) self.page_size = PageSizeOperations(self._client, self._config, self._serialize, self._deserialize) + self.xml_pagination = XmlPaginationOperations(self._client, self._config, self._serialize, self._deserialize) def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any diff --git a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/models/__init__.py b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/models/__init__.py index eca9f6d7b8b..86649d779f3 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/models/__init__.py +++ b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/models/__init__.py @@ -9,6 +9,7 @@ from ._models import ( # type: ignore Pet, + XmlPet, ) from ._patch import __all__ as _patch_all from ._patch import * @@ -16,6 +17,7 @@ __all__ = [ "Pet", + "XmlPet", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/models/_models.py b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/models/_models.py index b2b0cc11f1e..3eb89ee9ea3 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/models/_models.py @@ -37,3 +37,44 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) + + +class XmlPet(_Model): + """An XML pet item. + + :ivar id: Required. + :vartype id: str + :ivar name: Required. + :vartype name: str + """ + + id: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Id", "text": False, "unwrapped": False}, + ) + """Required.""" + name: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "Name", "text": False, "unwrapped": False}, + ) + """Required.""" + + _xml = {"attribute": False, "name": "Pet", "text": False, "unwrapped": False} + + @overload + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + name: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) diff --git a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/__init__.py b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/aio/__init__.py b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/aio/__init__.py new file mode 100644 index 00000000000..d55ccad1f57 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/aio/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/aio/operations/__init__.py b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/aio/operations/__init__.py new file mode 100644 index 00000000000..c0046a5fec3 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/aio/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import XmlPaginationOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "XmlPaginationOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/aio/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/aio/operations/_operations.py new file mode 100644 index 00000000000..138b7b05d19 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/aio/operations/_operations.py @@ -0,0 +1,171 @@ +# coding=utf-8 +from collections.abc import MutableMapping +from typing import Any, Callable, Optional, TypeVar +from xml.etree import ElementTree as ET + +from corehttp.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from corehttp.paging import AsyncItemPaged, AsyncList +from corehttp.rest import AsyncHttpResponse, HttpRequest +from corehttp.runtime import AsyncPipelineClient +from corehttp.runtime.pipeline import PipelineResponse + +from .... import models as _models3 +from ...._utils.model_base import _deserialize +from ...._utils.serialization import Deserializer, Serializer +from ....aio._configuration import PageableClientConfiguration +from ...operations._operations import ( + build_xml_pagination_list_with_continuation_request, + build_xml_pagination_list_with_next_link_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]] + + +class XmlPaginationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~payload.pageable.aio.PageableClient`'s + :attr:`xml_pagination` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PageableClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def list_with_continuation(self, **kwargs: Any) -> AsyncItemPaged["_models3.XmlPet"]: + """list_with_continuation. + + :return: An iterator like instance of XmlPet + :rtype: ~corehttp.paging.AsyncItemPaged[~payload.pageable.models.XmlPet] + :raises ~corehttp.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models3.XmlPet]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_xml_pagination_list_with_continuation_request( + marker=_continuation_token, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request + + async def extract_data(pipeline_response): + deserialized = ET.fromstring(pipeline_response.http_response.text()) + list_of_elem = _deserialize(list[_models3.XmlPet], deserialized.find("Pets")) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + _cont_token_elem = deserialized.find("NextMarker") + return _cont_token_elem.text if _cont_token_elem is not None else None, AsyncList(list_of_elem) + + async def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + pipeline_response: PipelineResponse = await self._client.pipeline.run(_request, stream=_stream, **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) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + def list_with_next_link(self, **kwargs: Any) -> AsyncItemPaged["_models3.XmlPet"]: + """list_with_next_link. + + :return: An iterator like instance of XmlPet + :rtype: ~corehttp.paging.AsyncItemPaged[~payload.pageable.models.XmlPet] + :raises ~corehttp.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models3.XmlPet]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_xml_pagination_list_with_next_link_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = ET.fromstring(pipeline_response.http_response.text()) + list_of_elem = _deserialize(list[_models3.XmlPet], deserialized.find("Pets")) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + _cont_token_elem = deserialized.find("NextLink") + return _cont_token_elem.text if _cont_token_elem is not None else None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client.pipeline.run(_request, stream=_stream, **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) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) diff --git a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/aio/operations/_patch.py b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/aio/operations/_patch.py new file mode 100644 index 00000000000..bbe39eaf695 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/aio/operations/_patch.py @@ -0,0 +1,18 @@ +# coding=utf-8 + +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/operations/__init__.py b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/operations/__init__.py new file mode 100644 index 00000000000..c0046a5fec3 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# pylint: disable=wrong-import-position + +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from ._patch import * # pylint: disable=unused-wildcard-import + +from ._operations import XmlPaginationOperations # type: ignore + +from ._patch import __all__ as _patch_all +from ._patch import * +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "XmlPaginationOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore +_patch_sdk() diff --git a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/operations/_operations.py new file mode 100644 index 00000000000..06b715ffb31 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/operations/_operations.py @@ -0,0 +1,206 @@ +# coding=utf-8 +from collections.abc import MutableMapping +from typing import Any, Callable, Optional, TypeVar +from xml.etree import ElementTree as ET + +from corehttp.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from corehttp.paging import ItemPaged +from corehttp.rest import HttpRequest, HttpResponse +from corehttp.runtime import PipelineClient +from corehttp.runtime.pipeline import PipelineResponse +from corehttp.utils import case_insensitive_dict + +from ... import models as _models2 +from ..._configuration import PageableClientConfiguration +from ..._utils.model_base import _deserialize +from ..._utils.serialization import Deserializer, Serializer + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_xml_pagination_list_with_continuation_request( # pylint: disable=name-too-long + *, marker: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + accept = _headers.pop("Accept", "application/xml") + + # Construct URL + _url = "/payload/pageable/xml/list-with-continuation" + + # Construct parameters + if marker is not None: + _params["marker"] = _SERIALIZER.query("marker", marker, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_xml_pagination_list_with_next_link_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/xml") + + # Construct URL + _url = "/payload/pageable/xml/list-with-next-link" + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + +class XmlPaginationOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~payload.pageable.PageableClient`'s + :attr:`xml_pagination` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: PageableClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def list_with_continuation(self, **kwargs: Any) -> ItemPaged["_models2.XmlPet"]: + """list_with_continuation. + + :return: An iterator like instance of XmlPet + :rtype: ~corehttp.paging.ItemPaged[~payload.pageable.models.XmlPet] + :raises ~corehttp.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models2.XmlPet]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_xml_pagination_list_with_continuation_request( + marker=_continuation_token, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request + + def extract_data(pipeline_response): + deserialized = ET.fromstring(pipeline_response.http_response.text()) + list_of_elem = _deserialize(list[_models2.XmlPet], deserialized.find("Pets")) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + _cont_token_elem = deserialized.find("NextMarker") + return _cont_token_elem.text if _cont_token_elem is not None else None, iter(list_of_elem) + + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + pipeline_response: PipelineResponse = self._client.pipeline.run(_request, stream=_stream, **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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + def list_with_next_link(self, **kwargs: Any) -> ItemPaged["_models2.XmlPet"]: + """list_with_next_link. + + :return: An iterator like instance of XmlPet + :rtype: ~corehttp.paging.ItemPaged[~payload.pageable.models.XmlPet] + :raises ~corehttp.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[list[_models2.XmlPet]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_xml_pagination_list_with_next_link_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + _request = HttpRequest("GET", next_link) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = ET.fromstring(pipeline_response.http_response.text()) + list_of_elem = _deserialize(list[_models2.XmlPet], deserialized.find("Pets")) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + _cont_token_elem = deserialized.find("NextLink") + return _cont_token_elem.text if _cont_token_elem is not None else None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client.pipeline.run(_request, stream=_stream, **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) + + return pipeline_response + + return ItemPaged(get_next, extract_data) diff --git a/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/operations/_patch.py b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/operations/_patch.py new file mode 100644 index 00000000000..bbe39eaf695 --- /dev/null +++ b/packages/typespec-python/test/unbranded/generated/payload-pageable/payload/pageable/xmlpagination/operations/_patch.py @@ -0,0 +1,18 @@ +# coding=utf-8 + +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + + +__all__: list[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/_client.py b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/_client.py index dad2e5c4554..ece3ab737e6 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/_client.py +++ b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/_client.py @@ -22,6 +22,7 @@ ModelWithTextValueOperations, ModelWithUnwrappedArrayValueOperations, SimpleModelValueOperations, + XmlErrorValueOperations, ) @@ -60,6 +61,8 @@ class XmlClient: # pylint: disable=client-accepts-api-version-keyword,too-many- :ivar model_with_encoded_names_value: ModelWithEncodedNamesValueOperations operations :vartype model_with_encoded_names_value: payload.xml.operations.ModelWithEncodedNamesValueOperations + :ivar xml_error_value: XmlErrorValueOperations operations + :vartype xml_error_value: payload.xml.operations.XmlErrorValueOperations :keyword endpoint: Service host. Default value is "http://localhost:3000". :paramtype endpoint: str """ @@ -122,6 +125,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential self.model_with_encoded_names_value = ModelWithEncodedNamesValueOperations( self._client, self._config, self._serialize, self._deserialize ) + self.xml_error_value = XmlErrorValueOperations(self._client, self._config, self._serialize, self._deserialize) def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/aio/_client.py b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/aio/_client.py index f0707b94024..e43bbbac610 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/aio/_client.py +++ b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/aio/_client.py @@ -22,6 +22,7 @@ ModelWithTextValueOperations, ModelWithUnwrappedArrayValueOperations, SimpleModelValueOperations, + XmlErrorValueOperations, ) @@ -62,6 +63,8 @@ class XmlClient: # pylint: disable=client-accepts-api-version-keyword,too-many- :ivar model_with_encoded_names_value: ModelWithEncodedNamesValueOperations operations :vartype model_with_encoded_names_value: payload.xml.aio.operations.ModelWithEncodedNamesValueOperations + :ivar xml_error_value: XmlErrorValueOperations operations + :vartype xml_error_value: payload.xml.aio.operations.XmlErrorValueOperations :keyword endpoint: Service host. Default value is "http://localhost:3000". :paramtype endpoint: str """ @@ -124,6 +127,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential self.model_with_encoded_names_value = ModelWithEncodedNamesValueOperations( self._client, self._config, self._serialize, self._deserialize ) + self.xml_error_value = XmlErrorValueOperations(self._client, self._config, self._serialize, self._deserialize) def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any diff --git a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/aio/operations/__init__.py b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/aio/operations/__init__.py index d8583cd48b3..16e69dfebe4 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/aio/operations/__init__.py +++ b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/aio/operations/__init__.py @@ -18,6 +18,7 @@ from ._operations import ModelWithTextValueOperations # type: ignore from ._operations import ModelWithDictionaryValueOperations # type: ignore from ._operations import ModelWithEncodedNamesValueOperations # type: ignore +from ._operations import XmlErrorValueOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * @@ -36,6 +37,7 @@ "ModelWithTextValueOperations", "ModelWithDictionaryValueOperations", "ModelWithEncodedNamesValueOperations", + "XmlErrorValueOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/aio/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/aio/operations/_operations.py index 61bfe211c78..52f2d0b6b17 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/aio/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/aio/operations/_operations.py @@ -19,7 +19,7 @@ from corehttp.utils import case_insensitive_dict from ... import models as _models -from ..._utils.model_base import _deserialize_xml, _get_element +from ..._utils.model_base import _deserialize_xml, _failsafe_deserialize_xml, _get_element from ..._utils.serialization import Deserializer, Serializer from ...operations._operations import ( build_model_with_array_of_model_value_get_request, @@ -46,6 +46,7 @@ build_model_with_unwrapped_array_value_put_request, build_simple_model_value_get_request, build_simple_model_value_put_request, + build_xml_error_value_get_request, ) from .._configuration import XmlClientConfiguration @@ -1515,3 +1516,80 @@ async def put(self, input: _models.ModelWithEncodedNames, **kwargs: Any) -> None if cls: return cls(pipeline_response, None, {}) # type: ignore + + +class XmlErrorValueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~payload.xml.aio.XmlClient`'s + :attr:`xml_error_value` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: XmlClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def get(self, **kwargs: Any) -> _models.SimpleModel: + """get. + + :return: SimpleModel. The SimpleModel is compatible with MutableMapping + :rtype: ~payload.xml.models.SimpleModel + :raises ~corehttp.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SimpleModel] = kwargs.pop("cls", None) + + _request = build_xml_error_value_get_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client.pipeline.run(_request, stream=_stream, **kwargs) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + 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 = None + if response.status_code == 400: + error = _failsafe_deserialize_xml(_models.XmlErrorBody, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize_xml(_models.SimpleModel, response.text()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/__init__.py b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/__init__.py index e89a33c7aac..8b46708868b 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/__init__.py +++ b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/__init__.py @@ -20,6 +20,7 @@ ModelWithText, ModelWithUnwrappedArray, SimpleModel, + XmlErrorBody, ) from ._patch import __all__ as _patch_all from ._patch import * @@ -38,6 +39,7 @@ "ModelWithText", "ModelWithUnwrappedArray", "SimpleModel", + "XmlErrorBody", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/_models.py b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/_models.py index 27b1dcb9156..75505ef7ce1 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/_models.py +++ b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/models/_models.py @@ -490,3 +490,44 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) + + +class XmlErrorBody(_Model): + """The body of an XML error response. + + :ivar message: Required. + :vartype message: str + :ivar code: Required. + :vartype code: int + """ + + message: str = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "message", "text": False, "unwrapped": False}, + ) + """Required.""" + code: int = rest_field( + visibility=["read", "create", "update", "delete", "query"], + xml={"attribute": False, "name": "code", "text": False, "unwrapped": False}, + ) + """Required.""" + + _xml = {"attribute": False, "name": "XmlErrorBody", "text": False, "unwrapped": False} + + @overload + def __init__( + self, + *, + message: str, + code: int, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) diff --git a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/operations/__init__.py b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/operations/__init__.py index d8583cd48b3..16e69dfebe4 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/operations/__init__.py +++ b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/operations/__init__.py @@ -18,6 +18,7 @@ from ._operations import ModelWithTextValueOperations # type: ignore from ._operations import ModelWithDictionaryValueOperations # type: ignore from ._operations import ModelWithEncodedNamesValueOperations # type: ignore +from ._operations import XmlErrorValueOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * @@ -36,6 +37,7 @@ "ModelWithTextValueOperations", "ModelWithDictionaryValueOperations", "ModelWithEncodedNamesValueOperations", + "XmlErrorValueOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() diff --git a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/operations/_operations.py b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/operations/_operations.py index 8eebb3c707b..6216b749ad2 100644 --- a/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/operations/_operations.py +++ b/packages/typespec-python/test/unbranded/generated/payload-xml/payload/xml/operations/_operations.py @@ -20,7 +20,7 @@ from .. import models as _models from .._configuration import XmlClientConfiguration -from .._utils.model_base import _deserialize_xml, _get_element +from .._utils.model_base import _deserialize_xml, _failsafe_deserialize_xml, _get_element from .._utils.serialization import Deserializer, Serializer T = TypeVar("T") @@ -354,6 +354,20 @@ def build_model_with_encoded_names_value_put_request(**kwargs: Any) -> HttpReque return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) +def build_xml_error_value_get_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + accept = _headers.pop("Accept", "application/xml") + + # Construct URL + _url = "/payload/xml/error" + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, headers=_headers, **kwargs) + + class SimpleModelValueOperations: """ .. warning:: @@ -1838,3 +1852,80 @@ def put( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore + + +class XmlErrorValueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~payload.xml.XmlClient`'s + :attr:`xml_error_value` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: XmlClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def get(self, **kwargs: Any) -> _models.SimpleModel: + """get. + + :return: SimpleModel. The SimpleModel is compatible with MutableMapping + :rtype: ~payload.xml.models.SimpleModel + :raises ~corehttp.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.SimpleModel] = kwargs.pop("cls", None) + + _request = build_xml_error_value_get_request( + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client.pipeline.run(_request, stream=_stream, **kwargs) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + 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 = None + if response.status_code == 400: + error = _failsafe_deserialize_xml(_models.XmlErrorBody, response) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize_xml(_models.SimpleModel, response.text()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 240a9aae3f5..4749a5bc2c7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -60,8 +60,8 @@ importers: specifier: ~1.0.2 version: 1.0.2 '@typespec/http-client-python': - specifier: ~0.26.3 - version: 0.26.3(pyd672ib3v6bthqtwhqpae7pk4) + specifier: 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 + version: 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(pyd672ib3v6bthqtwhqpae7pk4) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -82,8 +82,8 @@ importers: packages/typespec-python: dependencies: '@typespec/http-client-python': - specifier: ~0.26.3 - version: 0.26.3(pyd672ib3v6bthqtwhqpae7pk4) + specifier: 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 + version: 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(pyd672ib3v6bthqtwhqpae7pk4) fs-extra: specifier: ~11.2.0 version: 11.2.0 @@ -98,8 +98,8 @@ importers: version: 4.19.3 devDependencies: '@azure-tools/azure-http-specs': - specifier: 0.1.0-alpha.36 - version: 0.1.0-alpha.36(76dotbmzpfj2ua2zbinupv72ei) + specifier: 0.1.0-alpha.37-dev.1 + version: 0.1.0-alpha.37-dev.1(76dotbmzpfj2ua2zbinupv72ei) '@azure-tools/typespec-autorest': specifier: ~0.64.1 version: 0.64.1(jzo7kuo6fjo5kkcajadlzhggh4) @@ -140,8 +140,8 @@ importers: specifier: ^1.8.0 version: 1.8.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0))) '@typespec/http-specs': - specifier: 0.1.0-alpha.32-dev.1 - version: 0.1.0-alpha.32-dev.1(@types/node@24.1.0)(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/http@1.8.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0))))(@typespec/rest@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/http@1.8.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0)))))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0)))(@typespec/versioning@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0)))(@typespec/xml@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0))) + specifier: 0.1.0-alpha.32-dev.5 + version: 0.1.0-alpha.32-dev.5(@types/node@24.1.0)(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/http@1.8.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0))))(@typespec/rest@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/http@1.8.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0)))))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0)))(@typespec/versioning@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0)))(@typespec/xml@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0))) '@typespec/openapi': specifier: ^1.8.0 version: 1.8.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/http@1.8.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0)))) @@ -209,16 +209,16 @@ packages: resolution: {integrity: sha512-T21naRb6JDdjjn2s/zwr9iCIv/9jviL/PRtiWAhi+3UA2WKH2wrId2VqJa4uVD7iEV8BLkuGgFmMkaMBG26hFw==} engines: {node: '>=12.0.0'} - '@azure-tools/azure-http-specs@0.1.0-alpha.36': - resolution: {integrity: sha512-tn6qiiTA+ToLmOqj4CSJNAbeuSUj6hIRiXzDhR8b7jilFLnXQ2MYKnJNnjL2O/CDd0utWUqg/2kNlQitSLnxmA==} + '@azure-tools/azure-http-specs@0.1.0-alpha.37-dev.1': + resolution: {integrity: sha512-lGu4bBoN8ghpHWUwRJK2auHcY+AUpPkcVbD18Z06FBi66vR8m7e0dczOl40YpUKUlbjlGjZon9QT2iSp9hKoWA==} engines: {node: '>=20.0.0'} peerDependencies: - '@azure-tools/typespec-azure-core': ^0.64.0 + '@azure-tools/typespec-azure-core': ^0.64.0 || >=0.65.0-dev <0.65.0 '@typespec/compiler': ^1.8.0 '@typespec/http': ^1.8.0 - '@typespec/rest': ^0.78.0 - '@typespec/versioning': ^0.78.0 - '@typespec/xml': ^0.78.0 + '@typespec/rest': ^0.78.0 || >=0.79.0-dev <0.79.0 + '@typespec/versioning': ^0.78.0 || >=0.79.0-dev <0.79.0 + '@typespec/xml': ^0.78.0 || >=0.79.0-dev <0.79.0 '@azure-tools/typespec-autorest@0.64.1': resolution: {integrity: sha512-WzSRiX0XS7hCL+uiivLBYMbirEUenxNzPT4giF0J+r54CVNXq/u8PLnA/06F5EHkXPa92swF4BxB1vFWB2TKow==} @@ -1740,8 +1740,9 @@ packages: peerDependencies: '@typespec/compiler': ^1.8.0 - '@typespec/http-client-python@0.26.3': - resolution: {integrity: sha512-LKBi+giSTDbIc1UoAr1+8zGomhes9z68GyIGjxpuN+BxLbdFAUJurDFyDILSJw9rcS8WgYXnVXhHxmP33mqjvw==} + '@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': + resolution: {tarball: 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} + version: 0.26.3 engines: {node: '>=20.0.0'} peerDependencies: '@azure-tools/typespec-autorest': '>=0.64.1 <1.0.0' @@ -1759,8 +1760,8 @@ packages: '@typespec/versioning': '>=0.78.0 <1.0.0' '@typespec/xml': '>=0.78.0 <1.0.0' - '@typespec/http-specs@0.1.0-alpha.32-dev.1': - resolution: {integrity: sha512-b+uzFhToERrmV154eqnCoQiw4Jekn+DRamfZVAl7ndVeayDq9zLNZyPnCmeU1+bdKxUGO8WoGkpA9BeGP3teeA==} + '@typespec/http-specs@0.1.0-alpha.32-dev.5': + resolution: {integrity: sha512-MD1nWHuste79REtadDyPGTTAZwgGCGD/kB9K8zNX2nTTbAMiWzUTBhpztZtQ+A08G3Snn1ZwSFy4OTyYkHCg6g==} engines: {node: '>=16.0.0'} peerDependencies: '@typespec/compiler': ^1.8.0 @@ -4995,7 +4996,7 @@ snapshots: command-exists: 1.2.9 semver: 7.6.3 - '@azure-tools/azure-http-specs@0.1.0-alpha.36(76dotbmzpfj2ua2zbinupv72ei)': + '@azure-tools/azure-http-specs@0.1.0-alpha.37-dev.1(76dotbmzpfj2ua2zbinupv72ei)': dependencies: '@azure-tools/typespec-azure-core': 0.64.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/http@1.8.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0))))(@typespec/rest@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/http@1.8.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0))))) '@typespec/compiler': 1.8.0(@types/node@24.1.0) @@ -6643,7 +6644,7 @@ snapshots: dependencies: '@typespec/compiler': 1.8.0(@types/node@24.1.0) - '@typespec/http-client-python@0.26.3(pyd672ib3v6bthqtwhqpae7pk4)': + '@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(pyd672ib3v6bthqtwhqpae7pk4)': dependencies: '@azure-tools/typespec-autorest': 0.64.1(jzo7kuo6fjo5kkcajadlzhggh4) '@azure-tools/typespec-azure-core': 0.64.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/http@1.8.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0))))(@typespec/rest@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/http@1.8.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0))))) @@ -6668,7 +6669,7 @@ snapshots: - bufferutil - utf-8-validate - '@typespec/http-specs@0.1.0-alpha.32-dev.1(@types/node@24.1.0)(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/http@1.8.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0))))(@typespec/rest@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/http@1.8.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0)))))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0)))(@typespec/versioning@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0)))(@typespec/xml@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0)))': + '@typespec/http-specs@0.1.0-alpha.32-dev.5(@types/node@24.1.0)(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/http@1.8.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0))))(@typespec/rest@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/http@1.8.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0)))))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0)))(@typespec/versioning@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0)))(@typespec/xml@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0)))': dependencies: '@typespec/compiler': 1.8.0(@types/node@24.1.0) '@typespec/http': 1.8.0(@typespec/compiler@1.8.0(@types/node@24.1.0))(@typespec/streams@0.78.0(@typespec/compiler@1.8.0(@types/node@24.1.0)))