diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/__init__.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/__init__.py index 8d68d0a13e4a..1f76267967cf 100644 --- a/azure-mgmt-monitor/azure/mgmt/monitor/models/__init__.py +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/__init__.py @@ -101,6 +101,8 @@ from .schedule_py3 import Schedule from .action_py3 import Action from .log_search_rule_resource_py3 import LogSearchRuleResource + from .log_search_rule_resource_patch_py3 import LogSearchRuleResourcePatch + from .log_metric_trigger_py3 import LogMetricTrigger from .trigger_condition_py3 import TriggerCondition from .az_ns_action_group_py3 import AzNsActionGroup from .alerting_action_py3 import AlertingAction @@ -196,6 +198,8 @@ from .schedule import Schedule from .action import Action from .log_search_rule_resource import LogSearchRuleResource + from .log_search_rule_resource_patch import LogSearchRuleResourcePatch + from .log_metric_trigger import LogMetricTrigger from .trigger_condition import TriggerCondition from .az_ns_action_group import AzNsActionGroup from .alerting_action import AlertingAction @@ -214,8 +218,6 @@ MetricStatisticType, TimeAggregationType, ComparisonOperationType, - ConditionalOperator, - MetricTriggerType, ScaleDirection, ScaleType, RecurrenceFrequency, @@ -230,6 +232,8 @@ Enabled, ProvisioningState, QueryType, + ConditionalOperator, + MetricTriggerType, AlertSeverity, ResultType, ) @@ -326,6 +330,8 @@ 'Schedule', 'Action', 'LogSearchRuleResource', + 'LogSearchRuleResourcePatch', + 'LogMetricTrigger', 'TriggerCondition', 'AzNsActionGroup', 'AlertingAction', @@ -343,8 +349,6 @@ 'MetricStatisticType', 'TimeAggregationType', 'ComparisonOperationType', - 'ConditionalOperator', - 'MetricTriggerType', 'ScaleDirection', 'ScaleType', 'RecurrenceFrequency', @@ -359,6 +363,8 @@ 'Enabled', 'ProvisioningState', 'QueryType', + 'ConditionalOperator', + 'MetricTriggerType', 'AlertSeverity', 'ResultType', ] diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/log_metric_trigger.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/log_metric_trigger.py new file mode 100644 index 000000000000..754ab30066fc --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/log_metric_trigger.py @@ -0,0 +1,45 @@ +# 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 LogMetricTrigger(Model): + """LogMetricTrigger. + + :param threshold_operator: Evaluation operation for Metric -'GreaterThan' + or 'LessThan' or 'Equal'. Possible values include: 'GreaterThan', + 'LessThan', 'Equal' + :type threshold_operator: str or + ~azure.mgmt.monitor.models.ConditionalOperator + :param threshold: + :type threshold: float + :param metric_trigger_type: Metric Trigger Type - 'Consecutive' or + 'Total'. Possible values include: 'Consecutive', 'Total' + :type metric_trigger_type: str or + ~azure.mgmt.monitor.models.MetricTriggerType + :param metric_column: Evaluation of metric on a particular column + :type metric_column: str + """ + + _attribute_map = { + 'threshold_operator': {'key': 'thresholdOperator', 'type': 'str'}, + 'threshold': {'key': 'threshold', 'type': 'float'}, + 'metric_trigger_type': {'key': 'metricTriggerType', 'type': 'str'}, + 'metric_column': {'key': 'metricColumn', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(LogMetricTrigger, self).__init__(**kwargs) + self.threshold_operator = kwargs.get('threshold_operator', None) + self.threshold = kwargs.get('threshold', None) + self.metric_trigger_type = kwargs.get('metric_trigger_type', None) + self.metric_column = kwargs.get('metric_column', None) diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/log_metric_trigger_py3.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/log_metric_trigger_py3.py new file mode 100644 index 000000000000..bcf1cfa94dc5 --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/log_metric_trigger_py3.py @@ -0,0 +1,45 @@ +# 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 LogMetricTrigger(Model): + """LogMetricTrigger. + + :param threshold_operator: Evaluation operation for Metric -'GreaterThan' + or 'LessThan' or 'Equal'. Possible values include: 'GreaterThan', + 'LessThan', 'Equal' + :type threshold_operator: str or + ~azure.mgmt.monitor.models.ConditionalOperator + :param threshold: + :type threshold: float + :param metric_trigger_type: Metric Trigger Type - 'Consecutive' or + 'Total'. Possible values include: 'Consecutive', 'Total' + :type metric_trigger_type: str or + ~azure.mgmt.monitor.models.MetricTriggerType + :param metric_column: Evaluation of metric on a particular column + :type metric_column: str + """ + + _attribute_map = { + 'threshold_operator': {'key': 'thresholdOperator', 'type': 'str'}, + 'threshold': {'key': 'threshold', 'type': 'float'}, + 'metric_trigger_type': {'key': 'metricTriggerType', 'type': 'str'}, + 'metric_column': {'key': 'metricColumn', 'type': 'str'}, + } + + def __init__(self, *, threshold_operator=None, threshold: float=None, metric_trigger_type=None, metric_column: str=None, **kwargs) -> None: + super(LogMetricTrigger, self).__init__(**kwargs) + self.threshold_operator = threshold_operator + self.threshold = threshold + self.metric_trigger_type = metric_trigger_type + self.metric_column = metric_column diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/log_search_rule_resource_patch.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/log_search_rule_resource_patch.py new file mode 100644 index 000000000000..350f17ce36ac --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/log_search_rule_resource_patch.py @@ -0,0 +1,34 @@ +# 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 LogSearchRuleResourcePatch(Model): + """The log search rule resource for patch operations. + + :param tags: Resource tags + :type tags: dict[str, str] + :param enabled: The flag which indicates whether the Log Search rule is + enabled. Value should be true or false. Possible values include: 'true', + 'false' + :type enabled: str or ~azure.mgmt.monitor.models.Enabled + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'enabled': {'key': 'properties.enabled', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(LogSearchRuleResourcePatch, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + self.enabled = kwargs.get('enabled', None) diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/log_search_rule_resource_patch_py3.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/log_search_rule_resource_patch_py3.py new file mode 100644 index 000000000000..010407469673 --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/log_search_rule_resource_patch_py3.py @@ -0,0 +1,34 @@ +# 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 LogSearchRuleResourcePatch(Model): + """The log search rule resource for patch operations. + + :param tags: Resource tags + :type tags: dict[str, str] + :param enabled: The flag which indicates whether the Log Search rule is + enabled. Value should be true or false. Possible values include: 'true', + 'false' + :type enabled: str or ~azure.mgmt.monitor.models.Enabled + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'enabled': {'key': 'properties.enabled', 'type': 'str'}, + } + + def __init__(self, *, tags=None, enabled=None, **kwargs) -> None: + super(LogSearchRuleResourcePatch, self).__init__(**kwargs) + self.tags = tags + self.enabled = enabled diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_trigger.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_trigger.py index c674b66489f5..0bc042577bb6 100644 --- a/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_trigger.py +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_trigger.py @@ -49,17 +49,6 @@ class MetricTrigger(Model): :param threshold: Required. the threshold of the metric that triggers the scale action. :type threshold: float - :param threshold_operator: Evaluation operation for Metric -'GreaterThan' - or 'LessThan' or 'Equal'. Possible values include: 'GreaterThan', - 'LessThan', 'Equal' - :type threshold_operator: str or - ~azure.mgmt.monitor.models.ConditionalOperator - :param metric_trigger_type: Metric Trigger Type - 'Consecutive' or - 'Total'. Possible values include: 'Consecutive', 'Total' - :type metric_trigger_type: str or - ~azure.mgmt.monitor.models.MetricTriggerType - :param metric_column: Evaluation of metric on a particular column - :type metric_column: str """ _validation = { @@ -82,9 +71,6 @@ class MetricTrigger(Model): 'time_aggregation': {'key': 'timeAggregation', 'type': 'TimeAggregationType'}, 'operator': {'key': 'operator', 'type': 'ComparisonOperationType'}, 'threshold': {'key': 'threshold', 'type': 'float'}, - 'threshold_operator': {'key': 'thresholdOperator', 'type': 'str'}, - 'metric_trigger_type': {'key': 'metricTriggerType', 'type': 'str'}, - 'metric_column': {'key': 'metricColumn', 'type': 'str'}, } def __init__(self, **kwargs): @@ -97,6 +83,3 @@ def __init__(self, **kwargs): self.time_aggregation = kwargs.get('time_aggregation', None) self.operator = kwargs.get('operator', None) self.threshold = kwargs.get('threshold', None) - self.threshold_operator = kwargs.get('threshold_operator', None) - self.metric_trigger_type = kwargs.get('metric_trigger_type', None) - self.metric_column = kwargs.get('metric_column', None) diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_trigger_py3.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_trigger_py3.py index 4cd6f809b9e7..991b29d2707c 100644 --- a/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_trigger_py3.py +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_trigger_py3.py @@ -49,17 +49,6 @@ class MetricTrigger(Model): :param threshold: Required. the threshold of the metric that triggers the scale action. :type threshold: float - :param threshold_operator: Evaluation operation for Metric -'GreaterThan' - or 'LessThan' or 'Equal'. Possible values include: 'GreaterThan', - 'LessThan', 'Equal' - :type threshold_operator: str or - ~azure.mgmt.monitor.models.ConditionalOperator - :param metric_trigger_type: Metric Trigger Type - 'Consecutive' or - 'Total'. Possible values include: 'Consecutive', 'Total' - :type metric_trigger_type: str or - ~azure.mgmt.monitor.models.MetricTriggerType - :param metric_column: Evaluation of metric on a particular column - :type metric_column: str """ _validation = { @@ -82,12 +71,9 @@ class MetricTrigger(Model): 'time_aggregation': {'key': 'timeAggregation', 'type': 'TimeAggregationType'}, 'operator': {'key': 'operator', 'type': 'ComparisonOperationType'}, 'threshold': {'key': 'threshold', 'type': 'float'}, - 'threshold_operator': {'key': 'thresholdOperator', 'type': 'str'}, - 'metric_trigger_type': {'key': 'metricTriggerType', 'type': 'str'}, - 'metric_column': {'key': 'metricColumn', 'type': 'str'}, } - def __init__(self, *, metric_name: str, metric_resource_uri: str, time_grain, statistic, time_window, time_aggregation, operator, threshold: float, threshold_operator=None, metric_trigger_type=None, metric_column: str=None, **kwargs) -> None: + def __init__(self, *, metric_name: str, metric_resource_uri: str, time_grain, statistic, time_window, time_aggregation, operator, threshold: float, **kwargs) -> None: super(MetricTrigger, self).__init__(**kwargs) self.metric_name = metric_name self.metric_resource_uri = metric_resource_uri @@ -97,6 +83,3 @@ def __init__(self, *, metric_name: str, metric_resource_uri: str, time_grain, st self.time_aggregation = time_aggregation self.operator = operator self.threshold = threshold - self.threshold_operator = threshold_operator - self.metric_trigger_type = metric_trigger_type - self.metric_column = metric_column diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/monitor_management_client_enums.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/monitor_management_client_enums.py index de796532bfb7..d2bda057fbd3 100644 --- a/azure-mgmt-monitor/azure/mgmt/monitor/models/monitor_management_client_enums.py +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/monitor_management_client_enums.py @@ -39,19 +39,6 @@ class ComparisonOperationType(str, Enum): less_than_or_equal = "LessThanOrEqual" -class ConditionalOperator(str, Enum): - - greater_than = "GreaterThan" - less_than = "LessThan" - equal = "Equal" - - -class MetricTriggerType(str, Enum): - - consecutive = "Consecutive" - total = "Total" - - class ScaleDirection(str, Enum): none = "None" @@ -166,6 +153,19 @@ class QueryType(str, Enum): result_count = "ResultCount" +class ConditionalOperator(str, Enum): + + greater_than = "GreaterThan" + less_than = "LessThan" + equal = "Equal" + + +class MetricTriggerType(str, Enum): + + consecutive = "Consecutive" + total = "Total" + + class AlertSeverity(str, Enum): zero = "0" diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/trigger_condition.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/trigger_condition.py index 9c011b1fcd62..e89fdc8c18f1 100644 --- a/azure-mgmt-monitor/azure/mgmt/monitor/models/trigger_condition.py +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/trigger_condition.py @@ -26,7 +26,7 @@ class TriggerCondition(Model): should be triggered. :type threshold: float :param metric_trigger: Trigger condition for metric query rule - :type metric_trigger: ~azure.mgmt.monitor.models.MetricTrigger + :type metric_trigger: ~azure.mgmt.monitor.models.LogMetricTrigger """ _validation = { @@ -37,7 +37,7 @@ class TriggerCondition(Model): _attribute_map = { 'threshold_operator': {'key': 'thresholdOperator', 'type': 'str'}, 'threshold': {'key': 'threshold', 'type': 'float'}, - 'metric_trigger': {'key': 'metricTrigger', 'type': 'MetricTrigger'}, + 'metric_trigger': {'key': 'metricTrigger', 'type': 'LogMetricTrigger'}, } def __init__(self, **kwargs): diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/trigger_condition_py3.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/trigger_condition_py3.py index 1a492de47033..b21e39d9a53e 100644 --- a/azure-mgmt-monitor/azure/mgmt/monitor/models/trigger_condition_py3.py +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/trigger_condition_py3.py @@ -26,7 +26,7 @@ class TriggerCondition(Model): should be triggered. :type threshold: float :param metric_trigger: Trigger condition for metric query rule - :type metric_trigger: ~azure.mgmt.monitor.models.MetricTrigger + :type metric_trigger: ~azure.mgmt.monitor.models.LogMetricTrigger """ _validation = { @@ -37,7 +37,7 @@ class TriggerCondition(Model): _attribute_map = { 'threshold_operator': {'key': 'thresholdOperator', 'type': 'str'}, 'threshold': {'key': 'threshold', 'type': 'float'}, - 'metric_trigger': {'key': 'metricTrigger', 'type': 'MetricTrigger'}, + 'metric_trigger': {'key': 'metricTrigger', 'type': 'LogMetricTrigger'}, } def __init__(self, *, threshold_operator, threshold: float, metric_trigger=None, **kwargs) -> None: diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/operations/scheduled_query_rules_operations.py b/azure-mgmt-monitor/azure/mgmt/monitor/operations/scheduled_query_rules_operations.py index 6227f567f391..16230f44386c 100644 --- a/azure-mgmt-monitor/azure/mgmt/monitor/operations/scheduled_query_rules_operations.py +++ b/azure-mgmt-monitor/azure/mgmt/monitor/operations/scheduled_query_rules_operations.py @@ -166,6 +166,79 @@ def get( return deserialized get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules/{ruleName}'} + def update( + self, resource_group_name, rule_name, tags=None, enabled=None, custom_headers=None, raw=False, **operation_config): + """Update log search Rule. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param rule_name: The name of the rule. + :type rule_name: str + :param tags: Resource tags + :type tags: dict[str, str] + :param enabled: The flag which indicates whether the Log Search rule + is enabled. Value should be true or false. Possible values include: + 'true', 'false' + :type enabled: str or ~azure.mgmt.monitor.models.Enabled + :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: LogSearchRuleResource or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.monitor.models.LogSearchRuleResource or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException` + """ + parameters = models.LogSearchRuleResourcePatch(tags=tags, enabled=enabled) + + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'ruleName': self._serialize.url("rule_name", rule_name, '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(parameters, 'LogSearchRuleResourcePatch') + + # Construct and send request + request = self._client.patch(url, query_parameters) + response = self._client.send( + request, header_parameters, body_content, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('LogSearchRuleResource', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules/{ruleName}'} + def delete( self, resource_group_name, rule_name, custom_headers=None, raw=False, **operation_config): """Deletes a Log Search rule.