From 6874c9b82a94bdbca825ca4f701a9b03efe7a755 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 8 Mar 2021 14:38:08 +0000 Subject: [PATCH] CodeGen from PR 13275 in Azure/azure-rest-api-specs Merge 7e158ee8e3a015e37cab9a12266ba6ba2e435ddb into d3f2ecf27be1e1043427f581f5b41687b722b04f --- .../azure/mgmt/monitor/_configuration.py | 2 +- .../monitor/_monitor_management_client.py | 18 +- .../azure/mgmt/monitor/models.py | 4 +- .../mgmt/monitor/v2020_10_01/__init__.py | 19 + .../monitor/v2020_10_01/_configuration.py | 48 ++ .../v2020_10_01/_monitor_management_client.py | 49 ++ .../monitor/v2020_10_01/models/__init__.py | 45 ++ .../monitor/v2020_10_01/models/_models.py | 348 ++++++++++++++ .../monitor/v2020_10_01/models/_models_py3.py | 348 ++++++++++++++ .../v2020_10_01/models/_paged_models.py | 27 ++ .../v2020_10_01/operations/__init__.py | 16 + .../_activity_log_alerts_operations.py | 436 ++++++++++++++++++ .../azure/mgmt/monitor/v2020_10_01/version.py | 13 + 13 files changed, 1369 insertions(+), 4 deletions(-) create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/__init__.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models_py3.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_paged_models.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/__init__.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py create mode 100644 sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/version.py diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py index 88436f6b4a33..c6ef8a63dfd2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py @@ -21,7 +21,7 @@ class MonitorManagementClientConfiguration(AzureConfiguration): :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object` - :param subscription_id: The Azure subscription Id. + :param subscription_id: The ID of the target subscription. :type subscription_id: str :param str base_url: Service URL """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py index 5390a603781a..d7d1023e3ef7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py @@ -46,25 +46,27 @@ class MonitorManagementClient(MultiApiClientMixin, SDKClient): :type profile: azure.profiles.KnownProfiles """ - DEFAULT_API_VERSION = '2019-10-17-preview' + DEFAULT_API_VERSION = '2020-10-01' _PROFILE_TAG = "azure.mgmt.monitor.MonitorManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { None: DEFAULT_API_VERSION, 'action_groups': '2019-06-01', - 'activity_log_alerts': '2017-04-01', 'activity_logs': '2015-04-01', 'alert_rule_incidents': '2016-03-01', 'alert_rules': '2016-03-01', 'autoscale_settings': '2015-04-01', 'baseline': '2018-09-01', 'baselines': '2019-03-01', + 'data_collection_rule_associations': '2019-11-01-preview', + 'data_collection_rules': '2019-11-01-preview', 'diagnostic_settings': '2017-05-01-preview', 'diagnostic_settings_category': '2017-05-01-preview', 'event_categories': '2015-04-01', 'guest_diagnostics_settings': '2018-06-01-preview', 'guest_diagnostics_settings_association': '2018-06-01-preview', 'log_profiles': '2016-03-01', + 'management_group_diagnostic_settings': '2020-01-01-preview', 'metric_alerts': '2018-03-01', 'metric_alerts_status': '2018-03-01', 'metric_baseline': '2018-09-01', @@ -72,6 +74,11 @@ class MonitorManagementClient(MultiApiClientMixin, SDKClient): 'metric_namespaces': '2017-12-01-preview', 'metrics': '2018-01-01', 'operations': '2015-04-01', + 'private_endpoint_connections': '2019-10-17-preview', + 'private_link_resources': '2019-10-17-preview', + 'private_link_scope_operation_status': '2019-10-17-preview', + 'private_link_scoped_resources': '2019-10-17-preview', + 'private_link_scopes': '2019-10-17-preview', 'scheduled_query_rules': '2018-04-16', 'service_diagnostic_settings': '2016-09-01', 'subscription_diagnostic_settings': '2017-05-01-preview', @@ -119,6 +126,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2019-11-01-preview: :mod:`v2019_11_01_preview.models` * 2020-01-01-preview: :mod:`v2020_01_01_preview.models` * 2020-05-01-preview: :mod:`v2020_05_01_preview.models` + * 2020-10-01: :mod:`v2020_10_01.models` """ if api_version == '2015-04-01': from .v2015_04_01 import models @@ -183,6 +191,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2020-05-01-preview': from .v2020_05_01_preview import models return models + elif api_version == '2020-10-01': + from .v2020_10_01 import models + return models raise NotImplementedError("APIVersion {} is not available".format(api_version)) @property @@ -216,12 +227,15 @@ def activity_log_alerts(self): * 2017-03-01-preview: :class:`ActivityLogAlertsOperations` * 2017-04-01: :class:`ActivityLogAlertsOperations` + * 2020-10-01: :class:`ActivityLogAlertsOperations` """ api_version = self._get_api_version('activity_log_alerts') if api_version == '2017-03-01-preview': from .v2017_03_01_preview.operations import ActivityLogAlertsOperations as OperationClass elif api_version == '2017-04-01': from .v2017_04_01.operations import ActivityLogAlertsOperations as OperationClass + elif api_version == '2020-10-01': + from .v2020_10_01.operations import ActivityLogAlertsOperations as OperationClass else: raise NotImplementedError("APIVersion {} is not available".format(api_version)) return OperationClass(self._client, self.config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models.py index 09110c75b60e..8db2e90295ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/models.py @@ -7,7 +7,6 @@ from .v2015_04_01.models import * from .v2016_03_01.models import * from .v2016_09_01.models import * -from .v2017_04_01.models import * from .v2017_05_01_preview.models import * from .v2017_12_01_preview.models import * from .v2018_01_01.models import * @@ -19,3 +18,6 @@ from .v2019_03_01.models import * from .v2019_06_01.models import * from .v2019_10_17.models import * +from .v2019_11_01_preview.models import * +from .v2020_01_01_preview.models import * +from .v2020_10_01.models import * diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py new file mode 100644 index 000000000000..8e97360e5ffb --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py @@ -0,0 +1,19 @@ +# 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 ._configuration import MonitorManagementClientConfiguration +from ._monitor_management_client import MonitorManagementClient +__all__ = ['MonitorManagementClient', 'MonitorManagementClientConfiguration'] + +from .version import VERSION + +__version__ = VERSION + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py new file mode 100644 index 000000000000..c6ef8a63dfd2 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py @@ -0,0 +1,48 @@ +# 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 msrestazure import AzureConfiguration + +from .version import VERSION + + +class MonitorManagementClientConfiguration(AzureConfiguration): + """Configuration for MonitorManagementClient + 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: The ID of the target subscription. + :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(MonitorManagementClientConfiguration, self).__init__(base_url) + + # Starting Autorest.Python 4.0.64, make connection pool activated by default + self.keep_alive = True + + self.add_user_agent('azure-mgmt-monitor/{}'.format(VERSION)) + self.add_user_agent('Azure-SDK-For-Python') + + self.credentials = credentials + self.subscription_id = subscription_id diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py new file mode 100644 index 000000000000..395924bc8b8d --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py @@ -0,0 +1,49 @@ +# 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 ._configuration import MonitorManagementClientConfiguration +from .operations import ActivityLogAlertsOperations +from . import models + + +class MonitorManagementClient(SDKClient): + """Monitor Management Client + + :ivar config: Configuration for client. + :vartype config: MonitorManagementClientConfiguration + + :ivar activity_log_alerts: ActivityLogAlerts operations + :vartype activity_log_alerts: $(python-base-namespace).v2020_10_01.operations.ActivityLogAlertsOperations + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param str base_url: Service URL + """ + + def __init__( + self, credentials, subscription_id, base_url=None): + + self.config = MonitorManagementClientConfiguration(credentials, subscription_id, base_url) + super(MonitorManagementClient, 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 = '2020-10-01' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + self.activity_log_alerts = ActivityLogAlertsOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/__init__.py new file mode 100644 index 000000000000..83ae6633f667 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/__init__.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. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import ActionGroup + from ._models_py3 import ActionList + from ._models_py3 import ActivityLogAlertResource + from ._models_py3 import AlertRuleAllOfCondition + from ._models_py3 import AlertRuleAnyOfOrLeafCondition + from ._models_py3 import AlertRuleLeafCondition + from ._models_py3 import AlertRulePatchObject + from ._models_py3 import AzureResource + from ._models_py3 import ErrorResponse, ErrorResponseException +except (SyntaxError, ImportError): + from ._models import ActionGroup + from ._models import ActionList + from ._models import ActivityLogAlertResource + from ._models import AlertRuleAllOfCondition + from ._models import AlertRuleAnyOfOrLeafCondition + from ._models import AlertRuleLeafCondition + from ._models import AlertRulePatchObject + from ._models import AzureResource + from ._models import ErrorResponse, ErrorResponseException +from ._paged_models import ActivityLogAlertResourcePaged + +__all__ = [ + 'ActionGroup', + 'ActionList', + 'ActivityLogAlertResource', + 'AlertRuleAllOfCondition', + 'AlertRuleAnyOfOrLeafCondition', + 'AlertRuleLeafCondition', + 'AlertRulePatchObject', + 'AzureResource', + 'ErrorResponse', 'ErrorResponseException', + 'ActivityLogAlertResourcePaged', +] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models.py new file mode 100644 index 000000000000..9cb1b3e3ef19 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models.py @@ -0,0 +1,348 @@ +# 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 +from msrest.exceptions import HttpOperationError + + +class ActionGroup(Model): + """A pointer to an Azure Action Group. + + All required parameters must be populated in order to send to Azure. + + :param action_group_id: Required. The resource ID of the Action Group. + This cannot be null or empty. + :type action_group_id: str + :param webhook_properties: the dictionary of custom properties to include + with the post operation. These data are appended to the webhook payload. + :type webhook_properties: dict[str, str] + """ + + _validation = { + 'action_group_id': {'required': True}, + } + + _attribute_map = { + 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, + 'webhook_properties': {'key': 'webhookProperties', 'type': '{str}'}, + } + + def __init__(self, **kwargs): + super(ActionGroup, self).__init__(**kwargs) + self.action_group_id = kwargs.get('action_group_id', None) + self.webhook_properties = kwargs.get('webhook_properties', None) + + +class ActionList(Model): + """A list of Activity Log Alert rule actions. + + :param action_groups: The list of the Action Groups. + :type action_groups: + list[~$(python-base-namespace).v2020_10_01.models.ActionGroup] + """ + + _attribute_map = { + 'action_groups': {'key': 'actionGroups', 'type': '[ActionGroup]'}, + } + + def __init__(self, **kwargs): + super(ActionList, self).__init__(**kwargs) + self.action_groups = kwargs.get('action_groups', None) + + +class AzureResource(Model): + """An Azure resource object. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The resource Id. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :param location: The location of the resource. Since Azure Activity Log + Alerts is a global service, the location of the rules should always be + 'global'. Default value: "global" . + :type location: str + :param tags: The tags of the resource. + :type tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__(self, **kwargs): + super(AzureResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = kwargs.get('location', "global") + self.tags = kwargs.get('tags', None) + + +class ActivityLogAlertResource(AzureResource): + """An Activity Log Alert rule resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource Id. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :param location: The location of the resource. Since Azure Activity Log + Alerts is a global service, the location of the rules should always be + 'global'. Default value: "global" . + :type location: str + :param tags: The tags of the resource. + :type tags: dict[str, str] + :param scopes: Required. A list of resource IDs that will be used as + prefixes. The alert will only apply to Activity Log events with resource + IDs that fall under one of these prefixes. This list must include at least + one item. + :type scopes: list[str] + :param condition: Required. The condition that will cause this alert to + activate. + :type condition: + ~$(python-base-namespace).v2020_10_01.models.AlertRuleAllOfCondition + :param actions: Required. The actions that will activate when the + condition is met. + :type actions: ~$(python-base-namespace).v2020_10_01.models.ActionList + :param enabled: Indicates whether this Activity Log Alert rule is enabled. + If an Activity Log Alert rule is not enabled, then none of its actions + will be activated. Default value: True . + :type enabled: bool + :param description: A description of this Activity Log Alert rule. + :type description: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'scopes': {'required': True}, + 'condition': {'required': True}, + 'actions': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'scopes': {'key': 'properties.scopes', 'type': '[str]'}, + 'condition': {'key': 'properties.condition', 'type': 'AlertRuleAllOfCondition'}, + 'actions': {'key': 'properties.actions', 'type': 'ActionList'}, + 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ActivityLogAlertResource, self).__init__(**kwargs) + self.scopes = kwargs.get('scopes', None) + self.condition = kwargs.get('condition', None) + self.actions = kwargs.get('actions', None) + self.enabled = kwargs.get('enabled', True) + self.description = kwargs.get('description', None) + + +class AlertRuleAllOfCondition(Model): + """An Activity Log Alert rule condition that is met when all its member + conditions are met. + + All required parameters must be populated in order to send to Azure. + + :param all_of: Required. The list of Activity Log Alert rule conditions. + :type all_of: + list[~$(python-base-namespace).v2020_10_01.models.AlertRuleAnyOfOrLeafCondition] + """ + + _validation = { + 'all_of': {'required': True}, + } + + _attribute_map = { + 'all_of': {'key': 'allOf', 'type': '[AlertRuleAnyOfOrLeafCondition]'}, + } + + def __init__(self, **kwargs): + super(AlertRuleAllOfCondition, self).__init__(**kwargs) + self.all_of = kwargs.get('all_of', None) + + +class AlertRuleLeafCondition(Model): + """An Activity Log Alert rule condition that is met by comparing the field and + value of an Activity Log event. + This condition must contain 'field' and either 'equals' or 'containsAny'. + + :param field: The name of the Activity Log event's field that this + condition will examine. + The possible values for this field are (case-insensitive): 'resourceId', + 'category', 'caller', 'level', 'operationName', 'resourceGroup', + 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything + beginning with 'properties'. + :type field: str + :param equals: The value of the event's field will be compared to this + value (case-insensitive) to determine if the condition is met. + :type equals: str + :param contains_any: The value of the event's field will be compared to + the values in this array (case-insensitive) to determine if the condition + is met. + :type contains_any: list[str] + """ + + _attribute_map = { + 'field': {'key': 'field', 'type': 'str'}, + 'equals': {'key': 'equals', 'type': 'str'}, + 'contains_any': {'key': 'containsAny', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(AlertRuleLeafCondition, self).__init__(**kwargs) + self.field = kwargs.get('field', None) + self.equals = kwargs.get('equals', None) + self.contains_any = kwargs.get('contains_any', None) + + +class AlertRuleAnyOfOrLeafCondition(AlertRuleLeafCondition): + """An Activity Log Alert rule condition that is met when all its member + conditions are met. + Each condition can be of one of the following types: + __Important__: Each type has its unique subset of properties. Properties + from different types CANNOT exist in one condition. + * __Leaf Condition -__ must contain 'field' and either 'equals' or + 'containsAny'. + _Please note, 'anyOf' should __not__ be set in a Leaf Condition._ + * __AnyOf Condition -__ must contain __only__ 'anyOf' (which is an array of + Leaf Conditions). + _Please note, 'field', 'equals' and 'containsAny' should __not__ be set in + an AnyOf Condition._ + . + + :param field: The name of the Activity Log event's field that this + condition will examine. + The possible values for this field are (case-insensitive): 'resourceId', + 'category', 'caller', 'level', 'operationName', 'resourceGroup', + 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything + beginning with 'properties'. + :type field: str + :param equals: The value of the event's field will be compared to this + value (case-insensitive) to determine if the condition is met. + :type equals: str + :param contains_any: The value of the event's field will be compared to + the values in this array (case-insensitive) to determine if the condition + is met. + :type contains_any: list[str] + :param any_of: An Activity Log Alert rule 'anyOf' condition. An Activity + Log Alert rule condition that is met when at least one of its member leaf + conditions are met. + :type any_of: + list[~$(python-base-namespace).v2020_10_01.models.AlertRuleLeafCondition] + """ + + _attribute_map = { + 'field': {'key': 'field', 'type': 'str'}, + 'equals': {'key': 'equals', 'type': 'str'}, + 'contains_any': {'key': 'containsAny', 'type': '[str]'}, + 'any_of': {'key': 'anyOf', 'type': '[AlertRuleLeafCondition]'}, + } + + def __init__(self, **kwargs): + super(AlertRuleAnyOfOrLeafCondition, self).__init__(**kwargs) + self.any_of = kwargs.get('any_of', None) + + +class AlertRulePatchObject(Model): + """An Activity Log Alert rule object for the body of patch operations. + + :param tags: The resource tags + :type tags: dict[str, str] + :param enabled: Indicates whether this Activity Log Alert rule is enabled. + If an Activity Log Alert rule is not enabled, then none of its actions + will be activated. Default value: True . + :type enabled: bool + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + } + + def __init__(self, **kwargs): + super(AlertRulePatchObject, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + self.enabled = kwargs.get('enabled', True) + + +class CloudError(Model): + """CloudError. + """ + + _attribute_map = { + } + + +class ErrorResponse(Model): + """The error response. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message indicating why the operation failed. + :vartype message: str + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ErrorResponse, self).__init__(**kwargs) + self.code = None + self.message = None + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models_py3.py new file mode 100644 index 000000000000..7fc34a3dc5eb --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models_py3.py @@ -0,0 +1,348 @@ +# 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 +from msrest.exceptions import HttpOperationError + + +class ActionGroup(Model): + """A pointer to an Azure Action Group. + + All required parameters must be populated in order to send to Azure. + + :param action_group_id: Required. The resource ID of the Action Group. + This cannot be null or empty. + :type action_group_id: str + :param webhook_properties: the dictionary of custom properties to include + with the post operation. These data are appended to the webhook payload. + :type webhook_properties: dict[str, str] + """ + + _validation = { + 'action_group_id': {'required': True}, + } + + _attribute_map = { + 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, + 'webhook_properties': {'key': 'webhookProperties', 'type': '{str}'}, + } + + def __init__(self, *, action_group_id: str, webhook_properties=None, **kwargs) -> None: + super(ActionGroup, self).__init__(**kwargs) + self.action_group_id = action_group_id + self.webhook_properties = webhook_properties + + +class ActionList(Model): + """A list of Activity Log Alert rule actions. + + :param action_groups: The list of the Action Groups. + :type action_groups: + list[~$(python-base-namespace).v2020_10_01.models.ActionGroup] + """ + + _attribute_map = { + 'action_groups': {'key': 'actionGroups', 'type': '[ActionGroup]'}, + } + + def __init__(self, *, action_groups=None, **kwargs) -> None: + super(ActionList, self).__init__(**kwargs) + self.action_groups = action_groups + + +class AzureResource(Model): + """An Azure resource object. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: The resource Id. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :param location: The location of the resource. Since Azure Activity Log + Alerts is a global service, the location of the rules should always be + 'global'. Default value: "global" . + :type location: str + :param tags: The tags of the resource. + :type tags: dict[str, str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + } + + def __init__(self, *, location: str="global", tags=None, **kwargs) -> None: + super(AzureResource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + self.location = location + self.tags = tags + + +class ActivityLogAlertResource(AzureResource): + """An Activity Log Alert rule resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: The resource Id. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. + :vartype type: str + :param location: The location of the resource. Since Azure Activity Log + Alerts is a global service, the location of the rules should always be + 'global'. Default value: "global" . + :type location: str + :param tags: The tags of the resource. + :type tags: dict[str, str] + :param scopes: Required. A list of resource IDs that will be used as + prefixes. The alert will only apply to Activity Log events with resource + IDs that fall under one of these prefixes. This list must include at least + one item. + :type scopes: list[str] + :param condition: Required. The condition that will cause this alert to + activate. + :type condition: + ~$(python-base-namespace).v2020_10_01.models.AlertRuleAllOfCondition + :param actions: Required. The actions that will activate when the + condition is met. + :type actions: ~$(python-base-namespace).v2020_10_01.models.ActionList + :param enabled: Indicates whether this Activity Log Alert rule is enabled. + If an Activity Log Alert rule is not enabled, then none of its actions + will be activated. Default value: True . + :type enabled: bool + :param description: A description of this Activity Log Alert rule. + :type description: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'scopes': {'required': True}, + 'condition': {'required': True}, + 'actions': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'scopes': {'key': 'properties.scopes', 'type': '[str]'}, + 'condition': {'key': 'properties.condition', 'type': 'AlertRuleAllOfCondition'}, + 'actions': {'key': 'properties.actions', 'type': 'ActionList'}, + 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + } + + def __init__(self, *, scopes, condition, actions, location: str="global", tags=None, enabled: bool=True, description: str=None, **kwargs) -> None: + super(ActivityLogAlertResource, self).__init__(location=location, tags=tags, **kwargs) + self.scopes = scopes + self.condition = condition + self.actions = actions + self.enabled = enabled + self.description = description + + +class AlertRuleAllOfCondition(Model): + """An Activity Log Alert rule condition that is met when all its member + conditions are met. + + All required parameters must be populated in order to send to Azure. + + :param all_of: Required. The list of Activity Log Alert rule conditions. + :type all_of: + list[~$(python-base-namespace).v2020_10_01.models.AlertRuleAnyOfOrLeafCondition] + """ + + _validation = { + 'all_of': {'required': True}, + } + + _attribute_map = { + 'all_of': {'key': 'allOf', 'type': '[AlertRuleAnyOfOrLeafCondition]'}, + } + + def __init__(self, *, all_of, **kwargs) -> None: + super(AlertRuleAllOfCondition, self).__init__(**kwargs) + self.all_of = all_of + + +class AlertRuleLeafCondition(Model): + """An Activity Log Alert rule condition that is met by comparing the field and + value of an Activity Log event. + This condition must contain 'field' and either 'equals' or 'containsAny'. + + :param field: The name of the Activity Log event's field that this + condition will examine. + The possible values for this field are (case-insensitive): 'resourceId', + 'category', 'caller', 'level', 'operationName', 'resourceGroup', + 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything + beginning with 'properties'. + :type field: str + :param equals: The value of the event's field will be compared to this + value (case-insensitive) to determine if the condition is met. + :type equals: str + :param contains_any: The value of the event's field will be compared to + the values in this array (case-insensitive) to determine if the condition + is met. + :type contains_any: list[str] + """ + + _attribute_map = { + 'field': {'key': 'field', 'type': 'str'}, + 'equals': {'key': 'equals', 'type': 'str'}, + 'contains_any': {'key': 'containsAny', 'type': '[str]'}, + } + + def __init__(self, *, field: str=None, equals: str=None, contains_any=None, **kwargs) -> None: + super(AlertRuleLeafCondition, self).__init__(**kwargs) + self.field = field + self.equals = equals + self.contains_any = contains_any + + +class AlertRuleAnyOfOrLeafCondition(AlertRuleLeafCondition): + """An Activity Log Alert rule condition that is met when all its member + conditions are met. + Each condition can be of one of the following types: + __Important__: Each type has its unique subset of properties. Properties + from different types CANNOT exist in one condition. + * __Leaf Condition -__ must contain 'field' and either 'equals' or + 'containsAny'. + _Please note, 'anyOf' should __not__ be set in a Leaf Condition._ + * __AnyOf Condition -__ must contain __only__ 'anyOf' (which is an array of + Leaf Conditions). + _Please note, 'field', 'equals' and 'containsAny' should __not__ be set in + an AnyOf Condition._ + . + + :param field: The name of the Activity Log event's field that this + condition will examine. + The possible values for this field are (case-insensitive): 'resourceId', + 'category', 'caller', 'level', 'operationName', 'resourceGroup', + 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything + beginning with 'properties'. + :type field: str + :param equals: The value of the event's field will be compared to this + value (case-insensitive) to determine if the condition is met. + :type equals: str + :param contains_any: The value of the event's field will be compared to + the values in this array (case-insensitive) to determine if the condition + is met. + :type contains_any: list[str] + :param any_of: An Activity Log Alert rule 'anyOf' condition. An Activity + Log Alert rule condition that is met when at least one of its member leaf + conditions are met. + :type any_of: + list[~$(python-base-namespace).v2020_10_01.models.AlertRuleLeafCondition] + """ + + _attribute_map = { + 'field': {'key': 'field', 'type': 'str'}, + 'equals': {'key': 'equals', 'type': 'str'}, + 'contains_any': {'key': 'containsAny', 'type': '[str]'}, + 'any_of': {'key': 'anyOf', 'type': '[AlertRuleLeafCondition]'}, + } + + def __init__(self, *, field: str=None, equals: str=None, contains_any=None, any_of=None, **kwargs) -> None: + super(AlertRuleAnyOfOrLeafCondition, self).__init__(field=field, equals=equals, contains_any=contains_any, **kwargs) + self.any_of = any_of + + +class AlertRulePatchObject(Model): + """An Activity Log Alert rule object for the body of patch operations. + + :param tags: The resource tags + :type tags: dict[str, str] + :param enabled: Indicates whether this Activity Log Alert rule is enabled. + If an Activity Log Alert rule is not enabled, then none of its actions + will be activated. Default value: True . + :type enabled: bool + """ + + _attribute_map = { + 'tags': {'key': 'tags', 'type': '{str}'}, + 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, + } + + def __init__(self, *, tags=None, enabled: bool=True, **kwargs) -> None: + super(AlertRulePatchObject, self).__init__(**kwargs) + self.tags = tags + self.enabled = enabled + + +class CloudError(Model): + """CloudError. + """ + + _attribute_map = { + } + + +class ErrorResponse(Model): + """The error response. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message indicating why the operation failed. + :vartype message: str + """ + + _validation = { + 'code': {'readonly': True}, + 'message': {'readonly': True}, + } + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, **kwargs) -> None: + super(ErrorResponse, self).__init__(**kwargs) + self.code = None + self.message = None + + +class ErrorResponseException(HttpOperationError): + """Server responsed with exception of type: 'ErrorResponse'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(ErrorResponseException, self).__init__(deserialize, response, 'ErrorResponse', *args) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_paged_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_paged_models.py new file mode 100644 index 000000000000..6437cc5f4deb --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_paged_models.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 ActivityLogAlertResourcePaged(Paged): + """ + A paging container for iterating over a list of :class:`ActivityLogAlertResource <$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource>` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[ActivityLogAlertResource]'} + } + + def __init__(self, *args, **kwargs): + + super(ActivityLogAlertResourcePaged, self).__init__(*args, **kwargs) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/__init__.py new file mode 100644 index 000000000000..8074538b1a4a --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/__init__.py @@ -0,0 +1,16 @@ +# 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 ._activity_log_alerts_operations import ActivityLogAlertsOperations + +__all__ = [ + 'ActivityLogAlertsOperations', +] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py new file mode 100644 index 000000000000..201199a26e1e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py @@ -0,0 +1,436 @@ +# 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 .. import models + + +class ActivityLogAlertsOperations(object): + """ActivityLogAlertsOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :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: The API version to use for this operation. Constant value: "2020-10-01". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2020-10-01" + + self.config = config + + def create_or_update( + self, resource_group_name, activity_log_alert_name, activity_log_alert_rule, custom_headers=None, raw=False, **operation_config): + """Create a new Activity Log Alert rule or update an existing one. + + :param resource_group_name: The name of the resource group. The name + is case insensitive. + :type resource_group_name: str + :param activity_log_alert_name: The name of the Activity Log Alert + rule. + :type activity_log_alert_name: str + :param activity_log_alert_rule: The Activity Log Alert rule to create + or use for the update. + :type activity_log_alert_rule: + ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource + :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: ActivityLogAlertResource or ClientRawResponse if raw=true + :rtype: + ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException<$(python-base-namespace).v2020_10_01.models.ErrorResponseException>` + """ + # Construct URL + url = self.create_or_update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + + # 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(activity_log_alert_rule, 'ActivityLogAlertResource') + + # 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]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ActivityLogAlertResource', response) + if response.status_code == 201: + deserialized = self._deserialize('ActivityLogAlertResource', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}'} + + def get( + self, resource_group_name, activity_log_alert_name, custom_headers=None, raw=False, **operation_config): + """Get an Activity Log Alert rule. + + :param resource_group_name: The name of the resource group. The name + is case insensitive. + :type resource_group_name: str + :param activity_log_alert_name: The name of the Activity Log Alert + rule. + :type activity_log_alert_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: ActivityLogAlertResource or ClientRawResponse if raw=true + :rtype: + ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException<$(python-base-namespace).v2020_10_01.models.ErrorResponseException>` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + + # 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]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ActivityLogAlertResource', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}'} + + def delete( + self, resource_group_name, activity_log_alert_name, custom_headers=None, raw=False, **operation_config): + """Delete an Activity Log Alert rule. + + :param resource_group_name: The name of the resource group. The name + is case insensitive. + :type resource_group_name: str + :param activity_log_alert_name: The name of the Activity Log Alert + rule. + :type activity_log_alert_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException<$(python-base-namespace).v2020_10_01.models.ErrorResponseException>` + """ + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + + # 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 [200, 204]: + raise models.ErrorResponseException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}'} + + def update( + self, resource_group_name, activity_log_alert_name, activity_log_alert_rule_patch, custom_headers=None, raw=False, **operation_config): + """Updates 'tags' and 'enabled' fields in an existing Alert rule. This + method is used to update the Alert rule tags, and to enable or disable + the Alert rule. To update other fields use CreateOrUpdate operation. + + :param resource_group_name: The name of the resource group. The name + is case insensitive. + :type resource_group_name: str + :param activity_log_alert_name: The name of the Activity Log Alert + rule. + :type activity_log_alert_name: str + :param activity_log_alert_rule_patch: Parameters supplied to the + operation. + :type activity_log_alert_rule_patch: + ~$(python-base-namespace).v2020_10_01.models.AlertRulePatchObject + :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: ActivityLogAlertResource or ClientRawResponse if raw=true + :rtype: + ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource + or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`ErrorResponseException<$(python-base-namespace).v2020_10_01.models.ErrorResponseException>` + """ + # Construct URL + url = self.update.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str', min_length=1) + + # 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(activity_log_alert_rule_patch, 'AlertRulePatchObject') + + # Construct and send request + request = self._client.patch(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ActivityLogAlertResource', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}'} + + def list_by_subscription_id( + self, custom_headers=None, raw=False, **operation_config): + """Get a list of all Activity Log Alert rules in a subscription. + + :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 ActivityLogAlertResource + :rtype: + ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResourcePaged[~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource] + :raises: + :class:`ErrorResponseException<$(python-base-namespace).v2020_10_01.models.ErrorResponseException>` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_subscription_id.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', 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', min_length=1) + + 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) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.ActivityLogAlertResourcePaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_by_subscription_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts'} + + def list_by_resource_group( + self, resource_group_name, custom_headers=None, raw=False, **operation_config): + """Get a list of all Activity Log Alert rules in a resource group. + + :param resource_group_name: The name of the resource group. The name + is case insensitive. + :type resource_group_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 ActivityLogAlertResource + :rtype: + ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResourcePaged[~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource] + :raises: + :class:`ErrorResponseException<$(python-base-namespace).v2020_10_01.models.ErrorResponseException>` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$') + } + 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', min_length=1) + + 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) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.ErrorResponseException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.ActivityLogAlertResourcePaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts'} diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/version.py new file mode 100644 index 000000000000..f1684021ce87 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/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 = "2020-10-01" +