diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/_meta.json b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/_meta.json index 87aaa163f434..bfdde1e922c1 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/_meta.json +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/_meta.json @@ -1,11 +1,11 @@ { - "commit": "43f10d3b8bacd5fc6b01254b5050c613f26c3573", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "commit": "c29452397f8d29456182b951987a765d1ae01bb1", + "repository_url": "https://github.com/test-repo-billy/azure-rest-api-specs", "autorest": "3.10.2", "use": [ - "@autorest/python@6.13.19", + "@autorest/python@6.19.0", "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/appcomplianceautomation/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.13.19 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "autorest_command": "autorest specification/appcomplianceautomation/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.19.0 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/appcomplianceautomation/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/_app_compliance_automation_mgmt_client.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/_app_compliance_automation_mgmt_client.py index bc62f5383303..2687e8b21d3b 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/_app_compliance_automation_mgmt_client.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/_app_compliance_automation_mgmt_client.py @@ -8,6 +8,7 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse @@ -127,7 +128,7 @@ def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: def close(self) -> None: self._client.close() - def __enter__(self) -> "AppComplianceAutomationMgmtClient": + def __enter__(self) -> Self: self._client.__enter__() return self diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/_serialization.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/_serialization.py index f0c6180722c8..8139854b97bb 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/_serialization.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/_serialization.py @@ -144,6 +144,8 @@ def _json_attemp(data): # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") raise DeserializationError("XML is invalid") from err + elif content_type.startswith("text/"): + return data_as_str raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/_vendor.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/_vendor.py deleted file mode 100644 index 0dafe0e287ff..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/_vendor.py +++ /dev/null @@ -1,16 +0,0 @@ -# -------------------------------------------------------------------------- -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.pipeline.transport import HttpRequest - - -def _convert_request(request, files=None): - data = request.content if not files else None - request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) - if files: - request.set_formdata_body(files) - return request diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/_version.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/_version.py index c47f66669f1b..e5754a47ce68 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/_version.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/_app_compliance_automation_mgmt_client.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/_app_compliance_automation_mgmt_client.py index a98996476101..3cd900f21574 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/_app_compliance_automation_mgmt_client.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/_app_compliance_automation_mgmt_client.py @@ -8,6 +8,7 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from typing_extensions import Self from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest @@ -129,7 +130,7 @@ def _send_request( async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "AppComplianceAutomationMgmtClient": + async def __aenter__(self) -> Self: await self._client.__aenter__() return self diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_evidence_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_evidence_operations.py index 1d24d65e6fd3..9ea4c051dd2a 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_evidence_operations.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_evidence_operations.py @@ -21,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._evidence_operations import ( build_create_or_update_request, build_delete_request, @@ -132,7 +130,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -148,7 +145,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -211,7 +207,6 @@ async def get(self, report_name: str, evidence_name: str, **kwargs: Any) -> _mod headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -226,7 +221,7 @@ async def get(self, report_name: str, evidence_name: str, **kwargs: Any) -> _mod error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("EvidenceResource", pipeline_response) + deserialized = self._deserialize("EvidenceResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -238,7 +233,7 @@ async def create_or_update( self, report_name: str, evidence_name: str, - properties: _models.EvidenceResource, + resource: _models.EvidenceResource, offer_guid: Optional[str] = None, report_creator_tenant_id: Optional[str] = None, *, @@ -251,8 +246,8 @@ async def create_or_update( :type report_name: str :param evidence_name: The evidence name. Required. :type evidence_name: str - :param properties: Parameters for the create or update operation. Required. - :type properties: ~azure.mgmt.appcomplianceautomation.models.EvidenceResource + :param resource: Parameters for the create or update operation. Required. + :type resource: ~azure.mgmt.appcomplianceautomation.models.EvidenceResource :param offer_guid: The offerGuid which mapping to the reports. Default value is None. :type offer_guid: str :param report_creator_tenant_id: The tenant id of the report creator. Default value is None. @@ -270,7 +265,7 @@ async def create_or_update( self, report_name: str, evidence_name: str, - properties: IO[bytes], + resource: IO[bytes], offer_guid: Optional[str] = None, report_creator_tenant_id: Optional[str] = None, *, @@ -283,8 +278,8 @@ async def create_or_update( :type report_name: str :param evidence_name: The evidence name. Required. :type evidence_name: str - :param properties: Parameters for the create or update operation. Required. - :type properties: IO[bytes] + :param resource: Parameters for the create or update operation. Required. + :type resource: IO[bytes] :param offer_guid: The offerGuid which mapping to the reports. Default value is None. :type offer_guid: str :param report_creator_tenant_id: The tenant id of the report creator. Default value is None. @@ -302,7 +297,7 @@ async def create_or_update( self, report_name: str, evidence_name: str, - properties: Union[_models.EvidenceResource, IO[bytes]], + resource: Union[_models.EvidenceResource, IO[bytes]], offer_guid: Optional[str] = None, report_creator_tenant_id: Optional[str] = None, **kwargs: Any @@ -313,9 +308,9 @@ async def create_or_update( :type report_name: str :param evidence_name: The evidence name. Required. :type evidence_name: str - :param properties: Parameters for the create or update operation. Is either a EvidenceResource + :param resource: Parameters for the create or update operation. Is either a EvidenceResource type or a IO[bytes] type. Required. - :type properties: ~azure.mgmt.appcomplianceautomation.models.EvidenceResource or IO[bytes] + :type resource: ~azure.mgmt.appcomplianceautomation.models.EvidenceResource or IO[bytes] :param offer_guid: The offerGuid which mapping to the reports. Default value is None. :type offer_guid: str :param report_creator_tenant_id: The tenant id of the report creator. Default value is None. @@ -342,10 +337,10 @@ async def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties + if isinstance(resource, (IOBase, bytes)): + _content = resource else: - _json = self._serialize.body(properties, "EvidenceResource") + _json = self._serialize.body(resource, "EvidenceResource") _request = build_create_or_update_request( report_name=report_name, @@ -359,7 +354,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -374,11 +368,7 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("EvidenceResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("EvidenceResource", pipeline_response) + deserialized = self._deserialize("EvidenceResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -420,7 +410,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -544,7 +533,6 @@ async def download( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -559,7 +547,7 @@ async def download( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("EvidenceFileDownloadResponse", pipeline_response) + deserialized = self._deserialize("EvidenceFileDownloadResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_operations.py index 51d11b449cdc..c67289d21b28 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_operations.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_operations.py @@ -20,14 +20,12 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._operations import build_list_request if sys.version_info >= (3, 9): @@ -88,7 +86,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -104,7 +101,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_provider_actions_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_provider_actions_operations.py index 44c7536572ae..c7ac3bb714fe 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_provider_actions_operations.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_provider_actions_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,19 +16,19 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._provider_actions_operations import ( build_check_name_availability_request, build_get_collection_count_request, @@ -142,7 +142,6 @@ async def check_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -157,7 +156,7 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityResponse", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -240,7 +239,6 @@ async def get_collection_count( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -255,7 +253,7 @@ async def get_collection_count( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GetCollectionCountResponse", pipeline_response) + deserialized = self._deserialize("GetCollectionCountResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -338,7 +336,6 @@ async def get_overview_status( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -353,7 +350,7 @@ async def get_overview_status( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GetOverviewStatusResponse", pipeline_response) + deserialized = self._deserialize("GetOverviewStatusResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -437,7 +434,6 @@ async def list_in_use_storage_accounts( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -452,7 +448,7 @@ async def list_in_use_storage_accounts( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ListInUseStorageAccountsResponse", pipeline_response) + deserialized = self._deserialize("ListInUseStorageAccountsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -461,7 +457,7 @@ async def list_in_use_storage_accounts( async def _onboard_initial( self, body: Union[_models.OnboardRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OnboardResponse]: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -475,7 +471,7 @@ async def _onboard_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.OnboardResponse]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -493,10 +489,10 @@ async def _onboard_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -504,19 +500,21 @@ async def _onboard_initial( 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("OnboardResponse", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -592,10 +590,11 @@ async def begin_onboard( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OnboardResponse", pipeline_response) + deserialized = self._deserialize("OnboardResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -621,7 +620,7 @@ def get_long_running_output(pipeline_response): async def _trigger_evaluation_initial( self, body: Union[_models.TriggerEvaluationRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.TriggerEvaluationResponse]: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -635,7 +634,7 @@ async def _trigger_evaluation_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TriggerEvaluationResponse]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -653,10 +652,10 @@ async def _trigger_evaluation_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -664,19 +663,21 @@ async def _trigger_evaluation_initial( 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TriggerEvaluationResponse", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -752,10 +753,11 @@ async def begin_trigger_evaluation( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TriggerEvaluationResponse", pipeline_response) + deserialized = self._deserialize("TriggerEvaluationResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_report_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_report_operations.py index bb2971ed2658..b530661ea65b 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_report_operations.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_report_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._report_operations import ( build_create_or_update_request, build_delete_request, @@ -135,7 +135,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -151,7 +150,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -211,7 +209,6 @@ async def get(self, report_name: str, **kwargs: Any) -> _models.ReportResource: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -226,7 +223,7 @@ async def get(self, report_name: str, **kwargs: Any) -> _models.ReportResource: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ReportResource", pipeline_response) + deserialized = self._deserialize("ReportResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -234,8 +231,8 @@ async def get(self, report_name: str, **kwargs: Any) -> _models.ReportResource: return deserialized # type: ignore async def _create_or_update_initial( - self, report_name: str, properties: Union[_models.ReportResource, IO[bytes]], **kwargs: Any - ) -> _models.ReportResource: + self, report_name: str, resource: Union[_models.ReportResource, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -249,15 +246,15 @@ async def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ReportResource] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties + if isinstance(resource, (IOBase, bytes)): + _content = resource else: - _json = self._serialize.body(properties, "ReportResource") + _json = self._serialize.body(resource, "ReportResource") _request = build_create_or_update_request( report_name=report_name, @@ -268,10 +265,10 @@ async def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -279,18 +276,19 @@ async def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ReportResource", pipeline_response) - if response.status_code == 201: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("ReportResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -301,7 +299,7 @@ async def _create_or_update_initial( async def begin_create_or_update( self, report_name: str, - properties: _models.ReportResource, + resource: _models.ReportResource, *, content_type: str = "application/json", **kwargs: Any @@ -311,8 +309,8 @@ async def begin_create_or_update( :param report_name: Report Name. Required. :type report_name: str - :param properties: Parameters for the create or update operation. Required. - :type properties: ~azure.mgmt.appcomplianceautomation.models.ReportResource + :param resource: Parameters for the create or update operation. Required. + :type resource: ~azure.mgmt.appcomplianceautomation.models.ReportResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -325,15 +323,15 @@ async def begin_create_or_update( @overload async def begin_create_or_update( - self, report_name: str, properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + self, report_name: str, resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.ReportResource]: """Create a new AppComplianceAutomation report or update an exiting AppComplianceAutomation report. :param report_name: Report Name. Required. :type report_name: str - :param properties: Parameters for the create or update operation. Required. - :type properties: IO[bytes] + :param resource: Parameters for the create or update operation. Required. + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -346,16 +344,16 @@ async def begin_create_or_update( @distributed_trace_async async def begin_create_or_update( - self, report_name: str, properties: Union[_models.ReportResource, IO[bytes]], **kwargs: Any + self, report_name: str, resource: Union[_models.ReportResource, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ReportResource]: """Create a new AppComplianceAutomation report or update an exiting AppComplianceAutomation report. :param report_name: Report Name. Required. :type report_name: str - :param properties: Parameters for the create or update operation. Is either a ReportResource - type or a IO[bytes] type. Required. - :type properties: ~azure.mgmt.appcomplianceautomation.models.ReportResource or IO[bytes] + :param resource: Parameters for the create or update operation. Is either a ReportResource type + or a IO[bytes] type. Required. + :type resource: ~azure.mgmt.appcomplianceautomation.models.ReportResource or IO[bytes] :return: An instance of AsyncLROPoller that returns either ReportResource or the result of cls(response) :rtype: @@ -374,7 +372,7 @@ async def begin_create_or_update( if cont_token is None: raw_result = await self._create_or_update_initial( report_name=report_name, - properties=properties, + resource=resource, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -382,10 +380,11 @@ async def begin_create_or_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ReportResource", pipeline_response) + deserialized = self._deserialize("ReportResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -412,7 +411,7 @@ def get_long_running_output(pipeline_response): async def _update_initial( self, report_name: str, properties: Union[_models.ReportResourcePatch, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ReportResource]: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -426,7 +425,7 @@ async def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ReportResource]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -445,10 +444,10 @@ async def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -456,19 +455,21 @@ async def _update_initial( 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ReportResource", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -556,10 +557,11 @@ async def begin_update( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ReportResource", pipeline_response) + deserialized = self._deserialize("ReportResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -583,9 +585,7 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, report_name: str, **kwargs: Any - ) -> None: + async def _delete_initial(self, report_name: str, **kwargs: Any) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -598,7 +598,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( report_name=report_name, @@ -606,10 +606,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -617,6 +617,10 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202, 204]: + 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -626,8 +630,12 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async async def begin_delete(self, report_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -648,7 +656,7 @@ async def begin_delete(self, report_name: str, **kwargs: Any) -> AsyncLROPoller[ 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._delete_initial( # type: ignore + raw_result = await self._delete_initial( report_name=report_name, api_version=api_version, cls=lambda x, y, z: x, @@ -656,6 +664,7 @@ async def begin_delete(self, report_name: str, **kwargs: Any) -> AsyncLROPoller[ params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -768,7 +777,6 @@ async def nested_resource_check_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -783,14 +791,14 @@ async def nested_resource_check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityResponse", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _fix_initial(self, report_name: str, **kwargs: Any) -> Optional[_models.ReportFixResult]: + async def _fix_initial(self, report_name: str, **kwargs: Any) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -803,7 +811,7 @@ async def _fix_initial(self, report_name: str, **kwargs: Any) -> Optional[_model _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.ReportFixResult]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_fix_request( report_name=report_name, @@ -811,10 +819,10 @@ async def _fix_initial(self, report_name: str, **kwargs: Any) -> Optional[_model headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -822,19 +830,21 @@ async def _fix_initial(self, report_name: str, **kwargs: Any) -> Optional[_model 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ReportFixResult", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -870,10 +880,11 @@ async def begin_fix(self, report_name: str, **kwargs: Any) -> AsyncLROPoller[_mo params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ReportFixResult", pipeline_response) + deserialized = self._deserialize("ReportFixResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -928,7 +939,6 @@ async def get_scoping_questions(self, report_name: str, **kwargs: Any) -> _model headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -943,7 +953,7 @@ async def get_scoping_questions(self, report_name: str, **kwargs: Any) -> _model error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ScopingQuestions", pipeline_response) + deserialized = self._deserialize("ScopingQuestions", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -952,7 +962,7 @@ async def get_scoping_questions(self, report_name: str, **kwargs: Any) -> _model async def _sync_cert_record_initial( self, report_name: str, body: Union[_models.SyncCertRecordRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.SyncCertRecordResponse]: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -966,7 +976,7 @@ async def _sync_cert_record_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.SyncCertRecordResponse]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -985,10 +995,10 @@ async def _sync_cert_record_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -996,19 +1006,21 @@ async def _sync_cert_record_initial( 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SyncCertRecordResponse", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1096,10 +1108,11 @@ async def begin_sync_cert_record( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SyncCertRecordResponse", pipeline_response) + deserialized = self._deserialize("SyncCertRecordResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1123,7 +1136,7 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - async def _verify_initial(self, report_name: str, **kwargs: Any) -> Optional[_models.ReportVerificationResult]: + async def _verify_initial(self, report_name: str, **kwargs: Any) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1136,7 +1149,7 @@ async def _verify_initial(self, report_name: str, **kwargs: Any) -> Optional[_mo _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.ReportVerificationResult]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) _request = build_verify_request( report_name=report_name, @@ -1144,10 +1157,10 @@ async def _verify_initial(self, report_name: str, **kwargs: Any) -> Optional[_mo headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1155,19 +1168,21 @@ async def _verify_initial(self, report_name: str, **kwargs: Any) -> Optional[_mo 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ReportVerificationResult", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1202,10 +1217,11 @@ async def begin_verify(self, report_name: str, **kwargs: Any) -> AsyncLROPoller[ params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ReportVerificationResult", pipeline_response) + deserialized = self._deserialize("ReportVerificationResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_scoping_configuration_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_scoping_configuration_operations.py index 38eae06feabb..2fc37dddd249 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_scoping_configuration_operations.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_scoping_configuration_operations.py @@ -21,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._scoping_configuration_operations import ( build_create_or_update_request, build_delete_request, @@ -99,7 +97,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -115,7 +112,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -180,7 +176,6 @@ async def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -195,7 +190,7 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ScopingConfigurationResource", pipeline_response) + deserialized = self._deserialize("ScopingConfigurationResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -207,7 +202,7 @@ async def create_or_update( self, report_name: str, scoping_configuration_name: str, - properties: _models.ScopingConfigurationResource, + resource: _models.ScopingConfigurationResource, *, content_type: str = "application/json", **kwargs: Any @@ -218,9 +213,9 @@ async def create_or_update( :type report_name: str :param scoping_configuration_name: The scoping configuration of the specific report. Required. :type scoping_configuration_name: str - :param properties: Parameters for the create or update operation, this is a singleton resource, + :param resource: Parameters for the create or update operation, this is a singleton resource, so please make sure you're using 'default' as the name. Required. - :type properties: ~azure.mgmt.appcomplianceautomation.models.ScopingConfigurationResource + :type resource: ~azure.mgmt.appcomplianceautomation.models.ScopingConfigurationResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -234,7 +229,7 @@ async def create_or_update( self, report_name: str, scoping_configuration_name: str, - properties: IO[bytes], + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -245,9 +240,9 @@ async def create_or_update( :type report_name: str :param scoping_configuration_name: The scoping configuration of the specific report. Required. :type scoping_configuration_name: str - :param properties: Parameters for the create or update operation, this is a singleton resource, + :param resource: Parameters for the create or update operation, this is a singleton resource, so please make sure you're using 'default' as the name. Required. - :type properties: IO[bytes] + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -261,7 +256,7 @@ async def create_or_update( self, report_name: str, scoping_configuration_name: str, - properties: Union[_models.ScopingConfigurationResource, IO[bytes]], + resource: Union[_models.ScopingConfigurationResource, IO[bytes]], **kwargs: Any ) -> _models.ScopingConfigurationResource: """Get the AppComplianceAutomation scoping configuration of the specific report. @@ -270,10 +265,10 @@ async def create_or_update( :type report_name: str :param scoping_configuration_name: The scoping configuration of the specific report. Required. :type scoping_configuration_name: str - :param properties: Parameters for the create or update operation, this is a singleton resource, + :param resource: Parameters for the create or update operation, this is a singleton resource, so please make sure you're using 'default' as the name. Is either a ScopingConfigurationResource type or a IO[bytes] type. Required. - :type properties: ~azure.mgmt.appcomplianceautomation.models.ScopingConfigurationResource or + :type resource: ~azure.mgmt.appcomplianceautomation.models.ScopingConfigurationResource or IO[bytes] :return: ScopingConfigurationResource or the result of cls(response) :rtype: ~azure.mgmt.appcomplianceautomation.models.ScopingConfigurationResource @@ -297,10 +292,10 @@ async def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties + if isinstance(resource, (IOBase, bytes)): + _content = resource else: - _json = self._serialize.body(properties, "ScopingConfigurationResource") + _json = self._serialize.body(resource, "ScopingConfigurationResource") _request = build_create_or_update_request( report_name=report_name, @@ -312,7 +307,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -327,11 +321,7 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ScopingConfigurationResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ScopingConfigurationResource", pipeline_response) + deserialized = self._deserialize("ScopingConfigurationResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -373,7 +363,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_snapshot_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_snapshot_operations.py index d09f74cd9e97..984a82a02de5 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_snapshot_operations.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_snapshot_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -18,12 +18,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict @@ -31,7 +32,6 @@ from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models -from ..._vendor import _convert_request from ...operations._snapshot_operations import build_download_request, build_get_request, build_list_request if sys.version_info >= (3, 9): @@ -128,7 +128,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -144,7 +143,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -207,7 +205,6 @@ async def get(self, report_name: str, snapshot_name: str, **kwargs: Any) -> _mod headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -222,7 +219,7 @@ async def get(self, report_name: str, snapshot_name: str, **kwargs: Any) -> _mod error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SnapshotResource", pipeline_response) + deserialized = self._deserialize("SnapshotResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -235,7 +232,7 @@ async def _download_initial( snapshot_name: str, body: Union[_models.SnapshotDownloadRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.DownloadResponse]: + ) -> AsyncIterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -249,7 +246,7 @@ async def _download_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.DownloadResponse]] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -269,10 +266,10 @@ async def _download_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -280,19 +277,21 @@ async def _download_initial( 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("DownloadResponse", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -398,10 +397,11 @@ async def begin_download( params=_params, **kwargs ) + await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DownloadResponse", pipeline_response) + deserialized = self._deserialize("DownloadResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_webhook_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_webhook_operations.py index e204e2a6f9db..81dc92c1c2e4 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_webhook_operations.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/aio/operations/_webhook_operations.py @@ -21,15 +21,13 @@ map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models -from ..._vendor import _convert_request from ...operations._webhook_operations import ( build_create_or_update_request, build_delete_request, @@ -132,7 +130,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -148,7 +145,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -211,7 +207,6 @@ async def get(self, report_name: str, webhook_name: str, **kwargs: Any) -> _mode headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -226,7 +221,7 @@ async def get(self, report_name: str, webhook_name: str, **kwargs: Any) -> _mode error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebhookResource", pipeline_response) + deserialized = self._deserialize("WebhookResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -238,7 +233,7 @@ async def create_or_update( self, report_name: str, webhook_name: str, - properties: _models.WebhookResource, + resource: _models.WebhookResource, *, content_type: str = "application/json", **kwargs: Any @@ -250,8 +245,8 @@ async def create_or_update( :type report_name: str :param webhook_name: Webhook Name. Required. :type webhook_name: str - :param properties: Parameters for the create or update operation. Required. - :type properties: ~azure.mgmt.appcomplianceautomation.models.WebhookResource + :param resource: Parameters for the create or update operation. Required. + :type resource: ~azure.mgmt.appcomplianceautomation.models.WebhookResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -265,7 +260,7 @@ async def create_or_update( self, report_name: str, webhook_name: str, - properties: IO[bytes], + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -277,8 +272,8 @@ async def create_or_update( :type report_name: str :param webhook_name: Webhook Name. Required. :type webhook_name: str - :param properties: Parameters for the create or update operation. Required. - :type properties: IO[bytes] + :param resource: Parameters for the create or update operation. Required. + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -289,7 +284,7 @@ async def create_or_update( @distributed_trace_async async def create_or_update( - self, report_name: str, webhook_name: str, properties: Union[_models.WebhookResource, IO[bytes]], **kwargs: Any + self, report_name: str, webhook_name: str, resource: Union[_models.WebhookResource, IO[bytes]], **kwargs: Any ) -> _models.WebhookResource: """Create a new AppComplianceAutomation webhook or update an exiting AppComplianceAutomation webhook. @@ -298,9 +293,9 @@ async def create_or_update( :type report_name: str :param webhook_name: Webhook Name. Required. :type webhook_name: str - :param properties: Parameters for the create or update operation. Is either a WebhookResource + :param resource: Parameters for the create or update operation. Is either a WebhookResource type or a IO[bytes] type. Required. - :type properties: ~azure.mgmt.appcomplianceautomation.models.WebhookResource or IO[bytes] + :type resource: ~azure.mgmt.appcomplianceautomation.models.WebhookResource or IO[bytes] :return: WebhookResource or the result of cls(response) :rtype: ~azure.mgmt.appcomplianceautomation.models.WebhookResource :raises ~azure.core.exceptions.HttpResponseError: @@ -323,10 +318,10 @@ async def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties + if isinstance(resource, (IOBase, bytes)): + _content = resource else: - _json = self._serialize.body(properties, "WebhookResource") + _json = self._serialize.body(resource, "WebhookResource") _request = build_create_or_update_request( report_name=report_name, @@ -338,7 +333,6 @@ async def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -353,11 +347,7 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("WebhookResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("WebhookResource", pipeline_response) + deserialized = self._deserialize("WebhookResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -470,7 +460,6 @@ async def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -485,7 +474,7 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebhookResource", pipeline_response) + deserialized = self._deserialize("WebhookResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -527,7 +516,6 @@ async def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_evidence_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_evidence_operations.py index 0d94b41ca64b..9ca0109d1e8e 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_evidence_operations.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_evidence_operations.py @@ -21,15 +21,13 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -307,7 +305,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -323,7 +320,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -386,7 +382,6 @@ def get(self, report_name: str, evidence_name: str, **kwargs: Any) -> _models.Ev headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -401,7 +396,7 @@ def get(self, report_name: str, evidence_name: str, **kwargs: Any) -> _models.Ev error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("EvidenceResource", pipeline_response) + deserialized = self._deserialize("EvidenceResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -413,7 +408,7 @@ def create_or_update( self, report_name: str, evidence_name: str, - properties: _models.EvidenceResource, + resource: _models.EvidenceResource, offer_guid: Optional[str] = None, report_creator_tenant_id: Optional[str] = None, *, @@ -426,8 +421,8 @@ def create_or_update( :type report_name: str :param evidence_name: The evidence name. Required. :type evidence_name: str - :param properties: Parameters for the create or update operation. Required. - :type properties: ~azure.mgmt.appcomplianceautomation.models.EvidenceResource + :param resource: Parameters for the create or update operation. Required. + :type resource: ~azure.mgmt.appcomplianceautomation.models.EvidenceResource :param offer_guid: The offerGuid which mapping to the reports. Default value is None. :type offer_guid: str :param report_creator_tenant_id: The tenant id of the report creator. Default value is None. @@ -445,7 +440,7 @@ def create_or_update( self, report_name: str, evidence_name: str, - properties: IO[bytes], + resource: IO[bytes], offer_guid: Optional[str] = None, report_creator_tenant_id: Optional[str] = None, *, @@ -458,8 +453,8 @@ def create_or_update( :type report_name: str :param evidence_name: The evidence name. Required. :type evidence_name: str - :param properties: Parameters for the create or update operation. Required. - :type properties: IO[bytes] + :param resource: Parameters for the create or update operation. Required. + :type resource: IO[bytes] :param offer_guid: The offerGuid which mapping to the reports. Default value is None. :type offer_guid: str :param report_creator_tenant_id: The tenant id of the report creator. Default value is None. @@ -477,7 +472,7 @@ def create_or_update( self, report_name: str, evidence_name: str, - properties: Union[_models.EvidenceResource, IO[bytes]], + resource: Union[_models.EvidenceResource, IO[bytes]], offer_guid: Optional[str] = None, report_creator_tenant_id: Optional[str] = None, **kwargs: Any @@ -488,9 +483,9 @@ def create_or_update( :type report_name: str :param evidence_name: The evidence name. Required. :type evidence_name: str - :param properties: Parameters for the create or update operation. Is either a EvidenceResource + :param resource: Parameters for the create or update operation. Is either a EvidenceResource type or a IO[bytes] type. Required. - :type properties: ~azure.mgmt.appcomplianceautomation.models.EvidenceResource or IO[bytes] + :type resource: ~azure.mgmt.appcomplianceautomation.models.EvidenceResource or IO[bytes] :param offer_guid: The offerGuid which mapping to the reports. Default value is None. :type offer_guid: str :param report_creator_tenant_id: The tenant id of the report creator. Default value is None. @@ -517,10 +512,10 @@ def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties + if isinstance(resource, (IOBase, bytes)): + _content = resource else: - _json = self._serialize.body(properties, "EvidenceResource") + _json = self._serialize.body(resource, "EvidenceResource") _request = build_create_or_update_request( report_name=report_name, @@ -534,7 +529,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -549,11 +543,7 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("EvidenceResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("EvidenceResource", pipeline_response) + deserialized = self._deserialize("EvidenceResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -595,7 +585,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -719,7 +708,6 @@ def download( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -734,7 +722,7 @@ def download( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("EvidenceFileDownloadResponse", pipeline_response) + deserialized = self._deserialize("EvidenceFileDownloadResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_operations.py index 9ba9dcd4e347..1a203bf93667 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_operations.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_operations.py @@ -20,15 +20,13 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -109,7 +107,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -125,7 +122,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_provider_actions_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_provider_actions_operations.py index f9dc9131c2f2..ede25fff8045 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_provider_actions_operations.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_provider_actions_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterator, Optional, Type, TypeVar, Union, cast, overload from azure.core.exceptions import ( ClientAuthenticationError, @@ -16,12 +16,13 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -29,7 +30,6 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -270,7 +270,6 @@ def check_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -285,7 +284,7 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityResponse", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -368,7 +367,6 @@ def get_collection_count( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -383,7 +381,7 @@ def get_collection_count( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GetCollectionCountResponse", pipeline_response) + deserialized = self._deserialize("GetCollectionCountResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -466,7 +464,6 @@ def get_overview_status( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -481,7 +478,7 @@ def get_overview_status( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("GetOverviewStatusResponse", pipeline_response) + deserialized = self._deserialize("GetOverviewStatusResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -565,7 +562,6 @@ def list_in_use_storage_accounts( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -580,16 +576,14 @@ def list_in_use_storage_accounts( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ListInUseStorageAccountsResponse", pipeline_response) + deserialized = self._deserialize("ListInUseStorageAccountsResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _onboard_initial( - self, body: Union[_models.OnboardRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.OnboardResponse]: + def _onboard_initial(self, body: Union[_models.OnboardRequest, IO[bytes]], **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -603,7 +597,7 @@ def _onboard_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.OnboardResponse]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -621,10 +615,10 @@ def _onboard_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -632,19 +626,21 @@ def _onboard_initial( 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("OnboardResponse", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -720,10 +716,11 @@ def begin_onboard( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("OnboardResponse", pipeline_response) + deserialized = self._deserialize("OnboardResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -749,7 +746,7 @@ def get_long_running_output(pipeline_response): def _trigger_evaluation_initial( self, body: Union[_models.TriggerEvaluationRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.TriggerEvaluationResponse]: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -763,7 +760,7 @@ def _trigger_evaluation_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.TriggerEvaluationResponse]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -781,10 +778,10 @@ def _trigger_evaluation_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -792,19 +789,21 @@ def _trigger_evaluation_initial( 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("TriggerEvaluationResponse", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -880,10 +879,11 @@ def begin_trigger_evaluation( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("TriggerEvaluationResponse", pipeline_response) + deserialized = self._deserialize("TriggerEvaluationResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_report_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_report_operations.py index b22e5fe881c4..fa576599a310 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_report_operations.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_report_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +32,6 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -406,7 +406,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -422,7 +421,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -482,7 +480,6 @@ def get(self, report_name: str, **kwargs: Any) -> _models.ReportResource: headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -497,7 +494,7 @@ def get(self, report_name: str, **kwargs: Any) -> _models.ReportResource: error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ReportResource", pipeline_response) + deserialized = self._deserialize("ReportResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -505,8 +502,8 @@ def get(self, report_name: str, **kwargs: Any) -> _models.ReportResource: return deserialized # type: ignore def _create_or_update_initial( - self, report_name: str, properties: Union[_models.ReportResource, IO[bytes]], **kwargs: Any - ) -> _models.ReportResource: + self, report_name: str, resource: Union[_models.ReportResource, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -520,15 +517,15 @@ def _create_or_update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ReportResource] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties + if isinstance(resource, (IOBase, bytes)): + _content = resource else: - _json = self._serialize.body(properties, "ReportResource") + _json = self._serialize.body(resource, "ReportResource") _request = build_create_or_update_request( report_name=report_name, @@ -539,10 +536,10 @@ def _create_or_update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -550,18 +547,19 @@ def _create_or_update_initial( response = pipeline_response.http_response if response.status_code not in [200, 201]: + 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ReportResource", pipeline_response) - if response.status_code == 201: response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) - deserialized = self._deserialize("ReportResource", pipeline_response) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -572,7 +570,7 @@ def _create_or_update_initial( def begin_create_or_update( self, report_name: str, - properties: _models.ReportResource, + resource: _models.ReportResource, *, content_type: str = "application/json", **kwargs: Any @@ -582,8 +580,8 @@ def begin_create_or_update( :param report_name: Report Name. Required. :type report_name: str - :param properties: Parameters for the create or update operation. Required. - :type properties: ~azure.mgmt.appcomplianceautomation.models.ReportResource + :param resource: Parameters for the create or update operation. Required. + :type resource: ~azure.mgmt.appcomplianceautomation.models.ReportResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -596,15 +594,15 @@ def begin_create_or_update( @overload def begin_create_or_update( - self, report_name: str, properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + self, report_name: str, resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.ReportResource]: """Create a new AppComplianceAutomation report or update an exiting AppComplianceAutomation report. :param report_name: Report Name. Required. :type report_name: str - :param properties: Parameters for the create or update operation. Required. - :type properties: IO[bytes] + :param resource: Parameters for the create or update operation. Required. + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -617,16 +615,16 @@ def begin_create_or_update( @distributed_trace def begin_create_or_update( - self, report_name: str, properties: Union[_models.ReportResource, IO[bytes]], **kwargs: Any + self, report_name: str, resource: Union[_models.ReportResource, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ReportResource]: """Create a new AppComplianceAutomation report or update an exiting AppComplianceAutomation report. :param report_name: Report Name. Required. :type report_name: str - :param properties: Parameters for the create or update operation. Is either a ReportResource - type or a IO[bytes] type. Required. - :type properties: ~azure.mgmt.appcomplianceautomation.models.ReportResource or IO[bytes] + :param resource: Parameters for the create or update operation. Is either a ReportResource type + or a IO[bytes] type. Required. + :type resource: ~azure.mgmt.appcomplianceautomation.models.ReportResource or IO[bytes] :return: An instance of LROPoller that returns either ReportResource or the result of cls(response) :rtype: @@ -645,7 +643,7 @@ def begin_create_or_update( if cont_token is None: raw_result = self._create_or_update_initial( report_name=report_name, - properties=properties, + resource=resource, api_version=api_version, content_type=content_type, cls=lambda x, y, z: x, @@ -653,10 +651,11 @@ def begin_create_or_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ReportResource", pipeline_response) + deserialized = self._deserialize("ReportResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -682,7 +681,7 @@ def get_long_running_output(pipeline_response): def _update_initial( self, report_name: str, properties: Union[_models.ReportResourcePatch, IO[bytes]], **kwargs: Any - ) -> Optional[_models.ReportResource]: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -696,7 +695,7 @@ def _update_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.ReportResource]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -715,10 +714,10 @@ def _update_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -726,19 +725,21 @@ def _update_initial( 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ReportResource", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -826,10 +827,11 @@ def begin_update( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ReportResource", pipeline_response) + deserialized = self._deserialize("ReportResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -853,9 +855,7 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _delete_initial( # pylint: disable=inconsistent-return-statements - self, report_name: str, **kwargs: Any - ) -> None: + def _delete_initial(self, report_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -868,7 +868,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_delete_request( report_name=report_name, @@ -876,10 +876,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -887,6 +887,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response = pipeline_response.http_response if response.status_code not in [202, 204]: + 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -896,8 +900,12 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace def begin_delete(self, report_name: str, **kwargs: Any) -> LROPoller[None]: @@ -918,7 +926,7 @@ def begin_delete(self, report_name: str, **kwargs: Any) -> LROPoller[None]: 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._delete_initial( # type: ignore + raw_result = self._delete_initial( report_name=report_name, api_version=api_version, cls=lambda x, y, z: x, @@ -926,6 +934,7 @@ def begin_delete(self, report_name: str, **kwargs: Any) -> LROPoller[None]: params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements @@ -1038,7 +1047,6 @@ def nested_resource_check_name_availability( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1053,14 +1061,14 @@ def nested_resource_check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("CheckNameAvailabilityResponse", pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _fix_initial(self, report_name: str, **kwargs: Any) -> Optional[_models.ReportFixResult]: + def _fix_initial(self, report_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1073,7 +1081,7 @@ def _fix_initial(self, report_name: str, **kwargs: Any) -> Optional[_models.Repo _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.ReportFixResult]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_fix_request( report_name=report_name, @@ -1081,10 +1089,10 @@ def _fix_initial(self, report_name: str, **kwargs: Any) -> Optional[_models.Repo headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1092,19 +1100,21 @@ def _fix_initial(self, report_name: str, **kwargs: Any) -> Optional[_models.Repo 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ReportFixResult", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1140,10 +1150,11 @@ def begin_fix(self, report_name: str, **kwargs: Any) -> LROPoller[_models.Report params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ReportFixResult", pipeline_response) + deserialized = self._deserialize("ReportFixResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1198,7 +1209,6 @@ def get_scoping_questions(self, report_name: str, **kwargs: Any) -> _models.Scop headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -1213,7 +1223,7 @@ def get_scoping_questions(self, report_name: str, **kwargs: Any) -> _models.Scop error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ScopingQuestions", pipeline_response) + deserialized = self._deserialize("ScopingQuestions", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -1222,7 +1232,7 @@ def get_scoping_questions(self, report_name: str, **kwargs: Any) -> _models.Scop def _sync_cert_record_initial( self, report_name: str, body: Union[_models.SyncCertRecordRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.SyncCertRecordResponse]: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1236,7 +1246,7 @@ def _sync_cert_record_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.SyncCertRecordResponse]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -1255,10 +1265,10 @@ def _sync_cert_record_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1266,19 +1276,21 @@ def _sync_cert_record_initial( 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("SyncCertRecordResponse", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1366,10 +1378,11 @@ def begin_sync_cert_record( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("SyncCertRecordResponse", pipeline_response) + deserialized = self._deserialize("SyncCertRecordResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized @@ -1393,7 +1406,7 @@ def get_long_running_output(pipeline_response): self._client, raw_result, get_long_running_output, polling_method # type: ignore ) - def _verify_initial(self, report_name: str, **kwargs: Any) -> Optional[_models.ReportVerificationResult]: + def _verify_initial(self, report_name: str, **kwargs: Any) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1406,7 +1419,7 @@ def _verify_initial(self, report_name: str, **kwargs: Any) -> Optional[_models.R _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) - cls: ClsType[Optional[_models.ReportVerificationResult]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) _request = build_verify_request( report_name=report_name, @@ -1414,10 +1427,10 @@ def _verify_initial(self, report_name: str, **kwargs: Any) -> Optional[_models.R headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -1425,19 +1438,21 @@ def _verify_initial(self, report_name: str, **kwargs: Any) -> Optional[_models.R 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("ReportVerificationResult", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -1472,10 +1487,11 @@ def begin_verify(self, report_name: str, **kwargs: Any) -> LROPoller[_models.Rep params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ReportVerificationResult", pipeline_response) + deserialized = self._deserialize("ReportVerificationResult", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_scoping_configuration_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_scoping_configuration_operations.py index cf349bf0f2c5..2782742ef30e 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_scoping_configuration_operations.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_scoping_configuration_operations.py @@ -21,15 +21,13 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -215,7 +213,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -231,7 +228,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -296,7 +292,6 @@ def get( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -311,7 +306,7 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("ScopingConfigurationResource", pipeline_response) + deserialized = self._deserialize("ScopingConfigurationResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -323,7 +318,7 @@ def create_or_update( self, report_name: str, scoping_configuration_name: str, - properties: _models.ScopingConfigurationResource, + resource: _models.ScopingConfigurationResource, *, content_type: str = "application/json", **kwargs: Any @@ -334,9 +329,9 @@ def create_or_update( :type report_name: str :param scoping_configuration_name: The scoping configuration of the specific report. Required. :type scoping_configuration_name: str - :param properties: Parameters for the create or update operation, this is a singleton resource, + :param resource: Parameters for the create or update operation, this is a singleton resource, so please make sure you're using 'default' as the name. Required. - :type properties: ~azure.mgmt.appcomplianceautomation.models.ScopingConfigurationResource + :type resource: ~azure.mgmt.appcomplianceautomation.models.ScopingConfigurationResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -350,7 +345,7 @@ def create_or_update( self, report_name: str, scoping_configuration_name: str, - properties: IO[bytes], + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -361,9 +356,9 @@ def create_or_update( :type report_name: str :param scoping_configuration_name: The scoping configuration of the specific report. Required. :type scoping_configuration_name: str - :param properties: Parameters for the create or update operation, this is a singleton resource, + :param resource: Parameters for the create or update operation, this is a singleton resource, so please make sure you're using 'default' as the name. Required. - :type properties: IO[bytes] + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -377,7 +372,7 @@ def create_or_update( self, report_name: str, scoping_configuration_name: str, - properties: Union[_models.ScopingConfigurationResource, IO[bytes]], + resource: Union[_models.ScopingConfigurationResource, IO[bytes]], **kwargs: Any ) -> _models.ScopingConfigurationResource: """Get the AppComplianceAutomation scoping configuration of the specific report. @@ -386,10 +381,10 @@ def create_or_update( :type report_name: str :param scoping_configuration_name: The scoping configuration of the specific report. Required. :type scoping_configuration_name: str - :param properties: Parameters for the create or update operation, this is a singleton resource, + :param resource: Parameters for the create or update operation, this is a singleton resource, so please make sure you're using 'default' as the name. Is either a ScopingConfigurationResource type or a IO[bytes] type. Required. - :type properties: ~azure.mgmt.appcomplianceautomation.models.ScopingConfigurationResource or + :type resource: ~azure.mgmt.appcomplianceautomation.models.ScopingConfigurationResource or IO[bytes] :return: ScopingConfigurationResource or the result of cls(response) :rtype: ~azure.mgmt.appcomplianceautomation.models.ScopingConfigurationResource @@ -413,10 +408,10 @@ def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties + if isinstance(resource, (IOBase, bytes)): + _content = resource else: - _json = self._serialize.body(properties, "ScopingConfigurationResource") + _json = self._serialize.body(resource, "ScopingConfigurationResource") _request = build_create_or_update_request( report_name=report_name, @@ -428,7 +423,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -443,11 +437,7 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("ScopingConfigurationResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("ScopingConfigurationResource", pipeline_response) + deserialized = self._deserialize("ScopingConfigurationResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -489,7 +479,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_snapshot_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_snapshot_operations.py index 970ef840f99f..bcf10fd6b295 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_snapshot_operations.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_snapshot_operations.py @@ -8,7 +8,7 @@ # -------------------------------------------------------------------------- from io import IOBase import sys -from typing import Any, Callable, Dict, IO, Iterable, Optional, Type, TypeVar, Union, cast, overload +from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, Type, TypeVar, Union, cast, overload import urllib.parse from azure.core.exceptions import ( @@ -17,13 +17,14 @@ ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, + StreamClosedError, + StreamConsumedError, map_error, ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat @@ -31,7 +32,6 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -239,7 +239,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -255,7 +254,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -318,7 +316,6 @@ def get(self, report_name: str, snapshot_name: str, **kwargs: Any) -> _models.Sn headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -333,7 +330,7 @@ def get(self, report_name: str, snapshot_name: str, **kwargs: Any) -> _models.Sn error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SnapshotResource", pipeline_response) + deserialized = self._deserialize("SnapshotResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -346,7 +343,7 @@ def _download_initial( snapshot_name: str, body: Union[_models.SnapshotDownloadRequest, IO[bytes]], **kwargs: Any - ) -> Optional[_models.DownloadResponse]: + ) -> Iterator[bytes]: error_map: MutableMapping[int, Type[HttpResponseError]] = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -360,7 +357,7 @@ def _download_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Optional[_models.DownloadResponse]] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None @@ -380,10 +377,10 @@ def _download_initial( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -391,19 +388,21 @@ def _download_initial( 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 = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = None response_headers = {} - if response.status_code == 200: - deserialized = self._deserialize("DownloadResponse", pipeline_response) - if response.status_code == 202: response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) + if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -509,10 +508,11 @@ def begin_download( params=_params, **kwargs ) + raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize("DownloadResponse", pipeline_response) + deserialized = self._deserialize("DownloadResponse", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_webhook_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_webhook_operations.py index 2cc89b2528e3..be075e1d97a9 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_webhook_operations.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/azure/mgmt/appcomplianceautomation/operations/_webhook_operations.py @@ -21,15 +21,13 @@ ) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpResponse -from azure.core.rest import HttpRequest +from azure.core.rest import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request if sys.version_info >= (3, 9): from collections.abc import MutableMapping @@ -293,7 +291,6 @@ def prepare_request(next_link=None): headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) else: @@ -309,7 +306,6 @@ def prepare_request(next_link=None): _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _request.method = "GET" return _request @@ -372,7 +368,6 @@ def get(self, report_name: str, webhook_name: str, **kwargs: Any) -> _models.Web headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -387,7 +382,7 @@ def get(self, report_name: str, webhook_name: str, **kwargs: Any) -> _models.Web error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebhookResource", pipeline_response) + deserialized = self._deserialize("WebhookResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -399,7 +394,7 @@ def create_or_update( self, report_name: str, webhook_name: str, - properties: _models.WebhookResource, + resource: _models.WebhookResource, *, content_type: str = "application/json", **kwargs: Any @@ -411,8 +406,8 @@ def create_or_update( :type report_name: str :param webhook_name: Webhook Name. Required. :type webhook_name: str - :param properties: Parameters for the create or update operation. Required. - :type properties: ~azure.mgmt.appcomplianceautomation.models.WebhookResource + :param resource: Parameters for the create or update operation. Required. + :type resource: ~azure.mgmt.appcomplianceautomation.models.WebhookResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -426,7 +421,7 @@ def create_or_update( self, report_name: str, webhook_name: str, - properties: IO[bytes], + resource: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -438,8 +433,8 @@ def create_or_update( :type report_name: str :param webhook_name: Webhook Name. Required. :type webhook_name: str - :param properties: Parameters for the create or update operation. Required. - :type properties: IO[bytes] + :param resource: Parameters for the create or update operation. Required. + :type resource: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -450,7 +445,7 @@ def create_or_update( @distributed_trace def create_or_update( - self, report_name: str, webhook_name: str, properties: Union[_models.WebhookResource, IO[bytes]], **kwargs: Any + self, report_name: str, webhook_name: str, resource: Union[_models.WebhookResource, IO[bytes]], **kwargs: Any ) -> _models.WebhookResource: """Create a new AppComplianceAutomation webhook or update an exiting AppComplianceAutomation webhook. @@ -459,9 +454,9 @@ def create_or_update( :type report_name: str :param webhook_name: Webhook Name. Required. :type webhook_name: str - :param properties: Parameters for the create or update operation. Is either a WebhookResource + :param resource: Parameters for the create or update operation. Is either a WebhookResource type or a IO[bytes] type. Required. - :type properties: ~azure.mgmt.appcomplianceautomation.models.WebhookResource or IO[bytes] + :type resource: ~azure.mgmt.appcomplianceautomation.models.WebhookResource or IO[bytes] :return: WebhookResource or the result of cls(response) :rtype: ~azure.mgmt.appcomplianceautomation.models.WebhookResource :raises ~azure.core.exceptions.HttpResponseError: @@ -484,10 +479,10 @@ def create_or_update( content_type = content_type or "application/json" _json = None _content = None - if isinstance(properties, (IOBase, bytes)): - _content = properties + if isinstance(resource, (IOBase, bytes)): + _content = resource else: - _json = self._serialize.body(properties, "WebhookResource") + _json = self._serialize.body(resource, "WebhookResource") _request = build_create_or_update_request( report_name=report_name, @@ -499,7 +494,6 @@ def create_or_update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -514,11 +508,7 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize("WebhookResource", pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize("WebhookResource", pipeline_response) + deserialized = self._deserialize("WebhookResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -631,7 +621,6 @@ def update( headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False @@ -646,7 +635,7 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("WebhookResource", pipeline_response) + deserialized = self._deserialize("WebhookResource", pipeline_response.http_response) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -688,7 +677,6 @@ def delete( # pylint: disable=inconsistent-return-statements headers=_headers, params=_params, ) - _request = _convert_request(_request) _request.url = self._client.format_url(_request.url) _stream = False diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/evidence_delete.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/evidence_delete.py deleted file mode 100644 index 1362051c10a2..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/evidence_delete.py +++ /dev/null @@ -1,40 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-appcomplianceautomation -# USAGE - python evidence_delete.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = AppComplianceAutomationMgmtClient( - credential=DefaultAzureCredential(), - ) - - client.evidence.delete( - report_name="testReportName", - evidence_name="evidence1", - ) - - -# x-ms-original-file: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Evidence_Delete.json -if __name__ == "__main__": - main() diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/evidence_get.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/evidence_get.py deleted file mode 100644 index 2da6a465c98a..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/evidence_get.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-appcomplianceautomation -# USAGE - python evidence_get.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = AppComplianceAutomationMgmtClient( - credential=DefaultAzureCredential(), - ) - - response = client.evidence.get( - report_name="testReportName", - evidence_name="evidence1", - ) - print(response) - - -# x-ms-original-file: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Evidence_Get.json -if __name__ == "__main__": - main() diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/evidence_list_by_report.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/evidence_list_by_report.py deleted file mode 100644 index 50e17acd199a..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/evidence_list_by_report.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-appcomplianceautomation -# USAGE - python evidence_list_by_report.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = AppComplianceAutomationMgmtClient( - credential=DefaultAzureCredential(), - ) - - response = client.evidence.list_by_report( - report_name="reportName", - ) - for item in response: - print(item) - - -# x-ms-original-file: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Evidence_ListByReport.json -if __name__ == "__main__": - main() diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/operations_list.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/operations_list.py deleted file mode 100644 index 538a6d0c56d2..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/operations_list.py +++ /dev/null @@ -1,39 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-appcomplianceautomation -# USAGE - python operations_list.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = AppComplianceAutomationMgmtClient( - credential=DefaultAzureCredential(), - ) - - response = client.operations.list() - for item in response: - print(item) - - -# x-ms-original-file: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Operations_List.json -if __name__ == "__main__": - main() diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/report_delete.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/report_delete.py deleted file mode 100644 index c61b8f8074c7..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/report_delete.py +++ /dev/null @@ -1,39 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-appcomplianceautomation -# USAGE - python report_delete.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = AppComplianceAutomationMgmtClient( - credential=DefaultAzureCredential(), - ) - - client.report.begin_delete( - report_name="testReportName", - ).result() - - -# x-ms-original-file: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Report_Delete.json -if __name__ == "__main__": - main() diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/report_fix.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/report_fix.py deleted file mode 100644 index ddefdf10f84a..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/report_fix.py +++ /dev/null @@ -1,40 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-appcomplianceautomation -# USAGE - python report_fix.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = AppComplianceAutomationMgmtClient( - credential=DefaultAzureCredential(), - ) - - response = client.report.begin_fix( - report_name="testReport", - ).result() - print(response) - - -# x-ms-original-file: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Report_Fix.json -if __name__ == "__main__": - main() diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/report_get.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/report_get.py deleted file mode 100644 index e0da861f2a55..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/report_get.py +++ /dev/null @@ -1,40 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-appcomplianceautomation -# USAGE - python report_get.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = AppComplianceAutomationMgmtClient( - credential=DefaultAzureCredential(), - ) - - response = client.report.get( - report_name="testReport", - ) - print(response) - - -# x-ms-original-file: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Report_Get.json -if __name__ == "__main__": - main() diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/report_get_scoping_questions.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/report_get_scoping_questions.py deleted file mode 100644 index e5710d98bc5f..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/report_get_scoping_questions.py +++ /dev/null @@ -1,40 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-appcomplianceautomation -# USAGE - python report_get_scoping_questions.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = AppComplianceAutomationMgmtClient( - credential=DefaultAzureCredential(), - ) - - response = client.report.get_scoping_questions( - report_name="testReportName", - ) - print(response) - - -# x-ms-original-file: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Report_GetScopingQuestions.json -if __name__ == "__main__": - main() diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/report_list.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/report_list.py deleted file mode 100644 index f2f3fced62e7..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/report_list.py +++ /dev/null @@ -1,39 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-appcomplianceautomation -# USAGE - python report_list.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = AppComplianceAutomationMgmtClient( - credential=DefaultAzureCredential(), - ) - - response = client.report.list() - for item in response: - print(item) - - -# x-ms-original-file: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Report_List.json -if __name__ == "__main__": - main() diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/report_verify.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/report_verify.py deleted file mode 100644 index b1aa7fa89f92..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/report_verify.py +++ /dev/null @@ -1,40 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-appcomplianceautomation -# USAGE - python report_verify.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = AppComplianceAutomationMgmtClient( - credential=DefaultAzureCredential(), - ) - - response = client.report.begin_verify( - report_name="testReport", - ).result() - print(response) - - -# x-ms-original-file: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Report_Verify.json -if __name__ == "__main__": - main() diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/scoping_configuration_delete.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/scoping_configuration_delete.py deleted file mode 100644 index 3e7a259fe95e..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/scoping_configuration_delete.py +++ /dev/null @@ -1,40 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-appcomplianceautomation -# USAGE - python scoping_configuration_delete.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = AppComplianceAutomationMgmtClient( - credential=DefaultAzureCredential(), - ) - - client.scoping_configuration.delete( - report_name="testReportName", - scoping_configuration_name="default", - ) - - -# x-ms-original-file: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/ScopingConfiguration_Delete.json -if __name__ == "__main__": - main() diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/scoping_configuration_get.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/scoping_configuration_get.py deleted file mode 100644 index ea2a4b3d4963..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/scoping_configuration_get.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-appcomplianceautomation -# USAGE - python scoping_configuration_get.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = AppComplianceAutomationMgmtClient( - credential=DefaultAzureCredential(), - ) - - response = client.scoping_configuration.get( - report_name="testReportName", - scoping_configuration_name="default", - ) - print(response) - - -# x-ms-original-file: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/ScopingConfiguration_Get.json -if __name__ == "__main__": - main() diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/scoping_configuration_list.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/scoping_configuration_list.py deleted file mode 100644 index 8245b5d765e5..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/scoping_configuration_list.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-appcomplianceautomation -# USAGE - python scoping_configuration_list.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = AppComplianceAutomationMgmtClient( - credential=DefaultAzureCredential(), - ) - - response = client.scoping_configuration.list( - report_name="testReportName", - ) - for item in response: - print(item) - - -# x-ms-original-file: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/ScopingConfiguration_List.json -if __name__ == "__main__": - main() diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/snapshot_get.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/snapshot_get.py deleted file mode 100644 index 4a98c799d971..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/snapshot_get.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-appcomplianceautomation -# USAGE - python snapshot_get.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = AppComplianceAutomationMgmtClient( - credential=DefaultAzureCredential(), - ) - - response = client.snapshot.get( - report_name="testReportName", - snapshot_name="testSnapshot", - ) - print(response) - - -# x-ms-original-file: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Snapshot_Get.json -if __name__ == "__main__": - main() diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/snapshot_list.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/snapshot_list.py deleted file mode 100644 index 59392c28bbd8..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/snapshot_list.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-appcomplianceautomation -# USAGE - python snapshot_list.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = AppComplianceAutomationMgmtClient( - credential=DefaultAzureCredential(), - ) - - response = client.snapshot.list( - report_name="testReportName", - ) - for item in response: - print(item) - - -# x-ms-original-file: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Snapshot_List.json -if __name__ == "__main__": - main() diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/webhook_delete.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/webhook_delete.py deleted file mode 100644 index c16ba25edcbd..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/webhook_delete.py +++ /dev/null @@ -1,40 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-appcomplianceautomation -# USAGE - python webhook_delete.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = AppComplianceAutomationMgmtClient( - credential=DefaultAzureCredential(), - ) - - client.webhook.delete( - report_name="testReportName", - webhook_name="testWebhookName", - ) - - -# x-ms-original-file: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Webhook_Delete.json -if __name__ == "__main__": - main() diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/webhook_get.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/webhook_get.py deleted file mode 100644 index cc2549134e92..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/webhook_get.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-appcomplianceautomation -# USAGE - python webhook_get.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = AppComplianceAutomationMgmtClient( - credential=DefaultAzureCredential(), - ) - - response = client.webhook.get( - report_name="testReportName", - webhook_name="testWebhookName", - ) - print(response) - - -# x-ms-original-file: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Webhook_Get.json -if __name__ == "__main__": - main() diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/webhook_list.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/webhook_list.py deleted file mode 100644 index 06252b39ef62..000000000000 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_samples/webhook_list.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential - -from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-appcomplianceautomation -# USAGE - python webhook_list.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = AppComplianceAutomationMgmtClient( - credential=DefaultAzureCredential(), - ) - - response = client.webhook.list( - report_name="testReportName", - ) - for item in response: - print(item) - - -# x-ms-original-file: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Webhook_List.json -if __name__ == "__main__": - main() diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/conftest.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/conftest.py new file mode 100644 index 000000000000..114487a96db6 --- /dev/null +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/conftest.py @@ -0,0 +1,47 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import os +import pytest +from dotenv import load_dotenv +from devtools_testutils import ( + test_proxy, + add_general_regex_sanitizer, + add_body_key_sanitizer, + add_header_regex_sanitizer, +) + +load_dotenv() + + +# aovid record sensitive identity information in recordings +@pytest.fixture(scope="session", autouse=True) +def add_sanitizers(test_proxy): + appcomplianceautomationmgmt_subscription_id = os.environ.get( + "AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000" + ) + appcomplianceautomationmgmt_tenant_id = os.environ.get("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + appcomplianceautomationmgmt_client_id = os.environ.get("AZURE_CLIENT_ID", "00000000-0000-0000-0000-000000000000") + appcomplianceautomationmgmt_client_secret = os.environ.get( + "AZURE_CLIENT_SECRET", "00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=appcomplianceautomationmgmt_subscription_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=appcomplianceautomationmgmt_tenant_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=appcomplianceautomationmgmt_client_id, value="00000000-0000-0000-0000-000000000000" + ) + add_general_regex_sanitizer( + regex=appcomplianceautomationmgmt_client_secret, value="00000000-0000-0000-0000-000000000000" + ) + + add_header_regex_sanitizer(key="Set-Cookie", value="[set-cookie;]") + add_header_regex_sanitizer(key="Cookie", value="cookie;") + add_body_key_sanitizer(json_path="$..access_token", value="access_token") diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_evidence_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_evidence_operations.py new file mode 100644 index 000000000000..706bdd223150 --- /dev/null +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_evidence_operations.py @@ -0,0 +1,100 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppComplianceAutomationMgmtEvidenceOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppComplianceAutomationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_by_report(self, resource_group): + response = self.client.evidence.list_by_report( + report_name="str", + api_version="2024-06-27", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.evidence.get( + report_name="str", + evidence_name="str", + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.evidence.create_or_update( + report_name="str", + evidence_name="str", + resource={ + "properties": { + "filePath": "str", + "controlId": "str", + "evidenceType": "str", + "extraData": "str", + "provisioningState": "str", + "responsibilityId": "str", + }, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.evidence.delete( + report_name="str", + evidence_name="str", + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_download(self, resource_group): + response = self.client.evidence.download( + report_name="str", + evidence_name="str", + body={"offerGuid": "str", "reportCreatorTenantId": "str"}, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_evidence_operations_async.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_evidence_operations_async.py new file mode 100644 index 000000000000..eefb6a0a9fcc --- /dev/null +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_evidence_operations_async.py @@ -0,0 +1,101 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appcomplianceautomation.aio import AppComplianceAutomationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppComplianceAutomationMgmtEvidenceOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppComplianceAutomationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_by_report(self, resource_group): + response = self.client.evidence.list_by_report( + report_name="str", + api_version="2024-06-27", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.evidence.get( + report_name="str", + evidence_name="str", + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.evidence.create_or_update( + report_name="str", + evidence_name="str", + resource={ + "properties": { + "filePath": "str", + "controlId": "str", + "evidenceType": "str", + "extraData": "str", + "provisioningState": "str", + "responsibilityId": "str", + }, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.evidence.delete( + report_name="str", + evidence_name="str", + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_download(self, resource_group): + response = await self.client.evidence.download( + report_name="str", + evidence_name="str", + body={"offerGuid": "str", "reportCreatorTenantId": "str"}, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_operations.py new file mode 100644 index 000000000000..62d4359b59d9 --- /dev/null +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_operations.py @@ -0,0 +1,29 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppComplianceAutomationMgmtOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppComplianceAutomationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-06-27", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_operations_async.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_operations_async.py new file mode 100644 index 000000000000..0a3c83082238 --- /dev/null +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_operations_async.py @@ -0,0 +1,30 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appcomplianceautomation.aio import AppComplianceAutomationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppComplianceAutomationMgmtOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppComplianceAutomationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.operations.list( + api_version="2024-06-27", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_provider_actions_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_provider_actions_operations.py new file mode 100644 index 000000000000..3c34ae001341 --- /dev/null +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_provider_actions_operations.py @@ -0,0 +1,85 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppComplianceAutomationMgmtProviderActionsOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppComplianceAutomationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_check_name_availability(self, resource_group): + response = self.client.provider_actions.check_name_availability( + body={"name": "str", "type": "str"}, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_collection_count(self, resource_group): + response = self.client.provider_actions.get_collection_count( + body={"type": "str"}, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_overview_status(self, resource_group): + response = self.client.provider_actions.get_overview_status( + body={"type": "str"}, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list_in_use_storage_accounts(self, resource_group): + response = self.client.provider_actions.list_in_use_storage_accounts( + body={"subscriptionIds": ["str"]}, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_onboard(self, resource_group): + response = self.client.provider_actions.begin_onboard( + body={"subscriptionIds": ["str"]}, + api_version="2024-06-27", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_trigger_evaluation(self, resource_group): + response = self.client.provider_actions.begin_trigger_evaluation( + body={"resourceIds": ["str"]}, + api_version="2024-06-27", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_provider_actions_operations_async.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_provider_actions_operations_async.py new file mode 100644 index 000000000000..4f924574e274 --- /dev/null +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_provider_actions_operations_async.py @@ -0,0 +1,90 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appcomplianceautomation.aio import AppComplianceAutomationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppComplianceAutomationMgmtProviderActionsOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppComplianceAutomationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_check_name_availability(self, resource_group): + response = await self.client.provider_actions.check_name_availability( + body={"name": "str", "type": "str"}, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_collection_count(self, resource_group): + response = await self.client.provider_actions.get_collection_count( + body={"type": "str"}, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_overview_status(self, resource_group): + response = await self.client.provider_actions.get_overview_status( + body={"type": "str"}, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list_in_use_storage_accounts(self, resource_group): + response = await self.client.provider_actions.list_in_use_storage_accounts( + body={"subscriptionIds": ["str"]}, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_onboard(self, resource_group): + response = await ( + await self.client.provider_actions.begin_onboard( + body={"subscriptionIds": ["str"]}, + api_version="2024-06-27", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_trigger_evaluation(self, resource_group): + response = await ( + await self.client.provider_actions.begin_trigger_evaluation( + body={"resourceIds": ["str"]}, + api_version="2024-06-27", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_report_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_report_operations.py new file mode 100644 index 000000000000..01439f638536 --- /dev/null +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_report_operations.py @@ -0,0 +1,240 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppComplianceAutomationMgmtReportOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppComplianceAutomationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.report.list( + api_version="2024-06-27", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.report.get( + report_name="str", + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_create_or_update(self, resource_group): + response = self.client.report.begin_create_or_update( + report_name="str", + resource={ + "properties": { + "resources": [ + { + "resourceId": "str", + "accountId": "str", + "resourceKind": "str", + "resourceOrigin": "str", + "resourceType": "str", + } + ], + "timeZone": "str", + "triggerTime": "2020-02-20 00:00:00", + "certRecords": [ + { + "certificationStatus": "str", + "controls": [{"controlId": "str", "controlStatus": "str"}], + "ingestionStatus": "str", + "offerGuid": "str", + } + ], + "complianceStatus": { + "m365": { + "failedCount": 0, + "manualCount": 0, + "notApplicableCount": 0, + "passedCount": 0, + "pendingCount": 0, + } + }, + "errors": ["str"], + "lastTriggerTime": "2020-02-20 00:00:00", + "nextTriggerTime": "2020-02-20 00:00:00", + "offerGuid": "str", + "provisioningState": "str", + "status": "str", + "storageInfo": { + "accountName": "str", + "location": "str", + "resourceGroup": "str", + "subscriptionId": "str", + }, + "subscriptions": ["str"], + "tenantId": "str", + }, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-06-27", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_update(self, resource_group): + response = self.client.report.begin_update( + report_name="str", + properties={ + "properties": { + "certRecords": [ + { + "certificationStatus": "str", + "controls": [{"controlId": "str", "controlStatus": "str"}], + "ingestionStatus": "str", + "offerGuid": "str", + } + ], + "complianceStatus": { + "m365": { + "failedCount": 0, + "manualCount": 0, + "notApplicableCount": 0, + "passedCount": 0, + "pendingCount": 0, + } + }, + "errors": ["str"], + "lastTriggerTime": "2020-02-20 00:00:00", + "nextTriggerTime": "2020-02-20 00:00:00", + "offerGuid": "str", + "provisioningState": "str", + "resources": [ + { + "resourceId": "str", + "accountId": "str", + "resourceKind": "str", + "resourceOrigin": "str", + "resourceType": "str", + } + ], + "status": "str", + "storageInfo": { + "accountName": "str", + "location": "str", + "resourceGroup": "str", + "subscriptionId": "str", + }, + "subscriptions": ["str"], + "tenantId": "str", + "timeZone": "str", + "triggerTime": "2020-02-20 00:00:00", + } + }, + api_version="2024-06-27", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_delete(self, resource_group): + response = self.client.report.begin_delete( + report_name="str", + api_version="2024-06-27", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_nested_resource_check_name_availability(self, resource_group): + response = self.client.report.nested_resource_check_name_availability( + report_name="str", + body={"name": "str", "type": "str"}, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_fix(self, resource_group): + response = self.client.report.begin_fix( + report_name="str", + api_version="2024-06-27", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get_scoping_questions(self, resource_group): + response = self.client.report.get_scoping_questions( + report_name="str", + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_sync_cert_record(self, resource_group): + response = self.client.report.begin_sync_cert_record( + report_name="str", + body={ + "certRecord": { + "certificationStatus": "str", + "controls": [{"controlId": "str", "controlStatus": "str"}], + "ingestionStatus": "str", + "offerGuid": "str", + } + }, + api_version="2024-06-27", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_verify(self, resource_group): + response = self.client.report.begin_verify( + report_name="str", + api_version="2024-06-27", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_report_operations_async.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_report_operations_async.py new file mode 100644 index 000000000000..2eba9edbd888 --- /dev/null +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_report_operations_async.py @@ -0,0 +1,253 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appcomplianceautomation.aio import AppComplianceAutomationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppComplianceAutomationMgmtReportOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppComplianceAutomationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.report.list( + api_version="2024-06-27", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.report.get( + report_name="str", + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_create_or_update(self, resource_group): + response = await ( + await self.client.report.begin_create_or_update( + report_name="str", + resource={ + "properties": { + "resources": [ + { + "resourceId": "str", + "accountId": "str", + "resourceKind": "str", + "resourceOrigin": "str", + "resourceType": "str", + } + ], + "timeZone": "str", + "triggerTime": "2020-02-20 00:00:00", + "certRecords": [ + { + "certificationStatus": "str", + "controls": [{"controlId": "str", "controlStatus": "str"}], + "ingestionStatus": "str", + "offerGuid": "str", + } + ], + "complianceStatus": { + "m365": { + "failedCount": 0, + "manualCount": 0, + "notApplicableCount": 0, + "passedCount": 0, + "pendingCount": 0, + } + }, + "errors": ["str"], + "lastTriggerTime": "2020-02-20 00:00:00", + "nextTriggerTime": "2020-02-20 00:00:00", + "offerGuid": "str", + "provisioningState": "str", + "status": "str", + "storageInfo": { + "accountName": "str", + "location": "str", + "resourceGroup": "str", + "subscriptionId": "str", + }, + "subscriptions": ["str"], + "tenantId": "str", + }, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-06-27", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_update(self, resource_group): + response = await ( + await self.client.report.begin_update( + report_name="str", + properties={ + "properties": { + "certRecords": [ + { + "certificationStatus": "str", + "controls": [{"controlId": "str", "controlStatus": "str"}], + "ingestionStatus": "str", + "offerGuid": "str", + } + ], + "complianceStatus": { + "m365": { + "failedCount": 0, + "manualCount": 0, + "notApplicableCount": 0, + "passedCount": 0, + "pendingCount": 0, + } + }, + "errors": ["str"], + "lastTriggerTime": "2020-02-20 00:00:00", + "nextTriggerTime": "2020-02-20 00:00:00", + "offerGuid": "str", + "provisioningState": "str", + "resources": [ + { + "resourceId": "str", + "accountId": "str", + "resourceKind": "str", + "resourceOrigin": "str", + "resourceType": "str", + } + ], + "status": "str", + "storageInfo": { + "accountName": "str", + "location": "str", + "resourceGroup": "str", + "subscriptionId": "str", + }, + "subscriptions": ["str"], + "tenantId": "str", + "timeZone": "str", + "triggerTime": "2020-02-20 00:00:00", + } + }, + api_version="2024-06-27", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_delete(self, resource_group): + response = await ( + await self.client.report.begin_delete( + report_name="str", + api_version="2024-06-27", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_nested_resource_check_name_availability(self, resource_group): + response = await self.client.report.nested_resource_check_name_availability( + report_name="str", + body={"name": "str", "type": "str"}, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_fix(self, resource_group): + response = await ( + await self.client.report.begin_fix( + report_name="str", + api_version="2024-06-27", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get_scoping_questions(self, resource_group): + response = await self.client.report.get_scoping_questions( + report_name="str", + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_sync_cert_record(self, resource_group): + response = await ( + await self.client.report.begin_sync_cert_record( + report_name="str", + body={ + "certRecord": { + "certificationStatus": "str", + "controls": [{"controlId": "str", "controlStatus": "str"}], + "ingestionStatus": "str", + "offerGuid": "str", + } + }, + api_version="2024-06-27", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_verify(self, resource_group): + response = await ( + await self.client.report.begin_verify( + report_name="str", + api_version="2024-06-27", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_scoping_configuration_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_scoping_configuration_operations.py new file mode 100644 index 000000000000..11481e08ef0d --- /dev/null +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_scoping_configuration_operations.py @@ -0,0 +1,80 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppComplianceAutomationMgmtScopingConfigurationOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppComplianceAutomationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.scoping_configuration.list( + report_name="str", + api_version="2024-06-27", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.scoping_configuration.get( + report_name="str", + scoping_configuration_name="str", + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.scoping_configuration.create_or_update( + report_name="str", + scoping_configuration_name="str", + resource={ + "properties": {"answers": [{"answers": ["str"], "questionId": "str"}], "provisioningState": "str"}, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.scoping_configuration.delete( + report_name="str", + scoping_configuration_name="str", + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_scoping_configuration_operations_async.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_scoping_configuration_operations_async.py new file mode 100644 index 000000000000..ba7c119aea9d --- /dev/null +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_scoping_configuration_operations_async.py @@ -0,0 +1,81 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appcomplianceautomation.aio import AppComplianceAutomationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppComplianceAutomationMgmtScopingConfigurationOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppComplianceAutomationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.scoping_configuration.list( + report_name="str", + api_version="2024-06-27", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.scoping_configuration.get( + report_name="str", + scoping_configuration_name="str", + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.scoping_configuration.create_or_update( + report_name="str", + scoping_configuration_name="str", + resource={ + "properties": {"answers": [{"answers": ["str"], "questionId": "str"}], "provisioningState": "str"}, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.scoping_configuration.delete( + report_name="str", + scoping_configuration_name="str", + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_snapshot_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_snapshot_operations.py new file mode 100644 index 000000000000..7b1221e31814 --- /dev/null +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_snapshot_operations.py @@ -0,0 +1,55 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppComplianceAutomationMgmtSnapshotOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppComplianceAutomationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.snapshot.list( + report_name="str", + api_version="2024-06-27", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.snapshot.get( + report_name="str", + snapshot_name="str", + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_begin_download(self, resource_group): + response = self.client.snapshot.begin_download( + report_name="str", + snapshot_name="str", + body={"downloadType": "str", "offerGuid": "str", "reportCreatorTenantId": "str"}, + api_version="2024-06-27", + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_snapshot_operations_async.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_snapshot_operations_async.py new file mode 100644 index 000000000000..5f9a045a5b6e --- /dev/null +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_snapshot_operations_async.py @@ -0,0 +1,58 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appcomplianceautomation.aio import AppComplianceAutomationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppComplianceAutomationMgmtSnapshotOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppComplianceAutomationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.snapshot.list( + report_name="str", + api_version="2024-06-27", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.snapshot.get( + report_name="str", + snapshot_name="str", + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_begin_download(self, resource_group): + response = await ( + await self.client.snapshot.begin_download( + report_name="str", + snapshot_name="str", + body={"downloadType": "str", "offerGuid": "str", "reportCreatorTenantId": "str"}, + api_version="2024-06-27", + ) + ).result() # call '.result()' to poll until service return final result + + # please add some check logic here by yourself + # ... diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_webhook_operations.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_webhook_operations.py new file mode 100644 index 000000000000..a91d05dea302 --- /dev/null +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_webhook_operations.py @@ -0,0 +1,123 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appcomplianceautomation import AppComplianceAutomationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer, recorded_by_proxy + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppComplianceAutomationMgmtWebhookOperations(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppComplianceAutomationMgmtClient) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_list(self, resource_group): + response = self.client.webhook.list( + report_name="str", + api_version="2024-06-27", + ) + result = [r for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_get(self, resource_group): + response = self.client.webhook.get( + report_name="str", + webhook_name="str", + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_create_or_update(self, resource_group): + response = self.client.webhook.create_or_update( + report_name="str", + webhook_name="str", + resource={ + "properties": { + "contentType": "str", + "deliveryStatus": "str", + "enableSslVerification": "str", + "events": ["str"], + "payloadUrl": "str", + "provisioningState": "str", + "sendAllEvents": "str", + "status": "str", + "tenantId": "str", + "updateWebhookKey": "str", + "webhookId": "str", + "webhookKey": "str", + "webhookKeyEnabled": "str", + }, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_update(self, resource_group): + response = self.client.webhook.update( + report_name="str", + webhook_name="str", + properties={ + "properties": { + "contentType": "str", + "deliveryStatus": "str", + "enableSslVerification": "str", + "events": ["str"], + "payloadUrl": "str", + "provisioningState": "str", + "sendAllEvents": "str", + "status": "str", + "tenantId": "str", + "updateWebhookKey": "str", + "webhookId": "str", + "webhookKey": "str", + "webhookKeyEnabled": "str", + } + }, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy + def test_delete(self, resource_group): + response = self.client.webhook.delete( + report_name="str", + webhook_name="str", + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_webhook_operations_async.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_webhook_operations_async.py new file mode 100644 index 000000000000..07e321e785f2 --- /dev/null +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/generated_tests/test_app_compliance_automation_mgmt_webhook_operations_async.py @@ -0,0 +1,124 @@ +# 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) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import pytest +from azure.mgmt.appcomplianceautomation.aio import AppComplianceAutomationMgmtClient + +from devtools_testutils import AzureMgmtRecordedTestCase, RandomNameResourceGroupPreparer +from devtools_testutils.aio import recorded_by_proxy_async + +AZURE_LOCATION = "eastus" + + +@pytest.mark.skip("you may need to update the auto-generated test case before run it") +class TestAppComplianceAutomationMgmtWebhookOperationsAsync(AzureMgmtRecordedTestCase): + def setup_method(self, method): + self.client = self.create_mgmt_client(AppComplianceAutomationMgmtClient, is_async=True) + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_list(self, resource_group): + response = self.client.webhook.list( + report_name="str", + api_version="2024-06-27", + ) + result = [r async for r in response] + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_get(self, resource_group): + response = await self.client.webhook.get( + report_name="str", + webhook_name="str", + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_create_or_update(self, resource_group): + response = await self.client.webhook.create_or_update( + report_name="str", + webhook_name="str", + resource={ + "properties": { + "contentType": "str", + "deliveryStatus": "str", + "enableSslVerification": "str", + "events": ["str"], + "payloadUrl": "str", + "provisioningState": "str", + "sendAllEvents": "str", + "status": "str", + "tenantId": "str", + "updateWebhookKey": "str", + "webhookId": "str", + "webhookKey": "str", + "webhookKeyEnabled": "str", + }, + "id": "str", + "name": "str", + "systemData": { + "createdAt": "2020-02-20 00:00:00", + "createdBy": "str", + "createdByType": "str", + "lastModifiedAt": "2020-02-20 00:00:00", + "lastModifiedBy": "str", + "lastModifiedByType": "str", + }, + "type": "str", + }, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_update(self, resource_group): + response = await self.client.webhook.update( + report_name="str", + webhook_name="str", + properties={ + "properties": { + "contentType": "str", + "deliveryStatus": "str", + "enableSslVerification": "str", + "events": ["str"], + "payloadUrl": "str", + "provisioningState": "str", + "sendAllEvents": "str", + "status": "str", + "tenantId": "str", + "updateWebhookKey": "str", + "webhookId": "str", + "webhookKey": "str", + "webhookKeyEnabled": "str", + } + }, + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... + + @RandomNameResourceGroupPreparer(location=AZURE_LOCATION) + @recorded_by_proxy_async + async def test_delete(self, resource_group): + response = await self.client.webhook.delete( + report_name="str", + webhook_name="str", + api_version="2024-06-27", + ) + + # please add some check logic here by yourself + # ... diff --git a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/setup.py b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/setup.py index 4cb815f9aa9a..9953ab017fb2 100644 --- a/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/setup.py +++ b/sdk/appcomplianceautomation/azure-mgmt-appcomplianceautomation/setup.py @@ -75,6 +75,7 @@ }, install_requires=[ "isodate>=0.6.1", + "typing-extensions>=4.6.0", "azure-common>=1.1", "azure-mgmt-core>=1.3.2", ],