From 4d58ae7a2c945a77939847b3fdd42dc139e5ea5d Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Wed, 28 Feb 2018 08:38:24 -0800 Subject: [PATCH] [AutoPR web/resource-manager] Fix recommendation resource properties, add disable recommendation APIs (#2063) * Generated from 00ffb2040dfb1d813a1780159b322c53cd2efb30 Add disable recommendation APIs * Generated from 00ffb2040dfb1d813a1780159b322c53cd2efb30 Add disable recommendation APIs --- .../azure/mgmt/web/models/__init__.py | 2 + .../azure/mgmt/web/models/recommendation.py | 71 ++-- .../mgmt/web/models/recommendation_paged.py | 27 ++ .../mgmt/web/models/recommendation_rule.py | 59 ++- .../operations/recommendations_operations.py | 374 ++++++++++++------ azure-mgmt-web/azure/mgmt/web/version.py | 2 +- 6 files changed, 377 insertions(+), 158 deletions(-) create mode 100644 azure-mgmt-web/azure/mgmt/web/models/recommendation_paged.py diff --git a/azure-mgmt-web/azure/mgmt/web/models/__init__.py b/azure-mgmt-web/azure/mgmt/web/models/__init__.py index a50f89c31cf9..0b1a573e7329 100644 --- a/azure-mgmt-web/azure/mgmt/web/models/__init__.py +++ b/azure-mgmt-web/azure/mgmt/web/models/__init__.py @@ -225,6 +225,7 @@ from .analysis_definition_paged import AnalysisDefinitionPaged from .detector_definition_paged import DetectorDefinitionPaged from .application_stack_paged import ApplicationStackPaged +from .recommendation_paged import RecommendationPaged from .source_control_paged import SourceControlPaged from .geo_region_paged import GeoRegionPaged from .identifier_paged import IdentifierPaged @@ -537,6 +538,7 @@ 'AnalysisDefinitionPaged', 'DetectorDefinitionPaged', 'ApplicationStackPaged', + 'RecommendationPaged', 'SourceControlPaged', 'GeoRegionPaged', 'IdentifierPaged', diff --git a/azure-mgmt-web/azure/mgmt/web/models/recommendation.py b/azure-mgmt-web/azure/mgmt/web/models/recommendation.py index f53222b7f41d..bc2ff02a1140 100644 --- a/azure-mgmt-web/azure/mgmt/web/models/recommendation.py +++ b/azure-mgmt-web/azure/mgmt/web/models/recommendation.py @@ -9,12 +9,23 @@ # regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +from .proxy_only_resource import ProxyOnlyResource -class Recommendation(Model): +class Recommendation(ProxyOnlyResource): """Represents a recommendation result generated by the recommendation engine. + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource Name. + :vartype name: str + :param kind: Kind of resource. + :type kind: str + :ivar type: Resource type. + :vartype type: str :param creation_time: Timestamp when this instance was created. :type creation_time: datetime :param recommendation_id: A GUID value that each recommendation object is @@ -74,32 +85,42 @@ class Recommendation(Model): :type forward_link: str """ + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + _attribute_map = { - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, - 'recommendation_id': {'key': 'recommendationId', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, - 'resource_scope': {'key': 'resourceScope', 'type': 'str'}, - 'rule_name': {'key': 'ruleName', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'level': {'key': 'level', 'type': 'NotificationLevel'}, - 'channels': {'key': 'channels', 'type': 'Channels'}, - 'tags': {'key': 'tags', 'type': '[str]'}, - 'action_name': {'key': 'actionName', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'end_time': {'key': 'endTime', 'type': 'iso-8601'}, - 'next_notification_time': {'key': 'nextNotificationTime', 'type': 'iso-8601'}, - 'notification_expiration_time': {'key': 'notificationExpirationTime', 'type': 'iso-8601'}, - 'notified_time': {'key': 'notifiedTime', 'type': 'iso-8601'}, - 'score': {'key': 'score', 'type': 'float'}, - 'is_dynamic': {'key': 'isDynamic', 'type': 'bool'}, - 'extension_name': {'key': 'extensionName', 'type': 'str'}, - 'blade_name': {'key': 'bladeName', 'type': 'str'}, - 'forward_link': {'key': 'forwardLink', 'type': 'str'}, + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, + 'recommendation_id': {'key': 'properties.recommendationId', 'type': 'str'}, + 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, + 'resource_scope': {'key': 'properties.resourceScope', 'type': 'str'}, + 'rule_name': {'key': 'properties.ruleName', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'message': {'key': 'properties.message', 'type': 'str'}, + 'level': {'key': 'properties.level', 'type': 'NotificationLevel'}, + 'channels': {'key': 'properties.channels', 'type': 'Channels'}, + 'tags': {'key': 'properties.tags', 'type': '[str]'}, + 'action_name': {'key': 'properties.actionName', 'type': 'str'}, + 'start_time': {'key': 'properties.startTime', 'type': 'iso-8601'}, + 'end_time': {'key': 'properties.endTime', 'type': 'iso-8601'}, + 'next_notification_time': {'key': 'properties.nextNotificationTime', 'type': 'iso-8601'}, + 'notification_expiration_time': {'key': 'properties.notificationExpirationTime', 'type': 'iso-8601'}, + 'notified_time': {'key': 'properties.notifiedTime', 'type': 'iso-8601'}, + 'score': {'key': 'properties.score', 'type': 'float'}, + 'is_dynamic': {'key': 'properties.isDynamic', 'type': 'bool'}, + 'extension_name': {'key': 'properties.extensionName', 'type': 'str'}, + 'blade_name': {'key': 'properties.bladeName', 'type': 'str'}, + 'forward_link': {'key': 'properties.forwardLink', 'type': 'str'}, } - def __init__(self, creation_time=None, recommendation_id=None, resource_id=None, resource_scope=None, rule_name=None, display_name=None, message=None, level=None, channels=None, tags=None, action_name=None, start_time=None, end_time=None, next_notification_time=None, notification_expiration_time=None, notified_time=None, score=None, is_dynamic=None, extension_name=None, blade_name=None, forward_link=None): - super(Recommendation, self).__init__() + def __init__(self, kind=None, creation_time=None, recommendation_id=None, resource_id=None, resource_scope=None, rule_name=None, display_name=None, message=None, level=None, channels=None, tags=None, action_name=None, start_time=None, end_time=None, next_notification_time=None, notification_expiration_time=None, notified_time=None, score=None, is_dynamic=None, extension_name=None, blade_name=None, forward_link=None): + super(Recommendation, self).__init__(kind=kind) self.creation_time = creation_time self.recommendation_id = recommendation_id self.resource_id = resource_id diff --git a/azure-mgmt-web/azure/mgmt/web/models/recommendation_paged.py b/azure-mgmt-web/azure/mgmt/web/models/recommendation_paged.py new file mode 100644 index 000000000000..2eaf7b6d2ebd --- /dev/null +++ b/azure-mgmt-web/azure/mgmt/web/models/recommendation_paged.py @@ -0,0 +1,27 @@ +# 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 RecommendationPaged(Paged): + """ + A paging container for iterating over a list of :class:`Recommendation ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[Recommendation]'} + } + + def __init__(self, *args, **kwargs): + + super(RecommendationPaged, self).__init__(*args, **kwargs) diff --git a/azure-mgmt-web/azure/mgmt/web/models/recommendation_rule.py b/azure-mgmt-web/azure/mgmt/web/models/recommendation_rule.py index d8e666053a44..cbc61204c922 100644 --- a/azure-mgmt-web/azure/mgmt/web/models/recommendation_rule.py +++ b/azure-mgmt-web/azure/mgmt/web/models/recommendation_rule.py @@ -9,15 +9,26 @@ # regenerated. # -------------------------------------------------------------------------- -from msrest.serialization import Model +from .proxy_only_resource import ProxyOnlyResource -class RecommendationRule(Model): +class RecommendationRule(ProxyOnlyResource): """Represents a recommendation rule that the recommendation engine can perform. - :param name: Unique name of the rule. - :type name: str + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource Name. + :vartype name: str + :param kind: Kind of resource. + :type kind: str + :ivar type: Resource type. + :vartype type: str + :param recommendation_rule_name: Unique name of the rule. + :type recommendation_rule_name: str :param display_name: UI friendly name of the rule. :type display_name: str :param message: Localized name of the rule (Good for UI). @@ -54,25 +65,35 @@ class RecommendationRule(Model): :type forward_link: str """ + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'recommendation_id': {'key': 'recommendationId', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'action_name': {'key': 'actionName', 'type': 'str'}, - 'level': {'key': 'level', 'type': 'NotificationLevel'}, - 'channels': {'key': 'channels', 'type': 'Channels'}, - 'tags': {'key': 'tags', 'type': '[str]'}, - 'is_dynamic': {'key': 'isDynamic', 'type': 'bool'}, - 'extension_name': {'key': 'extensionName', 'type': 'str'}, - 'blade_name': {'key': 'bladeName', 'type': 'str'}, - 'forward_link': {'key': 'forwardLink', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'recommendation_rule_name': {'key': 'properties.name', 'type': 'str'}, + 'display_name': {'key': 'properties.displayName', 'type': 'str'}, + 'message': {'key': 'properties.message', 'type': 'str'}, + 'recommendation_id': {'key': 'properties.recommendationId', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'action_name': {'key': 'properties.actionName', 'type': 'str'}, + 'level': {'key': 'properties.level', 'type': 'NotificationLevel'}, + 'channels': {'key': 'properties.channels', 'type': 'Channels'}, + 'tags': {'key': 'properties.tags', 'type': '[str]'}, + 'is_dynamic': {'key': 'properties.isDynamic', 'type': 'bool'}, + 'extension_name': {'key': 'properties.extensionName', 'type': 'str'}, + 'blade_name': {'key': 'properties.bladeName', 'type': 'str'}, + 'forward_link': {'key': 'properties.forwardLink', 'type': 'str'}, } - def __init__(self, name=None, display_name=None, message=None, recommendation_id=None, description=None, action_name=None, level=None, channels=None, tags=None, is_dynamic=None, extension_name=None, blade_name=None, forward_link=None): - super(RecommendationRule, self).__init__() - self.name = name + def __init__(self, kind=None, recommendation_rule_name=None, display_name=None, message=None, recommendation_id=None, description=None, action_name=None, level=None, channels=None, tags=None, is_dynamic=None, extension_name=None, blade_name=None, forward_link=None): + super(RecommendationRule, self).__init__(kind=kind) + self.recommendation_rule_name = recommendation_rule_name self.display_name = display_name self.message = message self.recommendation_id = recommendation_id diff --git a/azure-mgmt-web/azure/mgmt/web/operations/recommendations_operations.py b/azure-mgmt-web/azure/mgmt/web/operations/recommendations_operations.py index 737ad36f893a..79c8c4c870fd 100644 --- a/azure-mgmt-web/azure/mgmt/web/operations/recommendations_operations.py +++ b/azure-mgmt-web/azure/mgmt/web/operations/recommendations_operations.py @@ -57,13 +57,83 @@ def list( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :return: list or ClientRawResponse if raw=true - :rtype: list[~azure.mgmt.web.models.Recommendation] or - ~msrest.pipeline.ClientRawResponse + :return: An iterator like instance of Recommendation + :rtype: + ~azure.mgmt.web.models.RecommendationPaged[~azure.mgmt.web.models.Recommendation] + :raises: :class:`CloudError` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # 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 = {} + if featured is not None: + query_parameters['featured'] = self._serialize.query("featured", featured, 'bool') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + 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.RecommendationPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.RecommendationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Web/recommendations'} + + def reset_all_filters( + self, custom_headers=None, raw=False, **operation_config): + """Reset all recommendation opt-out settings for a subscription. + + Reset all recommendation opt-out settings for a subscription. + + :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 = self.list.metadata['url'] + url = self.reset_all_filters.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } @@ -71,10 +141,6 @@ def list( # Construct parameters query_parameters = {} - if featured is not None: - query_parameters['featured'] = self._serialize.query("featured", featured, 'bool') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers @@ -88,32 +154,29 @@ def list( 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) + request = self._client.post(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) - if response.status_code not in [200]: + if response.status_code not in [204]: 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('[Recommendation]', response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response = ClientRawResponse(None, response) return client_raw_response + reset_all_filters.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Web/recommendations/reset'} - return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Web/recommendations'} - - def reset_all_filters( - self, custom_headers=None, raw=False, **operation_config): - """Reset all recommendation opt-out settings for a subscription. + def disable_recommendation_for_subscription( + self, name, custom_headers=None, raw=False, **operation_config): + """Disables the specified rule so it will not apply to a subscription in + the future. - Reset all recommendation opt-out settings for a subscription. + Disables the specified rule so it will not apply to a subscription in + the future. + :param name: Rule name + :type name: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -124,8 +187,9 @@ def reset_all_filters( :raises: :class:`CloudError` """ # Construct URL - url = self.reset_all_filters.metadata['url'] + url = self.disable_recommendation_for_subscription.metadata['url'] path_format_arguments = { + 'name': self._serialize.url("name", name, 'str'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) @@ -148,7 +212,7 @@ def reset_all_filters( request = self._client.post(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) - if response.status_code not in [204]: + if response.status_code not in [200]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp @@ -156,7 +220,7 @@ def reset_all_filters( if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response - reset_all_filters.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Web/recommendations/reset'} + disable_recommendation_for_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Web/recommendations/{name}/disable'} def list_history_for_web_app( self, resource_group_name, site_name, filter=None, custom_headers=None, raw=False, **operation_config): @@ -181,52 +245,61 @@ def list_history_for_web_app( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :return: list or ClientRawResponse if raw=true - :rtype: list[~azure.mgmt.web.models.Recommendation] or - ~msrest.pipeline.ClientRawResponse + :return: An iterator like instance of Recommendation + :rtype: + ~azure.mgmt.web.models.RecommendationPaged[~azure.mgmt.web.models.Recommendation] :raises: :class:`CloudError` """ - # Construct URL - url = self.list_history_for_web_app.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'), - 'siteName': self._serialize.url("site_name", site_name, 'str'), - '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 = {} - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - 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('[Recommendation]', response) + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list_history_for_web_app.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'), + 'siteName': self._serialize.url("site_name", site_name, 'str'), + '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 = {} + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + 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.RecommendationPaged(internal_paging, self._deserialize.dependencies) if raw: - client_raw_response = ClientRawResponse(deserialized, response) + header_dict = {} + client_raw_response = models.RecommendationPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized @@ -256,54 +329,63 @@ def list_recommended_rules_for_web_app( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :return: list or ClientRawResponse if raw=true - :rtype: list[~azure.mgmt.web.models.Recommendation] or - ~msrest.pipeline.ClientRawResponse + :return: An iterator like instance of Recommendation + :rtype: + ~azure.mgmt.web.models.RecommendationPaged[~azure.mgmt.web.models.Recommendation] :raises: :class:`CloudError` """ - # Construct URL - url = self.list_recommended_rules_for_web_app.metadata['url'] - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'), - 'siteName': self._serialize.url("site_name", site_name, 'str'), - '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 = {} - if featured is not None: - query_parameters['featured'] = self._serialize.query("featured", featured, 'bool') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) - 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('[Recommendation]', response) + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list_recommended_rules_for_web_app.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'), + 'siteName': self._serialize.url("site_name", site_name, 'str'), + '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 = {} + if featured is not None: + query_parameters['featured'] = self._serialize.query("featured", featured, 'bool') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, 'str', skip_quote=True) + 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.RecommendationPaged(internal_paging, self._deserialize.dependencies) if raw: - client_raw_response = ClientRawResponse(deserialized, response) + header_dict = {} + client_raw_response = models.RecommendationPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized @@ -424,7 +506,7 @@ def reset_all_filters_for_web_app( reset_all_filters_for_web_app.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/recommendations/reset'} def get_rule_details_by_web_app( - self, resource_group_name, site_name, name, update_seen=None, custom_headers=None, raw=False, **operation_config): + self, resource_group_name, site_name, name, update_seen=None, recommendation_id=None, custom_headers=None, raw=False, **operation_config): """Get a recommendation rule for an app. Get a recommendation rule for an app. @@ -439,6 +521,10 @@ def get_rule_details_by_web_app( :param update_seen: Specify true to update the last-seen timestamp of the recommendation object. :type update_seen: bool + :param recommendation_id: The GUID of the recommedation object if you + query an expired one. You don't need to specify it to query an active + entry. + :type recommendation_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 @@ -463,6 +549,8 @@ def get_rule_details_by_web_app( query_parameters = {} if update_seen is not None: query_parameters['updateSeen'] = self._serialize.query("update_seen", update_seen, 'bool') + if recommendation_id is not None: + query_parameters['recommendationId'] = self._serialize.query("recommendation_id", recommendation_id, 'str') query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') # Construct headers @@ -495,3 +583,63 @@ def get_rule_details_by_web_app( return deserialized get_rule_details_by_web_app.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/recommendations/{name}'} + + def disable_recommendation_for_site( + self, resource_group_name, site_name, name, custom_headers=None, raw=False, **operation_config): + """Disables the specific rule for a web site permanently. + + Disables the specific rule for a web site permanently. + + :param resource_group_name: Name of the resource group to which the + resource belongs. + :type resource_group_name: str + :param site_name: Site name + :type site_name: str + :param name: Rule name + :type name: 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 = self.disable_recommendation_for_site.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'), + 'siteName': self._serialize.url("site_name", site_name, 'str'), + 'name': self._serialize.url("name", name, 'str'), + '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.post(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 + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + disable_recommendation_for_site.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/recommendations/{name}/disable'} diff --git a/azure-mgmt-web/azure/mgmt/web/version.py b/azure-mgmt-web/azure/mgmt/web/version.py index 8ae395630e43..53a203f32aaf 100644 --- a/azure-mgmt-web/azure/mgmt/web/version.py +++ b/azure-mgmt-web/azure/mgmt/web/version.py @@ -9,5 +9,5 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "0.36.0" +VERSION = ""