diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/__init__.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/__init__.py index 2887504c5541..ab112298e2d7 100644 --- a/azure-mgmt-monitor/azure/mgmt/monitor/models/__init__.py +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/__init__.py @@ -97,6 +97,12 @@ from .metric_dimension_py3 import MetricDimension from .metric_criteria_py3 import MetricCriteria from .metric_alert_single_resource_multiple_metric_criteria_py3 import MetricAlertSingleResourceMultipleMetricCriteria + from .source_py3 import Source + from .schedule_py3 import Schedule + from .log_search_rule_resource_py3 import LogSearchRuleResource + from .trigger_condition_py3 import TriggerCondition + from .az_ns_action_group_py3 import AzNsActionGroup + from .alerting_action_py3 import AlertingAction except (SyntaxError, ImportError): from .resource import Resource from .scale_capacity import ScaleCapacity @@ -185,6 +191,12 @@ from .metric_dimension import MetricDimension from .metric_criteria import MetricCriteria from .metric_alert_single_resource_multiple_metric_criteria import MetricAlertSingleResourceMultipleMetricCriteria + from .source import Source + from .schedule import Schedule + from .log_search_rule_resource import LogSearchRuleResource + from .trigger_condition import TriggerCondition + from .az_ns_action_group import AzNsActionGroup + from .alerting_action import AlertingAction from .autoscale_setting_resource_paged import AutoscaleSettingResourcePaged from .incident_paged import IncidentPaged from .alert_rule_resource_paged import AlertRuleResourcePaged @@ -195,10 +207,13 @@ from .localizable_string_paged import LocalizableStringPaged from .metric_definition_paged import MetricDefinitionPaged from .metric_alert_resource_paged import MetricAlertResourcePaged +from .log_search_rule_resource_paged import LogSearchRuleResourcePaged from .monitor_management_client_enums import ( MetricStatisticType, TimeAggregationType, ComparisonOperationType, + ConditionalOperator, + MetricTriggerType, ScaleDirection, ScaleType, RecurrenceFrequency, @@ -210,6 +225,11 @@ Unit, AggregationType, Sensitivity, + Enabled, + SkuType, + QueryType, + AlertSeverity, + AlertStatus, ResultType, ) @@ -301,6 +321,12 @@ 'MetricDimension', 'MetricCriteria', 'MetricAlertSingleResourceMultipleMetricCriteria', + 'Source', + 'Schedule', + 'LogSearchRuleResource', + 'TriggerCondition', + 'AzNsActionGroup', + 'AlertingAction', 'AutoscaleSettingResourcePaged', 'IncidentPaged', 'AlertRuleResourcePaged', @@ -311,9 +337,12 @@ 'LocalizableStringPaged', 'MetricDefinitionPaged', 'MetricAlertResourcePaged', + 'LogSearchRuleResourcePaged', 'MetricStatisticType', 'TimeAggregationType', 'ComparisonOperationType', + 'ConditionalOperator', + 'MetricTriggerType', 'ScaleDirection', 'ScaleType', 'RecurrenceFrequency', @@ -325,5 +354,10 @@ 'Unit', 'AggregationType', 'Sensitivity', + 'Enabled', + 'SkuType', + 'QueryType', + 'AlertSeverity', + 'AlertStatus', 'ResultType', ] diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/action.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/action.py index 2a3b021da608..dcb773260063 100644 --- a/azure-mgmt-monitor/azure/mgmt/monitor/models/action.py +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/action.py @@ -15,18 +15,35 @@ class Action(Model): """An alert action. + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: AlertingAction + + All required parameters must be populated in order to send to Azure. + :param action_group_id: the id of the action group to use. :type action_group_id: str :param webhook_properties: :type webhook_properties: dict[str, str] + :param odatatype: Required. Constant filled by server. + :type odatatype: str """ + _validation = { + 'odatatype': {'required': True}, + } + _attribute_map = { 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, 'webhook_properties': {'key': 'webhookProperties', 'type': '{str}'}, + 'odatatype': {'key': 'odata\\.type', 'type': 'str'}, + } + + _subtype_map = { + 'odatatype': {'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction': 'AlertingAction'} } def __init__(self, **kwargs): super(Action, self).__init__(**kwargs) self.action_group_id = kwargs.get('action_group_id', None) self.webhook_properties = kwargs.get('webhook_properties', None) + self.odatatype = None diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/action_py3.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/action_py3.py index d4a73ae683cb..8f20cdeaafe4 100644 --- a/azure-mgmt-monitor/azure/mgmt/monitor/models/action_py3.py +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/action_py3.py @@ -15,18 +15,35 @@ class Action(Model): """An alert action. + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: AlertingAction + + All required parameters must be populated in order to send to Azure. + :param action_group_id: the id of the action group to use. :type action_group_id: str :param webhook_properties: :type webhook_properties: dict[str, str] + :param odatatype: Required. Constant filled by server. + :type odatatype: str """ + _validation = { + 'odatatype': {'required': True}, + } + _attribute_map = { 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, 'webhook_properties': {'key': 'webhookProperties', 'type': '{str}'}, + 'odatatype': {'key': 'odata\\.type', 'type': 'str'}, + } + + _subtype_map = { + 'odatatype': {'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction': 'AlertingAction'} } def __init__(self, *, action_group_id: str=None, webhook_properties=None, **kwargs) -> None: super(Action, self).__init__(**kwargs) self.action_group_id = action_group_id self.webhook_properties = webhook_properties + self.odatatype = None diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/alerting_action.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/alerting_action.py new file mode 100644 index 000000000000..6124bbfaf787 --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/alerting_action.py @@ -0,0 +1,74 @@ +# 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 .action import Action + + +class AlertingAction(Action): + """AlertingAction. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param action_group_id: the id of the action group to use. + :type action_group_id: str + :param webhook_properties: + :type webhook_properties: dict[str, str] + :param odatatype: Required. Constant filled by server. + :type odatatype: str + :ivar last_fired_time: Last time the rule was fired in IS08601 format. + :vartype last_fired_time: str + :param severity: Severity of the alert. Possible values include: '1', '2', + '3', '4' + :type severity: str or ~azure.mgmt.monitor.models.AlertSeverity + :ivar status: Alert state. Possible values include: 'Active', 'Inactive' + :vartype status: str or ~azure.mgmt.monitor.models.AlertStatus + :param azns_action: Required. azns notification group reference. + :type azns_action: ~azure.mgmt.monitor.models.AzNsActionGroup + :param throttle_till_date: Time untill alert should not be fired in + ISO8601 format. + :type throttle_till_date: datetime + :param trigger: Required. The trigger condition that results in the alert + rule being. + :type trigger: ~azure.mgmt.monitor.models.TriggerCondition + """ + + _validation = { + 'odatatype': {'required': True}, + 'last_fired_time': {'readonly': True}, + 'status': {'readonly': True}, + 'azns_action': {'required': True}, + 'trigger': {'required': True}, + } + + _attribute_map = { + 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, + 'webhook_properties': {'key': 'webhookProperties', 'type': '{str}'}, + 'odatatype': {'key': 'odata\\.type', 'type': 'str'}, + 'last_fired_time': {'key': 'lastFiredTime', 'type': 'str'}, + 'severity': {'key': 'severity', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'azns_action': {'key': 'aznsAction', 'type': 'AzNsActionGroup'}, + 'throttle_till_date': {'key': 'throttleTillDate', 'type': 'iso-8601'}, + 'trigger': {'key': 'trigger', 'type': 'TriggerCondition'}, + } + + def __init__(self, **kwargs): + super(AlertingAction, self).__init__(**kwargs) + self.last_fired_time = None + self.severity = kwargs.get('severity', None) + self.status = None + self.azns_action = kwargs.get('azns_action', None) + self.throttle_till_date = kwargs.get('throttle_till_date', None) + self.trigger = kwargs.get('trigger', None) + self.odatatype = 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction' diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/alerting_action_py3.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/alerting_action_py3.py new file mode 100644 index 000000000000..a2ad9982de60 --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/alerting_action_py3.py @@ -0,0 +1,74 @@ +# 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 .action import Action + + +class AlertingAction(Action): + """AlertingAction. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :param action_group_id: the id of the action group to use. + :type action_group_id: str + :param webhook_properties: + :type webhook_properties: dict[str, str] + :param odatatype: Required. Constant filled by server. + :type odatatype: str + :ivar last_fired_time: Last time the rule was fired in IS08601 format. + :vartype last_fired_time: str + :param severity: Severity of the alert. Possible values include: '1', '2', + '3', '4' + :type severity: str or ~azure.mgmt.monitor.models.AlertSeverity + :ivar status: Alert state. Possible values include: 'Active', 'Inactive' + :vartype status: str or ~azure.mgmt.monitor.models.AlertStatus + :param azns_action: Required. azns notification group reference. + :type azns_action: ~azure.mgmt.monitor.models.AzNsActionGroup + :param throttle_till_date: Time untill alert should not be fired in + ISO8601 format. + :type throttle_till_date: datetime + :param trigger: Required. The trigger condition that results in the alert + rule being. + :type trigger: ~azure.mgmt.monitor.models.TriggerCondition + """ + + _validation = { + 'odatatype': {'required': True}, + 'last_fired_time': {'readonly': True}, + 'status': {'readonly': True}, + 'azns_action': {'required': True}, + 'trigger': {'required': True}, + } + + _attribute_map = { + 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, + 'webhook_properties': {'key': 'webhookProperties', 'type': '{str}'}, + 'odatatype': {'key': 'odata\\.type', 'type': 'str'}, + 'last_fired_time': {'key': 'lastFiredTime', 'type': 'str'}, + 'severity': {'key': 'severity', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'azns_action': {'key': 'aznsAction', 'type': 'AzNsActionGroup'}, + 'throttle_till_date': {'key': 'throttleTillDate', 'type': 'iso-8601'}, + 'trigger': {'key': 'trigger', 'type': 'TriggerCondition'}, + } + + def __init__(self, *, azns_action, trigger, action_group_id: str=None, webhook_properties=None, severity=None, throttle_till_date=None, **kwargs) -> None: + super(AlertingAction, self).__init__(action_group_id=action_group_id, webhook_properties=webhook_properties, **kwargs) + self.last_fired_time = None + self.severity = severity + self.status = None + self.azns_action = azns_action + self.throttle_till_date = throttle_till_date + self.trigger = trigger + self.odatatype = 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction' diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/az_ns_action_group.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/az_ns_action_group.py new file mode 100644 index 000000000000..c7182d68962e --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/az_ns_action_group.py @@ -0,0 +1,37 @@ +# 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 AzNsActionGroup(Model): + """azns notification group. + + :param action_group: azns notification group reference. + :type action_group: list[str] + :param email_subject: Custom subject for Azns email + :type email_subject: str + :param custom_webhook_payload: Custom webhook payload to be send to azns + action group + :type custom_webhook_payload: str + """ + + _attribute_map = { + 'action_group': {'key': 'actionGroup', 'type': '[str]'}, + 'email_subject': {'key': 'emailSubject', 'type': 'str'}, + 'custom_webhook_payload': {'key': 'customWebhookPayload', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(AzNsActionGroup, self).__init__(**kwargs) + self.action_group = kwargs.get('action_group', None) + self.email_subject = kwargs.get('email_subject', None) + self.custom_webhook_payload = kwargs.get('custom_webhook_payload', None) diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/az_ns_action_group_py3.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/az_ns_action_group_py3.py new file mode 100644 index 000000000000..1a93d16bd168 --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/az_ns_action_group_py3.py @@ -0,0 +1,37 @@ +# 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 AzNsActionGroup(Model): + """azns notification group. + + :param action_group: azns notification group reference. + :type action_group: list[str] + :param email_subject: Custom subject for Azns email + :type email_subject: str + :param custom_webhook_payload: Custom webhook payload to be send to azns + action group + :type custom_webhook_payload: str + """ + + _attribute_map = { + 'action_group': {'key': 'actionGroup', 'type': '[str]'}, + 'email_subject': {'key': 'emailSubject', 'type': 'str'}, + 'custom_webhook_payload': {'key': 'customWebhookPayload', 'type': 'str'}, + } + + def __init__(self, *, action_group=None, email_subject: str=None, custom_webhook_payload: str=None, **kwargs) -> None: + super(AzNsActionGroup, self).__init__(**kwargs) + self.action_group = action_group + self.email_subject = email_subject + self.custom_webhook_payload = custom_webhook_payload diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/log_search_rule_resource.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/log_search_rule_resource.py new file mode 100644 index 000000000000..357840437b17 --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/log_search_rule_resource.py @@ -0,0 +1,91 @@ +# 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 import Resource + + +class LogSearchRuleResource(Resource): + """The Log Search Rule resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Azure resource Id + :vartype id: str + :ivar name: Azure resource name + :vartype name: str + :ivar type: Azure resource type + :vartype type: str + :param location: Required. Resource location + :type location: str + :param tags: Resource tags + :type tags: dict[str, str] + :param description: The description of the Log Search rule. + :type description: 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 sku_type: SKU Type {L1, L2, L3}. Possible values include: 'L1', + 'L2', 'L3' + :type sku_type: str or ~azure.mgmt.monitor.models.SkuType + :ivar last_updated_time: Last time the rule was updated in IS08601 format. + :vartype last_updated_time: datetime + :ivar provisioning_state: Provisioning state of the scheduledquery rule + :vartype provisioning_state: str + :param source: Required. + :type source: ~azure.mgmt.monitor.models.Source + :param schedule: Required. + :type schedule: ~azure.mgmt.monitor.models.Schedule + :param action: Required. + :type action: ~azure.mgmt.monitor.models.Action + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'last_updated_time': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'source': {'required': True}, + 'schedule': {'required': True}, + 'action': {'required': 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}'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'enabled': {'key': 'properties.Enabled', 'type': 'str'}, + 'sku_type': {'key': 'properties.skuType', 'type': 'str'}, + 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'source': {'key': 'properties.source', 'type': 'Source'}, + 'schedule': {'key': 'properties.schedule', 'type': 'Schedule'}, + 'action': {'key': 'properties.action', 'type': 'Action'}, + } + + def __init__(self, **kwargs): + super(LogSearchRuleResource, self).__init__(**kwargs) + self.description = kwargs.get('description', None) + self.enabled = kwargs.get('enabled', None) + self.sku_type = kwargs.get('sku_type', None) + self.last_updated_time = None + self.provisioning_state = None + self.source = kwargs.get('source', None) + self.schedule = kwargs.get('schedule', None) + self.action = kwargs.get('action', None) diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/log_search_rule_resource_paged.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/log_search_rule_resource_paged.py new file mode 100644 index 000000000000..fbec51381f06 --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/log_search_rule_resource_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 LogSearchRuleResourcePaged(Paged): + """ + A paging container for iterating over a list of :class:`LogSearchRuleResource ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[LogSearchRuleResource]'} + } + + def __init__(self, *args, **kwargs): + + super(LogSearchRuleResourcePaged, self).__init__(*args, **kwargs) diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/log_search_rule_resource_py3.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/log_search_rule_resource_py3.py new file mode 100644 index 000000000000..a127e8e83cb2 --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/log_search_rule_resource_py3.py @@ -0,0 +1,91 @@ +# 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 import Resource + + +class LogSearchRuleResource(Resource): + """The Log Search Rule resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Azure resource Id + :vartype id: str + :ivar name: Azure resource name + :vartype name: str + :ivar type: Azure resource type + :vartype type: str + :param location: Required. Resource location + :type location: str + :param tags: Resource tags + :type tags: dict[str, str] + :param description: The description of the Log Search rule. + :type description: 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 sku_type: SKU Type {L1, L2, L3}. Possible values include: 'L1', + 'L2', 'L3' + :type sku_type: str or ~azure.mgmt.monitor.models.SkuType + :ivar last_updated_time: Last time the rule was updated in IS08601 format. + :vartype last_updated_time: datetime + :ivar provisioning_state: Provisioning state of the scheduledquery rule + :vartype provisioning_state: str + :param source: Required. + :type source: ~azure.mgmt.monitor.models.Source + :param schedule: Required. + :type schedule: ~azure.mgmt.monitor.models.Schedule + :param action: Required. + :type action: ~azure.mgmt.monitor.models.Action + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'last_updated_time': {'readonly': True}, + 'provisioning_state': {'readonly': True}, + 'source': {'required': True}, + 'schedule': {'required': True}, + 'action': {'required': 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}'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'enabled': {'key': 'properties.Enabled', 'type': 'str'}, + 'sku_type': {'key': 'properties.skuType', 'type': 'str'}, + 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, + 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + 'source': {'key': 'properties.source', 'type': 'Source'}, + 'schedule': {'key': 'properties.schedule', 'type': 'Schedule'}, + 'action': {'key': 'properties.action', 'type': 'Action'}, + } + + def __init__(self, *, location: str, source, schedule, action, tags=None, description: str=None, enabled=None, sku_type=None, **kwargs) -> None: + super(LogSearchRuleResource, self).__init__(location=location, tags=tags, **kwargs) + self.description = description + self.enabled = enabled + self.sku_type = sku_type + self.last_updated_time = None + self.provisioning_state = None + self.source = source + self.schedule = schedule + self.action = action 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 0bc042577bb6..c674b66489f5 100644 --- a/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_trigger.py +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/metric_trigger.py @@ -49,6 +49,17 @@ 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 = { @@ -71,6 +82,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, **kwargs): @@ -83,3 +97,6 @@ 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 991b29d2707c..4cd6f809b9e7 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,6 +49,17 @@ 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 = { @@ -71,9 +82,12 @@ 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, **kwargs) -> None: + 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: super(MetricTrigger, self).__init__(**kwargs) self.metric_name = metric_name self.metric_resource_uri = metric_resource_uri @@ -83,3 +97,6 @@ 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 0f3e04d11484..b0cab8b4cace 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,6 +39,19 @@ 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" @@ -134,6 +147,39 @@ class Sensitivity(str, Enum): high = "High" +class Enabled(str, Enum): + + true = "true" + false = "false" + + +class SkuType(str, Enum): + + l1 = "L1" + l2 = "L2" + l3 = "L3" + + +class QueryType(str, Enum): + + result_count = "ResultCount" + number = "Number" + + +class AlertSeverity(str, Enum): + + one = "1" + two = "2" + three = "3" + four = "4" + + +class AlertStatus(str, Enum): + + active = "Active" + inactive = "Inactive" + + class ResultType(str, Enum): data = "Data" diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/schedule.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/schedule.py new file mode 100644 index 000000000000..1ddff6b7910d --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/schedule.py @@ -0,0 +1,42 @@ +# 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 Schedule(Model): + """Defines how often to run the search and the time interval. + + All required parameters must be populated in order to send to Azure. + + :param frequency_in_minutes: Required. frequency (in minutes) at which + rule condition should be evaluated. + :type frequency_in_minutes: int + :param time_window_in_minutes: Required. Time window for which data needs + to be fetched for query (should be greater than or equal to + frequencyInMinutes). + :type time_window_in_minutes: int + """ + + _validation = { + 'frequency_in_minutes': {'required': True}, + 'time_window_in_minutes': {'required': True}, + } + + _attribute_map = { + 'frequency_in_minutes': {'key': 'frequencyInMinutes', 'type': 'int'}, + 'time_window_in_minutes': {'key': 'timeWindowInMinutes', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(Schedule, self).__init__(**kwargs) + self.frequency_in_minutes = kwargs.get('frequency_in_minutes', None) + self.time_window_in_minutes = kwargs.get('time_window_in_minutes', None) diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/schedule_py3.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/schedule_py3.py new file mode 100644 index 000000000000..a1f87d04605a --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/schedule_py3.py @@ -0,0 +1,42 @@ +# 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 Schedule(Model): + """Defines how often to run the search and the time interval. + + All required parameters must be populated in order to send to Azure. + + :param frequency_in_minutes: Required. frequency (in minutes) at which + rule condition should be evaluated. + :type frequency_in_minutes: int + :param time_window_in_minutes: Required. Time window for which data needs + to be fetched for query (should be greater than or equal to + frequencyInMinutes). + :type time_window_in_minutes: int + """ + + _validation = { + 'frequency_in_minutes': {'required': True}, + 'time_window_in_minutes': {'required': True}, + } + + _attribute_map = { + 'frequency_in_minutes': {'key': 'frequencyInMinutes', 'type': 'int'}, + 'time_window_in_minutes': {'key': 'timeWindowInMinutes', 'type': 'int'}, + } + + def __init__(self, *, frequency_in_minutes: int, time_window_in_minutes: int, **kwargs) -> None: + super(Schedule, self).__init__(**kwargs) + self.frequency_in_minutes = frequency_in_minutes + self.time_window_in_minutes = time_window_in_minutes diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/source.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/source.py new file mode 100644 index 000000000000..0de214c27087 --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/source.py @@ -0,0 +1,50 @@ +# 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 Source(Model): + """Specifies the log search query. + + All required parameters must be populated in order to send to Azure. + + :param query: Required. Log search query. + :type query: str + :param authorized_resources: List of Resource referred into query + :type authorized_resources: list[str] + :param datasource_id: Required. The resource uri over which log search + query is to be run. + :type datasource_id: str + :param query_type: Set value to ResultCount if query should be returning + search result count. Set it to Number if its a metric query. Possible + values include: 'ResultCount', 'Number' + :type query_type: str or ~azure.mgmt.monitor.models.QueryType + """ + + _validation = { + 'query': {'required': True}, + 'datasource_id': {'required': True}, + } + + _attribute_map = { + 'query': {'key': 'query', 'type': 'str'}, + 'authorized_resources': {'key': 'authorizedResources', 'type': '[str]'}, + 'datasource_id': {'key': 'datasourceId', 'type': 'str'}, + 'query_type': {'key': 'queryType', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Source, self).__init__(**kwargs) + self.query = kwargs.get('query', None) + self.authorized_resources = kwargs.get('authorized_resources', None) + self.datasource_id = kwargs.get('datasource_id', None) + self.query_type = kwargs.get('query_type', None) diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/source_py3.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/source_py3.py new file mode 100644 index 000000000000..81bfe9d64374 --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/source_py3.py @@ -0,0 +1,50 @@ +# 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 Source(Model): + """Specifies the log search query. + + All required parameters must be populated in order to send to Azure. + + :param query: Required. Log search query. + :type query: str + :param authorized_resources: List of Resource referred into query + :type authorized_resources: list[str] + :param datasource_id: Required. The resource uri over which log search + query is to be run. + :type datasource_id: str + :param query_type: Set value to ResultCount if query should be returning + search result count. Set it to Number if its a metric query. Possible + values include: 'ResultCount', 'Number' + :type query_type: str or ~azure.mgmt.monitor.models.QueryType + """ + + _validation = { + 'query': {'required': True}, + 'datasource_id': {'required': True}, + } + + _attribute_map = { + 'query': {'key': 'query', 'type': 'str'}, + 'authorized_resources': {'key': 'authorizedResources', 'type': '[str]'}, + 'datasource_id': {'key': 'datasourceId', 'type': 'str'}, + 'query_type': {'key': 'queryType', 'type': 'str'}, + } + + def __init__(self, *, query: str, datasource_id: str, authorized_resources=None, query_type=None, **kwargs) -> None: + super(Source, self).__init__(**kwargs) + self.query = query + self.authorized_resources = authorized_resources + self.datasource_id = datasource_id + self.query_type = query_type diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/models/trigger_condition.py b/azure-mgmt-monitor/azure/mgmt/monitor/models/trigger_condition.py new file mode 100644 index 000000000000..9c011b1fcd62 --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/trigger_condition.py @@ -0,0 +1,47 @@ +# 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 TriggerCondition(Model): + """The condition that results in the Log Search rule. + + All required parameters must be populated in order to send to Azure. + + :param threshold_operator: Required. Evaluation operation for rule - + 'GreaterThan' or 'LessThan. Possible values include: 'GreaterThan', + 'LessThan', 'Equal' + :type threshold_operator: str or + ~azure.mgmt.monitor.models.ConditionalOperator + :param threshold: Required. Result or count threshold based on which rule + should be triggered. + :type threshold: float + :param metric_trigger: Trigger condition for metric query rule + :type metric_trigger: ~azure.mgmt.monitor.models.MetricTrigger + """ + + _validation = { + 'threshold_operator': {'required': True}, + 'threshold': {'required': True}, + } + + _attribute_map = { + 'threshold_operator': {'key': 'thresholdOperator', 'type': 'str'}, + 'threshold': {'key': 'threshold', 'type': 'float'}, + 'metric_trigger': {'key': 'metricTrigger', 'type': 'MetricTrigger'}, + } + + def __init__(self, **kwargs): + super(TriggerCondition, self).__init__(**kwargs) + self.threshold_operator = kwargs.get('threshold_operator', None) + self.threshold = kwargs.get('threshold', None) + self.metric_trigger = kwargs.get('metric_trigger', None) 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 new file mode 100644 index 000000000000..1a492de47033 --- /dev/null +++ b/azure-mgmt-monitor/azure/mgmt/monitor/models/trigger_condition_py3.py @@ -0,0 +1,47 @@ +# 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 TriggerCondition(Model): + """The condition that results in the Log Search rule. + + All required parameters must be populated in order to send to Azure. + + :param threshold_operator: Required. Evaluation operation for rule - + 'GreaterThan' or 'LessThan. Possible values include: 'GreaterThan', + 'LessThan', 'Equal' + :type threshold_operator: str or + ~azure.mgmt.monitor.models.ConditionalOperator + :param threshold: Required. Result or count threshold based on which rule + should be triggered. + :type threshold: float + :param metric_trigger: Trigger condition for metric query rule + :type metric_trigger: ~azure.mgmt.monitor.models.MetricTrigger + """ + + _validation = { + 'threshold_operator': {'required': True}, + 'threshold': {'required': True}, + } + + _attribute_map = { + 'threshold_operator': {'key': 'thresholdOperator', 'type': 'str'}, + 'threshold': {'key': 'threshold', 'type': 'float'}, + 'metric_trigger': {'key': 'metricTrigger', 'type': 'MetricTrigger'}, + } + + def __init__(self, *, threshold_operator, threshold: float, metric_trigger=None, **kwargs) -> None: + super(TriggerCondition, self).__init__(**kwargs) + self.threshold_operator = threshold_operator + self.threshold = threshold + self.metric_trigger = metric_trigger diff --git a/azure-mgmt-monitor/azure/mgmt/monitor/monitor_management_client.py b/azure-mgmt-monitor/azure/mgmt/monitor/monitor_management_client.py index e8f408e00bae..735675e3ca3b 100644 --- a/azure-mgmt-monitor/azure/mgmt/monitor/monitor_management_client.py +++ b/azure-mgmt-monitor/azure/mgmt/monitor/monitor_management_client.py @@ -13,6 +13,9 @@ from msrest import Serializer, Deserializer from msrestazure import AzureConfiguration from .version import VERSION +from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError +import uuid from .operations.autoscale_settings_operations import AutoscaleSettingsOperations from .operations.operations import Operations from .operations.alert_rule_incidents_operations import AlertRuleIncidentsOperations @@ -158,3 +161,273 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.metric_alerts_status = MetricAlertsStatusOperations( self._client, self.config, self._serialize, self._deserialize) + + def create_or_update_scheduled_query_rules( + self, resource_group_name, rule_name, parameters, custom_headers=None, raw=False, **operation_config): + """Creates or updates an log search rule. + Request method: PUT Request URI: + https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/microsoft.insights/scheduledQueryRules/{logsearch-rule-name}?api-version={api-version}. + + :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 parameters: The parameters of the rule to create or update. + :type parameters: ~azure.mgmt.monitor.models.LogSearchRuleResource + :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:`CloudError` + """ + api_version = "2018-04-16" + + # Construct URL + url = self.create_or_update_scheduled_query_rules.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("api_version", 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, 'LogSearchRuleResource') + + # 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 [200, 201]: + 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('LogSearchRuleResource', response) + if response.status_code == 201: + deserialized = self._deserialize('LogSearchRuleResource', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_or_update_scheduled_query_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules/{ruleName}'} + + def get_scheduled_query_rule( + self, resource_group_name, rule_name, custom_headers=None, raw=False, **operation_config): + """Gets an 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 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:`CloudError` + """ + api_version = "2018-04-16" + + # Construct URL + url = self.get_scheduled_query_rule.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'ruleName': self._serialize.url("rule_name", rule_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("api_version", 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, 404]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('LogSearchRuleResource', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get_scheduled_query_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules/{ruleName}'} + + def delete_scheduled_query_rules( + self, resource_group_name, rule_name, custom_headers=None, raw=False, **operation_config): + """Deletes a 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 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` + """ + api_version = "2018-04-16" + + # Construct URL + url = self.delete_scheduled_query_rules.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'ruleName': self._serialize.url("rule_name", rule_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("api_version", 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.delete(url, query_parameters) + response = self._client.send(request, header_parameters, stream=False, **operation_config) + + if response.status_code not in [200, 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 + delete_scheduled_query_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules/{ruleName}'} + + def get_list_scheduled_query_rules( + self, resource_group_name, filter=None, custom_headers=None, raw=False, **operation_config): + """List the Log Search rules within a resource group. + + :param resource_group_name: The name of the resource group. + :type resource_group_name: str + :param filter: The filter to apply on the operation. For more + information please see + https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx + :type filter: 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 LogSearchRuleResource + :rtype: + ~azure.mgmt.monitor.models.LogSearchRuleResourcePaged[~azure.mgmt.monitor.models.LogSearchRuleResource] + :raises: :class:`CloudError` + """ + api_version = "2018-04-16" + + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.get_list_scheduled_query_rules.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_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("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = self._serialize.query("filter", filter, '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.LogSearchRuleResourcePaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.LogSearchRuleResourcePaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + get_list_scheduled_query_rules.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules'}