diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/advisor_management_client.py b/azure-mgmt-advisor/azure/mgmt/advisor/advisor_management_client.py index 0b48d2c719d5..74fb1fe43136 100644 --- a/azure-mgmt-advisor/azure/mgmt/advisor/advisor_management_client.py +++ b/azure-mgmt-advisor/azure/mgmt/advisor/advisor_management_client.py @@ -9,11 +9,10 @@ # regenerated. # -------------------------------------------------------------------------- -from msrest.service_client import ServiceClient +from msrest.service_client import SDKClient from msrest import Serializer, Deserializer from msrestazure import AzureConfiguration from .version import VERSION -from .operations.configurations_operations import ConfigurationsOperations from .operations.recommendations_operations import RecommendationsOperations from .operations.operations import Operations from .operations.suppressions_operations import SuppressionsOperations @@ -52,14 +51,12 @@ def __init__( self.subscription_id = subscription_id -class AdvisorManagementClient(object): +class AdvisorManagementClient(SDKClient): """REST APIs for Azure Advisor :ivar config: Configuration for client. :vartype config: AdvisorManagementClientConfiguration - :ivar configurations: Configurations operations - :vartype configurations: azure.mgmt.advisor.operations.ConfigurationsOperations :ivar recommendations: Recommendations operations :vartype recommendations: azure.mgmt.advisor.operations.RecommendationsOperations :ivar operations: Operations operations @@ -79,15 +76,13 @@ def __init__( self, credentials, subscription_id, base_url=None): self.config = AdvisorManagementClientConfiguration(credentials, subscription_id, base_url) - self._client = ServiceClient(self.config.credentials, self.config) + super(AdvisorManagementClient, self).__init__(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} - self.api_version = '2017-04-19' + self.api_version = '2018-01-02-preview' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) - self.configurations = ConfigurationsOperations( - self._client, self.config, self._serialize, self._deserialize) self.recommendations = RecommendationsOperations( self._client, self.config, self._serialize, self._deserialize) self.operations = Operations( diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/__init__.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/__init__.py index 63972056a984..4f0d9db08490 100644 --- a/azure-mgmt-advisor/azure/mgmt/advisor/models/__init__.py +++ b/azure-mgmt-advisor/azure/mgmt/advisor/models/__init__.py @@ -9,19 +9,22 @@ # regenerated. # -------------------------------------------------------------------------- -from .config_data_properties import ConfigDataProperties -from .config_data import ConfigData -from .arm_error_response_body import ARMErrorResponseBody -from .short_description import ShortDescription -from .resource_recommendation_base import ResourceRecommendationBase -from .resource import Resource -from .operation_display_info import OperationDisplayInfo -from .operation_entity import OperationEntity -from .suppression_contract import SuppressionContract -from .config_data_paged import ConfigDataPaged +try: + from .short_description_py3 import ShortDescription + from .resource_recommendation_base_py3 import ResourceRecommendationBase + from .resource_py3 import Resource + from .operation_display_info_py3 import OperationDisplayInfo + from .operation_entity_py3 import OperationEntity + from .suppression_contract_py3 import SuppressionContract +except (SyntaxError, ImportError): + from .short_description import ShortDescription + from .resource_recommendation_base import ResourceRecommendationBase + from .resource import Resource + from .operation_display_info import OperationDisplayInfo + from .operation_entity import OperationEntity + from .suppression_contract import SuppressionContract from .resource_recommendation_base_paged import ResourceRecommendationBasePaged from .operation_entity_paged import OperationEntityPaged -from .suppression_contract_paged import SuppressionContractPaged from .advisor_management_client_enums import ( Category, Impact, @@ -29,19 +32,14 @@ ) __all__ = [ - 'ConfigDataProperties', - 'ConfigData', - 'ARMErrorResponseBody', 'ShortDescription', 'ResourceRecommendationBase', 'Resource', 'OperationDisplayInfo', 'OperationEntity', 'SuppressionContract', - 'ConfigDataPaged', 'ResourceRecommendationBasePaged', 'OperationEntityPaged', - 'SuppressionContractPaged', 'Category', 'Impact', 'Risk', diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/advisor_management_client_enums.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/advisor_management_client_enums.py index 835a92ce544d..477dbe954da5 100644 --- a/azure-mgmt-advisor/azure/mgmt/advisor/models/advisor_management_client_enums.py +++ b/azure-mgmt-advisor/azure/mgmt/advisor/models/advisor_management_client_enums.py @@ -12,7 +12,7 @@ from enum import Enum -class Category(Enum): +class Category(str, Enum): high_availability = "HighAvailability" security = "Security" @@ -20,14 +20,14 @@ class Category(Enum): cost = "Cost" -class Impact(Enum): +class Impact(str, Enum): high = "High" medium = "Medium" low = "Low" -class Risk(Enum): +class Risk(str, Enum): error = "Error" warning = "Warning" diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/arm_error_response_body.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/arm_error_response_body.py deleted file mode 100644 index 5bf889bbbd27..000000000000 --- a/azure-mgmt-advisor/azure/mgmt/advisor/models/arm_error_response_body.py +++ /dev/null @@ -1,34 +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 msrest.serialization import Model - - -class ARMErrorResponseBody(Model): - """ARM error response body. - - :param message: Gets or sets the string that describes the error in detail - and provides debugging information. - :type message: str - :param code: Gets or sets the string that can be used to programmatically - identify the error. - :type code: str - """ - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'code': {'key': 'code', 'type': 'str'}, - } - - def __init__(self, message=None, code=None): - super(ARMErrorResponseBody, self).__init__() - self.message = message - self.code = code diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/config_data.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/config_data.py deleted file mode 100644 index 3d4039cf76d6..000000000000 --- a/azure-mgmt-advisor/azure/mgmt/advisor/models/config_data.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 msrest.serialization import Model - - -class ConfigData(Model): - """The Advisor configuration data structure. - - :param id: The resource Id of the configuration resource. - :type id: str - :param type: The type of the configuration resource. - :type type: str - :param name: The name of the configuration resource. - :type name: str - :param properties: The list of property name/value pairs. - :type properties: ~azure.mgmt.advisor.models.ConfigDataProperties - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ConfigDataProperties'}, - } - - def __init__(self, id=None, type=None, name=None, properties=None): - super(ConfigData, self).__init__() - self.id = id - self.type = type - self.name = name - self.properties = properties diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/config_data_paged.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/config_data_paged.py deleted file mode 100644 index 9c35c2eaccc4..000000000000 --- a/azure-mgmt-advisor/azure/mgmt/advisor/models/config_data_paged.py +++ /dev/null @@ -1,27 +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 msrest.paging import Paged - - -class ConfigDataPaged(Paged): - """ - A paging container for iterating over a list of :class:`ConfigData ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ConfigData]'} - } - - def __init__(self, *args, **kwargs): - - super(ConfigDataPaged, self).__init__(*args, **kwargs) diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/config_data_properties.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/config_data_properties.py deleted file mode 100644 index 9e5d1e0217f8..000000000000 --- a/azure-mgmt-advisor/azure/mgmt/advisor/models/config_data_properties.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 msrest.serialization import Model - - -class ConfigDataProperties(Model): - """The list of property name/value pairs. - - :param additional_properties: Unmatched properties from the message are - deserialized this collection - :type additional_properties: dict[str, object] - :param exclude: Exclude the resource from Advisor evaluations. Valid - values: False (default) or True. - :type exclude: bool - :param low_cpu_threshold: Minimum percentage threshold for Advisor low CPU - utilization evaluation. Valid only for subscriptions. Valid values: 5 - (default), 10, 15 or 20. - :type low_cpu_threshold: str - """ - - _attribute_map = { - 'additional_properties': {'key': '', 'type': '{object}'}, - 'exclude': {'key': 'exclude', 'type': 'bool'}, - 'low_cpu_threshold': {'key': 'low_cpu_threshold', 'type': 'str'}, - } - - def __init__(self, additional_properties=None, exclude=None, low_cpu_threshold=None): - super(ConfigDataProperties, self).__init__() - self.additional_properties = additional_properties - self.exclude = exclude - self.low_cpu_threshold = low_cpu_threshold diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/operation_display_info.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/operation_display_info.py index b338bd668c8e..d4f103558727 100644 --- a/azure-mgmt-advisor/azure/mgmt/advisor/models/operation_display_info.py +++ b/azure-mgmt-advisor/azure/mgmt/advisor/models/operation_display_info.py @@ -33,9 +33,9 @@ class OperationDisplayInfo(Model): 'resource': {'key': 'resource', 'type': 'str'}, } - def __init__(self, description=None, operation=None, provider=None, resource=None): - super(OperationDisplayInfo, self).__init__() - self.description = description - self.operation = operation - self.provider = provider - self.resource = resource + def __init__(self, **kwargs): + super(OperationDisplayInfo, self).__init__(**kwargs) + self.description = kwargs.get('description', None) + self.operation = kwargs.get('operation', None) + self.provider = kwargs.get('provider', None) + self.resource = kwargs.get('resource', None) diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/operation_display_info_py3.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/operation_display_info_py3.py new file mode 100644 index 000000000000..24ca7bb48ec2 --- /dev/null +++ b/azure-mgmt-advisor/azure/mgmt/advisor/models/operation_display_info_py3.py @@ -0,0 +1,41 @@ +# 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 msrest.serialization import Model + + +class OperationDisplayInfo(Model): + """The operation supported by Advisor. + + :param description: The description of the operation. + :type description: str + :param operation: The action that users can perform, based on their + permission level. + :type operation: str + :param provider: Service provider: Microsoft Advisor. + :type provider: str + :param resource: Resource on which the operation is performed. + :type resource: str + """ + + _attribute_map = { + 'description': {'key': 'description', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + } + + def __init__(self, *, description: str=None, operation: str=None, provider: str=None, resource: str=None, **kwargs) -> None: + super(OperationDisplayInfo, self).__init__(**kwargs) + self.description = description + self.operation = operation + self.provider = provider + self.resource = resource diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/operation_entity.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/operation_entity.py index 974966de9aa6..9872949cbe52 100644 --- a/azure-mgmt-advisor/azure/mgmt/advisor/models/operation_entity.py +++ b/azure-mgmt-advisor/azure/mgmt/advisor/models/operation_entity.py @@ -26,7 +26,7 @@ class OperationEntity(Model): 'display': {'key': 'display', 'type': 'OperationDisplayInfo'}, } - def __init__(self, name=None, display=None): - super(OperationEntity, self).__init__() - self.name = name - self.display = display + def __init__(self, **kwargs): + super(OperationEntity, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display = kwargs.get('display', None) diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/operation_entity_py3.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/operation_entity_py3.py new file mode 100644 index 000000000000..24c1b1b6eb82 --- /dev/null +++ b/azure-mgmt-advisor/azure/mgmt/advisor/models/operation_entity_py3.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class OperationEntity(Model): + """The operation supported by Advisor. + + :param name: Operation name: {provider}/{resource}/{operation}. + :type name: str + :param display: The operation supported by Advisor. + :type display: ~azure.mgmt.advisor.models.OperationDisplayInfo + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplayInfo'}, + } + + def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + super(OperationEntity, self).__init__(**kwargs) + self.name = name + self.display = display diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/resource.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/resource.py index 92c78390e734..45d0d49bf815 100644 --- a/azure-mgmt-advisor/azure/mgmt/advisor/models/resource.py +++ b/azure-mgmt-advisor/azure/mgmt/advisor/models/resource.py @@ -24,6 +24,11 @@ class Resource(Model): :vartype name: str :ivar type: The type of the resource. :vartype type: str + :param location: The location of the resource. This cannot be changed + after the resource is created. + :type location: str + :param tags: The tags of the resource. + :type tags: dict[str, str] """ _validation = { @@ -36,10 +41,14 @@ class Resource(Model): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, } - def __init__(self): - super(Resource, self).__init__() + def __init__(self, **kwargs): + super(Resource, self).__init__(**kwargs) self.id = None self.name = None self.type = None + self.location = kwargs.get('location', None) + self.tags = kwargs.get('tags', None) diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/resource_py3.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/resource_py3.py new file mode 100644 index 000000000000..92554a28e38a --- /dev/null +++ b/azure-mgmt-advisor/azure/mgmt/advisor/models/resource_py3.py @@ -0,0 +1,54 @@ +# 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 msrest.serialization import Model + + +class Resource(Model): + """An Azure resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :param location: The location of the resource. This cannot be changed + after the resource is created. + :type location: str + :param tags: The tags of the resource. + :type tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__(self, *, location: str=None, tags=None, **kwargs) -> None: + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/resource_recommendation_base.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/resource_recommendation_base.py index d00353cb69c6..63496408e3de 100644 --- a/azure-mgmt-advisor/azure/mgmt/advisor/models/resource_recommendation_base.py +++ b/azure-mgmt-advisor/azure/mgmt/advisor/models/resource_recommendation_base.py @@ -9,21 +9,17 @@ # regenerated. # -------------------------------------------------------------------------- -from .resource import Resource +from msrest.serialization import Model -class ResourceRecommendationBase(Resource): +class ResourceRecommendationBase(Model): """Advisor Recommendation. - Variables are only populated by the server, and will be ignored when - sending a request. - - :ivar id: The resource ID. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. - :vartype type: str + :param id: The fully qualified recommendation ID, for example + /subscriptions/subscriptionId/resourceGroups/resourceGroup1/providers/Microsoft.ClassicCompute/virtualMachines/vm1/providers/Microsoft.Advisor/recommendations/recommendationGUID. + :type id: str + :param name: The name of recommendation. + :type name: str :param category: The category of the recommendation. Possible values include: 'HighAvailability', 'Security', 'Performance', 'Cost' :type category: str or ~azure.mgmt.advisor.models.Category @@ -49,18 +45,13 @@ class ResourceRecommendationBase(Resource): :param suppression_ids: The list of snoozed and dismissed rules for the recommendation. :type suppression_ids: list[str] + :param type: The recommendation type: Microsoft.Advisor/recommendations. + :type type: str """ - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, 'category': {'key': 'properties.category', 'type': 'str'}, 'impact': {'key': 'properties.impact', 'type': 'str'}, 'impacted_field': {'key': 'properties.impactedField', 'type': 'str'}, @@ -70,18 +61,22 @@ class ResourceRecommendationBase(Resource): 'recommendation_type_id': {'key': 'properties.recommendationTypeId', 'type': 'str'}, 'risk': {'key': 'properties.risk', 'type': 'str'}, 'short_description': {'key': 'properties.shortDescription', 'type': 'ShortDescription'}, - 'suppression_ids': {'key': 'properties.suppressionIds', 'type': '[str]'}, + 'suppression_ids': {'key': 'suppressionIds', 'type': '[str]'}, + 'type': {'key': 'type', 'type': 'str'}, } - def __init__(self, category=None, impact=None, impacted_field=None, impacted_value=None, last_updated=None, metadata=None, recommendation_type_id=None, risk=None, short_description=None, suppression_ids=None): - super(ResourceRecommendationBase, self).__init__() - self.category = category - self.impact = impact - self.impacted_field = impacted_field - self.impacted_value = impacted_value - self.last_updated = last_updated - self.metadata = metadata - self.recommendation_type_id = recommendation_type_id - self.risk = risk - self.short_description = short_description - self.suppression_ids = suppression_ids + def __init__(self, **kwargs): + super(ResourceRecommendationBase, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.name = kwargs.get('name', None) + self.category = kwargs.get('category', None) + self.impact = kwargs.get('impact', None) + self.impacted_field = kwargs.get('impacted_field', None) + self.impacted_value = kwargs.get('impacted_value', None) + self.last_updated = kwargs.get('last_updated', None) + self.metadata = kwargs.get('metadata', None) + self.recommendation_type_id = kwargs.get('recommendation_type_id', None) + self.risk = kwargs.get('risk', None) + self.short_description = kwargs.get('short_description', None) + self.suppression_ids = kwargs.get('suppression_ids', None) + self.type = kwargs.get('type', None) diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/resource_recommendation_base_py3.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/resource_recommendation_base_py3.py new file mode 100644 index 000000000000..9422dcad843f --- /dev/null +++ b/azure-mgmt-advisor/azure/mgmt/advisor/models/resource_recommendation_base_py3.py @@ -0,0 +1,82 @@ +# 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 msrest.serialization import Model + + +class ResourceRecommendationBase(Model): + """Advisor Recommendation. + + :param id: The fully qualified recommendation ID, for example + /subscriptions/subscriptionId/resourceGroups/resourceGroup1/providers/Microsoft.ClassicCompute/virtualMachines/vm1/providers/Microsoft.Advisor/recommendations/recommendationGUID. + :type id: str + :param name: The name of recommendation. + :type name: str + :param category: The category of the recommendation. Possible values + include: 'HighAvailability', 'Security', 'Performance', 'Cost' + :type category: str or ~azure.mgmt.advisor.models.Category + :param impact: The business impact of the recommendation. Possible values + include: 'High', 'Medium', 'Low' + :type impact: str or ~azure.mgmt.advisor.models.Impact + :param impacted_field: The resource type identified by Advisor. + :type impacted_field: str + :param impacted_value: The resource identified by Advisor. + :type impacted_value: str + :param last_updated: The most recent time that Advisor checked the + validity of the recommendation. + :type last_updated: datetime + :param metadata: The recommendation metadata. + :type metadata: dict[str, object] + :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 include: 'Error', 'Warning', 'None' + :type risk: str or ~azure.mgmt.advisor.models.Risk + :param short_description: A summary of the recommendation. + :type short_description: ~azure.mgmt.advisor.models.ShortDescription + :param suppression_ids: The list of snoozed and dismissed rules for the + recommendation. + :type suppression_ids: list[str] + :param type: The recommendation type: Microsoft.Advisor/recommendations. + :type type: str + """ + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'category': {'key': 'properties.category', 'type': 'str'}, + 'impact': {'key': 'properties.impact', 'type': 'str'}, + 'impacted_field': {'key': 'properties.impactedField', 'type': 'str'}, + 'impacted_value': {'key': 'properties.impactedValue', 'type': 'str'}, + 'last_updated': {'key': 'properties.lastUpdated', 'type': 'iso-8601'}, + 'metadata': {'key': 'properties.metadata', 'type': '{object}'}, + 'recommendation_type_id': {'key': 'properties.recommendationTypeId', 'type': 'str'}, + 'risk': {'key': 'properties.risk', 'type': 'str'}, + 'short_description': {'key': 'properties.shortDescription', 'type': 'ShortDescription'}, + 'suppression_ids': {'key': 'suppressionIds', 'type': '[str]'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__(self, *, id: str=None, name: str=None, 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, type: str=None, **kwargs) -> None: + super(ResourceRecommendationBase, self).__init__(**kwargs) + self.id = id + self.name = name + self.category = category + self.impact = impact + self.impacted_field = impacted_field + self.impacted_value = impacted_value + self.last_updated = last_updated + self.metadata = metadata + self.recommendation_type_id = recommendation_type_id + self.risk = risk + self.short_description = short_description + self.suppression_ids = suppression_ids + self.type = type diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/short_description.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/short_description.py index ba93541a0671..f2c722033a30 100644 --- a/azure-mgmt-advisor/azure/mgmt/advisor/models/short_description.py +++ b/azure-mgmt-advisor/azure/mgmt/advisor/models/short_description.py @@ -26,7 +26,7 @@ class ShortDescription(Model): 'solution': {'key': 'solution', 'type': 'str'}, } - def __init__(self, problem=None, solution=None): - super(ShortDescription, self).__init__() - self.problem = problem - self.solution = solution + def __init__(self, **kwargs): + super(ShortDescription, self).__init__(**kwargs) + self.problem = kwargs.get('problem', None) + self.solution = kwargs.get('solution', None) diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/short_description_py3.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/short_description_py3.py new file mode 100644 index 000000000000..ed3b7bd29aa2 --- /dev/null +++ b/azure-mgmt-advisor/azure/mgmt/advisor/models/short_description_py3.py @@ -0,0 +1,32 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class ShortDescription(Model): + """A summary of the recommendation. + + :param problem: The issue or opportunity identified by the recommendation. + :type problem: str + :param solution: The remediation action suggested by the recommendation. + :type solution: str + """ + + _attribute_map = { + 'problem': {'key': 'problem', 'type': 'str'}, + 'solution': {'key': 'solution', 'type': 'str'}, + } + + def __init__(self, *, problem: str=None, solution: str=None, **kwargs) -> None: + super(ShortDescription, self).__init__(**kwargs) + self.problem = problem + self.solution = solution diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/suppression_contract.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/suppression_contract.py index 358d6c239e36..7c5fc1043cd9 100644 --- a/azure-mgmt-advisor/azure/mgmt/advisor/models/suppression_contract.py +++ b/azure-mgmt-advisor/azure/mgmt/advisor/models/suppression_contract.py @@ -25,6 +25,11 @@ class SuppressionContract(Resource): :vartype name: str :ivar type: The type of the resource. :vartype type: str + :param location: The location of the resource. This cannot be changed + after the resource is created. + :type location: str + :param tags: The tags of the resource. + :type tags: dict[str, str] :param suppression_id: The GUID of the suppression. :type suppression_id: str :param ttl: The duration for which the suppression is valid. @@ -41,11 +46,13 @@ class SuppressionContract(Resource): 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, - 'suppression_id': {'key': 'properties.suppressionId', 'type': 'str'}, - 'ttl': {'key': 'properties.ttl', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'suppression_id': {'key': 'suppressionId', 'type': 'str'}, + 'ttl': {'key': 'ttl', 'type': 'str'}, } - def __init__(self, suppression_id=None, ttl=None): - super(SuppressionContract, self).__init__() - self.suppression_id = suppression_id - self.ttl = ttl + def __init__(self, **kwargs): + super(SuppressionContract, self).__init__(**kwargs) + self.suppression_id = kwargs.get('suppression_id', None) + self.ttl = kwargs.get('ttl', None) diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/suppression_contract_paged.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/suppression_contract_paged.py deleted file mode 100644 index 3ffc6c7f9a72..000000000000 --- a/azure-mgmt-advisor/azure/mgmt/advisor/models/suppression_contract_paged.py +++ /dev/null @@ -1,27 +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 msrest.paging import Paged - - -class SuppressionContractPaged(Paged): - """ - A paging container for iterating over a list of :class:`SuppressionContract ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[SuppressionContract]'} - } - - def __init__(self, *args, **kwargs): - - super(SuppressionContractPaged, self).__init__(*args, **kwargs) diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/models/suppression_contract_py3.py b/azure-mgmt-advisor/azure/mgmt/advisor/models/suppression_contract_py3.py new file mode 100644 index 000000000000..27636da3d219 --- /dev/null +++ b/azure-mgmt-advisor/azure/mgmt/advisor/models/suppression_contract_py3.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. +# -------------------------------------------------------------------------- + +from .resource_py3 import Resource + + +class SuppressionContract(Resource): + """The details of the snoozed or dismissed rule; for example, the duration, + name, and GUID associated with the rule. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The resource ID. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :param location: The location of the resource. This cannot be changed + after the resource is created. + :type location: str + :param tags: The tags of the resource. + :type tags: dict[str, str] + :param suppression_id: The GUID of the suppression. + :type suppression_id: str + :param ttl: The duration for which the suppression is valid. + :type ttl: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'suppression_id': {'key': 'suppressionId', 'type': 'str'}, + 'ttl': {'key': 'ttl', 'type': 'str'}, + } + + def __init__(self, *, location: str=None, tags=None, suppression_id: str=None, ttl: str=None, **kwargs) -> None: + super(SuppressionContract, self).__init__(location=location, tags=tags, **kwargs) + self.suppression_id = suppression_id + self.ttl = ttl diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/operations/__init__.py b/azure-mgmt-advisor/azure/mgmt/advisor/operations/__init__.py index 35b2918d8c2b..4443e8418732 100644 --- a/azure-mgmt-advisor/azure/mgmt/advisor/operations/__init__.py +++ b/azure-mgmt-advisor/azure/mgmt/advisor/operations/__init__.py @@ -9,13 +9,11 @@ # regenerated. # -------------------------------------------------------------------------- -from .configurations_operations import ConfigurationsOperations from .recommendations_operations import RecommendationsOperations from .operations import Operations from .suppressions_operations import SuppressionsOperations __all__ = [ - 'ConfigurationsOperations', 'RecommendationsOperations', 'Operations', 'SuppressionsOperations', diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/operations/configurations_operations.py b/azure-mgmt-advisor/azure/mgmt/advisor/operations/configurations_operations.py deleted file mode 100644 index 9a03137ea165..000000000000 --- a/azure-mgmt-advisor/azure/mgmt/advisor/operations/configurations_operations.py +++ /dev/null @@ -1,302 +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. -# -------------------------------------------------------------------------- - -import uuid -from msrest.pipeline import ClientRawResponse -from msrestazure.azure_exceptions import CloudError - -from .. import models - - -class ConfigurationsOperations(object): - """ConfigurationsOperations operations. - - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An objec model deserializer. - :ivar api_version: The version of the API to be used with the client request. Constant value: "2017-04-19". - """ - - models = models - - def __init__(self, client, config, serializer, deserializer): - - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self.api_version = "2017-04-19" - - self.config = config - - def list_by_subscription( - self, custom_headers=None, raw=False, **operation_config): - """Retrieve Azure Advisor configurations. - - Retrieve Azure Advisor configurations and also retrieve configurations - of contained resource groups. - - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ConfigData - :rtype: - ~azure.mgmt.advisor.models.ConfigDataPaged[~azure.mgmt.advisor.models.ConfigData] - :raises: :class:`CloudError` - """ - def internal_paging(next_link=None, raw=False): - - if not next_link: - # Construct URL - url = '/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/configurations' - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send( - request, header_parameters, 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 - - return response - - # Deserialize response - deserialized = models.ConfigDataPaged(internal_paging, self._deserialize.dependencies) - - if raw: - header_dict = {} - client_raw_response = models.ConfigDataPaged(internal_paging, self._deserialize.dependencies, header_dict) - return client_raw_response - - return deserialized - - def create_in_subscription( - self, config_contract, custom_headers=None, raw=False, **operation_config): - """Create/Overwrite Azure Advisor configuration. - - Create/Overwrite Azure Advisor configuration and also delete all - configurations of contained resource groups. - - :param config_contract: The Azure Advisor configuration data - structure. - :type config_contract: ~azure.mgmt.advisor.models.ConfigData - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ARMErrorResponseBody or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.advisor.models.ARMErrorResponseBody or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/configurations' - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(config_contract, 'ConfigData') - - # Construct and send request - request = self._client.put(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) - - if response.status_code not in [204, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - - if response.status_code == 400: - deserialized = self._deserialize('ARMErrorResponseBody', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized - - def list_by_resource_group( - self, resource_group, custom_headers=None, raw=False, **operation_config): - """Retrieve Azure Advisor configurations. - - :param resource_group: The name of the Azure resource group. - :type resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: An iterator like instance of ConfigData - :rtype: - ~azure.mgmt.advisor.models.ConfigDataPaged[~azure.mgmt.advisor.models.ConfigData] - :raises: :class:`CloudError` - """ - def internal_paging(next_link=None, raw=False): - - if not next_link: - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Advisor/configurations' - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'resourceGroup': self._serialize.url("resource_group", resource_group, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send( - request, header_parameters, 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 - - return response - - # Deserialize response - deserialized = models.ConfigDataPaged(internal_paging, self._deserialize.dependencies) - - if raw: - header_dict = {} - client_raw_response = models.ConfigDataPaged(internal_paging, self._deserialize.dependencies, header_dict) - return client_raw_response - - return deserialized - - def create_in_resource_group( - self, config_contract, resource_group, custom_headers=None, raw=False, **operation_config): - """Create/Overwrite Azure Advisor configuration. - - :param config_contract: The Azure Advisor configuration data - structure. - :type config_contract: ~azure.mgmt.advisor.models.ConfigData - :param resource_group: The name of the Azure resource group. - :type resource_group: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :param operation_config: :ref:`Operation configuration - overrides`. - :return: ARMErrorResponseBody or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.advisor.models.ARMErrorResponseBody or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Advisor/configurations' - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'resourceGroup': self._serialize.url("resource_group", resource_group, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct body - body_content = self._serialize.body(config_contract, 'ConfigData') - - # Construct and send request - request = self._client.put(url, query_parameters) - response = self._client.send( - request, header_parameters, body_content, stream=False, **operation_config) - - if response.status_code not in [204, 400]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - deserialized = None - - if response.status_code == 400: - deserialized = self._deserialize('ARMErrorResponseBody', response) - - if raw: - client_raw_response = ClientRawResponse(deserialized, response) - return client_raw_response - - return deserialized diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/operations/operations.py b/azure-mgmt-advisor/azure/mgmt/advisor/operations/operations.py index b1c46006013e..006beebe8ac5 100644 --- a/azure-mgmt-advisor/azure/mgmt/advisor/operations/operations.py +++ b/azure-mgmt-advisor/azure/mgmt/advisor/operations/operations.py @@ -22,8 +22,8 @@ class Operations(object): :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. - :param deserializer: An objec model deserializer. - :ivar api_version: The version of the API to be used with the client request. Constant value: "2017-04-19". + :param deserializer: An object model deserializer. + :ivar api_version: The version of the API to be used with the client request. Constant value: "2018-01-02-preview". """ models = models @@ -33,7 +33,7 @@ def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2017-04-19" + self.api_version = "2018-01-02-preview" self.config = config @@ -55,7 +55,7 @@ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL - url = '/providers/Microsoft.Advisor/operations' + url = self.list.metadata['url'] # Construct parameters query_parameters = {} @@ -96,3 +96,4 @@ def internal_paging(next_link=None, raw=False): return client_raw_response return deserialized + list.metadata = {'url': '/providers/Microsoft.Advisor/operations'} diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/operations/recommendations_operations.py b/azure-mgmt-advisor/azure/mgmt/advisor/operations/recommendations_operations.py index fc25a7a6ef45..dc33e89162c0 100644 --- a/azure-mgmt-advisor/azure/mgmt/advisor/operations/recommendations_operations.py +++ b/azure-mgmt-advisor/azure/mgmt/advisor/operations/recommendations_operations.py @@ -12,8 +12,6 @@ import uuid from msrest.pipeline import ClientRawResponse from msrestazure.azure_exceptions import CloudError -from msrest.exceptions import DeserializationError -from msrestazure.azure_operation import AzureOperationPoller from .. import models @@ -24,8 +22,8 @@ class RecommendationsOperations(object): :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. - :param deserializer: An objec model deserializer. - :ivar api_version: The version of the API to be used with the client request. Constant value: "2017-04-19". + :param deserializer: An object model deserializer. + :ivar api_version: The version of the API to be used with the client request. Constant value: "2018-01-02-preview". """ models = models @@ -35,7 +33,7 @@ def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2017-04-19" + self.api_version = "2018-01-02-preview" self.config = config @@ -55,7 +53,7 @@ def generate( :raises: :class:`CloudError` """ # Construct URL - url = '/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations' + url = self.generate.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } @@ -91,12 +89,29 @@ def generate( 'Retry-After': 'str', }) return client_raw_response + generate.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations'} - - def _get_generate_status_initial( + def get_generate_recommendations_status( self, operation_id, custom_headers=None, raw=False, **operation_config): + """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 field of the response + header. + + :param operation_id: The operation ID, which can be found from the + Location field in the generate recommendation response header. + :type operation_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ # Construct URL - url = '/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations/{operationId}' + url = self.get_generate_recommendations_status.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'operationId': self._serialize.url("operation_id", operation_id, 'str') @@ -129,66 +144,7 @@ def _get_generate_status_initial( if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response - - def get_generate_status( - self, operation_id, custom_headers=None, raw=False, **operation_config): - """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 field of the response - header. - - :param operation_id: The operation ID, which can be found from the - Location field in the generate recommendation response header. - :type operation_id: str - :param dict custom_headers: headers that will be added to the request - :param bool raw: returns the direct response alongside the - deserialized response - :return: An instance of AzureOperationPoller that returns None or - ClientRawResponse if raw=true - :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - raw_result = self._get_generate_status_initial( - operation_id=operation_id, - custom_headers=custom_headers, - raw=True, - **operation_config - ) - if raw: - return raw_result - - # Construct and send request - def long_running_send(): - return raw_result.response - - def get_long_running_status(status_link, headers=None): - - request = self._client.get(status_link) - if headers: - request.headers.update(headers) - header_parameters = {} - header_parameters['x-ms-client-request-id'] = raw_result.response.request.headers['x-ms-client-request-id'] - return self._client.send( - request, header_parameters, stream=False, **operation_config) - - def get_long_running_output(response): - - if response.status_code not in [202, 204]: - exp = CloudError(response) - exp.request_id = response.headers.get('x-ms-request-id') - raise exp - - if raw: - client_raw_response = ClientRawResponse(None, response) - return client_raw_response - - long_running_operation_timeout = operation_config.get( - 'long_running_operation_timeout', - self.config.long_running_operation_timeout) - return AzureOperationPoller( - long_running_send, get_long_running_output, - get_long_running_status, long_running_operation_timeout) + get_generate_recommendations_status.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/generateRecommendations/{operationId}'} def list( self, filter=None, top=None, skip_token=None, custom_headers=None, raw=False, **operation_config): @@ -217,7 +173,7 @@ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL - url = '/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/recommendations' + url = self.list.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } @@ -268,6 +224,7 @@ def internal_paging(next_link=None, raw=False): return client_raw_response return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/recommendations'} def get( self, resource_uri, recommendation_id, custom_headers=None, raw=False, **operation_config): @@ -289,7 +246,7 @@ def get( :raises: :class:`CloudError` """ # Construct URL - url = '/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}' + url = self.get.metadata['url'] path_format_arguments = { 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str'), 'recommendationId': self._serialize.url("recommendation_id", recommendation_id, 'str') @@ -329,3 +286,4 @@ def get( return client_raw_response return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}'} diff --git a/azure-mgmt-advisor/azure/mgmt/advisor/operations/suppressions_operations.py b/azure-mgmt-advisor/azure/mgmt/advisor/operations/suppressions_operations.py index 6c7806bc57e9..c2d5a6c623ed 100644 --- a/azure-mgmt-advisor/azure/mgmt/advisor/operations/suppressions_operations.py +++ b/azure-mgmt-advisor/azure/mgmt/advisor/operations/suppressions_operations.py @@ -22,8 +22,8 @@ class SuppressionsOperations(object): :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. - :param deserializer: An objec model deserializer. - :ivar api_version: The version of the API to be used with the client request. Constant value: "2017-04-19". + :param deserializer: An object model deserializer. + :ivar api_version: The version of the API to be used with the client request. Constant value: "2018-01-02-preview". """ models = models @@ -33,7 +33,7 @@ def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2017-04-19" + self.api_version = "2018-01-02-preview" self.config = config @@ -59,7 +59,7 @@ def get( :raises: :class:`CloudError` """ # Construct URL - url = '/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}' + url = self.get.metadata['url'] path_format_arguments = { 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str'), 'recommendationId': self._serialize.url("recommendation_id", recommendation_id, 'str'), @@ -100,9 +100,10 @@ def get( return client_raw_response return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}'} def create( - self, resource_uri, recommendation_id, name, suppression_id=None, ttl=None, custom_headers=None, raw=False, **operation_config): + self, resource_uri, recommendation_id, name, suppression_contract, custom_headers=None, raw=False, **operation_config): """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 @@ -115,10 +116,10 @@ def create( :type recommendation_id: str :param name: The name of the suppression. :type name: str - :param suppression_id: The GUID of the suppression. - :type suppression_id: str - :param ttl: The duration for which the suppression is valid. - :type ttl: str + :param suppression_contract: The snoozed or dismissed attribute; for + example, the snooze duration. + :type suppression_contract: + ~azure.mgmt.advisor.models.SuppressionContract :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -129,10 +130,8 @@ def create( ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ - suppression_contract = models.SuppressionContract(suppression_id=suppression_id, ttl=ttl) - # Construct URL - url = '/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}' + url = self.create.metadata['url'] path_format_arguments = { 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str'), 'recommendationId': self._serialize.url("recommendation_id", recommendation_id, 'str'), @@ -177,6 +176,7 @@ def create( return client_raw_response return deserialized + create.metadata = {'url': '/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}'} def delete( self, resource_uri, recommendation_id, name, custom_headers=None, raw=False, **operation_config): @@ -201,7 +201,7 @@ def delete( :raises: :class:`CloudError` """ # Construct URL - url = '/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}' + url = self.delete.metadata['url'] path_format_arguments = { 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str'), 'recommendationId': self._serialize.url("recommendation_id", recommendation_id, 'str'), @@ -235,79 +235,62 @@ def delete( if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response + delete.metadata = {'url': '/{resourceUri}/providers/Microsoft.Advisor/recommendations/{recommendationId}/suppressions/{name}'} def list( - self, top=None, skip_token=None, custom_headers=None, raw=False, **operation_config): + self, custom_headers=None, raw=False, **operation_config): """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. - :param top: The number of suppressions per page if a paged version of - this API is being used. - :type top: int - :param skip_token: The page-continuation token to use with a paged - version of this API. - :type skip_token: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :return: An iterator like instance of SuppressionContract - :rtype: - ~azure.mgmt.advisor.models.SuppressionContractPaged[~azure.mgmt.advisor.models.SuppressionContract] + :return: list or ClientRawResponse if raw=true + :rtype: list[~azure.mgmt.advisor.models.SuppressionContract] or + ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ - def internal_paging(next_link=None, raw=False): - - if not next_link: - # Construct URL - url = '/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/suppressions' - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} - query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if skip_token is not None: - query_parameters['$skipToken'] = self._serialize.query("skip_token", skip_token, 'str') - - else: - url = next_link - query_parameters = {} - - # Construct headers - header_parameters = {} - header_parameters['Content-Type'] = 'application/json; charset=utf-8' - if self.config.generate_client_request_id: - header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) - if custom_headers: - header_parameters.update(custom_headers) - if self.config.accept_language is not None: - header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') - - # Construct and send request - request = self._client.get(url, query_parameters) - response = self._client.send( - request, header_parameters, 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 - - return response - - # Deserialize response - deserialized = models.SuppressionContractPaged(internal_paging, self._deserialize.dependencies) + # Construct URL + url = self.list.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters) + response = self._client.send(request, header_parameters, 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 + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('[SuppressionContract]', response) if raw: - header_dict = {} - client_raw_response = models.SuppressionContractPaged(internal_paging, self._deserialize.dependencies, header_dict) + client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Advisor/suppressions'}