From d8ce7adbbe0188b050649b0ec5e8f0b681a96114 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Thu, 24 Jan 2019 14:45:48 +0000 Subject: [PATCH 1/6] Generated from b63cbf7f7de110a9611e2c0d1f0b077920963104 Merge branch 'master' of https://github.com/nirgfani/azure-rest-api-specs --- .../azure/mgmt/securityinsight/__init__.py | 18 + .../mgmt/securityinsight/models/__init__.py | 38 +++ .../mgmt/securityinsight/models/operation.py | 32 ++ .../models/operation_display.py | 40 +++ .../models/operation_display_py3.py | 40 +++ .../securityinsight/models/operation_paged.py | 27 ++ .../securityinsight/models/operation_py3.py | 32 ++ .../mgmt/securityinsight/models/resource.py | 45 +++ .../securityinsight/models/resource_py3.py | 45 +++ .../models/scheduled_alert_rule.py | 119 +++++++ .../models/scheduled_alert_rule_paged.py | 27 ++ .../models/scheduled_alert_rule_py3.py | 119 +++++++ .../models/security_insights_enums.py | 28 ++ .../securityinsight/operations/__init__.py | 18 + .../securityinsight/operations/operations.py | 99 ++++++ .../scheduled_alert_rules_operations.py | 323 ++++++++++++++++++ .../mgmt/securityinsight/security_insights.py | 86 +++++ .../azure/mgmt/securityinsight/version.py | 13 + 18 files changed, 1149 insertions(+) create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/__init__.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/__init__.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation_display.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation_display_py3.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation_paged.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation_py3.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/resource.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/resource_py3.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_paged.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/security_insights_enums.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/__init__.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/operations.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/scheduled_alert_rules_operations.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/security_insights.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/version.py diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/__init__.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/__init__.py new file mode 100644 index 000000000000..59c5d0a0e375 --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/__init__.py @@ -0,0 +1,18 @@ +# 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 .security_insights import SecurityInsights +from .version import VERSION + +__all__ = ['SecurityInsights'] + +__version__ = VERSION + diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/__init__.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/__init__.py new file mode 100644 index 000000000000..4239bdbf798b --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/__init__.py @@ -0,0 +1,38 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + from .operation_display_py3 import OperationDisplay + from .operation_py3 import Operation + from .scheduled_alert_rule_py3 import ScheduledAlertRule + from .resource_py3 import Resource +except (SyntaxError, ImportError): + from .operation_display import OperationDisplay + from .operation import Operation + from .scheduled_alert_rule import ScheduledAlertRule + from .resource import Resource +from .operation_paged import OperationPaged +from .scheduled_alert_rule_paged import ScheduledAlertRulePaged +from .security_insights_enums import ( + Severity, + AlertTriggerOperator, +) + +__all__ = [ + 'OperationDisplay', + 'Operation', + 'ScheduledAlertRule', + 'Resource', + 'OperationPaged', + 'ScheduledAlertRulePaged', + 'Severity', + 'AlertTriggerOperator', +] diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation.py new file mode 100644 index 000000000000..3bee7e1dac48 --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation.py @@ -0,0 +1,32 @@ +# 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 Operation(Model): + """Operation provided by provider. + + :param name: Name of the operation + :type name: str + :param display: Properties of the operation + :type display: ~azure.mgmt.securityinsight.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__(self, **kwargs): + super(Operation, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.display = kwargs.get('display', None) diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation_display.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation_display.py new file mode 100644 index 000000000000..89c4bdd6ccb6 --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation_display.py @@ -0,0 +1,40 @@ +# 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 OperationDisplay(Model): + """Properties of the operation. + + :param provider: Provider name + :type provider: str + :param resource: Resource name + :type resource: str + :param operation: Operation name + :type operation: str + :param description: Description of the operation + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(OperationDisplay, self).__init__(**kwargs) + self.provider = kwargs.get('provider', None) + self.resource = kwargs.get('resource', None) + self.operation = kwargs.get('operation', None) + self.description = kwargs.get('description', None) diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation_display_py3.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation_display_py3.py new file mode 100644 index 000000000000..fa3740dfc655 --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation_display_py3.py @@ -0,0 +1,40 @@ +# 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 OperationDisplay(Model): + """Properties of the operation. + + :param provider: Provider name + :type provider: str + :param resource: Resource name + :type resource: str + :param operation: Operation name + :type operation: str + :param description: Description of the operation + :type description: str + """ + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__(self, *, provider: str=None, resource: str=None, operation: str=None, description: str=None, **kwargs) -> None: + super(OperationDisplay, self).__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation_paged.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation_paged.py new file mode 100644 index 000000000000..a1b03b8047b8 --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation_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 OperationPaged(Paged): + """ + A paging container for iterating over a list of :class:`Operation ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[Operation]'} + } + + def __init__(self, *args, **kwargs): + + super(OperationPaged, self).__init__(*args, **kwargs) diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation_py3.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation_py3.py new file mode 100644 index 000000000000..d77122a675e5 --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/operation_py3.py @@ -0,0 +1,32 @@ +# 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 Operation(Model): + """Operation provided by provider. + + :param name: Name of the operation + :type name: str + :param display: Properties of the operation + :type display: ~azure.mgmt.securityinsight.models.OperationDisplay + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + } + + def __init__(self, *, name: str=None, display=None, **kwargs) -> None: + super(Operation, self).__init__(**kwargs) + self.name = name + self.display = display diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/resource.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/resource.py new file mode 100644 index 000000000000..7454d56b9033 --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/resource.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Resource(Model): + """An azure resource object. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Resource, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/resource_py3.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/resource_py3.py new file mode 100644 index 000000000000..83ff9951fb91 --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/resource_py3.py @@ -0,0 +1,45 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class Resource(Model): + """An azure resource object. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + } + + def __init__(self, **kwargs) -> None: + super(Resource, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py new file mode 100644 index 000000000000..7eccdec8fc7d --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py @@ -0,0 +1,119 @@ +# 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 ScheduledAlertRule(Resource): + """Alert rule. + + 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 type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + :param etag: Etag of the alert rule. + :type etag: str + :param rule_name: Required. The name for alerts created by this alert + rule. + :type rule_name: str + :param description: Required. The description of the alert rule. + :type description: str + :param severity: Required. The severity for alerts created by this alert + rule. Possible values include: 'Low', 'Medium', 'High', 'Informational' + :type severity: str or ~azure.mgmt.securityinsight.models.Severity + :param enabled: Required. Determines whether this alert rule is enabled or + disabled. + :type enabled: bool + :param query: Required. The query that creates alerts for this rule. + :type query: str + :param query_frequency: Required. TimeSpan format represents the frequncy + for this alert rule to run. + :type query_frequency: str + :param query_period: Required. TimeSpan format represents the period that + this alert rule looks at. + :type query_period: str + :param alert_trigger_operator: Required. The operation against the + threahold that triggers alert rule. Possible values include: 'gt', 'lt', + 'ne', 'eq' + :type alert_trigger_operator: str or + ~azure.mgmt.securityinsight.models.AlertTriggerOperator + :param alert_trigger_threshold: Required. The threahold triggers this + alert rule. + :type alert_trigger_threshold: int + :param suppression_enabled: Required. Determines whether the suppression + for this alert rule is enabled or disabled. + :type suppression_enabled: bool + :param suppression_duration: Required. TimeSpan format represents the + suppression to wait since last time this alert rule been triggered. + :type suppression_duration: str + :ivar last_modified_utc: The last time that this alert has been modified. + :vartype last_modified_utc: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'rule_name': {'required': True}, + 'description': {'required': True}, + 'severity': {'required': True}, + 'enabled': {'required': True}, + 'query': {'required': True}, + 'query_frequency': {'required': True, 'pattern': r'^(\d+\.)?\d{2}\:\d{2}\:\d{2}$'}, + 'query_period': {'required': True, 'pattern': r'^(\d+\.)?\d{2}\:\d{2}\:\d{2}$'}, + 'alert_trigger_operator': {'required': True}, + 'alert_trigger_threshold': {'required': True}, + 'suppression_enabled': {'required': True}, + 'suppression_duration': {'required': True, 'pattern': r'^(\d+\.)?\d{2}\:\d{2}\:\d{2}$'}, + 'last_modified_utc': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'rule_name': {'key': 'properties.ruleName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'severity': {'key': 'properties.severity', 'type': 'Severity'}, + 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + 'query': {'key': 'properties.query', 'type': 'str'}, + 'query_frequency': {'key': 'properties.queryFrequency', 'type': 'str'}, + 'query_period': {'key': 'properties.queryPeriod', 'type': 'str'}, + 'alert_trigger_operator': {'key': 'properties.alertTriggerOperator', 'type': 'AlertTriggerOperator'}, + 'alert_trigger_threshold': {'key': 'properties.alertTriggerThreshold', 'type': 'int'}, + 'suppression_enabled': {'key': 'properties.suppressionEnabled', 'type': 'bool'}, + 'suppression_duration': {'key': 'properties.suppressionDuration', 'type': 'str'}, + 'last_modified_utc': {'key': 'properties.lastModifiedUtc', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ScheduledAlertRule, self).__init__(**kwargs) + self.etag = kwargs.get('etag', None) + self.rule_name = kwargs.get('rule_name', None) + self.description = kwargs.get('description', None) + self.severity = kwargs.get('severity', None) + self.enabled = kwargs.get('enabled', None) + self.query = kwargs.get('query', None) + self.query_frequency = kwargs.get('query_frequency', None) + self.query_period = kwargs.get('query_period', None) + self.alert_trigger_operator = kwargs.get('alert_trigger_operator', None) + self.alert_trigger_threshold = kwargs.get('alert_trigger_threshold', None) + self.suppression_enabled = kwargs.get('suppression_enabled', None) + self.suppression_duration = kwargs.get('suppression_duration', None) + self.last_modified_utc = None diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_paged.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_paged.py new file mode 100644 index 000000000000..81a61b427c1e --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_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 ScheduledAlertRulePaged(Paged): + """ + A paging container for iterating over a list of :class:`ScheduledAlertRule ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[ScheduledAlertRule]'} + } + + def __init__(self, *args, **kwargs): + + super(ScheduledAlertRulePaged, self).__init__(*args, **kwargs) diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py new file mode 100644 index 000000000000..83f495af6180 --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py @@ -0,0 +1,119 @@ +# 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_py3 import Resource + + +class ScheduledAlertRule(Resource): + """Alert rule. + + 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 type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + :param etag: Etag of the alert rule. + :type etag: str + :param rule_name: Required. The name for alerts created by this alert + rule. + :type rule_name: str + :param description: Required. The description of the alert rule. + :type description: str + :param severity: Required. The severity for alerts created by this alert + rule. Possible values include: 'Low', 'Medium', 'High', 'Informational' + :type severity: str or ~azure.mgmt.securityinsight.models.Severity + :param enabled: Required. Determines whether this alert rule is enabled or + disabled. + :type enabled: bool + :param query: Required. The query that creates alerts for this rule. + :type query: str + :param query_frequency: Required. TimeSpan format represents the frequncy + for this alert rule to run. + :type query_frequency: str + :param query_period: Required. TimeSpan format represents the period that + this alert rule looks at. + :type query_period: str + :param alert_trigger_operator: Required. The operation against the + threahold that triggers alert rule. Possible values include: 'gt', 'lt', + 'ne', 'eq' + :type alert_trigger_operator: str or + ~azure.mgmt.securityinsight.models.AlertTriggerOperator + :param alert_trigger_threshold: Required. The threahold triggers this + alert rule. + :type alert_trigger_threshold: int + :param suppression_enabled: Required. Determines whether the suppression + for this alert rule is enabled or disabled. + :type suppression_enabled: bool + :param suppression_duration: Required. TimeSpan format represents the + suppression to wait since last time this alert rule been triggered. + :type suppression_duration: str + :ivar last_modified_utc: The last time that this alert has been modified. + :vartype last_modified_utc: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + 'rule_name': {'required': True}, + 'description': {'required': True}, + 'severity': {'required': True}, + 'enabled': {'required': True}, + 'query': {'required': True}, + 'query_frequency': {'required': True, 'pattern': r'^(\d+\.)?\d{2}\:\d{2}\:\d{2}$'}, + 'query_period': {'required': True, 'pattern': r'^(\d+\.)?\d{2}\:\d{2}\:\d{2}$'}, + 'alert_trigger_operator': {'required': True}, + 'alert_trigger_threshold': {'required': True}, + 'suppression_enabled': {'required': True}, + 'suppression_duration': {'required': True, 'pattern': r'^(\d+\.)?\d{2}\:\d{2}\:\d{2}$'}, + 'last_modified_utc': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + 'rule_name': {'key': 'properties.ruleName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'severity': {'key': 'properties.severity', 'type': 'Severity'}, + 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + 'query': {'key': 'properties.query', 'type': 'str'}, + 'query_frequency': {'key': 'properties.queryFrequency', 'type': 'str'}, + 'query_period': {'key': 'properties.queryPeriod', 'type': 'str'}, + 'alert_trigger_operator': {'key': 'properties.alertTriggerOperator', 'type': 'AlertTriggerOperator'}, + 'alert_trigger_threshold': {'key': 'properties.alertTriggerThreshold', 'type': 'int'}, + 'suppression_enabled': {'key': 'properties.suppressionEnabled', 'type': 'bool'}, + 'suppression_duration': {'key': 'properties.suppressionDuration', 'type': 'str'}, + 'last_modified_utc': {'key': 'properties.lastModifiedUtc', 'type': 'str'}, + } + + def __init__(self, *, rule_name: str, description: str, severity, enabled: bool, query: str, query_frequency: str, query_period: str, alert_trigger_operator, alert_trigger_threshold: int, suppression_enabled: bool, suppression_duration: str, etag: str=None, **kwargs) -> None: + super(ScheduledAlertRule, self).__init__(**kwargs) + self.etag = etag + self.rule_name = rule_name + self.description = description + self.severity = severity + self.enabled = enabled + self.query = query + self.query_frequency = query_frequency + self.query_period = query_period + self.alert_trigger_operator = alert_trigger_operator + self.alert_trigger_threshold = alert_trigger_threshold + self.suppression_enabled = suppression_enabled + self.suppression_duration = suppression_duration + self.last_modified_utc = None diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/security_insights_enums.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/security_insights_enums.py new file mode 100644 index 000000000000..aaefdb4bd06f --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/security_insights_enums.py @@ -0,0 +1,28 @@ +# 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 enum import Enum + + +class Severity(str, Enum): + + low = "Low" + medium = "Medium" + high = "High" + informational = "Informational" + + +class AlertTriggerOperator(str, Enum): + + gt = "gt" + lt = "lt" + ne = "ne" + eq = "eq" diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/__init__.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/__init__.py new file mode 100644 index 000000000000..a0d7733dc4dc --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/__init__.py @@ -0,0 +1,18 @@ +# 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 .operations import Operations +from .scheduled_alert_rules_operations import ScheduledAlertRulesOperations + +__all__ = [ + 'Operations', + 'ScheduledAlertRulesOperations', +] diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/operations.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/operations.py new file mode 100644 index 000000000000..4779a6e237a0 --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/operations.py @@ -0,0 +1,99 @@ +# 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. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError + +from .. import models + + +class Operations(object): + """Operations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: API version for the operation. Constant value: "2019-01-01-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-01-01-preview" + + self.config = config + + def list( + self, custom_headers=None, raw=False, **operation_config): + """Lists all operations available Azure Security Insights Resource + Provider. + + :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 Operation + :rtype: + ~azure.mgmt.securityinsight.models.OperationPaged[~azure.mgmt.securityinsight.models.Operation] + :raises: :class:`CloudError` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list.metadata['url'] + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + response = self._client.send(request, 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.OperationPaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list.metadata = {'url': '/providers/Microsoft.SecurityInsights/operations'} diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/scheduled_alert_rules_operations.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/scheduled_alert_rules_operations.py new file mode 100644 index 000000000000..5579e8b81f89 --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/scheduled_alert_rules_operations.py @@ -0,0 +1,323 @@ +# 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. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError + +from .. import models + + +class ScheduledAlertRulesOperations(object): + """ScheduledAlertRulesOperations operations. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: API version for the operation. Constant value: "2019-01-01-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-01-01-preview" + + self.config = config + + def list( + self, resource_group_name, operational_insights_resource_provider, workspace_name, custom_headers=None, raw=False, **operation_config): + """Gets all scheduled alert rules. + + :param resource_group_name: The name of the resource group within the + user's subscription. The name is case insensitive. + :type resource_group_name: str + :param operational_insights_resource_provider: The namespace of + workspaces resource provider- Microsoft.OperationalInsights. + :type operational_insights_resource_provider: str + :param workspace_name: The name of the workspace. + :type workspace_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: An iterator like instance of ScheduledAlertRule + :rtype: + ~azure.mgmt.securityinsight.models.ScheduledAlertRulePaged[~azure.mgmt.securityinsight.models.ScheduledAlertRule] + :raises: :class:`CloudError` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'operationalInsightsResourceProvider': self._serialize.url("operational_insights_resource_provider", operational_insights_resource_provider, 'str'), + 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=90, min_length=1) + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + response = self._client.send(request, 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.ScheduledAlertRulePaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.ScheduledAlertRulePaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/scheduledAlertRules'} + + def get( + self, resource_group_name, operational_insights_resource_provider, workspace_name, rule_id, custom_headers=None, raw=False, **operation_config): + """Gets a scheduled alert rule. + + :param resource_group_name: The name of the resource group within the + user's subscription. The name is case insensitive. + :type resource_group_name: str + :param operational_insights_resource_provider: The namespace of + workspaces resource provider- Microsoft.OperationalInsights. + :type operational_insights_resource_provider: str + :param workspace_name: The name of the workspace. + :type workspace_name: str + :param rule_id: Alert rule ID + :type rule_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ScheduledAlertRule or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.securityinsight.models.ScheduledAlertRule or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'operationalInsightsResourceProvider': self._serialize.url("operational_insights_resource_provider", operational_insights_resource_provider, 'str'), + 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=90, min_length=1), + 'ruleId': self._serialize.url("rule_id", rule_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('ScheduledAlertRule', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/scheduledAlertRules/{ruleId}'} + + def create( + self, resource_group_name, operational_insights_resource_provider, workspace_name, rule_id, alert_scheduledt_rule, custom_headers=None, raw=False, **operation_config): + """Creates or updates the alert rule. + + :param resource_group_name: The name of the resource group within the + user's subscription. The name is case insensitive. + :type resource_group_name: str + :param operational_insights_resource_provider: The namespace of + workspaces resource provider- Microsoft.OperationalInsights. + :type operational_insights_resource_provider: str + :param workspace_name: The name of the workspace. + :type workspace_name: str + :param rule_id: Alert rule ID + :type rule_id: str + :param alert_scheduledt_rule: The alert rule + :type alert_scheduledt_rule: + ~azure.mgmt.securityinsight.models.ScheduledAlertRule + :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: ScheduledAlertRule or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.securityinsight.models.ScheduledAlertRule or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.create.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'operationalInsightsResourceProvider': self._serialize.url("operational_insights_resource_provider", operational_insights_resource_provider, 'str'), + 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=90, min_length=1), + 'ruleId': self._serialize.url("rule_id", rule_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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(alert_scheduledt_rule, 'ScheduledAlertRule') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, 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('ScheduledAlertRule', response) + if response.status_code == 201: + deserialized = self._deserialize('ScheduledAlertRule', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/scheduledAlertRules/{ruleId}'} + + def delete( + self, resource_group_name, operational_insights_resource_provider, workspace_name, rule_id, custom_headers=None, raw=False, **operation_config): + """Delete the alert rule. + + :param resource_group_name: The name of the resource group within the + user's subscription. The name is case insensitive. + :type resource_group_name: str + :param operational_insights_resource_provider: The namespace of + workspaces resource provider- Microsoft.OperationalInsights. + :type operational_insights_resource_provider: str + :param workspace_name: The name of the workspace. + :type workspace_name: str + :param rule_id: Alert rule ID + :type rule_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'operationalInsightsResourceProvider': self._serialize.url("operational_insights_resource_provider", operational_insights_resource_provider, 'str'), + 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str', max_length=90, min_length=1), + 'ruleId': self._serialize.url("rule_id", rule_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + 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, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [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.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/scheduledAlertRules/{ruleId}'} diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/security_insights.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/security_insights.py new file mode 100644 index 000000000000..2c12449fbb3b --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/security_insights.py @@ -0,0 +1,86 @@ +# 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.service_client import SDKClient +from msrest import Serializer, Deserializer +from msrestazure import AzureConfiguration +from .version import VERSION +from .operations.operations import Operations +from .operations.scheduled_alert_rules_operations import ScheduledAlertRulesOperations +from . import models + + +class SecurityInsightsConfiguration(AzureConfiguration): + """Configuration for SecurityInsights + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: Azure subscription ID + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, credentials, subscription_id, base_url=None): + + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + if not base_url: + base_url = 'https://management.azure.com' + + super(SecurityInsightsConfiguration, self).__init__(base_url) + + self.add_user_agent('azure-mgmt-securityinsight/{}'.format(VERSION)) + self.add_user_agent('Azure-SDK-For-Python') + + self.credentials = credentials + self.subscription_id = subscription_id + + +class SecurityInsights(SDKClient): + """API spec for Microsoft.SecurityInsights (Azure Security Insights) resource provider + + :ivar config: Configuration for client. + :vartype config: SecurityInsightsConfiguration + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.securityinsight.operations.Operations + :ivar scheduled_alert_rules: ScheduledAlertRules operations + :vartype scheduled_alert_rules: azure.mgmt.securityinsight.operations.ScheduledAlertRulesOperations + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: Azure subscription ID + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, credentials, subscription_id, base_url=None): + + self.config = SecurityInsightsConfiguration(credentials, subscription_id, base_url) + super(SecurityInsights, self).__init__(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '2019-01-01-preview' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.operations = Operations( + self._client, self.config, self._serialize, self._deserialize) + self.scheduled_alert_rules = ScheduledAlertRulesOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/version.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/version.py new file mode 100644 index 000000000000..e0ec669828cb --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/version.py @@ -0,0 +1,13 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "0.1.0" + From ca3f6445ff91c009baf34a4096a9903aa4af8139 Mon Sep 17 00:00:00 2001 From: azuresdkci Date: Thu, 24 Jan 2019 15:05:16 +0000 Subject: [PATCH 2/6] Packaging update of azure-mgmt-securityinsight --- azure-mgmt-securityinsight/HISTORY.rst | 9 ++ azure-mgmt-securityinsight/MANIFEST.in | 4 + azure-mgmt-securityinsight/README.rst | 49 +++++++++++ azure-mgmt-securityinsight/azure/__init__.py | 1 + .../azure/mgmt/__init__.py | 1 + azure-mgmt-securityinsight/sdk_packaging.toml | 8 ++ azure-mgmt-securityinsight/setup.cfg | 2 + azure-mgmt-securityinsight/setup.py | 87 +++++++++++++++++++ 8 files changed, 161 insertions(+) create mode 100644 azure-mgmt-securityinsight/HISTORY.rst create mode 100644 azure-mgmt-securityinsight/MANIFEST.in create mode 100644 azure-mgmt-securityinsight/README.rst create mode 100644 azure-mgmt-securityinsight/azure/__init__.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/__init__.py create mode 100644 azure-mgmt-securityinsight/sdk_packaging.toml create mode 100644 azure-mgmt-securityinsight/setup.cfg create mode 100644 azure-mgmt-securityinsight/setup.py diff --git a/azure-mgmt-securityinsight/HISTORY.rst b/azure-mgmt-securityinsight/HISTORY.rst new file mode 100644 index 000000000000..8924d5d6c445 --- /dev/null +++ b/azure-mgmt-securityinsight/HISTORY.rst @@ -0,0 +1,9 @@ +.. :changelog: + +Release History +=============== + +0.1.0 (1970-01-01) +++++++++++++++++++ + +* Initial Release diff --git a/azure-mgmt-securityinsight/MANIFEST.in b/azure-mgmt-securityinsight/MANIFEST.in new file mode 100644 index 000000000000..6ceb27f7a96e --- /dev/null +++ b/azure-mgmt-securityinsight/MANIFEST.in @@ -0,0 +1,4 @@ +include *.rst +include azure/__init__.py +include azure/mgmt/__init__.py + diff --git a/azure-mgmt-securityinsight/README.rst b/azure-mgmt-securityinsight/README.rst new file mode 100644 index 000000000000..45de4e6b43dd --- /dev/null +++ b/azure-mgmt-securityinsight/README.rst @@ -0,0 +1,49 @@ +Microsoft Azure SDK for Python +============================== + +This is the Microsoft Azure MyService Management Client Library. + +Azure Resource Manager (ARM) is the next generation of management APIs that +replace the old Azure Service Management (ASM). + +This package has been tested with Python 2.7, 3.4, 3.5, 3.6 and 3.7. + +For the older Azure Service Management (ASM) libraries, see +`azure-servicemanagement-legacy `__ library. + +For a more complete set of Azure libraries, see the `azure `__ bundle package. + + +Compatibility +============= + +**IMPORTANT**: If you have an earlier version of the azure package +(version < 1.0), you should uninstall it before installing this package. + +You can check the version using pip: + +.. code:: shell + + pip freeze + +If you see azure==0.11.0 (or any version below 1.0), uninstall it first: + +.. code:: shell + + pip uninstall azure + + +Usage +===== + +For code examples, see `MyService Management +`__ +on docs.microsoft.com. + + +Provide Feedback +================ + +If you encounter any bugs or have suggestions, please file an issue in the +`Issues `__ +section of the project. diff --git a/azure-mgmt-securityinsight/azure/__init__.py b/azure-mgmt-securityinsight/azure/__init__.py new file mode 100644 index 000000000000..0260537a02bb --- /dev/null +++ b/azure-mgmt-securityinsight/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/azure-mgmt-securityinsight/azure/mgmt/__init__.py b/azure-mgmt-securityinsight/azure/mgmt/__init__.py new file mode 100644 index 000000000000..0260537a02bb --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file diff --git a/azure-mgmt-securityinsight/sdk_packaging.toml b/azure-mgmt-securityinsight/sdk_packaging.toml new file mode 100644 index 000000000000..74ac4f701334 --- /dev/null +++ b/azure-mgmt-securityinsight/sdk_packaging.toml @@ -0,0 +1,8 @@ +[packaging] +package_name = "azure-mgmt-securityinsight" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "MyService Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = true diff --git a/azure-mgmt-securityinsight/setup.cfg b/azure-mgmt-securityinsight/setup.cfg new file mode 100644 index 000000000000..3c6e79cf31da --- /dev/null +++ b/azure-mgmt-securityinsight/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/azure-mgmt-securityinsight/setup.py b/azure-mgmt-securityinsight/setup.py new file mode 100644 index 000000000000..0f1737e027b2 --- /dev/null +++ b/azure-mgmt-securityinsight/setup.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-securityinsight" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.rst', encoding='utf-8') as f: + readme = f.read() +with open('HISTORY.rst', encoding='utf-8') as f: + history = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + history, + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + 'azure.mgmt', + ]), + install_requires=[ + 'msrest>=0.5.0', + 'msrestazure>=0.4.32,<2.0.0', + 'azure-common~=1.1', + ], + extras_require={ + ":python_version<'3.0'": ['azure-mgmt-nspkg'], + } +) From e16fe4a006d47d8db901c052329ef9d1d81e94c1 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Fri, 25 Jan 2019 16:32:07 +0000 Subject: [PATCH 3/6] Generated from 1d1029b373596e1dfe05b66fce115d5fd4b5ea57 Fixing comments from PR- * Changing durations to fit standards * Changing operators to fit other RPs * Align naming to scheduledAlertRules * Adding 200 response to DeleteScheduledAlertRule --- .../models/scheduled_alert_rule.py | 36 +++++++++--------- .../models/scheduled_alert_rule_py3.py | 38 +++++++++---------- .../models/security_insights_enums.py | 8 ++-- .../scheduled_alert_rules_operations.py | 10 ++--- 4 files changed, 46 insertions(+), 46 deletions(-) diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py index 7eccdec8fc7d..b4df1eff33ff 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py @@ -41,26 +41,26 @@ class ScheduledAlertRule(Resource): :type enabled: bool :param query: Required. The query that creates alerts for this rule. :type query: str - :param query_frequency: Required. TimeSpan format represents the frequncy - for this alert rule to run. - :type query_frequency: str - :param query_period: Required. TimeSpan format represents the period that - this alert rule looks at. - :type query_period: str + :param query_frequency: Required. The frequency (in ISO 8601 duration + format) for this alert rule to run. + :type query_frequency: timedelta + :param query_period: Required. The period (in ISO 8601 duration format) + that this alert rule looks at. + :type query_period: timedelta :param alert_trigger_operator: Required. The operation against the - threahold that triggers alert rule. Possible values include: 'gt', 'lt', - 'ne', 'eq' + threshold that triggers alert rule. Possible values include: + 'GreaterThan', 'LessThan', 'Equal', 'NotEqual' :type alert_trigger_operator: str or ~azure.mgmt.securityinsight.models.AlertTriggerOperator - :param alert_trigger_threshold: Required. The threahold triggers this + :param alert_trigger_threshold: Required. The threshold triggers this alert rule. :type alert_trigger_threshold: int :param suppression_enabled: Required. Determines whether the suppression for this alert rule is enabled or disabled. :type suppression_enabled: bool - :param suppression_duration: Required. TimeSpan format represents the - suppression to wait since last time this alert rule been triggered. - :type suppression_duration: str + :param suppression_duration: Required. The suppression (in ISO 8601 + duration format) to wait since last time this alert rule been triggered. + :type suppression_duration: timedelta :ivar last_modified_utc: The last time that this alert has been modified. :vartype last_modified_utc: str """ @@ -74,12 +74,12 @@ class ScheduledAlertRule(Resource): 'severity': {'required': True}, 'enabled': {'required': True}, 'query': {'required': True}, - 'query_frequency': {'required': True, 'pattern': r'^(\d+\.)?\d{2}\:\d{2}\:\d{2}$'}, - 'query_period': {'required': True, 'pattern': r'^(\d+\.)?\d{2}\:\d{2}\:\d{2}$'}, + 'query_frequency': {'required': True}, + 'query_period': {'required': True}, 'alert_trigger_operator': {'required': True}, 'alert_trigger_threshold': {'required': True}, 'suppression_enabled': {'required': True}, - 'suppression_duration': {'required': True, 'pattern': r'^(\d+\.)?\d{2}\:\d{2}\:\d{2}$'}, + 'suppression_duration': {'required': True}, 'last_modified_utc': {'readonly': True}, } @@ -93,12 +93,12 @@ class ScheduledAlertRule(Resource): 'severity': {'key': 'properties.severity', 'type': 'Severity'}, 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, 'query': {'key': 'properties.query', 'type': 'str'}, - 'query_frequency': {'key': 'properties.queryFrequency', 'type': 'str'}, - 'query_period': {'key': 'properties.queryPeriod', 'type': 'str'}, + 'query_frequency': {'key': 'properties.queryFrequency', 'type': 'duration'}, + 'query_period': {'key': 'properties.queryPeriod', 'type': 'duration'}, 'alert_trigger_operator': {'key': 'properties.alertTriggerOperator', 'type': 'AlertTriggerOperator'}, 'alert_trigger_threshold': {'key': 'properties.alertTriggerThreshold', 'type': 'int'}, 'suppression_enabled': {'key': 'properties.suppressionEnabled', 'type': 'bool'}, - 'suppression_duration': {'key': 'properties.suppressionDuration', 'type': 'str'}, + 'suppression_duration': {'key': 'properties.suppressionDuration', 'type': 'duration'}, 'last_modified_utc': {'key': 'properties.lastModifiedUtc', 'type': 'str'}, } diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py index 83f495af6180..2644a1e1c400 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py @@ -41,26 +41,26 @@ class ScheduledAlertRule(Resource): :type enabled: bool :param query: Required. The query that creates alerts for this rule. :type query: str - :param query_frequency: Required. TimeSpan format represents the frequncy - for this alert rule to run. - :type query_frequency: str - :param query_period: Required. TimeSpan format represents the period that - this alert rule looks at. - :type query_period: str + :param query_frequency: Required. The frequency (in ISO 8601 duration + format) for this alert rule to run. + :type query_frequency: timedelta + :param query_period: Required. The period (in ISO 8601 duration format) + that this alert rule looks at. + :type query_period: timedelta :param alert_trigger_operator: Required. The operation against the - threahold that triggers alert rule. Possible values include: 'gt', 'lt', - 'ne', 'eq' + threshold that triggers alert rule. Possible values include: + 'GreaterThan', 'LessThan', 'Equal', 'NotEqual' :type alert_trigger_operator: str or ~azure.mgmt.securityinsight.models.AlertTriggerOperator - :param alert_trigger_threshold: Required. The threahold triggers this + :param alert_trigger_threshold: Required. The threshold triggers this alert rule. :type alert_trigger_threshold: int :param suppression_enabled: Required. Determines whether the suppression for this alert rule is enabled or disabled. :type suppression_enabled: bool - :param suppression_duration: Required. TimeSpan format represents the - suppression to wait since last time this alert rule been triggered. - :type suppression_duration: str + :param suppression_duration: Required. The suppression (in ISO 8601 + duration format) to wait since last time this alert rule been triggered. + :type suppression_duration: timedelta :ivar last_modified_utc: The last time that this alert has been modified. :vartype last_modified_utc: str """ @@ -74,12 +74,12 @@ class ScheduledAlertRule(Resource): 'severity': {'required': True}, 'enabled': {'required': True}, 'query': {'required': True}, - 'query_frequency': {'required': True, 'pattern': r'^(\d+\.)?\d{2}\:\d{2}\:\d{2}$'}, - 'query_period': {'required': True, 'pattern': r'^(\d+\.)?\d{2}\:\d{2}\:\d{2}$'}, + 'query_frequency': {'required': True}, + 'query_period': {'required': True}, 'alert_trigger_operator': {'required': True}, 'alert_trigger_threshold': {'required': True}, 'suppression_enabled': {'required': True}, - 'suppression_duration': {'required': True, 'pattern': r'^(\d+\.)?\d{2}\:\d{2}\:\d{2}$'}, + 'suppression_duration': {'required': True}, 'last_modified_utc': {'readonly': True}, } @@ -93,16 +93,16 @@ class ScheduledAlertRule(Resource): 'severity': {'key': 'properties.severity', 'type': 'Severity'}, 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, 'query': {'key': 'properties.query', 'type': 'str'}, - 'query_frequency': {'key': 'properties.queryFrequency', 'type': 'str'}, - 'query_period': {'key': 'properties.queryPeriod', 'type': 'str'}, + 'query_frequency': {'key': 'properties.queryFrequency', 'type': 'duration'}, + 'query_period': {'key': 'properties.queryPeriod', 'type': 'duration'}, 'alert_trigger_operator': {'key': 'properties.alertTriggerOperator', 'type': 'AlertTriggerOperator'}, 'alert_trigger_threshold': {'key': 'properties.alertTriggerThreshold', 'type': 'int'}, 'suppression_enabled': {'key': 'properties.suppressionEnabled', 'type': 'bool'}, - 'suppression_duration': {'key': 'properties.suppressionDuration', 'type': 'str'}, + 'suppression_duration': {'key': 'properties.suppressionDuration', 'type': 'duration'}, 'last_modified_utc': {'key': 'properties.lastModifiedUtc', 'type': 'str'}, } - def __init__(self, *, rule_name: str, description: str, severity, enabled: bool, query: str, query_frequency: str, query_period: str, alert_trigger_operator, alert_trigger_threshold: int, suppression_enabled: bool, suppression_duration: str, etag: str=None, **kwargs) -> None: + def __init__(self, *, rule_name: str, description: str, severity, enabled: bool, query: str, query_frequency, query_period, alert_trigger_operator, alert_trigger_threshold: int, suppression_enabled: bool, suppression_duration, etag: str=None, **kwargs) -> None: super(ScheduledAlertRule, self).__init__(**kwargs) self.etag = etag self.rule_name = rule_name diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/security_insights_enums.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/security_insights_enums.py index aaefdb4bd06f..4d2ad0f7fd1b 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/security_insights_enums.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/security_insights_enums.py @@ -22,7 +22,7 @@ class Severity(str, Enum): class AlertTriggerOperator(str, Enum): - gt = "gt" - lt = "lt" - ne = "ne" - eq = "eq" + greater_than = "GreaterThan" + less_than = "LessThan" + equal = "Equal" + not_equal = "NotEqual" diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/scheduled_alert_rules_operations.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/scheduled_alert_rules_operations.py index 5579e8b81f89..1baa89e49c69 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/scheduled_alert_rules_operations.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/scheduled_alert_rules_operations.py @@ -183,7 +183,7 @@ def get( get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/scheduledAlertRules/{ruleId}'} def create( - self, resource_group_name, operational_insights_resource_provider, workspace_name, rule_id, alert_scheduledt_rule, custom_headers=None, raw=False, **operation_config): + self, resource_group_name, operational_insights_resource_provider, workspace_name, rule_id, scheduled_alert_rule, custom_headers=None, raw=False, **operation_config): """Creates or updates the alert rule. :param resource_group_name: The name of the resource group within the @@ -196,8 +196,8 @@ def create( :type workspace_name: str :param rule_id: Alert rule ID :type rule_id: str - :param alert_scheduledt_rule: The alert rule - :type alert_scheduledt_rule: + :param scheduled_alert_rule: The alert rule + :type scheduled_alert_rule: ~azure.mgmt.securityinsight.models.ScheduledAlertRule :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the @@ -236,7 +236,7 @@ def create( header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body - body_content = self._serialize.body(alert_scheduledt_rule, 'ScheduledAlertRule') + body_content = self._serialize.body(scheduled_alert_rule, 'ScheduledAlertRule') # Construct and send request request = self._client.put(url, query_parameters, header_parameters, body_content) @@ -312,7 +312,7 @@ def delete( request = self._client.delete(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) - if response.status_code not in [204]: + if response.status_code not in [200, 204]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp From 138f78336c38ca19d0bd345f23f7ef239f1e34b2 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Mon, 28 Jan 2019 07:19:07 +0000 Subject: [PATCH 4/6] Generated from 573869de582350c81ae8c39877c2a170ac85cbfd Adding kind to AlertRule and making Scheduled as a specific kind --- .../mgmt/securityinsight/models/__init__.py | 16 ++++-- .../mgmt/securityinsight/models/alert_rule.py | 54 +++++++++++++++++++ .../models/alert_rule_kind1.py | 29 ++++++++++ .../models/alert_rule_kind1_py3.py | 29 ++++++++++ ...lert_rule_paged.py => alert_rule_paged.py} | 8 +-- .../securityinsight/models/alert_rule_py3.py | 54 +++++++++++++++++++ .../models/scheduled_alert_rule.py | 39 +++++++------- .../models/scheduled_alert_rule_py3.py | 43 ++++++++------- .../models/security_insights_enums.py | 7 ++- .../securityinsight/operations/__init__.py | 4 +- ...perations.py => alert_rules_operations.py} | 52 +++++++++--------- .../mgmt/securityinsight/security_insights.py | 8 +-- 12 files changed, 266 insertions(+), 77 deletions(-) create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_kind1.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_kind1_py3.py rename azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/{scheduled_alert_rule_paged.py => alert_rule_paged.py} (66%) create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_py3.py rename azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/{scheduled_alert_rules_operations.py => alert_rules_operations.py} (90%) diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/__init__.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/__init__.py index 4239bdbf798b..4269289ed2ad 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/__init__.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/__init__.py @@ -12,27 +12,35 @@ try: from .operation_display_py3 import OperationDisplay from .operation_py3 import Operation + from .alert_rule_py3 import AlertRule + from .alert_rule_kind1_py3 import AlertRuleKind1 from .scheduled_alert_rule_py3 import ScheduledAlertRule from .resource_py3 import Resource except (SyntaxError, ImportError): from .operation_display import OperationDisplay from .operation import Operation + from .alert_rule import AlertRule + from .alert_rule_kind1 import AlertRuleKind1 from .scheduled_alert_rule import ScheduledAlertRule from .resource import Resource from .operation_paged import OperationPaged -from .scheduled_alert_rule_paged import ScheduledAlertRulePaged +from .alert_rule_paged import AlertRulePaged from .security_insights_enums import ( + AlertRuleKind, Severity, - AlertTriggerOperator, + TriggerOperator, ) __all__ = [ 'OperationDisplay', 'Operation', + 'AlertRule', + 'AlertRuleKind1', 'ScheduledAlertRule', 'Resource', 'OperationPaged', - 'ScheduledAlertRulePaged', + 'AlertRulePaged', + 'AlertRuleKind', 'Severity', - 'AlertTriggerOperator', + 'TriggerOperator', ] diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule.py new file mode 100644 index 000000000000..99e5d5d66b20 --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule.py @@ -0,0 +1,54 @@ +# 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 AlertRule(Model): + """Alert rule. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + :param kind: The kind of the alert rule. Possible values include: + 'Scheduled' + :type kind: str or ~azure.mgmt.securityinsight.models.AlertRuleKind + :param etag: Etag of the alert rule. + :type etag: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(AlertRule, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.kind = kwargs.get('kind', None) + self.etag = kwargs.get('etag', None) diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_kind1.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_kind1.py new file mode 100644 index 000000000000..204fa1ddf932 --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_kind1.py @@ -0,0 +1,29 @@ +# 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 AlertRuleKind1(Model): + """Describes an Azure resource with kind. + + :param kind: The kind of the alert rule. Possible values include: + 'Scheduled' + :type kind: str or ~azure.mgmt.securityinsight.models.AlertRuleKind + """ + + _attribute_map = { + 'kind': {'key': 'kind', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(AlertRuleKind1, self).__init__(**kwargs) + self.kind = kwargs.get('kind', None) diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_kind1_py3.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_kind1_py3.py new file mode 100644 index 000000000000..aff9133b36c9 --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_kind1_py3.py @@ -0,0 +1,29 @@ +# 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 AlertRuleKind1(Model): + """Describes an Azure resource with kind. + + :param kind: The kind of the alert rule. Possible values include: + 'Scheduled' + :type kind: str or ~azure.mgmt.securityinsight.models.AlertRuleKind + """ + + _attribute_map = { + 'kind': {'key': 'kind', 'type': 'str'}, + } + + def __init__(self, *, kind=None, **kwargs) -> None: + super(AlertRuleKind1, self).__init__(**kwargs) + self.kind = kind diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_paged.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_paged.py similarity index 66% rename from azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_paged.py rename to azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_paged.py index 81a61b427c1e..765456eff7ec 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_paged.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_paged.py @@ -12,16 +12,16 @@ from msrest.paging import Paged -class ScheduledAlertRulePaged(Paged): +class AlertRulePaged(Paged): """ - A paging container for iterating over a list of :class:`ScheduledAlertRule ` object + A paging container for iterating over a list of :class:`AlertRule ` object """ _attribute_map = { 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ScheduledAlertRule]'} + 'current_page': {'key': 'value', 'type': '[AlertRule]'} } def __init__(self, *args, **kwargs): - super(ScheduledAlertRulePaged, self).__init__(*args, **kwargs) + super(AlertRulePaged, self).__init__(*args, **kwargs) diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_py3.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_py3.py new file mode 100644 index 000000000000..f770055d91c7 --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_py3.py @@ -0,0 +1,54 @@ +# 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 AlertRule(Model): + """Alert rule. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Azure resource Id + :vartype id: str + :ivar type: Azure resource type + :vartype type: str + :ivar name: Azure resource name + :vartype name: str + :param kind: The kind of the alert rule. Possible values include: + 'Scheduled' + :type kind: str or ~azure.mgmt.securityinsight.models.AlertRuleKind + :param etag: Etag of the alert rule. + :type etag: str + """ + + _validation = { + 'id': {'readonly': True}, + 'type': {'readonly': True}, + 'name': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'etag': {'key': 'etag', 'type': 'str'}, + } + + def __init__(self, *, kind=None, etag: str=None, **kwargs) -> None: + super(AlertRule, self).__init__(**kwargs) + self.id = None + self.type = None + self.name = None + self.kind = kind + self.etag = etag diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py index b4df1eff33ff..bb94feb32d86 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py @@ -9,11 +9,11 @@ # regenerated. # -------------------------------------------------------------------------- -from .resource import Resource +from .alert_rule import AlertRule -class ScheduledAlertRule(Resource): - """Alert rule. +class ScheduledAlertRule(AlertRule): + """Represents scheduled alert rule. Variables are only populated by the server, and will be ignored when sending a request. @@ -26,6 +26,9 @@ class ScheduledAlertRule(Resource): :vartype type: str :ivar name: Azure resource name :vartype name: str + :param kind: The kind of the alert rule. Possible values include: + 'Scheduled' + :type kind: str or ~azure.mgmt.securityinsight.models.AlertRuleKind :param etag: Etag of the alert rule. :type etag: str :param rule_name: Required. The name for alerts created by this alert @@ -47,14 +50,14 @@ class ScheduledAlertRule(Resource): :param query_period: Required. The period (in ISO 8601 duration format) that this alert rule looks at. :type query_period: timedelta - :param alert_trigger_operator: Required. The operation against the - threshold that triggers alert rule. Possible values include: - 'GreaterThan', 'LessThan', 'Equal', 'NotEqual' - :type alert_trigger_operator: str or - ~azure.mgmt.securityinsight.models.AlertTriggerOperator - :param alert_trigger_threshold: Required. The threshold triggers this - alert rule. - :type alert_trigger_threshold: int + :param trigger_operator: Required. The operation against the threshold + that triggers alert rule. Possible values include: 'GreaterThan', + 'LessThan', 'Equal', 'NotEqual' + :type trigger_operator: str or + ~azure.mgmt.securityinsight.models.TriggerOperator + :param trigger_threshold: Required. The threshold triggers this alert + rule. + :type trigger_threshold: int :param suppression_enabled: Required. Determines whether the suppression for this alert rule is enabled or disabled. :type suppression_enabled: bool @@ -76,8 +79,8 @@ class ScheduledAlertRule(Resource): 'query': {'required': True}, 'query_frequency': {'required': True}, 'query_period': {'required': True}, - 'alert_trigger_operator': {'required': True}, - 'alert_trigger_threshold': {'required': True}, + 'trigger_operator': {'required': True}, + 'trigger_threshold': {'required': True}, 'suppression_enabled': {'required': True}, 'suppression_duration': {'required': True}, 'last_modified_utc': {'readonly': True}, @@ -87,6 +90,7 @@ class ScheduledAlertRule(Resource): 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, 'etag': {'key': 'etag', 'type': 'str'}, 'rule_name': {'key': 'properties.ruleName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, @@ -95,8 +99,8 @@ class ScheduledAlertRule(Resource): 'query': {'key': 'properties.query', 'type': 'str'}, 'query_frequency': {'key': 'properties.queryFrequency', 'type': 'duration'}, 'query_period': {'key': 'properties.queryPeriod', 'type': 'duration'}, - 'alert_trigger_operator': {'key': 'properties.alertTriggerOperator', 'type': 'AlertTriggerOperator'}, - 'alert_trigger_threshold': {'key': 'properties.alertTriggerThreshold', 'type': 'int'}, + 'trigger_operator': {'key': 'properties.triggerOperator', 'type': 'TriggerOperator'}, + 'trigger_threshold': {'key': 'properties.triggerThreshold', 'type': 'int'}, 'suppression_enabled': {'key': 'properties.suppressionEnabled', 'type': 'bool'}, 'suppression_duration': {'key': 'properties.suppressionDuration', 'type': 'duration'}, 'last_modified_utc': {'key': 'properties.lastModifiedUtc', 'type': 'str'}, @@ -104,7 +108,6 @@ class ScheduledAlertRule(Resource): def __init__(self, **kwargs): super(ScheduledAlertRule, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) self.rule_name = kwargs.get('rule_name', None) self.description = kwargs.get('description', None) self.severity = kwargs.get('severity', None) @@ -112,8 +115,8 @@ def __init__(self, **kwargs): self.query = kwargs.get('query', None) self.query_frequency = kwargs.get('query_frequency', None) self.query_period = kwargs.get('query_period', None) - self.alert_trigger_operator = kwargs.get('alert_trigger_operator', None) - self.alert_trigger_threshold = kwargs.get('alert_trigger_threshold', None) + self.trigger_operator = kwargs.get('trigger_operator', None) + self.trigger_threshold = kwargs.get('trigger_threshold', None) self.suppression_enabled = kwargs.get('suppression_enabled', None) self.suppression_duration = kwargs.get('suppression_duration', None) self.last_modified_utc = None diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py index 2644a1e1c400..3796e16fb8ec 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py @@ -9,11 +9,11 @@ # regenerated. # -------------------------------------------------------------------------- -from .resource_py3 import Resource +from .alert_rule_py3 import AlertRule -class ScheduledAlertRule(Resource): - """Alert rule. +class ScheduledAlertRule(AlertRule): + """Represents scheduled alert rule. Variables are only populated by the server, and will be ignored when sending a request. @@ -26,6 +26,9 @@ class ScheduledAlertRule(Resource): :vartype type: str :ivar name: Azure resource name :vartype name: str + :param kind: The kind of the alert rule. Possible values include: + 'Scheduled' + :type kind: str or ~azure.mgmt.securityinsight.models.AlertRuleKind :param etag: Etag of the alert rule. :type etag: str :param rule_name: Required. The name for alerts created by this alert @@ -47,14 +50,14 @@ class ScheduledAlertRule(Resource): :param query_period: Required. The period (in ISO 8601 duration format) that this alert rule looks at. :type query_period: timedelta - :param alert_trigger_operator: Required. The operation against the - threshold that triggers alert rule. Possible values include: - 'GreaterThan', 'LessThan', 'Equal', 'NotEqual' - :type alert_trigger_operator: str or - ~azure.mgmt.securityinsight.models.AlertTriggerOperator - :param alert_trigger_threshold: Required. The threshold triggers this - alert rule. - :type alert_trigger_threshold: int + :param trigger_operator: Required. The operation against the threshold + that triggers alert rule. Possible values include: 'GreaterThan', + 'LessThan', 'Equal', 'NotEqual' + :type trigger_operator: str or + ~azure.mgmt.securityinsight.models.TriggerOperator + :param trigger_threshold: Required. The threshold triggers this alert + rule. + :type trigger_threshold: int :param suppression_enabled: Required. Determines whether the suppression for this alert rule is enabled or disabled. :type suppression_enabled: bool @@ -76,8 +79,8 @@ class ScheduledAlertRule(Resource): 'query': {'required': True}, 'query_frequency': {'required': True}, 'query_period': {'required': True}, - 'alert_trigger_operator': {'required': True}, - 'alert_trigger_threshold': {'required': True}, + 'trigger_operator': {'required': True}, + 'trigger_threshold': {'required': True}, 'suppression_enabled': {'required': True}, 'suppression_duration': {'required': True}, 'last_modified_utc': {'readonly': True}, @@ -87,6 +90,7 @@ class ScheduledAlertRule(Resource): 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, 'etag': {'key': 'etag', 'type': 'str'}, 'rule_name': {'key': 'properties.ruleName', 'type': 'str'}, 'description': {'key': 'properties.description', 'type': 'str'}, @@ -95,16 +99,15 @@ class ScheduledAlertRule(Resource): 'query': {'key': 'properties.query', 'type': 'str'}, 'query_frequency': {'key': 'properties.queryFrequency', 'type': 'duration'}, 'query_period': {'key': 'properties.queryPeriod', 'type': 'duration'}, - 'alert_trigger_operator': {'key': 'properties.alertTriggerOperator', 'type': 'AlertTriggerOperator'}, - 'alert_trigger_threshold': {'key': 'properties.alertTriggerThreshold', 'type': 'int'}, + 'trigger_operator': {'key': 'properties.triggerOperator', 'type': 'TriggerOperator'}, + 'trigger_threshold': {'key': 'properties.triggerThreshold', 'type': 'int'}, 'suppression_enabled': {'key': 'properties.suppressionEnabled', 'type': 'bool'}, 'suppression_duration': {'key': 'properties.suppressionDuration', 'type': 'duration'}, 'last_modified_utc': {'key': 'properties.lastModifiedUtc', 'type': 'str'}, } - def __init__(self, *, rule_name: str, description: str, severity, enabled: bool, query: str, query_frequency, query_period, alert_trigger_operator, alert_trigger_threshold: int, suppression_enabled: bool, suppression_duration, etag: str=None, **kwargs) -> None: - super(ScheduledAlertRule, self).__init__(**kwargs) - self.etag = etag + def __init__(self, *, rule_name: str, description: str, severity, enabled: bool, query: str, query_frequency, query_period, trigger_operator, trigger_threshold: int, suppression_enabled: bool, suppression_duration, kind=None, etag: str=None, **kwargs) -> None: + super(ScheduledAlertRule, self).__init__(kind=kind, etag=etag, **kwargs) self.rule_name = rule_name self.description = description self.severity = severity @@ -112,8 +115,8 @@ def __init__(self, *, rule_name: str, description: str, severity, enabled: bool, self.query = query self.query_frequency = query_frequency self.query_period = query_period - self.alert_trigger_operator = alert_trigger_operator - self.alert_trigger_threshold = alert_trigger_threshold + self.trigger_operator = trigger_operator + self.trigger_threshold = trigger_threshold self.suppression_enabled = suppression_enabled self.suppression_duration = suppression_duration self.last_modified_utc = None diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/security_insights_enums.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/security_insights_enums.py index 4d2ad0f7fd1b..1d640838c0da 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/security_insights_enums.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/security_insights_enums.py @@ -12,6 +12,11 @@ from enum import Enum +class AlertRuleKind(str, Enum): + + scheduled = "Scheduled" + + class Severity(str, Enum): low = "Low" @@ -20,7 +25,7 @@ class Severity(str, Enum): informational = "Informational" -class AlertTriggerOperator(str, Enum): +class TriggerOperator(str, Enum): greater_than = "GreaterThan" less_than = "LessThan" diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/__init__.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/__init__.py index a0d7733dc4dc..fccf5dd12dbe 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/__init__.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/__init__.py @@ -10,9 +10,9 @@ # -------------------------------------------------------------------------- from .operations import Operations -from .scheduled_alert_rules_operations import ScheduledAlertRulesOperations +from .alert_rules_operations import AlertRulesOperations __all__ = [ 'Operations', - 'ScheduledAlertRulesOperations', + 'AlertRulesOperations', ] diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/scheduled_alert_rules_operations.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/alert_rules_operations.py similarity index 90% rename from azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/scheduled_alert_rules_operations.py rename to azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/alert_rules_operations.py index 1baa89e49c69..01fec7a914c0 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/scheduled_alert_rules_operations.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/alert_rules_operations.py @@ -16,8 +16,8 @@ from .. import models -class ScheduledAlertRulesOperations(object): - """ScheduledAlertRulesOperations operations. +class AlertRulesOperations(object): + """AlertRulesOperations operations. :param client: Client for service requests. :param config: Configuration of service client. @@ -39,7 +39,7 @@ def __init__(self, client, config, serializer, deserializer): def list( self, resource_group_name, operational_insights_resource_provider, workspace_name, custom_headers=None, raw=False, **operation_config): - """Gets all scheduled alert rules. + """Gets all alert rules. :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. @@ -54,9 +54,9 @@ def list( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :return: An iterator like instance of ScheduledAlertRule + :return: An iterator like instance of AlertRule :rtype: - ~azure.mgmt.securityinsight.models.ScheduledAlertRulePaged[~azure.mgmt.securityinsight.models.ScheduledAlertRule] + ~azure.mgmt.securityinsight.models.AlertRulePaged[~azure.mgmt.securityinsight.models.AlertRule] :raises: :class:`CloudError` """ def internal_paging(next_link=None, raw=False): @@ -102,19 +102,19 @@ def internal_paging(next_link=None, raw=False): return response # Deserialize response - deserialized = models.ScheduledAlertRulePaged(internal_paging, self._deserialize.dependencies) + deserialized = models.AlertRulePaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} - client_raw_response = models.ScheduledAlertRulePaged(internal_paging, self._deserialize.dependencies, header_dict) + client_raw_response = models.AlertRulePaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/scheduledAlertRules'} + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/alertRules'} def get( self, resource_group_name, operational_insights_resource_provider, workspace_name, rule_id, custom_headers=None, raw=False, **operation_config): - """Gets a scheduled alert rule. + """Gets a alert rule. :param resource_group_name: The name of the resource group within the user's subscription. The name is case insensitive. @@ -131,8 +131,8 @@ def get( deserialized response :param operation_config: :ref:`Operation configuration overrides`. - :return: ScheduledAlertRule or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.securityinsight.models.ScheduledAlertRule or + :return: AlertRule or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.securityinsight.models.AlertRule or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ @@ -173,17 +173,17 @@ def get( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ScheduledAlertRule', response) + deserialized = self._deserialize('AlertRule', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/scheduledAlertRules/{ruleId}'} + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/alertRules/{ruleId}'} def create( - self, resource_group_name, operational_insights_resource_provider, workspace_name, rule_id, scheduled_alert_rule, custom_headers=None, raw=False, **operation_config): + self, resource_group_name, operational_insights_resource_provider, workspace_name, rule_id, kind=None, etag=None, custom_headers=None, raw=False, **operation_config): """Creates or updates the alert rule. :param resource_group_name: The name of the resource group within the @@ -196,19 +196,23 @@ def create( :type workspace_name: str :param rule_id: Alert rule ID :type rule_id: str - :param scheduled_alert_rule: The alert rule - :type scheduled_alert_rule: - ~azure.mgmt.securityinsight.models.ScheduledAlertRule + :param kind: The kind of the alert rule. Possible values include: + 'Scheduled' + :type kind: str or ~azure.mgmt.securityinsight.models.AlertRuleKind + :param etag: Etag of the alert rule. + :type etag: 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: ScheduledAlertRule or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.securityinsight.models.ScheduledAlertRule or + :return: AlertRule or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.securityinsight.models.AlertRule or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ + alert_rule = models.AlertRule(kind=kind, etag=etag) + # Construct URL url = self.create.metadata['url'] path_format_arguments = { @@ -236,7 +240,7 @@ def create( header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body - body_content = self._serialize.body(scheduled_alert_rule, 'ScheduledAlertRule') + body_content = self._serialize.body(alert_rule, 'AlertRule') # Construct and send request request = self._client.put(url, query_parameters, header_parameters, body_content) @@ -250,16 +254,16 @@ def create( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('ScheduledAlertRule', response) + deserialized = self._deserialize('AlertRule', response) if response.status_code == 201: - deserialized = self._deserialize('ScheduledAlertRule', response) + deserialized = self._deserialize('AlertRule', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized - create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/scheduledAlertRules/{ruleId}'} + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/alertRules/{ruleId}'} def delete( self, resource_group_name, operational_insights_resource_provider, workspace_name, rule_id, custom_headers=None, raw=False, **operation_config): @@ -320,4 +324,4 @@ def delete( if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/scheduledAlertRules/{ruleId}'} + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/alertRules/{ruleId}'} diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/security_insights.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/security_insights.py index 2c12449fbb3b..76cf6b21f37f 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/security_insights.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/security_insights.py @@ -14,7 +14,7 @@ from msrestazure import AzureConfiguration from .version import VERSION from .operations.operations import Operations -from .operations.scheduled_alert_rules_operations import ScheduledAlertRulesOperations +from .operations.alert_rules_operations import AlertRulesOperations from . import models @@ -58,8 +58,8 @@ class SecurityInsights(SDKClient): :ivar operations: Operations operations :vartype operations: azure.mgmt.securityinsight.operations.Operations - :ivar scheduled_alert_rules: ScheduledAlertRules operations - :vartype scheduled_alert_rules: azure.mgmt.securityinsight.operations.ScheduledAlertRulesOperations + :ivar alert_rules: AlertRules operations + :vartype alert_rules: azure.mgmt.securityinsight.operations.AlertRulesOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -82,5 +82,5 @@ def __init__( self.operations = Operations( self._client, self.config, self._serialize, self._deserialize) - self.scheduled_alert_rules = ScheduledAlertRulesOperations( + self.alert_rules = AlertRulesOperations( self._client, self.config, self._serialize, self._deserialize) From bca183ea7e4c76d1b09ba441402b53b59bb816b6 Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Mon, 28 Jan 2019 09:51:04 +0000 Subject: [PATCH 5/6] Generated from 27d8376898b34d8f7a3c1a0f31ba53ca217afa57 Fix some errors --- .../mgmt/securityinsight/models/__init__.py | 3 + .../models/scheduled_alert_rule.py | 78 +------------ .../models/scheduled_alert_rule_properties.py | 103 ++++++++++++++++++ .../scheduled_alert_rule_properties_py3.py | 103 ++++++++++++++++++ .../models/scheduled_alert_rule_py3.py | 80 +------------- 5 files changed, 220 insertions(+), 147 deletions(-) create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_properties.py create mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_properties_py3.py diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/__init__.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/__init__.py index 4269289ed2ad..8f637069d5b6 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/__init__.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/__init__.py @@ -14,6 +14,7 @@ from .operation_py3 import Operation from .alert_rule_py3 import AlertRule from .alert_rule_kind1_py3 import AlertRuleKind1 + from .scheduled_alert_rule_properties_py3 import ScheduledAlertRuleProperties from .scheduled_alert_rule_py3 import ScheduledAlertRule from .resource_py3 import Resource except (SyntaxError, ImportError): @@ -21,6 +22,7 @@ from .operation import Operation from .alert_rule import AlertRule from .alert_rule_kind1 import AlertRuleKind1 + from .scheduled_alert_rule_properties import ScheduledAlertRuleProperties from .scheduled_alert_rule import ScheduledAlertRule from .resource import Resource from .operation_paged import OperationPaged @@ -36,6 +38,7 @@ 'Operation', 'AlertRule', 'AlertRuleKind1', + 'ScheduledAlertRuleProperties', 'ScheduledAlertRule', 'Resource', 'OperationPaged', diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py index bb94feb32d86..46d4c024fc52 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py @@ -18,8 +18,6 @@ class ScheduledAlertRule(AlertRule): 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 type: Azure resource type @@ -31,59 +29,15 @@ class ScheduledAlertRule(AlertRule): :type kind: str or ~azure.mgmt.securityinsight.models.AlertRuleKind :param etag: Etag of the alert rule. :type etag: str - :param rule_name: Required. The name for alerts created by this alert - rule. - :type rule_name: str - :param description: Required. The description of the alert rule. - :type description: str - :param severity: Required. The severity for alerts created by this alert - rule. Possible values include: 'Low', 'Medium', 'High', 'Informational' - :type severity: str or ~azure.mgmt.securityinsight.models.Severity - :param enabled: Required. Determines whether this alert rule is enabled or - disabled. - :type enabled: bool - :param query: Required. The query that creates alerts for this rule. - :type query: str - :param query_frequency: Required. The frequency (in ISO 8601 duration - format) for this alert rule to run. - :type query_frequency: timedelta - :param query_period: Required. The period (in ISO 8601 duration format) - that this alert rule looks at. - :type query_period: timedelta - :param trigger_operator: Required. The operation against the threshold - that triggers alert rule. Possible values include: 'GreaterThan', - 'LessThan', 'Equal', 'NotEqual' - :type trigger_operator: str or - ~azure.mgmt.securityinsight.models.TriggerOperator - :param trigger_threshold: Required. The threshold triggers this alert - rule. - :type trigger_threshold: int - :param suppression_enabled: Required. Determines whether the suppression - for this alert rule is enabled or disabled. - :type suppression_enabled: bool - :param suppression_duration: Required. The suppression (in ISO 8601 - duration format) to wait since last time this alert rule been triggered. - :type suppression_duration: timedelta - :ivar last_modified_utc: The last time that this alert has been modified. - :vartype last_modified_utc: str + :param properties: Scheduled alert rule properties + :type properties: + ~azure.mgmt.securityinsight.models.ScheduledAlertRuleProperties """ _validation = { 'id': {'readonly': True}, 'type': {'readonly': True}, 'name': {'readonly': True}, - 'rule_name': {'required': True}, - 'description': {'required': True}, - 'severity': {'required': True}, - 'enabled': {'required': True}, - 'query': {'required': True}, - 'query_frequency': {'required': True}, - 'query_period': {'required': True}, - 'trigger_operator': {'required': True}, - 'trigger_threshold': {'required': True}, - 'suppression_enabled': {'required': True}, - 'suppression_duration': {'required': True}, - 'last_modified_utc': {'readonly': True}, } _attribute_map = { @@ -92,31 +46,9 @@ class ScheduledAlertRule(AlertRule): 'name': {'key': 'name', 'type': 'str'}, 'kind': {'key': 'kind', 'type': 'str'}, 'etag': {'key': 'etag', 'type': 'str'}, - 'rule_name': {'key': 'properties.ruleName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'Severity'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'query': {'key': 'properties.query', 'type': 'str'}, - 'query_frequency': {'key': 'properties.queryFrequency', 'type': 'duration'}, - 'query_period': {'key': 'properties.queryPeriod', 'type': 'duration'}, - 'trigger_operator': {'key': 'properties.triggerOperator', 'type': 'TriggerOperator'}, - 'trigger_threshold': {'key': 'properties.triggerThreshold', 'type': 'int'}, - 'suppression_enabled': {'key': 'properties.suppressionEnabled', 'type': 'bool'}, - 'suppression_duration': {'key': 'properties.suppressionDuration', 'type': 'duration'}, - 'last_modified_utc': {'key': 'properties.lastModifiedUtc', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'ScheduledAlertRuleProperties'}, } def __init__(self, **kwargs): super(ScheduledAlertRule, self).__init__(**kwargs) - self.rule_name = kwargs.get('rule_name', None) - self.description = kwargs.get('description', None) - self.severity = kwargs.get('severity', None) - self.enabled = kwargs.get('enabled', None) - self.query = kwargs.get('query', None) - self.query_frequency = kwargs.get('query_frequency', None) - self.query_period = kwargs.get('query_period', None) - self.trigger_operator = kwargs.get('trigger_operator', None) - self.trigger_threshold = kwargs.get('trigger_threshold', None) - self.suppression_enabled = kwargs.get('suppression_enabled', None) - self.suppression_duration = kwargs.get('suppression_duration', None) - self.last_modified_utc = None + self.properties = kwargs.get('properties', None) diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_properties.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_properties.py new file mode 100644 index 000000000000..fc686e66507a --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_properties.py @@ -0,0 +1,103 @@ +# 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 ScheduledAlertRuleProperties(Model): + """Alert rule property bag. + + 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 rule_name: Required. The name for alerts created by this alert + rule. + :type rule_name: str + :param description: Required. The description of the alert rule. + :type description: str + :param severity: Required. The severity for alerts created by this alert + rule. Possible values include: 'Low', 'Medium', 'High', 'Informational' + :type severity: str or ~azure.mgmt.securityinsight.models.Severity + :param enabled: Required. Determines whether this alert rule is enabled or + disabled. + :type enabled: bool + :param query: Required. The query that creates alerts for this rule. + :type query: str + :param query_frequency: Required. The frequency (in ISO 8601 duration + format) for this alert rule to run. + :type query_frequency: timedelta + :param query_period: Required. The period (in ISO 8601 duration format) + that this alert rule looks at. + :type query_period: timedelta + :param trigger_operator: Required. The operation against the threshold + that triggers alert rule. Possible values include: 'GreaterThan', + 'LessThan', 'Equal', 'NotEqual' + :type trigger_operator: str or + ~azure.mgmt.securityinsight.models.TriggerOperator + :param trigger_threshold: Required. The threshold triggers this alert + rule. + :type trigger_threshold: int + :param suppression_enabled: Required. Determines whether the suppression + for this alert rule is enabled or disabled. + :type suppression_enabled: bool + :param suppression_duration: Required. The suppression (in ISO 8601 + duration format) to wait since last time this alert rule been triggered. + :type suppression_duration: timedelta + :ivar last_modified_utc: The last time that this alert has been modified. + :vartype last_modified_utc: str + """ + + _validation = { + 'rule_name': {'required': True}, + 'description': {'required': True}, + 'severity': {'required': True}, + 'enabled': {'required': True}, + 'query': {'required': True}, + 'query_frequency': {'required': True}, + 'query_period': {'required': True}, + 'trigger_operator': {'required': True}, + 'trigger_threshold': {'required': True}, + 'suppression_enabled': {'required': True}, + 'suppression_duration': {'required': True}, + 'last_modified_utc': {'readonly': True}, + } + + _attribute_map = { + 'rule_name': {'key': 'ruleName', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'severity': {'key': 'severity', 'type': 'Severity'}, + 'enabled': {'key': 'enabled', 'type': 'bool'}, + 'query': {'key': 'query', 'type': 'str'}, + 'query_frequency': {'key': 'queryFrequency', 'type': 'duration'}, + 'query_period': {'key': 'queryPeriod', 'type': 'duration'}, + 'trigger_operator': {'key': 'triggerOperator', 'type': 'TriggerOperator'}, + 'trigger_threshold': {'key': 'triggerThreshold', 'type': 'int'}, + 'suppression_enabled': {'key': 'suppressionEnabled', 'type': 'bool'}, + 'suppression_duration': {'key': 'suppressionDuration', 'type': 'duration'}, + 'last_modified_utc': {'key': 'lastModifiedUtc', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ScheduledAlertRuleProperties, self).__init__(**kwargs) + self.rule_name = kwargs.get('rule_name', None) + self.description = kwargs.get('description', None) + self.severity = kwargs.get('severity', None) + self.enabled = kwargs.get('enabled', None) + self.query = kwargs.get('query', None) + self.query_frequency = kwargs.get('query_frequency', None) + self.query_period = kwargs.get('query_period', None) + self.trigger_operator = kwargs.get('trigger_operator', None) + self.trigger_threshold = kwargs.get('trigger_threshold', None) + self.suppression_enabled = kwargs.get('suppression_enabled', None) + self.suppression_duration = kwargs.get('suppression_duration', None) + self.last_modified_utc = None diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_properties_py3.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_properties_py3.py new file mode 100644 index 000000000000..b3f92b3b519f --- /dev/null +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_properties_py3.py @@ -0,0 +1,103 @@ +# 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 ScheduledAlertRuleProperties(Model): + """Alert rule property bag. + + 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 rule_name: Required. The name for alerts created by this alert + rule. + :type rule_name: str + :param description: Required. The description of the alert rule. + :type description: str + :param severity: Required. The severity for alerts created by this alert + rule. Possible values include: 'Low', 'Medium', 'High', 'Informational' + :type severity: str or ~azure.mgmt.securityinsight.models.Severity + :param enabled: Required. Determines whether this alert rule is enabled or + disabled. + :type enabled: bool + :param query: Required. The query that creates alerts for this rule. + :type query: str + :param query_frequency: Required. The frequency (in ISO 8601 duration + format) for this alert rule to run. + :type query_frequency: timedelta + :param query_period: Required. The period (in ISO 8601 duration format) + that this alert rule looks at. + :type query_period: timedelta + :param trigger_operator: Required. The operation against the threshold + that triggers alert rule. Possible values include: 'GreaterThan', + 'LessThan', 'Equal', 'NotEqual' + :type trigger_operator: str or + ~azure.mgmt.securityinsight.models.TriggerOperator + :param trigger_threshold: Required. The threshold triggers this alert + rule. + :type trigger_threshold: int + :param suppression_enabled: Required. Determines whether the suppression + for this alert rule is enabled or disabled. + :type suppression_enabled: bool + :param suppression_duration: Required. The suppression (in ISO 8601 + duration format) to wait since last time this alert rule been triggered. + :type suppression_duration: timedelta + :ivar last_modified_utc: The last time that this alert has been modified. + :vartype last_modified_utc: str + """ + + _validation = { + 'rule_name': {'required': True}, + 'description': {'required': True}, + 'severity': {'required': True}, + 'enabled': {'required': True}, + 'query': {'required': True}, + 'query_frequency': {'required': True}, + 'query_period': {'required': True}, + 'trigger_operator': {'required': True}, + 'trigger_threshold': {'required': True}, + 'suppression_enabled': {'required': True}, + 'suppression_duration': {'required': True}, + 'last_modified_utc': {'readonly': True}, + } + + _attribute_map = { + 'rule_name': {'key': 'ruleName', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + 'severity': {'key': 'severity', 'type': 'Severity'}, + 'enabled': {'key': 'enabled', 'type': 'bool'}, + 'query': {'key': 'query', 'type': 'str'}, + 'query_frequency': {'key': 'queryFrequency', 'type': 'duration'}, + 'query_period': {'key': 'queryPeriod', 'type': 'duration'}, + 'trigger_operator': {'key': 'triggerOperator', 'type': 'TriggerOperator'}, + 'trigger_threshold': {'key': 'triggerThreshold', 'type': 'int'}, + 'suppression_enabled': {'key': 'suppressionEnabled', 'type': 'bool'}, + 'suppression_duration': {'key': 'suppressionDuration', 'type': 'duration'}, + 'last_modified_utc': {'key': 'lastModifiedUtc', 'type': 'str'}, + } + + def __init__(self, *, rule_name: str, description: str, severity, enabled: bool, query: str, query_frequency, query_period, trigger_operator, trigger_threshold: int, suppression_enabled: bool, suppression_duration, **kwargs) -> None: + super(ScheduledAlertRuleProperties, self).__init__(**kwargs) + self.rule_name = rule_name + self.description = description + self.severity = severity + self.enabled = enabled + self.query = query + self.query_frequency = query_frequency + self.query_period = query_period + self.trigger_operator = trigger_operator + self.trigger_threshold = trigger_threshold + self.suppression_enabled = suppression_enabled + self.suppression_duration = suppression_duration + self.last_modified_utc = None diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py index 3796e16fb8ec..d8075dc8e518 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py @@ -18,8 +18,6 @@ class ScheduledAlertRule(AlertRule): 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 type: Azure resource type @@ -31,59 +29,15 @@ class ScheduledAlertRule(AlertRule): :type kind: str or ~azure.mgmt.securityinsight.models.AlertRuleKind :param etag: Etag of the alert rule. :type etag: str - :param rule_name: Required. The name for alerts created by this alert - rule. - :type rule_name: str - :param description: Required. The description of the alert rule. - :type description: str - :param severity: Required. The severity for alerts created by this alert - rule. Possible values include: 'Low', 'Medium', 'High', 'Informational' - :type severity: str or ~azure.mgmt.securityinsight.models.Severity - :param enabled: Required. Determines whether this alert rule is enabled or - disabled. - :type enabled: bool - :param query: Required. The query that creates alerts for this rule. - :type query: str - :param query_frequency: Required. The frequency (in ISO 8601 duration - format) for this alert rule to run. - :type query_frequency: timedelta - :param query_period: Required. The period (in ISO 8601 duration format) - that this alert rule looks at. - :type query_period: timedelta - :param trigger_operator: Required. The operation against the threshold - that triggers alert rule. Possible values include: 'GreaterThan', - 'LessThan', 'Equal', 'NotEqual' - :type trigger_operator: str or - ~azure.mgmt.securityinsight.models.TriggerOperator - :param trigger_threshold: Required. The threshold triggers this alert - rule. - :type trigger_threshold: int - :param suppression_enabled: Required. Determines whether the suppression - for this alert rule is enabled or disabled. - :type suppression_enabled: bool - :param suppression_duration: Required. The suppression (in ISO 8601 - duration format) to wait since last time this alert rule been triggered. - :type suppression_duration: timedelta - :ivar last_modified_utc: The last time that this alert has been modified. - :vartype last_modified_utc: str + :param properties: Scheduled alert rule properties + :type properties: + ~azure.mgmt.securityinsight.models.ScheduledAlertRuleProperties """ _validation = { 'id': {'readonly': True}, 'type': {'readonly': True}, 'name': {'readonly': True}, - 'rule_name': {'required': True}, - 'description': {'required': True}, - 'severity': {'required': True}, - 'enabled': {'required': True}, - 'query': {'required': True}, - 'query_frequency': {'required': True}, - 'query_period': {'required': True}, - 'trigger_operator': {'required': True}, - 'trigger_threshold': {'required': True}, - 'suppression_enabled': {'required': True}, - 'suppression_duration': {'required': True}, - 'last_modified_utc': {'readonly': True}, } _attribute_map = { @@ -92,31 +46,9 @@ class ScheduledAlertRule(AlertRule): 'name': {'key': 'name', 'type': 'str'}, 'kind': {'key': 'kind', 'type': 'str'}, 'etag': {'key': 'etag', 'type': 'str'}, - 'rule_name': {'key': 'properties.ruleName', 'type': 'str'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'Severity'}, - 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, - 'query': {'key': 'properties.query', 'type': 'str'}, - 'query_frequency': {'key': 'properties.queryFrequency', 'type': 'duration'}, - 'query_period': {'key': 'properties.queryPeriod', 'type': 'duration'}, - 'trigger_operator': {'key': 'properties.triggerOperator', 'type': 'TriggerOperator'}, - 'trigger_threshold': {'key': 'properties.triggerThreshold', 'type': 'int'}, - 'suppression_enabled': {'key': 'properties.suppressionEnabled', 'type': 'bool'}, - 'suppression_duration': {'key': 'properties.suppressionDuration', 'type': 'duration'}, - 'last_modified_utc': {'key': 'properties.lastModifiedUtc', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'ScheduledAlertRuleProperties'}, } - def __init__(self, *, rule_name: str, description: str, severity, enabled: bool, query: str, query_frequency, query_period, trigger_operator, trigger_threshold: int, suppression_enabled: bool, suppression_duration, kind=None, etag: str=None, **kwargs) -> None: + def __init__(self, *, kind=None, etag: str=None, properties=None, **kwargs) -> None: super(ScheduledAlertRule, self).__init__(kind=kind, etag=etag, **kwargs) - self.rule_name = rule_name - self.description = description - self.severity = severity - self.enabled = enabled - self.query = query - self.query_frequency = query_frequency - self.query_period = query_period - self.trigger_operator = trigger_operator - self.trigger_threshold = trigger_threshold - self.suppression_enabled = suppression_enabled - self.suppression_duration = suppression_duration - self.last_modified_utc = None + self.properties = properties From 408b60e2a77ef2ce2f9edf9be7c1fa602fff41af Mon Sep 17 00:00:00 2001 From: Azure SDK for Python bot Date: Tue, 29 Jan 2019 05:52:46 +0000 Subject: [PATCH 6/6] Generated from 0f74576d2fa0ae3526c5f42c39de849ddce62396 Trying to solve the model validator issues --- .../mgmt/securityinsight/models/__init__.py | 3 - .../mgmt/securityinsight/models/alert_rule.py | 19 +++- .../securityinsight/models/alert_rule_py3.py | 21 +++- .../models/scheduled_alert_rule.py | 87 +++++++++++++-- .../models/scheduled_alert_rule_properties.py | 103 ------------------ .../scheduled_alert_rule_properties_py3.py | 103 ------------------ .../models/scheduled_alert_rule_py3.py | 91 ++++++++++++++-- .../operations/alert_rules_operations.py | 11 +- 8 files changed, 190 insertions(+), 248 deletions(-) delete mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_properties.py delete mode 100644 azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_properties_py3.py diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/__init__.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/__init__.py index 8f637069d5b6..4269289ed2ad 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/__init__.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/__init__.py @@ -14,7 +14,6 @@ from .operation_py3 import Operation from .alert_rule_py3 import AlertRule from .alert_rule_kind1_py3 import AlertRuleKind1 - from .scheduled_alert_rule_properties_py3 import ScheduledAlertRuleProperties from .scheduled_alert_rule_py3 import ScheduledAlertRule from .resource_py3 import Resource except (SyntaxError, ImportError): @@ -22,7 +21,6 @@ from .operation import Operation from .alert_rule import AlertRule from .alert_rule_kind1 import AlertRuleKind1 - from .scheduled_alert_rule_properties import ScheduledAlertRuleProperties from .scheduled_alert_rule import ScheduledAlertRule from .resource import Resource from .operation_paged import OperationPaged @@ -38,7 +36,6 @@ 'Operation', 'AlertRule', 'AlertRuleKind1', - 'ScheduledAlertRuleProperties', 'ScheduledAlertRule', 'Resource', 'OperationPaged', diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule.py index 99e5d5d66b20..da97ab6a6f50 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule.py @@ -15,34 +15,43 @@ class AlertRule(Model): """Alert rule. + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: ScheduledAlertRule + 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 type: Azure resource type :vartype type: str :ivar name: Azure resource name :vartype name: str - :param kind: The kind of the alert rule. Possible values include: - 'Scheduled' - :type kind: str or ~azure.mgmt.securityinsight.models.AlertRuleKind :param etag: Etag of the alert rule. :type etag: str + :param kind: Required. Constant filled by server. + :type kind: str """ _validation = { 'id': {'readonly': True}, 'type': {'readonly': True}, 'name': {'readonly': True}, + 'kind': {'required': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, 'etag': {'key': 'etag', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + } + + _subtype_map = { + 'kind': {'Scheduled': 'ScheduledAlertRule'} } def __init__(self, **kwargs): @@ -50,5 +59,5 @@ def __init__(self, **kwargs): self.id = None self.type = None self.name = None - self.kind = kwargs.get('kind', None) self.etag = kwargs.get('etag', None) + self.kind = None diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_py3.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_py3.py index f770055d91c7..0bd3aa93133d 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_py3.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/alert_rule_py3.py @@ -15,40 +15,49 @@ class AlertRule(Model): """Alert rule. + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: ScheduledAlertRule + 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 type: Azure resource type :vartype type: str :ivar name: Azure resource name :vartype name: str - :param kind: The kind of the alert rule. Possible values include: - 'Scheduled' - :type kind: str or ~azure.mgmt.securityinsight.models.AlertRuleKind :param etag: Etag of the alert rule. :type etag: str + :param kind: Required. Constant filled by server. + :type kind: str """ _validation = { 'id': {'readonly': True}, 'type': {'readonly': True}, 'name': {'readonly': True}, + 'kind': {'required': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, 'etag': {'key': 'etag', 'type': 'str'}, + 'kind': {'key': 'kind', 'type': 'str'}, + } + + _subtype_map = { + 'kind': {'Scheduled': 'ScheduledAlertRule'} } - def __init__(self, *, kind=None, etag: str=None, **kwargs) -> None: + def __init__(self, *, etag: str=None, **kwargs) -> None: super(AlertRule, self).__init__(**kwargs) self.id = None self.type = None self.name = None - self.kind = kind self.etag = etag + self.kind = None diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py index 46d4c024fc52..fecadd7e4213 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule.py @@ -18,37 +18,106 @@ class ScheduledAlertRule(AlertRule): 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 type: Azure resource type :vartype type: str :ivar name: Azure resource name :vartype name: str - :param kind: The kind of the alert rule. Possible values include: - 'Scheduled' - :type kind: str or ~azure.mgmt.securityinsight.models.AlertRuleKind :param etag: Etag of the alert rule. :type etag: str - :param properties: Scheduled alert rule properties - :type properties: - ~azure.mgmt.securityinsight.models.ScheduledAlertRuleProperties + :param kind: Required. Constant filled by server. + :type kind: str + :param rule_name: Required. The name for alerts created by this alert + rule. + :type rule_name: str + :param description: Required. The description of the alert rule. + :type description: str + :param severity: Required. The severity for alerts created by this alert + rule. Possible values include: 'Low', 'Medium', 'High', 'Informational' + :type severity: str or ~azure.mgmt.securityinsight.models.Severity + :param enabled: Required. Determines whether this alert rule is enabled or + disabled. + :type enabled: bool + :param query: Required. The query that creates alerts for this rule. + :type query: str + :param query_frequency: Required. The frequency (in ISO 8601 duration + format) for this alert rule to run. + :type query_frequency: timedelta + :param query_period: Required. The period (in ISO 8601 duration format) + that this alert rule looks at. + :type query_period: timedelta + :param trigger_operator: Required. The operation against the threshold + that triggers alert rule. Possible values include: 'GreaterThan', + 'LessThan', 'Equal', 'NotEqual' + :type trigger_operator: str or + ~azure.mgmt.securityinsight.models.TriggerOperator + :param trigger_threshold: Required. The threshold triggers this alert + rule. + :type trigger_threshold: int + :param suppression_enabled: Required. Determines whether the suppression + for this alert rule is enabled or disabled. + :type suppression_enabled: bool + :param suppression_duration: Required. The suppression (in ISO 8601 + duration format) to wait since last time this alert rule been triggered. + :type suppression_duration: timedelta + :ivar last_modified_utc: The last time that this alert has been modified. + :vartype last_modified_utc: str """ _validation = { 'id': {'readonly': True}, 'type': {'readonly': True}, 'name': {'readonly': True}, + 'kind': {'required': True}, + 'rule_name': {'required': True}, + 'description': {'required': True}, + 'severity': {'required': True}, + 'enabled': {'required': True}, + 'query': {'required': True}, + 'query_frequency': {'required': True}, + 'query_period': {'required': True}, + 'trigger_operator': {'required': True}, + 'trigger_threshold': {'required': True}, + 'suppression_enabled': {'required': True}, + 'suppression_duration': {'required': True}, + 'last_modified_utc': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ScheduledAlertRuleProperties'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'rule_name': {'key': 'properties.ruleName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'severity': {'key': 'properties.severity', 'type': 'Severity'}, + 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + 'query': {'key': 'properties.query', 'type': 'str'}, + 'query_frequency': {'key': 'properties.queryFrequency', 'type': 'duration'}, + 'query_period': {'key': 'properties.queryPeriod', 'type': 'duration'}, + 'trigger_operator': {'key': 'properties.triggerOperator', 'type': 'TriggerOperator'}, + 'trigger_threshold': {'key': 'properties.triggerThreshold', 'type': 'int'}, + 'suppression_enabled': {'key': 'properties.suppressionEnabled', 'type': 'bool'}, + 'suppression_duration': {'key': 'properties.suppressionDuration', 'type': 'duration'}, + 'last_modified_utc': {'key': 'properties.lastModifiedUtc', 'type': 'str'}, } def __init__(self, **kwargs): super(ScheduledAlertRule, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) + self.rule_name = kwargs.get('rule_name', None) + self.description = kwargs.get('description', None) + self.severity = kwargs.get('severity', None) + self.enabled = kwargs.get('enabled', None) + self.query = kwargs.get('query', None) + self.query_frequency = kwargs.get('query_frequency', None) + self.query_period = kwargs.get('query_period', None) + self.trigger_operator = kwargs.get('trigger_operator', None) + self.trigger_threshold = kwargs.get('trigger_threshold', None) + self.suppression_enabled = kwargs.get('suppression_enabled', None) + self.suppression_duration = kwargs.get('suppression_duration', None) + self.last_modified_utc = None + self.kind = 'Scheduled' diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_properties.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_properties.py deleted file mode 100644 index fc686e66507a..000000000000 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_properties.py +++ /dev/null @@ -1,103 +0,0 @@ -# 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 ScheduledAlertRuleProperties(Model): - """Alert rule property bag. - - 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 rule_name: Required. The name for alerts created by this alert - rule. - :type rule_name: str - :param description: Required. The description of the alert rule. - :type description: str - :param severity: Required. The severity for alerts created by this alert - rule. Possible values include: 'Low', 'Medium', 'High', 'Informational' - :type severity: str or ~azure.mgmt.securityinsight.models.Severity - :param enabled: Required. Determines whether this alert rule is enabled or - disabled. - :type enabled: bool - :param query: Required. The query that creates alerts for this rule. - :type query: str - :param query_frequency: Required. The frequency (in ISO 8601 duration - format) for this alert rule to run. - :type query_frequency: timedelta - :param query_period: Required. The period (in ISO 8601 duration format) - that this alert rule looks at. - :type query_period: timedelta - :param trigger_operator: Required. The operation against the threshold - that triggers alert rule. Possible values include: 'GreaterThan', - 'LessThan', 'Equal', 'NotEqual' - :type trigger_operator: str or - ~azure.mgmt.securityinsight.models.TriggerOperator - :param trigger_threshold: Required. The threshold triggers this alert - rule. - :type trigger_threshold: int - :param suppression_enabled: Required. Determines whether the suppression - for this alert rule is enabled or disabled. - :type suppression_enabled: bool - :param suppression_duration: Required. The suppression (in ISO 8601 - duration format) to wait since last time this alert rule been triggered. - :type suppression_duration: timedelta - :ivar last_modified_utc: The last time that this alert has been modified. - :vartype last_modified_utc: str - """ - - _validation = { - 'rule_name': {'required': True}, - 'description': {'required': True}, - 'severity': {'required': True}, - 'enabled': {'required': True}, - 'query': {'required': True}, - 'query_frequency': {'required': True}, - 'query_period': {'required': True}, - 'trigger_operator': {'required': True}, - 'trigger_threshold': {'required': True}, - 'suppression_enabled': {'required': True}, - 'suppression_duration': {'required': True}, - 'last_modified_utc': {'readonly': True}, - } - - _attribute_map = { - 'rule_name': {'key': 'ruleName', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'Severity'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'query': {'key': 'query', 'type': 'str'}, - 'query_frequency': {'key': 'queryFrequency', 'type': 'duration'}, - 'query_period': {'key': 'queryPeriod', 'type': 'duration'}, - 'trigger_operator': {'key': 'triggerOperator', 'type': 'TriggerOperator'}, - 'trigger_threshold': {'key': 'triggerThreshold', 'type': 'int'}, - 'suppression_enabled': {'key': 'suppressionEnabled', 'type': 'bool'}, - 'suppression_duration': {'key': 'suppressionDuration', 'type': 'duration'}, - 'last_modified_utc': {'key': 'lastModifiedUtc', 'type': 'str'}, - } - - def __init__(self, **kwargs): - super(ScheduledAlertRuleProperties, self).__init__(**kwargs) - self.rule_name = kwargs.get('rule_name', None) - self.description = kwargs.get('description', None) - self.severity = kwargs.get('severity', None) - self.enabled = kwargs.get('enabled', None) - self.query = kwargs.get('query', None) - self.query_frequency = kwargs.get('query_frequency', None) - self.query_period = kwargs.get('query_period', None) - self.trigger_operator = kwargs.get('trigger_operator', None) - self.trigger_threshold = kwargs.get('trigger_threshold', None) - self.suppression_enabled = kwargs.get('suppression_enabled', None) - self.suppression_duration = kwargs.get('suppression_duration', None) - self.last_modified_utc = None diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_properties_py3.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_properties_py3.py deleted file mode 100644 index b3f92b3b519f..000000000000 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_properties_py3.py +++ /dev/null @@ -1,103 +0,0 @@ -# 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 ScheduledAlertRuleProperties(Model): - """Alert rule property bag. - - 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 rule_name: Required. The name for alerts created by this alert - rule. - :type rule_name: str - :param description: Required. The description of the alert rule. - :type description: str - :param severity: Required. The severity for alerts created by this alert - rule. Possible values include: 'Low', 'Medium', 'High', 'Informational' - :type severity: str or ~azure.mgmt.securityinsight.models.Severity - :param enabled: Required. Determines whether this alert rule is enabled or - disabled. - :type enabled: bool - :param query: Required. The query that creates alerts for this rule. - :type query: str - :param query_frequency: Required. The frequency (in ISO 8601 duration - format) for this alert rule to run. - :type query_frequency: timedelta - :param query_period: Required. The period (in ISO 8601 duration format) - that this alert rule looks at. - :type query_period: timedelta - :param trigger_operator: Required. The operation against the threshold - that triggers alert rule. Possible values include: 'GreaterThan', - 'LessThan', 'Equal', 'NotEqual' - :type trigger_operator: str or - ~azure.mgmt.securityinsight.models.TriggerOperator - :param trigger_threshold: Required. The threshold triggers this alert - rule. - :type trigger_threshold: int - :param suppression_enabled: Required. Determines whether the suppression - for this alert rule is enabled or disabled. - :type suppression_enabled: bool - :param suppression_duration: Required. The suppression (in ISO 8601 - duration format) to wait since last time this alert rule been triggered. - :type suppression_duration: timedelta - :ivar last_modified_utc: The last time that this alert has been modified. - :vartype last_modified_utc: str - """ - - _validation = { - 'rule_name': {'required': True}, - 'description': {'required': True}, - 'severity': {'required': True}, - 'enabled': {'required': True}, - 'query': {'required': True}, - 'query_frequency': {'required': True}, - 'query_period': {'required': True}, - 'trigger_operator': {'required': True}, - 'trigger_threshold': {'required': True}, - 'suppression_enabled': {'required': True}, - 'suppression_duration': {'required': True}, - 'last_modified_utc': {'readonly': True}, - } - - _attribute_map = { - 'rule_name': {'key': 'ruleName', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'Severity'}, - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'query': {'key': 'query', 'type': 'str'}, - 'query_frequency': {'key': 'queryFrequency', 'type': 'duration'}, - 'query_period': {'key': 'queryPeriod', 'type': 'duration'}, - 'trigger_operator': {'key': 'triggerOperator', 'type': 'TriggerOperator'}, - 'trigger_threshold': {'key': 'triggerThreshold', 'type': 'int'}, - 'suppression_enabled': {'key': 'suppressionEnabled', 'type': 'bool'}, - 'suppression_duration': {'key': 'suppressionDuration', 'type': 'duration'}, - 'last_modified_utc': {'key': 'lastModifiedUtc', 'type': 'str'}, - } - - def __init__(self, *, rule_name: str, description: str, severity, enabled: bool, query: str, query_frequency, query_period, trigger_operator, trigger_threshold: int, suppression_enabled: bool, suppression_duration, **kwargs) -> None: - super(ScheduledAlertRuleProperties, self).__init__(**kwargs) - self.rule_name = rule_name - self.description = description - self.severity = severity - self.enabled = enabled - self.query = query - self.query_frequency = query_frequency - self.query_period = query_period - self.trigger_operator = trigger_operator - self.trigger_threshold = trigger_threshold - self.suppression_enabled = suppression_enabled - self.suppression_duration = suppression_duration - self.last_modified_utc = None diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py index d8075dc8e518..b3eac8ccc2d8 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/models/scheduled_alert_rule_py3.py @@ -18,37 +18,106 @@ class ScheduledAlertRule(AlertRule): 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 type: Azure resource type :vartype type: str :ivar name: Azure resource name :vartype name: str - :param kind: The kind of the alert rule. Possible values include: - 'Scheduled' - :type kind: str or ~azure.mgmt.securityinsight.models.AlertRuleKind :param etag: Etag of the alert rule. :type etag: str - :param properties: Scheduled alert rule properties - :type properties: - ~azure.mgmt.securityinsight.models.ScheduledAlertRuleProperties + :param kind: Required. Constant filled by server. + :type kind: str + :param rule_name: Required. The name for alerts created by this alert + rule. + :type rule_name: str + :param description: Required. The description of the alert rule. + :type description: str + :param severity: Required. The severity for alerts created by this alert + rule. Possible values include: 'Low', 'Medium', 'High', 'Informational' + :type severity: str or ~azure.mgmt.securityinsight.models.Severity + :param enabled: Required. Determines whether this alert rule is enabled or + disabled. + :type enabled: bool + :param query: Required. The query that creates alerts for this rule. + :type query: str + :param query_frequency: Required. The frequency (in ISO 8601 duration + format) for this alert rule to run. + :type query_frequency: timedelta + :param query_period: Required. The period (in ISO 8601 duration format) + that this alert rule looks at. + :type query_period: timedelta + :param trigger_operator: Required. The operation against the threshold + that triggers alert rule. Possible values include: 'GreaterThan', + 'LessThan', 'Equal', 'NotEqual' + :type trigger_operator: str or + ~azure.mgmt.securityinsight.models.TriggerOperator + :param trigger_threshold: Required. The threshold triggers this alert + rule. + :type trigger_threshold: int + :param suppression_enabled: Required. Determines whether the suppression + for this alert rule is enabled or disabled. + :type suppression_enabled: bool + :param suppression_duration: Required. The suppression (in ISO 8601 + duration format) to wait since last time this alert rule been triggered. + :type suppression_duration: timedelta + :ivar last_modified_utc: The last time that this alert has been modified. + :vartype last_modified_utc: str """ _validation = { 'id': {'readonly': True}, 'type': {'readonly': True}, 'name': {'readonly': True}, + 'kind': {'required': True}, + 'rule_name': {'required': True}, + 'description': {'required': True}, + 'severity': {'required': True}, + 'enabled': {'required': True}, + 'query': {'required': True}, + 'query_frequency': {'required': True}, + 'query_period': {'required': True}, + 'trigger_operator': {'required': True}, + 'trigger_threshold': {'required': True}, + 'suppression_enabled': {'required': True}, + 'suppression_duration': {'required': True}, + 'last_modified_utc': {'readonly': True}, } _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ScheduledAlertRuleProperties'}, + 'kind': {'key': 'kind', 'type': 'str'}, + 'rule_name': {'key': 'properties.ruleName', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'severity': {'key': 'properties.severity', 'type': 'Severity'}, + 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + 'query': {'key': 'properties.query', 'type': 'str'}, + 'query_frequency': {'key': 'properties.queryFrequency', 'type': 'duration'}, + 'query_period': {'key': 'properties.queryPeriod', 'type': 'duration'}, + 'trigger_operator': {'key': 'properties.triggerOperator', 'type': 'TriggerOperator'}, + 'trigger_threshold': {'key': 'properties.triggerThreshold', 'type': 'int'}, + 'suppression_enabled': {'key': 'properties.suppressionEnabled', 'type': 'bool'}, + 'suppression_duration': {'key': 'properties.suppressionDuration', 'type': 'duration'}, + 'last_modified_utc': {'key': 'properties.lastModifiedUtc', 'type': 'str'}, } - def __init__(self, *, kind=None, etag: str=None, properties=None, **kwargs) -> None: - super(ScheduledAlertRule, self).__init__(kind=kind, etag=etag, **kwargs) - self.properties = properties + def __init__(self, *, rule_name: str, description: str, severity, enabled: bool, query: str, query_frequency, query_period, trigger_operator, trigger_threshold: int, suppression_enabled: bool, suppression_duration, etag: str=None, **kwargs) -> None: + super(ScheduledAlertRule, self).__init__(etag=etag, **kwargs) + self.rule_name = rule_name + self.description = description + self.severity = severity + self.enabled = enabled + self.query = query + self.query_frequency = query_frequency + self.query_period = query_period + self.trigger_operator = trigger_operator + self.trigger_threshold = trigger_threshold + self.suppression_enabled = suppression_enabled + self.suppression_duration = suppression_duration + self.last_modified_utc = None + self.kind = 'Scheduled' diff --git a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/alert_rules_operations.py b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/alert_rules_operations.py index 01fec7a914c0..ad49f712b1be 100644 --- a/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/alert_rules_operations.py +++ b/azure-mgmt-securityinsight/azure/mgmt/securityinsight/operations/alert_rules_operations.py @@ -183,7 +183,7 @@ def get( get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{operationalInsightsResourceProvider}/workspaces/{workspaceName}/providers/Microsoft.SecurityInsights/alertRules/{ruleId}'} def create( - self, resource_group_name, operational_insights_resource_provider, workspace_name, rule_id, kind=None, etag=None, custom_headers=None, raw=False, **operation_config): + self, resource_group_name, operational_insights_resource_provider, workspace_name, rule_id, alert_rule, custom_headers=None, raw=False, **operation_config): """Creates or updates the alert rule. :param resource_group_name: The name of the resource group within the @@ -196,11 +196,8 @@ def create( :type workspace_name: str :param rule_id: Alert rule ID :type rule_id: str - :param kind: The kind of the alert rule. Possible values include: - 'Scheduled' - :type kind: str or ~azure.mgmt.securityinsight.models.AlertRuleKind - :param etag: Etag of the alert rule. - :type etag: str + :param alert_rule: The alert rule + :type alert_rule: ~azure.mgmt.securityinsight.models.AlertRule :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response @@ -211,8 +208,6 @@ def create( ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError` """ - alert_rule = models.AlertRule(kind=kind, etag=etag) - # Construct URL url = self.create.metadata['url'] path_format_arguments = {