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