Skip to content

Commit

Permalink
CodeGen from PR 14396 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
add error response flag (Azure#14396)
  • Loading branch information
SDKAuto committed May 14, 2021
1 parent 9d8c393 commit ab39f93
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 59 deletions.
1 change: 1 addition & 0 deletions sdk/advisor/azure-mgmt-advisor/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include _meta.json
recursive-include tests *.py *.yaml
include *.md
include azure/__init__.py
Expand Down
8 changes: 8 additions & 0 deletions sdk/advisor/azure-mgmt-advisor/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"autorest": "V2",
"use": "@microsoft.azure/autorest.python@~4.0.71",
"commit": "6bc4561be16f8d7d8a8479617400f3b3600b07f0",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"autorest_command": "autorest specification/advisor/resource-manager/readme.md --keep-version-file --multiapi --no-async --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --use=@microsoft.azure/autorest.python@~4.0.71 --version=V2",
"readme": "specification/advisor/resource-manager/readme.md"
}
Original file line number Diff line number Diff line change
Expand Up @@ -310,17 +310,31 @@ class ResourceMetadata(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, object]
: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__(self, **kwargs):
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):
Expand Down Expand Up @@ -365,6 +379,24 @@ 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, object]]
:param remediation: The automated way to apply recommendation.
:type remediation: dict[str, object]
:param exposed_metadata_properties: The recommendation metadata properties
exposed to customer to provide additional information.
:type exposed_metadata_properties: dict[str, object]
"""

_validation = {
Expand All @@ -389,6 +421,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__(self, **kwargs):
Expand All @@ -405,6 +444,13 @@ def __init__(self, **kwargs):
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 ShortDescription(Model):
Expand Down Expand Up @@ -444,12 +490,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 +507,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 @@ -310,17 +310,31 @@ class ResourceMetadata(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, object]
: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__(self, *, resource_id: str=None, source: str=None, **kwargs) -> None:
def __init__(self, *, resource_id: str=None, source: str=None, action=None, singular: str=None, plural: str=None, **kwargs) -> None:
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):
Expand Down Expand Up @@ -365,6 +379,24 @@ 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, object]]
:param remediation: The automated way to apply recommendation.
:type remediation: dict[str, object]
:param exposed_metadata_properties: The recommendation metadata properties
exposed to customer to provide additional information.
:type exposed_metadata_properties: dict[str, object]
"""

_validation = {
Expand All @@ -389,9 +421,16 @@ 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__(self, *, category=None, impact=None, impacted_field: str=None, impacted_value: str=None, last_updated=None, metadata=None, recommendation_type_id: str=None, risk=None, short_description=None, suppression_ids=None, extended_properties=None, resource_metadata=None, **kwargs) -> None:
def __init__(self, *, category=None, impact=None, impacted_field: str=None, impacted_value: str=None, last_updated=None, metadata=None, recommendation_type_id: str=None, risk=None, short_description=None, suppression_ids=None, extended_properties=None, resource_metadata=None, description: str=None, label: str=None, learn_more_link: str=None, potential_benefits: str=None, actions=None, remediation=None, exposed_metadata_properties=None, **kwargs) -> None:
super(ResourceRecommendationBase, self).__init__(**kwargs)
self.category = category
self.impact = impact
Expand All @@ -405,6 +444,13 @@ def __init__(self, *, category=None, impact=None, impacted_field: str=None, impa
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 ShortDescription(Model):
Expand Down Expand Up @@ -444,12 +490,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 +507,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 @@ -11,7 +11,6 @@

import uuid
from msrest.pipeline import ClientRawResponse
from msrestazure.azure_exceptions import CloudError

from .. import models

Expand Down Expand Up @@ -51,7 +50,8 @@ def list(
:return: An iterator like instance of OperationEntity
:rtype:
~azure.mgmt.advisor.models.OperationEntityPaged[~azure.mgmt.advisor.models.OperationEntity]
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
:raises:
:class:`ArmErrorResponseException<azure.mgmt.advisor.models.ArmErrorResponseException>`
"""
def prepare_request(next_link=None):
if not next_link:
Expand Down Expand Up @@ -86,9 +86,7 @@ def internal_paging(next_link=None):
response = self._client.send(request, stream=False, **operation_config)

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

return response

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

import uuid
from msrest.pipeline import ClientRawResponse
from msrestazure.azure_exceptions import CloudError

from .. import models

Expand Down Expand Up @@ -52,7 +51,8 @@ def get(
overrides<msrest:optionsforoperations>`.
:return: object or ClientRawResponse if raw=true
:rtype: object or ~msrest.pipeline.ClientRawResponse
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
:raises:
:class:`ArmErrorResponseException<azure.mgmt.advisor.models.ArmErrorResponseException>`
"""
# Construct URL
url = self.get.metadata['url']
Expand Down Expand Up @@ -80,9 +80,7 @@ def get(
response = self._client.send(request, stream=False, **operation_config)

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

deserialized = None
if response.status_code == 200:
Expand All @@ -109,7 +107,8 @@ def list(
:return: An iterator like instance of MetadataEntity
:rtype:
~azure.mgmt.advisor.models.MetadataEntityPaged[~azure.mgmt.advisor.models.MetadataEntity]
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
:raises:
:class:`ArmErrorResponseException<azure.mgmt.advisor.models.ArmErrorResponseException>`
"""
def prepare_request(next_link=None):
if not next_link:
Expand Down Expand Up @@ -144,9 +143,7 @@ def internal_paging(next_link=None):
response = self._client.send(request, stream=False, **operation_config)

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

return response

Expand Down
Loading

0 comments on commit ab39f93

Please sign in to comment.