Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ReleasePR azure-mgmt-advisor] add error response flag for 400 code #15523

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,15 @@ class SuppressionContract(Resource):
:type suppression_id: str
:param ttl: The duration for which the suppression is valid.
:type ttl: str
:ivar expiration_time_stamp: Gets or sets the expiration time stamp.
:vartype expiration_time_stamp: datetime
"""

_validation = {
'id': {'readonly': True},
'name': {'readonly': True},
'type': {'readonly': True},
'expiration_time_stamp': {'readonly': True},
}

_attribute_map = {
Expand All @@ -458,9 +461,11 @@ class SuppressionContract(Resource):
'type': {'key': 'type', 'type': 'str'},
'suppression_id': {'key': 'properties.suppressionId', 'type': 'str'},
'ttl': {'key': 'properties.ttl', 'type': 'str'},
'expiration_time_stamp': {'key': 'properties.expirationTimeStamp', 'type': 'iso-8601'},
}

def __init__(self, **kwargs):
super(SuppressionContract, self).__init__(**kwargs)
self.suppression_id = kwargs.get('suppression_id', None)
self.ttl = kwargs.get('ttl', None)
self.expiration_time_stamp = None
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,15 @@ class SuppressionContract(Resource):
:type suppression_id: str
:param ttl: The duration for which the suppression is valid.
:type ttl: str
:ivar expiration_time_stamp: Gets or sets the expiration time stamp.
:vartype expiration_time_stamp: datetime
"""

_validation = {
'id': {'readonly': True},
'name': {'readonly': True},
'type': {'readonly': True},
'expiration_time_stamp': {'readonly': True},
}

_attribute_map = {
Expand All @@ -458,9 +461,11 @@ class SuppressionContract(Resource):
'type': {'key': 'type', 'type': 'str'},
'suppression_id': {'key': 'properties.suppressionId', 'type': 'str'},
'ttl': {'key': 'properties.ttl', 'type': 'str'},
'expiration_time_stamp': {'key': 'properties.expirationTimeStamp', 'type': 'iso-8601'},
}

def __init__(self, *, suppression_id: str=None, ttl: str=None, **kwargs) -> None:
super(SuppressionContract, self).__init__(**kwargs)
self.suppression_id = suppression_id
self.ttl = ttl
self.expiration_time_stamp = None
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ def list(
"""Obtains cached recommendations for a subscription. The recommendations
are generated or computed by invoking generateRecommendations.

:param filter: The filter to apply to the recommendations.
:param filter: The filter to apply to the recommendations.<br>Filter
can be applied to properties ['ResourceId', 'ResourceGroup',
'RecommendationTypeGuid', '[Category](#category)'] with operators
['eq', 'and', 'or'].<br>Example:<br>- $filter=Category eq 'Cost' and
ResourceGroup eq 'MyResourceGroup'
:type filter: str
:param top: The number of recommendations per page if a paged version
of this API is being used.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,8 @@ def get(
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:return: SuppressionContract or ClientRawResponse if raw=true
:rtype: ~azure.mgmt.advisor.models.SuppressionContract or
~msrest.pipeline.ClientRawResponse
:return: object or ClientRawResponse if raw=true
:rtype: object or ~msrest.pipeline.ClientRawResponse
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
"""
# Construct URL
Expand Down Expand Up @@ -87,14 +86,16 @@ def get(
request = self._client.get(url, query_parameters, header_parameters)
response = self._client.send(request, stream=False, **operation_config)

if response.status_code not in [200]:
if response.status_code not in [200, 404]:
exp = CloudError(response)
exp.request_id = response.headers.get('x-ms-request-id')
raise exp

deserialized = None
if response.status_code == 200:
deserialized = self._deserialize('SuppressionContract', response)
if response.status_code == 404:
deserialized = self._deserialize('ARMErrorResponseBody', response)

if raw:
client_raw_response = ClientRawResponse(deserialized, response)
Expand Down