1# coding=utf-8 2# -------------------------------------------------------------------------- 3# Copyright (c) Microsoft Corporation. All rights reserved. 4# Licensed under the MIT License. See License.txt in the project root for license information. 5# Code generated by Microsoft (R) AutoRest Code Generator. 6# Changes may cause incorrect behavior and will be lost if the code is regenerated. 7# -------------------------------------------------------------------------- 8 9from typing import Dict, List, Optional, Union 10 11from azure.core.exceptions import HttpResponseError 12import msrest.serialization 13 14from ._monitor_management_client_enums import * 15 16 17class Action(msrest.serialization.Model): 18 """Action descriptor. 19 20 You probably want to use the sub-classes and not this class directly. Known 21 sub-classes are: AlertingAction, LogToMetricAction. 22 23 All required parameters must be populated in order to send to Azure. 24 25 :param odata_type: Required. Specifies the action. Supported values - AlertingAction, 26 LogToMetricAction.Constant filled by server. 27 :type odata_type: str 28 """ 29 30 _validation = { 31 'odata_type': {'required': True}, 32 } 33 34 _attribute_map = { 35 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, 36 } 37 38 _subtype_map = { 39 'odata_type': {'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction': 'AlertingAction', 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction': 'LogToMetricAction'} 40 } 41 42 def __init__( 43 self, 44 **kwargs 45 ): 46 super(Action, self).__init__(**kwargs) 47 self.odata_type = None # type: Optional[str] 48 49 50class AlertingAction(Action): 51 """Specify action need to be taken when rule type is Alert. 52 53 All required parameters must be populated in order to send to Azure. 54 55 :param odata_type: Required. Specifies the action. Supported values - AlertingAction, 56 LogToMetricAction.Constant filled by server. 57 :type odata_type: str 58 :param severity: Required. Severity of the alert. Possible values include: "0", "1", "2", "3", 59 "4". 60 :type severity: str or ~$(python-base-namespace).v2018_04_16.models.AlertSeverity 61 :param azns_action: Azure action group reference. 62 :type azns_action: ~$(python-base-namespace).v2018_04_16.models.AzNsActionGroup 63 :param throttling_in_min: time (in minutes) for which Alerts should be throttled or suppressed. 64 :type throttling_in_min: int 65 :param trigger: Required. The trigger condition that results in the alert rule being. 66 :type trigger: ~$(python-base-namespace).v2018_04_16.models.TriggerCondition 67 """ 68 69 _validation = { 70 'odata_type': {'required': True}, 71 'severity': {'required': True}, 72 'trigger': {'required': True}, 73 } 74 75 _attribute_map = { 76 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, 77 'severity': {'key': 'severity', 'type': 'str'}, 78 'azns_action': {'key': 'aznsAction', 'type': 'AzNsActionGroup'}, 79 'throttling_in_min': {'key': 'throttlingInMin', 'type': 'int'}, 80 'trigger': {'key': 'trigger', 'type': 'TriggerCondition'}, 81 } 82 83 def __init__( 84 self, 85 *, 86 severity: Union[str, "AlertSeverity"], 87 trigger: "TriggerCondition", 88 azns_action: Optional["AzNsActionGroup"] = None, 89 throttling_in_min: Optional[int] = None, 90 **kwargs 91 ): 92 super(AlertingAction, self).__init__(**kwargs) 93 self.odata_type = 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction' # type: str 94 self.severity = severity 95 self.azns_action = azns_action 96 self.throttling_in_min = throttling_in_min 97 self.trigger = trigger 98 99 100class AzNsActionGroup(msrest.serialization.Model): 101 """Azure action group. 102 103 :param action_group: Azure Action Group reference. 104 :type action_group: list[str] 105 :param email_subject: Custom subject override for all email ids in Azure action group. 106 :type email_subject: str 107 :param custom_webhook_payload: Custom payload to be sent for all webhook URI in Azure action 108 group. 109 :type custom_webhook_payload: str 110 """ 111 112 _attribute_map = { 113 'action_group': {'key': 'actionGroup', 'type': '[str]'}, 114 'email_subject': {'key': 'emailSubject', 'type': 'str'}, 115 'custom_webhook_payload': {'key': 'customWebhookPayload', 'type': 'str'}, 116 } 117 118 def __init__( 119 self, 120 *, 121 action_group: Optional[List[str]] = None, 122 email_subject: Optional[str] = None, 123 custom_webhook_payload: Optional[str] = None, 124 **kwargs 125 ): 126 super(AzNsActionGroup, self).__init__(**kwargs) 127 self.action_group = action_group 128 self.email_subject = email_subject 129 self.custom_webhook_payload = custom_webhook_payload 130 131 132class Criteria(msrest.serialization.Model): 133 """Specifies the criteria for converting log to metric. 134 135 All required parameters must be populated in order to send to Azure. 136 137 :param metric_name: Required. Name of the metric. 138 :type metric_name: str 139 :param dimensions: List of Dimensions for creating metric. 140 :type dimensions: list[~$(python-base-namespace).v2018_04_16.models.Dimension] 141 """ 142 143 _validation = { 144 'metric_name': {'required': True}, 145 } 146 147 _attribute_map = { 148 'metric_name': {'key': 'metricName', 'type': 'str'}, 149 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, 150 } 151 152 def __init__( 153 self, 154 *, 155 metric_name: str, 156 dimensions: Optional[List["Dimension"]] = None, 157 **kwargs 158 ): 159 super(Criteria, self).__init__(**kwargs) 160 self.metric_name = metric_name 161 self.dimensions = dimensions 162 163 164class Dimension(msrest.serialization.Model): 165 """Specifies the criteria for converting log to metric. 166 167 All required parameters must be populated in order to send to Azure. 168 169 :param name: Required. Name of the dimension. 170 :type name: str 171 :param operator: Required. Operator for dimension values. Possible values include: "Include". 172 :type operator: str or ~$(python-base-namespace).v2018_04_16.models.Operator 173 :param values: Required. List of dimension values. 174 :type values: list[str] 175 """ 176 177 _validation = { 178 'name': {'required': True}, 179 'operator': {'required': True}, 180 'values': {'required': True}, 181 } 182 183 _attribute_map = { 184 'name': {'key': 'name', 'type': 'str'}, 185 'operator': {'key': 'operator', 'type': 'str'}, 186 'values': {'key': 'values', 'type': '[str]'}, 187 } 188 189 def __init__( 190 self, 191 *, 192 name: str, 193 operator: Union[str, "Operator"], 194 values: List[str], 195 **kwargs 196 ): 197 super(Dimension, self).__init__(**kwargs) 198 self.name = name 199 self.operator = operator 200 self.values = values 201 202 203class ErrorResponse(msrest.serialization.Model): 204 """Describes the format of Error response. 205 206 :param code: Error code. 207 :type code: str 208 :param message: Error message indicating why the operation failed. 209 :type message: str 210 """ 211 212 _attribute_map = { 213 'code': {'key': 'code', 'type': 'str'}, 214 'message': {'key': 'message', 'type': 'str'}, 215 } 216 217 def __init__( 218 self, 219 *, 220 code: Optional[str] = None, 221 message: Optional[str] = None, 222 **kwargs 223 ): 224 super(ErrorResponse, self).__init__(**kwargs) 225 self.code = code 226 self.message = message 227 228 229class LogMetricTrigger(msrest.serialization.Model): 230 """A log metrics trigger descriptor. 231 232 :param threshold_operator: Evaluation operation for Metric -'GreaterThan' or 'LessThan' or 233 'Equal'. Possible values include: "GreaterThan", "LessThan", "Equal". 234 :type threshold_operator: str or ~$(python-base- 235 namespace).v2018_04_16.models.ConditionalOperator 236 :param threshold: The threshold of the metric trigger. 237 :type threshold: float 238 :param metric_trigger_type: Metric Trigger Type - 'Consecutive' or 'Total'. Possible values 239 include: "Consecutive", "Total". 240 :type metric_trigger_type: str or ~$(python-base- 241 namespace).v2018_04_16.models.MetricTriggerType 242 :param metric_column: Evaluation of metric on a particular column. 243 :type metric_column: str 244 """ 245 246 _attribute_map = { 247 'threshold_operator': {'key': 'thresholdOperator', 'type': 'str'}, 248 'threshold': {'key': 'threshold', 'type': 'float'}, 249 'metric_trigger_type': {'key': 'metricTriggerType', 'type': 'str'}, 250 'metric_column': {'key': 'metricColumn', 'type': 'str'}, 251 } 252 253 def __init__( 254 self, 255 *, 256 threshold_operator: Optional[Union[str, "ConditionalOperator"]] = None, 257 threshold: Optional[float] = None, 258 metric_trigger_type: Optional[Union[str, "MetricTriggerType"]] = None, 259 metric_column: Optional[str] = None, 260 **kwargs 261 ): 262 super(LogMetricTrigger, self).__init__(**kwargs) 263 self.threshold_operator = threshold_operator 264 self.threshold = threshold 265 self.metric_trigger_type = metric_trigger_type 266 self.metric_column = metric_column 267 268 269class Resource(msrest.serialization.Model): 270 """An azure resource object. 271 272 Variables are only populated by the server, and will be ignored when sending a request. 273 274 All required parameters must be populated in order to send to Azure. 275 276 :ivar id: Azure resource Id. 277 :vartype id: str 278 :ivar name: Azure resource name. 279 :vartype name: str 280 :ivar type: Azure resource type. 281 :vartype type: str 282 :param location: Required. Resource location. 283 :type location: str 284 :param tags: A set of tags. Resource tags. 285 :type tags: dict[str, str] 286 """ 287 288 _validation = { 289 'id': {'readonly': True}, 290 'name': {'readonly': True}, 291 'type': {'readonly': True}, 292 'location': {'required': True}, 293 } 294 295 _attribute_map = { 296 'id': {'key': 'id', 'type': 'str'}, 297 'name': {'key': 'name', 'type': 'str'}, 298 'type': {'key': 'type', 'type': 'str'}, 299 'location': {'key': 'location', 'type': 'str'}, 300 'tags': {'key': 'tags', 'type': '{str}'}, 301 } 302 303 def __init__( 304 self, 305 *, 306 location: str, 307 tags: Optional[Dict[str, str]] = None, 308 **kwargs 309 ): 310 super(Resource, self).__init__(**kwargs) 311 self.id = None 312 self.name = None 313 self.type = None 314 self.location = location 315 self.tags = tags 316 317 318class LogSearchRuleResource(Resource): 319 """The Log Search Rule resource. 320 321 Variables are only populated by the server, and will be ignored when sending a request. 322 323 All required parameters must be populated in order to send to Azure. 324 325 :ivar id: Azure resource Id. 326 :vartype id: str 327 :ivar name: Azure resource name. 328 :vartype name: str 329 :ivar type: Azure resource type. 330 :vartype type: str 331 :param location: Required. Resource location. 332 :type location: str 333 :param tags: A set of tags. Resource tags. 334 :type tags: dict[str, str] 335 :param description: The description of the Log Search rule. 336 :type description: str 337 :param enabled: The flag which indicates whether the Log Search rule is enabled. Value should 338 be true or false. Possible values include: "true", "false". 339 :type enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled 340 :ivar last_updated_time: Last time the rule was updated in IS08601 format. 341 :vartype last_updated_time: ~datetime.datetime 342 :ivar provisioning_state: Provisioning state of the scheduled query rule. Possible values 343 include: "Succeeded", "Deploying", "Canceled", "Failed". 344 :vartype provisioning_state: str or ~$(python-base- 345 namespace).v2018_04_16.models.ProvisioningState 346 :param source: Required. Data Source against which rule will Query Data. 347 :type source: ~$(python-base-namespace).v2018_04_16.models.Source 348 :param schedule: Schedule (Frequency, Time Window) for rule. Required for action type - 349 AlertingAction. 350 :type schedule: ~$(python-base-namespace).v2018_04_16.models.Schedule 351 :param action: Required. Action needs to be taken on rule execution. 352 :type action: ~$(python-base-namespace).v2018_04_16.models.Action 353 """ 354 355 _validation = { 356 'id': {'readonly': True}, 357 'name': {'readonly': True}, 358 'type': {'readonly': True}, 359 'location': {'required': True}, 360 'last_updated_time': {'readonly': True}, 361 'provisioning_state': {'readonly': True}, 362 'source': {'required': True}, 363 'action': {'required': True}, 364 } 365 366 _attribute_map = { 367 'id': {'key': 'id', 'type': 'str'}, 368 'name': {'key': 'name', 'type': 'str'}, 369 'type': {'key': 'type', 'type': 'str'}, 370 'location': {'key': 'location', 'type': 'str'}, 371 'tags': {'key': 'tags', 'type': '{str}'}, 372 'description': {'key': 'properties.description', 'type': 'str'}, 373 'enabled': {'key': 'properties.enabled', 'type': 'str'}, 374 'last_updated_time': {'key': 'properties.lastUpdatedTime', 'type': 'iso-8601'}, 375 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, 376 'source': {'key': 'properties.source', 'type': 'Source'}, 377 'schedule': {'key': 'properties.schedule', 'type': 'Schedule'}, 378 'action': {'key': 'properties.action', 'type': 'Action'}, 379 } 380 381 def __init__( 382 self, 383 *, 384 location: str, 385 source: "Source", 386 action: "Action", 387 tags: Optional[Dict[str, str]] = None, 388 description: Optional[str] = None, 389 enabled: Optional[Union[str, "Enabled"]] = None, 390 schedule: Optional["Schedule"] = None, 391 **kwargs 392 ): 393 super(LogSearchRuleResource, self).__init__(location=location, tags=tags, **kwargs) 394 self.description = description 395 self.enabled = enabled 396 self.last_updated_time = None 397 self.provisioning_state = None 398 self.source = source 399 self.schedule = schedule 400 self.action = action 401 402 403class LogSearchRuleResourceCollection(msrest.serialization.Model): 404 """Represents a collection of Log Search rule resources. 405 406 :param value: The values for the Log Search Rule resources. 407 :type value: list[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource] 408 """ 409 410 _attribute_map = { 411 'value': {'key': 'value', 'type': '[LogSearchRuleResource]'}, 412 } 413 414 def __init__( 415 self, 416 *, 417 value: Optional[List["LogSearchRuleResource"]] = None, 418 **kwargs 419 ): 420 super(LogSearchRuleResourceCollection, self).__init__(**kwargs) 421 self.value = value 422 423 424class LogSearchRuleResourcePatch(msrest.serialization.Model): 425 """The log search rule resource for patch operations. 426 427 :param tags: A set of tags. Resource tags. 428 :type tags: dict[str, str] 429 :param enabled: The flag which indicates whether the Log Search rule is enabled. Value should 430 be true or false. Possible values include: "true", "false". 431 :type enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled 432 """ 433 434 _attribute_map = { 435 'tags': {'key': 'tags', 'type': '{str}'}, 436 'enabled': {'key': 'properties.enabled', 'type': 'str'}, 437 } 438 439 def __init__( 440 self, 441 *, 442 tags: Optional[Dict[str, str]] = None, 443 enabled: Optional[Union[str, "Enabled"]] = None, 444 **kwargs 445 ): 446 super(LogSearchRuleResourcePatch, self).__init__(**kwargs) 447 self.tags = tags 448 self.enabled = enabled 449 450 451class LogToMetricAction(Action): 452 """Specify action need to be taken when rule type is converting log to metric. 453 454 All required parameters must be populated in order to send to Azure. 455 456 :param odata_type: Required. Specifies the action. Supported values - AlertingAction, 457 LogToMetricAction.Constant filled by server. 458 :type odata_type: str 459 :param criteria: Required. Criteria of Metric. 460 :type criteria: list[~$(python-base-namespace).v2018_04_16.models.Criteria] 461 """ 462 463 _validation = { 464 'odata_type': {'required': True}, 465 'criteria': {'required': True}, 466 } 467 468 _attribute_map = { 469 'odata_type': {'key': 'odata\\.type', 'type': 'str'}, 470 'criteria': {'key': 'criteria', 'type': '[Criteria]'}, 471 } 472 473 def __init__( 474 self, 475 *, 476 criteria: List["Criteria"], 477 **kwargs 478 ): 479 super(LogToMetricAction, self).__init__(**kwargs) 480 self.odata_type = 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction' # type: str 481 self.criteria = criteria 482 483 484class Schedule(msrest.serialization.Model): 485 """Defines how often to run the search and the time interval. 486 487 All required parameters must be populated in order to send to Azure. 488 489 :param frequency_in_minutes: Required. frequency (in minutes) at which rule condition should be 490 evaluated. 491 :type frequency_in_minutes: int 492 :param time_window_in_minutes: Required. Time window for which data needs to be fetched for 493 query (should be greater than or equal to frequencyInMinutes). 494 :type time_window_in_minutes: int 495 """ 496 497 _validation = { 498 'frequency_in_minutes': {'required': True}, 499 'time_window_in_minutes': {'required': True}, 500 } 501 502 _attribute_map = { 503 'frequency_in_minutes': {'key': 'frequencyInMinutes', 'type': 'int'}, 504 'time_window_in_minutes': {'key': 'timeWindowInMinutes', 'type': 'int'}, 505 } 506 507 def __init__( 508 self, 509 *, 510 frequency_in_minutes: int, 511 time_window_in_minutes: int, 512 **kwargs 513 ): 514 super(Schedule, self).__init__(**kwargs) 515 self.frequency_in_minutes = frequency_in_minutes 516 self.time_window_in_minutes = time_window_in_minutes 517 518 519class Source(msrest.serialization.Model): 520 """Specifies the log search query. 521 522 All required parameters must be populated in order to send to Azure. 523 524 :param query: Log search query. Required for action type - AlertingAction. 525 :type query: str 526 :param authorized_resources: List of Resource referred into query. 527 :type authorized_resources: list[str] 528 :param data_source_id: Required. The resource uri over which log search query is to be run. 529 :type data_source_id: str 530 :param query_type: Set value to 'ResultCount' . Possible values include: "ResultCount". 531 :type query_type: str or ~$(python-base-namespace).v2018_04_16.models.QueryType 532 """ 533 534 _validation = { 535 'data_source_id': {'required': True}, 536 } 537 538 _attribute_map = { 539 'query': {'key': 'query', 'type': 'str'}, 540 'authorized_resources': {'key': 'authorizedResources', 'type': '[str]'}, 541 'data_source_id': {'key': 'dataSourceId', 'type': 'str'}, 542 'query_type': {'key': 'queryType', 'type': 'str'}, 543 } 544 545 def __init__( 546 self, 547 *, 548 data_source_id: str, 549 query: Optional[str] = None, 550 authorized_resources: Optional[List[str]] = None, 551 query_type: Optional[Union[str, "QueryType"]] = None, 552 **kwargs 553 ): 554 super(Source, self).__init__(**kwargs) 555 self.query = query 556 self.authorized_resources = authorized_resources 557 self.data_source_id = data_source_id 558 self.query_type = query_type 559 560 561class TriggerCondition(msrest.serialization.Model): 562 """The condition that results in the Log Search rule. 563 564 All required parameters must be populated in order to send to Azure. 565 566 :param threshold_operator: Required. Evaluation operation for rule - 'GreaterThan' or 567 'LessThan. Possible values include: "GreaterThan", "LessThan", "Equal". 568 :type threshold_operator: str or ~$(python-base- 569 namespace).v2018_04_16.models.ConditionalOperator 570 :param threshold: Required. Result or count threshold based on which rule should be triggered. 571 :type threshold: float 572 :param metric_trigger: Trigger condition for metric query rule. 573 :type metric_trigger: ~$(python-base-namespace).v2018_04_16.models.LogMetricTrigger 574 """ 575 576 _validation = { 577 'threshold_operator': {'required': True}, 578 'threshold': {'required': True}, 579 } 580 581 _attribute_map = { 582 'threshold_operator': {'key': 'thresholdOperator', 'type': 'str'}, 583 'threshold': {'key': 'threshold', 'type': 'float'}, 584 'metric_trigger': {'key': 'metricTrigger', 'type': 'LogMetricTrigger'}, 585 } 586 587 def __init__( 588 self, 589 *, 590 threshold_operator: Union[str, "ConditionalOperator"], 591 threshold: float, 592 metric_trigger: Optional["LogMetricTrigger"] = None, 593 **kwargs 594 ): 595 super(TriggerCondition, self).__init__(**kwargs) 596 self.threshold_operator = threshold_operator 597 self.threshold = threshold 598 self.metric_trigger = metric_trigger 599