diff --git a/sdk/advisor/azure-mgmt-advisor/MANIFEST.in b/sdk/advisor/azure-mgmt-advisor/MANIFEST.in index a3cb07df8765..3a9b6517412b 100644 --- a/sdk/advisor/azure-mgmt-advisor/MANIFEST.in +++ b/sdk/advisor/azure-mgmt-advisor/MANIFEST.in @@ -1,3 +1,4 @@ +include _meta.json recursive-include tests *.py *.yaml include *.md include azure/__init__.py diff --git a/sdk/advisor/azure-mgmt-advisor/_meta.json b/sdk/advisor/azure-mgmt-advisor/_meta.json new file mode 100644 index 000000000000..d13136e7698f --- /dev/null +++ b/sdk/advisor/azure-mgmt-advisor/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.4.2", + "use": [ + "@autorest/python@5.8.1", + "@autorest/modelerfour@4.19.2" + ], + "commit": "532e2ea87d651e2888ffa86dc3a5ec7402c4d393", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/advisor/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.1 --use=@autorest/modelerfour@4.19.2 --version=3.4.2", + "readme": "specification/advisor/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/_advisor_management_client.py b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/_advisor_management_client.py index 3247b8cc1418..2c59c36f1908 100644 --- a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/_advisor_management_client.py +++ b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/_advisor_management_client.py @@ -16,6 +16,7 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential + from azure.core.pipeline.transport import HttpRequest, HttpResponse from ._configuration import AdvisorManagementClientConfiguration from .operations import RecommendationMetadataOperations @@ -75,6 +76,24 @@ def __init__( self.suppressions = SuppressionsOperations( self._client, self._config, self._serialize, self._deserialize) + def _send_request(self, http_request, **kwargs): + # type: (HttpRequest, Any) -> HttpResponse + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.HttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + def close(self): # type: () -> None self._client.close() diff --git a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/_metadata.json b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/_metadata.json new file mode 100644 index 000000000000..8353ac0fc576 --- /dev/null +++ b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/_metadata.json @@ -0,0 +1,107 @@ +{ + "chosen_version": "2020-01-01", + "total_api_version_list": ["2020-01-01"], + "client": { + "name": "AdvisorManagementClient", + "filename": "_advisor_management_client", + "description": "REST APIs for Azure Advisor.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AdvisorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AdvisorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The Azure subscription ID.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The Azure subscription ID.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_default_policy_type": "BearerTokenCredentialPolicy", + "credential_default_policy_type_has_async_version": true, + "credential_key_header_name": null, + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "recommendation_metadata": "RecommendationMetadataOperations", + "configurations": "ConfigurationsOperations", + "recommendations": "RecommendationsOperations", + "operations": "Operations", + "suppressions": "SuppressionsOperations" + } +} \ No newline at end of file diff --git a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/_version.py b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/_version.py index b77ac9246082..6dddc002d43d 100644 --- a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/_version.py +++ b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "9.0.0" +VERSION = "9.0.0b1" diff --git a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/_advisor_management_client.py b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/_advisor_management_client.py index e3ec1109e996..5a5554a489f8 100644 --- a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/_advisor_management_client.py +++ b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/_advisor_management_client.py @@ -8,6 +8,7 @@ from typing import Any, Optional, TYPE_CHECKING +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer @@ -72,6 +73,23 @@ def __init__( self.suppressions = SuppressionsOperations( self._client, self._config, self._serialize, self._deserialize) + async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response + async def close(self) -> None: await self._client.close() diff --git a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_configurations_operations.py b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_configurations_operations.py index 67e44455c615..cdbd9d037451 100644 --- a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_configurations_operations.py +++ b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_configurations_operations.py @@ -43,7 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: def list_by_subscription( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ConfigurationListResult"]: """Retrieve Azure Advisor configurations. @@ -100,7 +100,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ArmErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -115,7 +115,7 @@ async def create_in_subscription( self, configuration_name: Union[str, "_models.ConfigurationName"], config_contract: "_models.ConfigData", - **kwargs + **kwargs: Any ) -> "_models.ConfigData": """Create/Overwrite Azure Advisor configuration. @@ -166,7 +166,7 @@ async def create_in_subscription( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ArmErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigData', pipeline_response) @@ -180,7 +180,7 @@ async def create_in_subscription( def list_by_resource_group( self, resource_group: str, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ConfigurationListResult"]: """Retrieve Azure Advisor configurations. @@ -239,7 +239,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ArmErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -255,7 +255,7 @@ async def create_in_resource_group( configuration_name: Union[str, "_models.ConfigurationName"], resource_group: str, config_contract: "_models.ConfigData", - **kwargs + **kwargs: Any ) -> "_models.ConfigData": """Create/Overwrite Azure Advisor configuration. @@ -308,7 +308,7 @@ async def create_in_resource_group( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ArmErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigData', pipeline_response) diff --git a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_operations.py b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_operations.py index 3fe50c593ca2..7e6b62b9f384 100644 --- a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_operations.py +++ b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_operations.py @@ -43,7 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.OperationEntityListResult"]: """Lists all the available Advisor REST API operations. @@ -93,8 +93,9 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_recommendation_metadata_operations.py b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_recommendation_metadata_operations.py index d27f76a07f7c..b95d86ac0e4e 100644 --- a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_recommendation_metadata_operations.py +++ b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_recommendation_metadata_operations.py @@ -5,7 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -44,8 +44,8 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get( self, name: str, - **kwargs - ) -> Union["_models.MetadataEntity", "_models.ARMErrorResponseBody"]: + **kwargs: Any + ) -> "_models.MetadataEntity": """Gets the metadata entity. Gets the metadata entity. @@ -53,13 +53,15 @@ async def get( :param name: Name of metadata entity. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetadataEntity or ARMErrorResponseBody, or the result of cls(response) - :rtype: ~azure.mgmt.advisor.models.MetadataEntity or ~azure.mgmt.advisor.models.ARMErrorResponseBody + :return: MetadataEntity, or the result of cls(response) + :rtype: ~azure.mgmt.advisor.models.MetadataEntity :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.MetadataEntity", "_models.ARMErrorResponseBody"]] + cls = kwargs.pop('cls', None) # type: ClsType["_models.MetadataEntity"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.ARMErrorResponseBody, response), error_format=ARMErrorFormat), } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-01-01" @@ -84,15 +86,12 @@ async def get( pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('MetadataEntity', pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 404: - deserialized = self._deserialize('ARMErrorResponseBody', pipeline_response) + deserialized = self._deserialize('MetadataEntity', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -102,7 +101,7 @@ async def get( def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.MetadataEntityListResult"]: """Gets the list of metadata entities. @@ -154,8 +153,9 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_recommendations_operations.py b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_recommendations_operations.py index 2f99233dc3f7..05ccfd222e31 100644 --- a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_recommendations_operations.py +++ b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_recommendations_operations.py @@ -43,7 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def generate( self, - **kwargs + **kwargs: Any ) -> None: """Initiates the recommendation generation or computation process for a subscription. This operation is asynchronous. The generated recommendations are stored in a cache in the Advisor @@ -60,6 +60,7 @@ async def generate( } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-01-01" + accept = "application/json" # Construct URL url = self.generate.metadata['url'] # type: ignore @@ -74,6 +75,7 @@ async def generate( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) @@ -81,7 +83,8 @@ async def generate( if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['Location']=self._deserialize('str', response.headers.get('Location')) @@ -95,7 +98,7 @@ async def generate( async def get_generate_status( self, operation_id: str, - **kwargs + **kwargs: Any ) -> None: """Retrieves the status of the recommendation computation or generation process. Invoke this API after calling the generation recommendation. The URI of this API is returned in the Location @@ -115,6 +118,7 @@ async def get_generate_status( } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-01-01" + accept = "application/json" # Construct URL url = self.get_generate_status.metadata['url'] # type: ignore @@ -130,6 +134,7 @@ async def get_generate_status( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) @@ -137,7 +142,8 @@ async def get_generate_status( if response.status_code not in [202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) @@ -149,7 +155,7 @@ def list( filter: Optional[str] = None, top: Optional[int] = None, skip_token: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.ResourceRecommendationBaseListResult"]: """Obtains cached recommendations for a subscription. The recommendations are generated or computed by invoking generateRecommendations. @@ -220,8 +226,9 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -234,7 +241,7 @@ async def get( self, resource_uri: str, recommendation_id: str, - **kwargs + **kwargs: Any ) -> "_models.ResourceRecommendationBase": """Obtains details of a cached recommendation. @@ -278,7 +285,8 @@ async def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ResourceRecommendationBase', pipeline_response) diff --git a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_suppressions_operations.py b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_suppressions_operations.py index 99073a34d763..cde4da193628 100644 --- a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_suppressions_operations.py +++ b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/aio/operations/_suppressions_operations.py @@ -5,7 +5,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -46,8 +46,8 @@ async def get( resource_uri: str, recommendation_id: str, name: str, - **kwargs - ) -> Union["_models.SuppressionContract", "_models.ArmErrorResponse"]: + **kwargs: Any + ) -> "_models.SuppressionContract": """Obtains the details of a suppression. :param resource_uri: The fully qualified Azure Resource Manager identifier of the resource to @@ -58,13 +58,15 @@ async def get( :param name: The name of the suppression. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SuppressionContract or ArmErrorResponse, or the result of cls(response) - :rtype: ~azure.mgmt.advisor.models.SuppressionContract or ~azure.mgmt.advisor.models.ArmErrorResponse + :return: SuppressionContract, or the result of cls(response) + :rtype: ~azure.mgmt.advisor.models.SuppressionContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.SuppressionContract", "_models.ArmErrorResponse"]] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SuppressionContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.ArmErrorResponse, response), error_format=ARMErrorFormat), } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-01-01" @@ -91,15 +93,12 @@ async def get( pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('SuppressionContract', pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 404: - deserialized = self._deserialize('ArmErrorResponse', pipeline_response) + deserialized = self._deserialize('SuppressionContract', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -113,8 +112,8 @@ async def create( recommendation_id: str, name: str, suppression_contract: "_models.SuppressionContract", - **kwargs - ) -> Union["_models.SuppressionContract", "_models.ArmErrorResponse"]: + **kwargs: Any + ) -> "_models.SuppressionContract": """Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation. @@ -130,13 +129,15 @@ async def create( duration. :type suppression_contract: ~azure.mgmt.advisor.models.SuppressionContract :keyword callable cls: A custom type or function that will be passed the direct response - :return: SuppressionContract or ArmErrorResponse, or the result of cls(response) - :rtype: ~azure.mgmt.advisor.models.SuppressionContract or ~azure.mgmt.advisor.models.ArmErrorResponse + :return: SuppressionContract, or the result of cls(response) + :rtype: ~azure.mgmt.advisor.models.SuppressionContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.SuppressionContract", "_models.ArmErrorResponse"]] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SuppressionContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.ArmErrorResponse, response), error_format=ARMErrorFormat), } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-01-01" @@ -168,15 +169,12 @@ async def create( pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize('SuppressionContract', pipeline_response) - - if response.status_code == 404: - deserialized = self._deserialize('ArmErrorResponse', pipeline_response) + deserialized = self._deserialize('SuppressionContract', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -189,7 +187,7 @@ async def delete( resource_uri: str, recommendation_id: str, name: str, - **kwargs + **kwargs: Any ) -> None: """Enables the activation of a snoozed or dismissed recommendation. The snoozed or dismissed attribute of a recommendation is referred to as a suppression. @@ -212,6 +210,7 @@ async def delete( } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-01-01" + accept = "application/json" # Construct URL url = self.delete.metadata['url'] # type: ignore @@ -228,6 +227,7 @@ async def delete( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) @@ -235,7 +235,8 @@ async def delete( if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) @@ -246,7 +247,7 @@ def list( self, top: Optional[int] = None, skip_token: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.SuppressionContractListResult"]: """Retrieves the list of snoozed or dismissed suppressions for a subscription. The snoozed or dismissed attribute of a recommendation is referred to as a suppression. @@ -309,8 +310,9 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/models/_models.py b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/models/_models.py index c61d143176dd..15d25393d982 100644 --- a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/models/_models.py +++ b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/models/_models.py @@ -375,11 +375,20 @@ class ResourceMetadata(msrest.serialization.Model): :type resource_id: str :param source: Source from which recommendation is generated. :type source: str + :param action: The action to view resource. + :type action: dict[str, any] + :param singular: The singular user friendly name of resource type. eg: virtual machine. + :type singular: str + :param plural: The plural user friendly name of resource type. eg: virtual machines. + :type plural: str """ _attribute_map = { 'resource_id': {'key': 'resourceId', 'type': 'str'}, 'source': {'key': 'source', 'type': 'str'}, + 'action': {'key': 'action', 'type': '{object}'}, + 'singular': {'key': 'singular', 'type': 'str'}, + 'plural': {'key': 'plural', 'type': 'str'}, } def __init__( @@ -389,6 +398,9 @@ def __init__( super(ResourceMetadata, self).__init__(**kwargs) self.resource_id = kwargs.get('resource_id', None) self.source = kwargs.get('source', None) + self.action = kwargs.get('action', None) + self.singular = kwargs.get('singular', None) + self.plural = kwargs.get('plural', None) class ResourceRecommendationBase(Resource): @@ -416,7 +428,7 @@ class ResourceRecommendationBase(Resource): recommendation. :type last_updated: ~datetime.datetime :param metadata: The recommendation metadata. - :type metadata: dict[str, object] + :type metadata: dict[str, any] :param recommendation_type_id: The recommendation-type GUID. :type recommendation_type_id: str :param risk: The potential risk of not implementing the recommendation. Possible values @@ -430,6 +442,21 @@ class ResourceRecommendationBase(Resource): :type extended_properties: dict[str, str] :param resource_metadata: Metadata of resource that was assessed. :type resource_metadata: ~azure.mgmt.advisor.models.ResourceMetadata + :param description: The detailed description of recommendation. + :type description: str + :param label: The label of recommendation. + :type label: str + :param learn_more_link: The link to learn more about recommendation and generation logic. + :type learn_more_link: str + :param potential_benefits: The potential benefit of implementing recommendation. + :type potential_benefits: str + :param actions: The list of recommended actions to implement recommendation. + :type actions: list[dict[str, any]] + :param remediation: The automated way to apply recommendation. + :type remediation: dict[str, any] + :param exposed_metadata_properties: The recommendation metadata properties exposed to customer + to provide additional information. + :type exposed_metadata_properties: dict[str, any] """ _validation = { @@ -454,6 +481,13 @@ class ResourceRecommendationBase(Resource): 'suppression_ids': {'key': 'properties.suppressionIds', 'type': '[str]'}, 'extended_properties': {'key': 'properties.extendedProperties', 'type': '{str}'}, 'resource_metadata': {'key': 'properties.resourceMetadata', 'type': 'ResourceMetadata'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'label': {'key': 'properties.label', 'type': 'str'}, + 'learn_more_link': {'key': 'properties.learnMoreLink', 'type': 'str'}, + 'potential_benefits': {'key': 'properties.potentialBenefits', 'type': 'str'}, + 'actions': {'key': 'properties.actions', 'type': '[{object}]'}, + 'remediation': {'key': 'properties.remediation', 'type': '{object}'}, + 'exposed_metadata_properties': {'key': 'properties.exposedMetadataProperties', 'type': '{object}'}, } def __init__( @@ -473,6 +507,13 @@ def __init__( self.suppression_ids = kwargs.get('suppression_ids', None) self.extended_properties = kwargs.get('extended_properties', None) self.resource_metadata = kwargs.get('resource_metadata', None) + self.description = kwargs.get('description', None) + self.label = kwargs.get('label', None) + self.learn_more_link = kwargs.get('learn_more_link', None) + self.potential_benefits = kwargs.get('potential_benefits', None) + self.actions = kwargs.get('actions', None) + self.remediation = kwargs.get('remediation', None) + self.exposed_metadata_properties = kwargs.get('exposed_metadata_properties', None) class ResourceRecommendationBaseListResult(msrest.serialization.Model): diff --git a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/models/_models_py3.py b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/models/_models_py3.py index 476150e82f26..3cef1a19b3d6 100644 --- a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/models/_models_py3.py +++ b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/models/_models_py3.py @@ -7,7 +7,7 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, Union from azure.core.exceptions import HttpResponseError import msrest.serialization @@ -424,11 +424,20 @@ class ResourceMetadata(msrest.serialization.Model): :type resource_id: str :param source: Source from which recommendation is generated. :type source: str + :param action: The action to view resource. + :type action: dict[str, any] + :param singular: The singular user friendly name of resource type. eg: virtual machine. + :type singular: str + :param plural: The plural user friendly name of resource type. eg: virtual machines. + :type plural: str """ _attribute_map = { 'resource_id': {'key': 'resourceId', 'type': 'str'}, 'source': {'key': 'source', 'type': 'str'}, + 'action': {'key': 'action', 'type': '{object}'}, + 'singular': {'key': 'singular', 'type': 'str'}, + 'plural': {'key': 'plural', 'type': 'str'}, } def __init__( @@ -436,11 +445,17 @@ def __init__( *, resource_id: Optional[str] = None, source: Optional[str] = None, + action: Optional[Dict[str, Any]] = None, + singular: Optional[str] = None, + plural: Optional[str] = None, **kwargs ): super(ResourceMetadata, self).__init__(**kwargs) self.resource_id = resource_id self.source = source + self.action = action + self.singular = singular + self.plural = plural class ResourceRecommendationBase(Resource): @@ -468,7 +483,7 @@ class ResourceRecommendationBase(Resource): recommendation. :type last_updated: ~datetime.datetime :param metadata: The recommendation metadata. - :type metadata: dict[str, object] + :type metadata: dict[str, any] :param recommendation_type_id: The recommendation-type GUID. :type recommendation_type_id: str :param risk: The potential risk of not implementing the recommendation. Possible values @@ -482,6 +497,21 @@ class ResourceRecommendationBase(Resource): :type extended_properties: dict[str, str] :param resource_metadata: Metadata of resource that was assessed. :type resource_metadata: ~azure.mgmt.advisor.models.ResourceMetadata + :param description: The detailed description of recommendation. + :type description: str + :param label: The label of recommendation. + :type label: str + :param learn_more_link: The link to learn more about recommendation and generation logic. + :type learn_more_link: str + :param potential_benefits: The potential benefit of implementing recommendation. + :type potential_benefits: str + :param actions: The list of recommended actions to implement recommendation. + :type actions: list[dict[str, any]] + :param remediation: The automated way to apply recommendation. + :type remediation: dict[str, any] + :param exposed_metadata_properties: The recommendation metadata properties exposed to customer + to provide additional information. + :type exposed_metadata_properties: dict[str, any] """ _validation = { @@ -506,6 +536,13 @@ class ResourceRecommendationBase(Resource): 'suppression_ids': {'key': 'properties.suppressionIds', 'type': '[str]'}, 'extended_properties': {'key': 'properties.extendedProperties', 'type': '{str}'}, 'resource_metadata': {'key': 'properties.resourceMetadata', 'type': 'ResourceMetadata'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'label': {'key': 'properties.label', 'type': 'str'}, + 'learn_more_link': {'key': 'properties.learnMoreLink', 'type': 'str'}, + 'potential_benefits': {'key': 'properties.potentialBenefits', 'type': 'str'}, + 'actions': {'key': 'properties.actions', 'type': '[{object}]'}, + 'remediation': {'key': 'properties.remediation', 'type': '{object}'}, + 'exposed_metadata_properties': {'key': 'properties.exposedMetadataProperties', 'type': '{object}'}, } def __init__( @@ -516,13 +553,20 @@ def __init__( impacted_field: Optional[str] = None, impacted_value: Optional[str] = None, last_updated: Optional[datetime.datetime] = None, - metadata: Optional[Dict[str, object]] = None, + metadata: Optional[Dict[str, Any]] = None, recommendation_type_id: Optional[str] = None, risk: Optional[Union[str, "Risk"]] = None, short_description: Optional["ShortDescription"] = None, suppression_ids: Optional[List[str]] = None, extended_properties: Optional[Dict[str, str]] = None, resource_metadata: Optional["ResourceMetadata"] = None, + description: Optional[str] = None, + label: Optional[str] = None, + learn_more_link: Optional[str] = None, + potential_benefits: Optional[str] = None, + actions: Optional[List[Dict[str, Any]]] = None, + remediation: Optional[Dict[str, Any]] = None, + exposed_metadata_properties: Optional[Dict[str, Any]] = None, **kwargs ): super(ResourceRecommendationBase, self).__init__(**kwargs) @@ -538,6 +582,13 @@ def __init__( self.suppression_ids = suppression_ids self.extended_properties = extended_properties self.resource_metadata = resource_metadata + self.description = description + self.label = label + self.learn_more_link = learn_more_link + self.potential_benefits = potential_benefits + self.actions = actions + self.remediation = remediation + self.exposed_metadata_properties = exposed_metadata_properties class ResourceRecommendationBaseListResult(msrest.serialization.Model): diff --git a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_configurations_operations.py b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_configurations_operations.py index 12a83d42a93b..75c84e7e8f34 100644 --- a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_configurations_operations.py +++ b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_configurations_operations.py @@ -105,7 +105,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ArmErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -172,7 +172,7 @@ def create_in_subscription( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ArmErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigData', pipeline_response) @@ -246,7 +246,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ArmErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -316,7 +316,7 @@ def create_in_resource_group( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ArmErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigData', pipeline_response) diff --git a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_operations.py b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_operations.py index f2745798f193..7df280dc3990 100644 --- a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_operations.py +++ b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_operations.py @@ -98,8 +98,9 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_recommendation_metadata_operations.py b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_recommendation_metadata_operations.py index aa850acf7984..bec3db4121dd 100644 --- a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_recommendation_metadata_operations.py +++ b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_recommendation_metadata_operations.py @@ -18,7 +18,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +50,7 @@ def get( name, # type: str **kwargs # type: Any ): - # type: (...) -> Union["_models.MetadataEntity", "_models.ARMErrorResponseBody"] + # type: (...) -> "_models.MetadataEntity" """Gets the metadata entity. Gets the metadata entity. @@ -58,13 +58,15 @@ def get( :param name: Name of metadata entity. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: MetadataEntity or ARMErrorResponseBody, or the result of cls(response) - :rtype: ~azure.mgmt.advisor.models.MetadataEntity or ~azure.mgmt.advisor.models.ARMErrorResponseBody + :return: MetadataEntity, or the result of cls(response) + :rtype: ~azure.mgmt.advisor.models.MetadataEntity :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.MetadataEntity", "_models.ARMErrorResponseBody"]] + cls = kwargs.pop('cls', None) # type: ClsType["_models.MetadataEntity"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.ARMErrorResponseBody, response), error_format=ARMErrorFormat), } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-01-01" @@ -89,15 +91,12 @@ def get( pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('MetadataEntity', pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 404: - deserialized = self._deserialize('ARMErrorResponseBody', pipeline_response) + deserialized = self._deserialize('MetadataEntity', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -160,8 +159,9 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_recommendations_operations.py b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_recommendations_operations.py index 13b4cf0fba58..dee5d0e803aa 100644 --- a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_recommendations_operations.py +++ b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_recommendations_operations.py @@ -65,6 +65,7 @@ def generate( } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-01-01" + accept = "application/json" # Construct URL url = self.generate.metadata['url'] # type: ignore @@ -79,6 +80,7 @@ def generate( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -86,7 +88,8 @@ def generate( if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} response_headers['Location']=self._deserialize('str', response.headers.get('Location')) @@ -121,6 +124,7 @@ def get_generate_status( } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-01-01" + accept = "application/json" # Construct URL url = self.get_generate_status.metadata['url'] # type: ignore @@ -136,6 +140,7 @@ def get_generate_status( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -143,7 +148,8 @@ def get_generate_status( if response.status_code not in [202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) @@ -227,8 +233,9 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response @@ -286,7 +293,8 @@ def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ResourceRecommendationBase', pipeline_response) diff --git a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_suppressions_operations.py b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_suppressions_operations.py index e6264f43763b..e185ae60293b 100644 --- a/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_suppressions_operations.py +++ b/sdk/advisor/azure-mgmt-advisor/azure/mgmt/advisor/operations/_suppressions_operations.py @@ -18,7 +18,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +52,7 @@ def get( name, # type: str **kwargs # type: Any ): - # type: (...) -> Union["_models.SuppressionContract", "_models.ArmErrorResponse"] + # type: (...) -> "_models.SuppressionContract" """Obtains the details of a suppression. :param resource_uri: The fully qualified Azure Resource Manager identifier of the resource to @@ -63,13 +63,15 @@ def get( :param name: The name of the suppression. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SuppressionContract or ArmErrorResponse, or the result of cls(response) - :rtype: ~azure.mgmt.advisor.models.SuppressionContract or ~azure.mgmt.advisor.models.ArmErrorResponse + :return: SuppressionContract, or the result of cls(response) + :rtype: ~azure.mgmt.advisor.models.SuppressionContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.SuppressionContract", "_models.ArmErrorResponse"]] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SuppressionContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.ArmErrorResponse, response), error_format=ARMErrorFormat), } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-01-01" @@ -96,15 +98,12 @@ def get( pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('SuppressionContract', pipeline_response) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 404: - deserialized = self._deserialize('ArmErrorResponse', pipeline_response) + deserialized = self._deserialize('SuppressionContract', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -120,7 +119,7 @@ def create( suppression_contract, # type: "_models.SuppressionContract" **kwargs # type: Any ): - # type: (...) -> Union["_models.SuppressionContract", "_models.ArmErrorResponse"] + # type: (...) -> "_models.SuppressionContract" """Enables the snoozed or dismissed attribute of a recommendation. The snoozed or dismissed attribute is referred to as a suppression. Use this API to create or update the snoozed or dismissed status of a recommendation. @@ -136,13 +135,15 @@ def create( duration. :type suppression_contract: ~azure.mgmt.advisor.models.SuppressionContract :keyword callable cls: A custom type or function that will be passed the direct response - :return: SuppressionContract or ArmErrorResponse, or the result of cls(response) - :rtype: ~azure.mgmt.advisor.models.SuppressionContract or ~azure.mgmt.advisor.models.ArmErrorResponse + :return: SuppressionContract, or the result of cls(response) + :rtype: ~azure.mgmt.advisor.models.SuppressionContract :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.SuppressionContract", "_models.ArmErrorResponse"]] + cls = kwargs.pop('cls', None) # type: ClsType["_models.SuppressionContract"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 404: lambda response: ResourceNotFoundError(response=response, model=self._deserialize(_models.ArmErrorResponse, response), error_format=ARMErrorFormat), } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-01-01" @@ -174,15 +175,12 @@ def create( pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 404]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if response.status_code == 200: - deserialized = self._deserialize('SuppressionContract', pipeline_response) - - if response.status_code == 404: - deserialized = self._deserialize('ArmErrorResponse', pipeline_response) + deserialized = self._deserialize('SuppressionContract', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) @@ -219,6 +217,7 @@ def delete( } error_map.update(kwargs.pop('error_map', {})) api_version = "2020-01-01" + accept = "application/json" # Construct URL url = self.delete.metadata['url'] # type: ignore @@ -235,6 +234,7 @@ def delete( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -242,7 +242,8 @@ def delete( if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) @@ -317,8 +318,9 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ArmErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response