diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/MANIFEST.in b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/MANIFEST.in index a3cb07df8765..3a9b6517412b 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/MANIFEST.in +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/MANIFEST.in @@ -1,3 +1,4 @@ +include _meta.json recursive-include tests *.py *.yaml include *.md include azure/__init__.py diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/_meta.json b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/_meta.json new file mode 100644 index 000000000000..4f2e5c2bb80d --- /dev/null +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.4.5", + "use": [ + "@autorest/python@5.8.4", + "@autorest/modelerfour@4.19.2" + ], + "commit": "42c447a9123ce7154bae8b99c4b8cb56a02e2a15", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/alertsmanagement/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "readme": "specification/alertsmanagement/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_alerts_management_client.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_alerts_management_client.py index b2f9a29fd2e7..53b096240001 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_alerts_management_client.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_alerts_management_client.py @@ -16,29 +16,27 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential + from azure.core.pipeline.transport import HttpRequest, HttpResponse from ._configuration import AlertsManagementClientConfiguration -from .operations import ActionRulesOperations +from .operations import AlertProcessingRulesOperations from .operations import Operations from .operations import AlertsOperations from .operations import SmartGroupsOperations -from .operations import SmartDetectorAlertRulesOperations from . import models class AlertsManagementClient(object): """AlertsManagement Client. - :ivar action_rules: ActionRulesOperations operations - :vartype action_rules: azure.mgmt.alertsmanagement.operations.ActionRulesOperations + :ivar alert_processing_rules: AlertProcessingRulesOperations operations + :vartype alert_processing_rules: azure.mgmt.alertsmanagement.operations.AlertProcessingRulesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.alertsmanagement.operations.Operations :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.alertsmanagement.operations.AlertsOperations :ivar smart_groups: SmartGroupsOperations operations :vartype smart_groups: azure.mgmt.alertsmanagement.operations.SmartGroupsOperations - :ivar smart_detector_alert_rules: SmartDetectorAlertRulesOperations operations - :vartype smart_detector_alert_rules: azure.mgmt.alertsmanagement.operations.SmartDetectorAlertRulesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. @@ -61,9 +59,10 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - self.action_rules = ActionRulesOperations( + self.alert_processing_rules = AlertProcessingRulesOperations( self._client, self._config, self._serialize, self._deserialize) self.operations = Operations( self._client, self._config, self._serialize, self._deserialize) @@ -71,8 +70,24 @@ def __init__( self._client, self._config, self._serialize, self._deserialize) self.smart_groups = SmartGroupsOperations( self._client, self._config, self._serialize, self._deserialize) - self.smart_detector_alert_rules = SmartDetectorAlertRulesOperations( - self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, http_request, **kwargs): + # type: (HttpRequest, Any) -> HttpResponse + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.HttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response def close(self): # type: () -> None diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_metadata.json b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_metadata.json new file mode 100644 index 000000000000..338f29cb15ff --- /dev/null +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_metadata.json @@ -0,0 +1,106 @@ +{ + "chosen_version": "", + "total_api_version_list": ["2019-05-05-preview", "2021-08-08-preview"], + "client": { + "name": "AlertsManagementClient", + "filename": "_alerts_management_client", + "description": "AlertsManagement Client.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AlertsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AlertsManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=None, # type: Optional[str]", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: Optional[str] = None,", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_default_policy_type": "BearerTokenCredentialPolicy", + "credential_default_policy_type_has_async_version": true, + "credential_key_header_name": null, + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "alert_processing_rules": "AlertProcessingRulesOperations", + "operations": "Operations", + "alerts": "AlertsOperations", + "smart_groups": "SmartGroupsOperations" + } +} \ No newline at end of file diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_version.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_version.py index c47f66669f1b..e5754a47ce68 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_version.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_alerts_management_client.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_alerts_management_client.py index 44af7da286eb..f225f43dcb0b 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_alerts_management_client.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_alerts_management_client.py @@ -8,6 +8,7 @@ from typing import Any, Optional, TYPE_CHECKING +from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer @@ -16,27 +17,24 @@ from azure.core.credentials_async import AsyncTokenCredential from ._configuration import AlertsManagementClientConfiguration -from .operations import ActionRulesOperations +from .operations import AlertProcessingRulesOperations from .operations import Operations from .operations import AlertsOperations from .operations import SmartGroupsOperations -from .operations import SmartDetectorAlertRulesOperations from .. import models class AlertsManagementClient(object): """AlertsManagement Client. - :ivar action_rules: ActionRulesOperations operations - :vartype action_rules: azure.mgmt.alertsmanagement.aio.operations.ActionRulesOperations + :ivar alert_processing_rules: AlertProcessingRulesOperations operations + :vartype alert_processing_rules: azure.mgmt.alertsmanagement.aio.operations.AlertProcessingRulesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.alertsmanagement.aio.operations.Operations :ivar alerts: AlertsOperations operations :vartype alerts: azure.mgmt.alertsmanagement.aio.operations.AlertsOperations :ivar smart_groups: SmartGroupsOperations operations :vartype smart_groups: azure.mgmt.alertsmanagement.aio.operations.SmartGroupsOperations - :ivar smart_detector_alert_rules: SmartDetectorAlertRulesOperations operations - :vartype smart_detector_alert_rules: azure.mgmt.alertsmanagement.aio.operations.SmartDetectorAlertRulesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. @@ -58,9 +56,10 @@ def __init__( client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) + self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) - self.action_rules = ActionRulesOperations( + self.alert_processing_rules = AlertProcessingRulesOperations( self._client, self._config, self._serialize, self._deserialize) self.operations = Operations( self._client, self._config, self._serialize, self._deserialize) @@ -68,8 +67,23 @@ def __init__( self._client, self._config, self._serialize, self._deserialize) self.smart_groups = SmartGroupsOperations( self._client, self._config, self._serialize, self._deserialize) - self.smart_detector_alert_rules = SmartDetectorAlertRulesOperations( - self._client, self._config, self._serialize, self._deserialize) + + async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + """Runs the network request through the client's chained policies. + + :param http_request: The network request you want to make. Required. + :type http_request: ~azure.core.pipeline.transport.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + """ + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + http_request.url = self._client.format_url(http_request.url, **path_format_arguments) + stream = kwargs.pop("stream", True) + pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) + return pipeline_response.http_response async def close(self) -> None: await self._client.close() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/__init__.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/__init__.py index 101018dc2503..7eb086190441 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/__init__.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/__init__.py @@ -6,16 +6,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._action_rules_operations import ActionRulesOperations +from ._alert_processing_rules_operations import AlertProcessingRulesOperations from ._operations import Operations from ._alerts_operations import AlertsOperations from ._smart_groups_operations import SmartGroupsOperations -from ._smart_detector_alert_rules_operations import SmartDetectorAlertRulesOperations __all__ = [ - 'ActionRulesOperations', + 'AlertProcessingRulesOperations', 'Operations', 'AlertsOperations', 'SmartGroupsOperations', - 'SmartDetectorAlertRulesOperations', ] diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_action_rules_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_action_rules_operations.py deleted file mode 100644 index 9021e45cdc06..000000000000 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_action_rules_operations.py +++ /dev/null @@ -1,561 +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 typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat - -from ... import models as _models - -T = TypeVar('T') -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - -class ActionRulesOperations: - """ActionRulesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.alertsmanagement.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_by_subscription( - self, - target_resource_group: Optional[str] = None, - target_resource_type: Optional[str] = None, - target_resource: Optional[str] = None, - severity: Optional[Union[str, "_models.Severity"]] = None, - monitor_service: Optional[Union[str, "_models.MonitorService"]] = None, - impacted_scope: Optional[str] = None, - description: Optional[str] = None, - alert_rule_id: Optional[str] = None, - action_group: Optional[str] = None, - name: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.ActionRulesList"]: - """Get all action rule in a given subscription. - - List all action rules of the subscription and given input filters. - - :param target_resource_group: Filter by target resource group name. Default value is select - all. - :type target_resource_group: str - :param target_resource_type: Filter by target resource type. Default value is select all. - :type target_resource_type: str - :param target_resource: Filter by target resource( which is full ARM ID) Default value is - select all. - :type target_resource: str - :param severity: Filter by severity. Default value is select all. - :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity - :param monitor_service: Filter by monitor service which generates the alert instance. Default - value is select all. - :type monitor_service: str or ~azure.mgmt.alertsmanagement.models.MonitorService - :param impacted_scope: filter by impacted/target scope (provide comma separated list for - multiple scopes). The value should be an well constructed ARM id of the scope. - :type impacted_scope: str - :param description: filter by alert rule description. - :type description: str - :param alert_rule_id: filter by alert rule id. - :type alert_rule_id: str - :param action_group: filter by action group configured as part of action rule. - :type action_group: str - :param name: filter by action rule name. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionRulesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.alertsmanagement.models.ActionRulesList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionRulesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-05-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - if target_resource_group is not None: - query_parameters['targetResourceGroup'] = self._serialize.query("target_resource_group", target_resource_group, 'str') - if target_resource_type is not None: - query_parameters['targetResourceType'] = self._serialize.query("target_resource_type", target_resource_type, 'str') - if target_resource is not None: - query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') - if severity is not None: - query_parameters['severity'] = self._serialize.query("severity", severity, 'str') - if monitor_service is not None: - query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') - if impacted_scope is not None: - query_parameters['impactedScope'] = self._serialize.query("impacted_scope", impacted_scope, 'str') - if description is not None: - query_parameters['description'] = self._serialize.query("description", description, 'str') - if alert_rule_id is not None: - query_parameters['alertRuleId'] = self._serialize.query("alert_rule_id", alert_rule_id, 'str') - if action_group is not None: - query_parameters['actionGroup'] = self._serialize.query("action_group", action_group, 'str') - if name is not None: - query_parameters['name'] = self._serialize.query("name", name, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ActionRulesList', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/actionRules'} # type: ignore - - def list_by_resource_group( - self, - resource_group_name: str, - target_resource_group: Optional[str] = None, - target_resource_type: Optional[str] = None, - target_resource: Optional[str] = None, - severity: Optional[Union[str, "_models.Severity"]] = None, - monitor_service: Optional[Union[str, "_models.MonitorService"]] = None, - impacted_scope: Optional[str] = None, - description: Optional[str] = None, - alert_rule_id: Optional[str] = None, - action_group: Optional[str] = None, - name: Optional[str] = None, - **kwargs - ) -> AsyncIterable["_models.ActionRulesList"]: - """Get all action rules created in a resource group. - - List all action rules of the subscription, created in given resource group and given input - filters. - - :param resource_group_name: Resource group name where the resource is created. - :type resource_group_name: str - :param target_resource_group: Filter by target resource group name. Default value is select - all. - :type target_resource_group: str - :param target_resource_type: Filter by target resource type. Default value is select all. - :type target_resource_type: str - :param target_resource: Filter by target resource( which is full ARM ID) Default value is - select all. - :type target_resource: str - :param severity: Filter by severity. Default value is select all. - :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity - :param monitor_service: Filter by monitor service which generates the alert instance. Default - value is select all. - :type monitor_service: str or ~azure.mgmt.alertsmanagement.models.MonitorService - :param impacted_scope: filter by impacted/target scope (provide comma separated list for - multiple scopes). The value should be an well constructed ARM id of the scope. - :type impacted_scope: str - :param description: filter by alert rule description. - :type description: str - :param alert_rule_id: filter by alert rule id. - :type alert_rule_id: str - :param action_group: filter by action group configured as part of action rule. - :type action_group: str - :param name: filter by action rule name. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionRulesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.alertsmanagement.models.ActionRulesList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionRulesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-05-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - 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'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if target_resource_group is not None: - query_parameters['targetResourceGroup'] = self._serialize.query("target_resource_group", target_resource_group, 'str') - if target_resource_type is not None: - query_parameters['targetResourceType'] = self._serialize.query("target_resource_type", target_resource_type, 'str') - if target_resource is not None: - query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') - if severity is not None: - query_parameters['severity'] = self._serialize.query("severity", severity, 'str') - if monitor_service is not None: - query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') - if impacted_scope is not None: - query_parameters['impactedScope'] = self._serialize.query("impacted_scope", impacted_scope, 'str') - if description is not None: - query_parameters['description'] = self._serialize.query("description", description, 'str') - if alert_rule_id is not None: - query_parameters['alertRuleId'] = self._serialize.query("alert_rule_id", alert_rule_id, 'str') - if action_group is not None: - query_parameters['actionGroup'] = self._serialize.query("action_group", action_group, 'str') - if name is not None: - query_parameters['name'] = self._serialize.query("name", name, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize('ActionRulesList', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules'} # type: ignore - - async def get_by_name( - self, - resource_group_name: str, - action_rule_name: str, - **kwargs - ) -> "_models.ActionRule": - """Get action rule by name. - - Get a specific action rule. - - :param resource_group_name: Resource group name where the resource is created. - :type resource_group_name: str - :param action_rule_name: The name of action rule that needs to be fetched. - :type action_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionRule, or the result of cls(response) - :rtype: ~azure.mgmt.alertsmanagement.models.ActionRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-05-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_name.metadata['url'] # type: ignore - 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'), - 'actionRuleName': self._serialize.url("action_rule_name", action_rule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) - deserialized = self._deserialize('ActionRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{actionRuleName}'} # type: ignore - - async def create_update( - self, - resource_group_name: str, - action_rule_name: str, - action_rule: "_models.ActionRule", - **kwargs - ) -> "_models.ActionRule": - """Create/update an action rule. - - Creates/Updates a specific action rule. - - :param resource_group_name: Resource group name where the resource is created. - :type resource_group_name: str - :param action_rule_name: The name of action rule that needs to be created/updated. - :type action_rule_name: str - :param action_rule: action rule to be created/updated. - :type action_rule: ~azure.mgmt.alertsmanagement.models.ActionRule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionRule, or the result of cls(response) - :rtype: ~azure.mgmt.alertsmanagement.models.ActionRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-05-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_update.metadata['url'] # type: ignore - 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'), - 'actionRuleName': self._serialize.url("action_rule_name", action_rule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_rule, 'ActionRule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) - deserialized = self._deserialize('ActionRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - create_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{actionRuleName}'} # type: ignore - - async def delete( - self, - resource_group_name: str, - action_rule_name: str, - **kwargs - ) -> bool: - """Delete action rule. - - Deletes a given action rule. - - :param resource_group_name: Resource group name where the resource is created. - :type resource_group_name: str - :param action_rule_name: The name that needs to be deleted. - :type action_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[bool] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-05-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - 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'), - 'actionRuleName': self._serialize.url("action_rule_name", action_rule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) - deserialized = self._deserialize('bool', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{actionRuleName}'} # type: ignore - - async def update( - self, - resource_group_name: str, - action_rule_name: str, - action_rule_patch: "_models.PatchObject", - **kwargs - ) -> "_models.ActionRule": - """Patch action rule. - - Update enabled flag and/or tags for the given action rule. - - :param resource_group_name: Resource group name where the resource is created. - :type resource_group_name: str - :param action_rule_name: The name that needs to be updated. - :type action_rule_name: str - :param action_rule_patch: Parameters supplied to the operation. - :type action_rule_patch: ~azure.mgmt.alertsmanagement.models.PatchObject - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionRule, or the result of cls(response) - :rtype: ~azure.mgmt.alertsmanagement.models.ActionRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-05-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - 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'), - 'actionRuleName': self._serialize.url("action_rule_name", action_rule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_rule_patch, 'PatchObject') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) - deserialized = self._deserialize('ActionRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{actionRuleName}'} # type: ignore diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_smart_detector_alert_rules_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alert_processing_rules_operations.py similarity index 66% rename from sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_smart_detector_alert_rules_operations.py rename to sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alert_processing_rules_operations.py index 3170a1f68923..18f8e2ec2534 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_smart_detector_alert_rules_operations.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alert_processing_rules_operations.py @@ -19,8 +19,8 @@ T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SmartDetectorAlertRulesOperations: - """SmartDetectorAlertRulesOperations async operations. +class AlertProcessingRulesOperations: + """AlertProcessingRulesOperations async operations. You should not instantiate this class directly. Instead, you should create a Client instance that instantiates it for you and attaches it as an attribute. @@ -41,26 +41,23 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config - def list( + def list_by_subscription( self, - expand_detector: Optional[bool] = None, - **kwargs - ) -> AsyncIterable["_models.AlertRulesList"]: - """List all the existing Smart Detector alert rules within the subscription. + **kwargs: Any + ) -> AsyncIterable["_models.AlertProcessingRulesList"]: + """List all alert processing rules in a subscription. - :param expand_detector: Indicates if Smart Detector should be expanded. - :type expand_detector: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRulesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.alertsmanagement.models.AlertRulesList] + :return: An iterator like instance of either AlertProcessingRulesList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.alertsmanagement.models.AlertProcessingRulesList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRulesList"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertProcessingRulesList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" + api_version = "2021-08-08-preview" accept = "application/json" def prepare_request(next_link=None): @@ -70,7 +67,7 @@ def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] # type: ignore + url = self.list_by_subscription.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), } @@ -78,8 +75,6 @@ def prepare_request(next_link=None): # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand_detector is not None: - query_parameters['expandDetector'] = self._serialize.query("expand_detector", expand_detector, 'bool') request = self._client.get(url, query_parameters, header_parameters) else: @@ -89,7 +84,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AlertRulesList', pipeline_response) + deserialized = self._deserialize('AlertProcessingRulesList', pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,7 +97,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.SmartDetectorErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -111,31 +106,28 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.alertsManagement/smartDetectorAlertRules'} # type: ignore + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/actionRules'} # type: ignore def list_by_resource_group( self, resource_group_name: str, - expand_detector: Optional[bool] = None, - **kwargs - ) -> AsyncIterable["_models.AlertRulesList"]: - """List all the existing Smart Detector alert rules within the subscription and resource group. + **kwargs: Any + ) -> AsyncIterable["_models.AlertProcessingRulesList"]: + """List all alert processing rules in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: Resource group name where the resource is created. :type resource_group_name: str - :param expand_detector: Indicates if Smart Detector should be expanded. - :type expand_detector: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRulesList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.alertsmanagement.models.AlertRulesList] + :return: An iterator like instance of either AlertProcessingRulesList or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.alertsmanagement.models.AlertProcessingRulesList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRulesList"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertProcessingRulesList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" + api_version = "2021-08-08-preview" accept = "application/json" def prepare_request(next_link=None): @@ -154,8 +146,6 @@ def prepare_request(next_link=None): # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand_detector is not None: - query_parameters['expandDetector'] = self._serialize.query("expand_detector", expand_detector, 'bool') request = self._client.get(url, query_parameters, header_parameters) else: @@ -165,7 +155,7 @@ def prepare_request(next_link=None): return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AlertRulesList', pipeline_response) + deserialized = self._deserialize('AlertProcessingRulesList', pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -178,7 +168,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.SmartDetectorErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -187,50 +177,46 @@ async def get_next(next_link=None): return AsyncItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules'} # type: ignore + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules'} # type: ignore - async def get( + async def get_by_name( self, resource_group_name: str, - alert_rule_name: str, - expand_detector: Optional[bool] = None, - **kwargs - ) -> "_models.AlertRule": - """Get a specific Smart Detector alert rule. + alert_processing_rule_name: str, + **kwargs: Any + ) -> "_models.AlertProcessingRule": + """Get an alert processing rule by name. - :param resource_group_name: The name of the resource group. + :param resource_group_name: Resource group name where the resource is created. :type resource_group_name: str - :param alert_rule_name: The name of the alert rule. - :type alert_rule_name: str - :param expand_detector: Indicates if Smart Detector should be expanded. - :type expand_detector: bool + :param alert_processing_rule_name: The name of the alert processing rule that needs to be + fetched. + :type alert_processing_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRule, or the result of cls(response) - :rtype: ~azure.mgmt.alertsmanagement.models.AlertRule + :return: AlertProcessingRule, or the result of cls(response) + :rtype: ~azure.mgmt.alertsmanagement.models.AlertProcessingRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRule"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertProcessingRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" + api_version = "2021-08-08-preview" accept = "application/json" # Construct URL - url = self.get.metadata['url'] # type: ignore + url = self.get_by_name.metadata['url'] # type: ignore 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'), - 'alertRuleName': self._serialize.url("alert_rule_name", alert_rule_name, 'str'), + 'alertProcessingRuleName': self._serialize.url("alert_processing_rule_name", alert_processing_rule_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand_detector is not None: - query_parameters['expandDetector'] = self._serialize.query("expand_detector", expand_detector, 'bool') # Construct headers header_parameters = {} # type: Dict[str, Any] @@ -242,43 +228,46 @@ async def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.SmartDetectorErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AlertRule', pipeline_response) + response_headers = {} + response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) + deserialized = self._deserialize('AlertProcessingRule', pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} # type: ignore + get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}'} # type: ignore async def create_or_update( self, resource_group_name: str, - alert_rule_name: str, - parameters: "_models.AlertRule", - **kwargs - ) -> "_models.AlertRule": - """Create or update a Smart Detector alert rule. + alert_processing_rule_name: str, + alert_processing_rule: "_models.AlertProcessingRule", + **kwargs: Any + ) -> "_models.AlertProcessingRule": + """Create or update an alert processing rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: Resource group name where the resource is created. :type resource_group_name: str - :param alert_rule_name: The name of the alert rule. - :type alert_rule_name: str - :param parameters: Parameters supplied to the operation. - :type parameters: ~azure.mgmt.alertsmanagement.models.AlertRule + :param alert_processing_rule_name: The name of the alert processing rule that needs to be + created/updated. + :type alert_processing_rule_name: str + :param alert_processing_rule: Alert processing rule to be created/updated. + :type alert_processing_rule: ~azure.mgmt.alertsmanagement.models.AlertProcessingRule :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRule, or the result of cls(response) - :rtype: ~azure.mgmt.alertsmanagement.models.AlertRule + :return: AlertProcessingRule, or the result of cls(response) + :rtype: ~azure.mgmt.alertsmanagement.models.AlertProcessingRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRule"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertProcessingRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" + api_version = "2021-08-08-preview" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -287,7 +276,7 @@ async def create_or_update( 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'), - 'alertRuleName': self._serialize.url("alert_rule_name", alert_rule_name, 'str'), + 'alertProcessingRuleName': self._serialize.url("alert_processing_rule_name", alert_processing_rule_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -301,7 +290,7 @@ async def create_or_update( header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AlertRule') + body_content = self._serialize.body(alert_processing_rule, 'AlertProcessingRule') body_content_kwargs['content'] = body_content request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) @@ -309,56 +298,56 @@ async def create_or_update( if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.SmartDetectorErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('AlertRule', pipeline_response) + response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) + deserialized = self._deserialize('AlertProcessingRule', pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AlertRule', pipeline_response) + response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) + deserialized = self._deserialize('AlertProcessingRule', pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} # type: ignore + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}'} # type: ignore - async def patch( + async def delete( self, resource_group_name: str, - alert_rule_name: str, - parameters: "_models.AlertRulePatchObject", - **kwargs - ) -> "_models.AlertRule": - """Patch a specific Smart Detector alert rule. + alert_processing_rule_name: str, + **kwargs: Any + ) -> None: + """Delete an alert processing rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: Resource group name where the resource is created. :type resource_group_name: str - :param alert_rule_name: The name of the alert rule. - :type alert_rule_name: str - :param parameters: Parameters supplied to the operation. - :type parameters: ~azure.mgmt.alertsmanagement.models.AlertRulePatchObject + :param alert_processing_rule_name: The name of the alert processing rule that needs to be + deleted. + :type alert_processing_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRule, or the result of cls(response) - :rtype: ~azure.mgmt.alertsmanagement.models.AlertRule + :return: None, or the result of cls(response) + :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRule"] + cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") + api_version = "2021-08-08-preview" accept = "application/json" # Construct URL - url = self.patch.metadata['url'] # type: ignore + url = self.delete.metadata['url'] # type: ignore 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'), - 'alertRuleName': self._serialize.url("alert_rule_name", alert_rule_name, 'str'), + 'alertProcessingRuleName': self._serialize.url("alert_processing_rule_name", alert_processing_rule_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -368,60 +357,64 @@ async def patch( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AlertRulePatchObject') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.SmartDetectorErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AlertRule', pipeline_response) + response_headers = {} + if response.status_code == 200: + response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) + + if response.status_code == 204: + response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, None, response_headers) - return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} # type: ignore + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}'} # type: ignore - async def delete( + async def update( self, resource_group_name: str, - alert_rule_name: str, - **kwargs - ) -> None: - """Delete an existing Smart Detector alert rule. + alert_processing_rule_name: str, + alert_processing_rule_patch: "_models.PatchObject", + **kwargs: Any + ) -> "_models.AlertProcessingRule": + """Enable, disable, or update tags for an alert processing rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: Resource group name where the resource is created. :type resource_group_name: str - :param alert_rule_name: The name of the alert rule. - :type alert_rule_name: str + :param alert_processing_rule_name: The name that needs to be updated. + :type alert_processing_rule_name: str + :param alert_processing_rule_patch: Parameters supplied to the operation. + :type alert_processing_rule_patch: ~azure.mgmt.alertsmanagement.models.PatchObject :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None + :return: AlertProcessingRule, or the result of cls(response) + :rtype: ~azure.mgmt.alertsmanagement.models.AlertProcessingRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertProcessingRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" + api_version = "2021-08-08-preview" + content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL - url = self.delete.metadata['url'] # type: ignore + url = self.update.metadata['url'] # type: ignore 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'), - 'alertRuleName': self._serialize.url("alert_rule_name", alert_rule_name, 'str'), + 'alertProcessingRuleName': self._serialize.url("alert_processing_rule_name", alert_processing_rule_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -431,18 +424,27 @@ async def delete( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.delete(url, query_parameters, header_parameters) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(alert_processing_rule_patch, 'PatchObject') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.SmartDetectorErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) + deserialized = self._deserialize('AlertProcessingRule', pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, response_headers) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} # type: ignore + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}'} # type: ignore diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alerts_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alerts_operations.py index 3f540db7c3a0..92554a7a96df 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alerts_operations.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alerts_operations.py @@ -44,7 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def meta_data( self, identifier: Union[str, "_models.Identifier"], - **kwargs + **kwargs: Any ) -> "_models.AlertsMetaData": """List alerts meta data information based on value of identifier parameter. @@ -81,7 +81,8 @@ async def meta_data( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertsMetaData', pipeline_response) @@ -106,11 +107,11 @@ def get_all( include_egress_config: Optional[bool] = None, page_count: Optional[int] = None, sort_by: Optional[Union[str, "_models.AlertsSortByFields"]] = None, - sort_order: Optional[Union[str, "_models.Enum11"]] = None, + sort_order: Optional[Union[str, "_models.Enum12"]] = None, select: Optional[str] = None, time_range: Optional[Union[str, "_models.TimeRange"]] = None, custom_time_range: Optional[str] = None, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.AlertsList"]: """List all existing alerts, where the results can be filtered on the basis of multiple parameters (e.g. time range). The results can then be sorted on the basis specific fields, with the @@ -147,23 +148,23 @@ def get_all( :param page_count: Determines number of alerts returned per page in response. Permissible value is between 1 to 250. When the "includeContent" filter is selected, maximum value allowed is 25. Default value is 25. - :type page_count: int + :type page_count: long :param sort_by: Sort the query results by input field, Default value is 'lastModifiedDateTime'. :type sort_by: str or ~azure.mgmt.alertsmanagement.models.AlertsSortByFields :param sort_order: Sort the query results order in either ascending or descending. Default value is 'desc' for time fields and 'asc' for others. - :type sort_order: str or ~azure.mgmt.alertsmanagement.models.Enum11 + :type sort_order: str or ~azure.mgmt.alertsmanagement.models.Enum12 :param select: This filter allows to selection of the fields(comma separated) which would be part of the essential section. This would allow to project only the required fields rather than getting entire content. Default is to fetch all the fields in the essentials section. :type select: str :param time_range: Filter by time range by below listed values. Default value is 1 day. :type time_range: str or ~azure.mgmt.alertsmanagement.models.TimeRange - :param custom_time_range: Filter by custom time range in the format :code:``/:code:`` where time is in (ISO-8601 format)'. Permissible values is within 30 - days from query time. Either timeRange or customTimeRange could be used but not both. Default - is none. + :param custom_time_range: Filter by custom time range in the format + :code:``/:code:`` where time is in (ISO-8601 format)'. Permissible + values is within 30 days from query time. Either timeRange or customTimeRange could be used + but not both. Default is none. :type custom_time_range: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertsList or the result of cls(response) @@ -215,7 +216,7 @@ def prepare_request(next_link=None): if include_egress_config is not None: query_parameters['includeEgressConfig'] = self._serialize.query("include_egress_config", include_egress_config, 'bool') if page_count is not None: - query_parameters['pageCount'] = self._serialize.query("page_count", page_count, 'int') + query_parameters['pageCount'] = self._serialize.query("page_count", page_count, 'long') if sort_by is not None: query_parameters['sortBy'] = self._serialize.query("sort_by", sort_by, 'str') if sort_order is not None: @@ -249,7 +250,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -263,7 +264,7 @@ async def get_next(next_link=None): async def get_by_id( self, alert_id: str, - **kwargs + **kwargs: Any ) -> "_models.Alert": """Get a specific alert. @@ -306,7 +307,7 @@ async def get_by_id( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Alert', pipeline_response) @@ -321,7 +322,7 @@ async def change_state( self, alert_id: str, new_state: Union[str, "_models.AlertState"], - **kwargs + **kwargs: Any ) -> "_models.Alert": """Change the state of an alert. @@ -365,7 +366,7 @@ async def change_state( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Alert', pipeline_response) @@ -379,7 +380,7 @@ async def change_state( async def get_history( self, alert_id: str, - **kwargs + **kwargs: Any ) -> "_models.AlertModification": """Get the history of an alert, which captures any monitor condition changes (Fired/Resolved) and alert state changes (New/Acknowledged/Closed). @@ -421,7 +422,7 @@ async def get_history( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertModification', pipeline_response) @@ -446,7 +447,7 @@ async def get_summary( alert_rule: Optional[str] = None, time_range: Optional[Union[str, "_models.TimeRange"]] = None, custom_time_range: Optional[str] = None, - **kwargs + **kwargs: Any ) -> "_models.AlertsSummary": """Get a summarized count of your alerts grouped by various parameters (e.g. grouping by 'Severity' returns the count of alerts for each severity). @@ -480,10 +481,10 @@ async def get_summary( :type alert_rule: str :param time_range: Filter by time range by below listed values. Default value is 1 day. :type time_range: str or ~azure.mgmt.alertsmanagement.models.TimeRange - :param custom_time_range: Filter by custom time range in the format :code:``/:code:`` where time is in (ISO-8601 format)'. Permissible values is within 30 - days from query time. Either timeRange or customTimeRange could be used but not both. Default - is none. + :param custom_time_range: Filter by custom time range in the format + :code:``/:code:`` where time is in (ISO-8601 format)'. Permissible + values is within 30 days from query time. Either timeRange or customTimeRange could be used + but not both. Default is none. :type custom_time_range: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertsSummary, or the result of cls(response) @@ -542,7 +543,7 @@ async def get_summary( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertsSummary', pipeline_response) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_operations.py index e666b633c3b3..a1662f015970 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_operations.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_operations.py @@ -43,7 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.OperationsList"]: """List all operations available through Azure Alerts Management Resource Provider. @@ -93,8 +93,9 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_smart_groups_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_smart_groups_operations.py index 51dbfdf0dcb1..319f058549db 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_smart_groups_operations.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_smart_groups_operations.py @@ -53,8 +53,8 @@ def get_all( time_range: Optional[Union[str, "_models.TimeRange"]] = None, page_count: Optional[int] = None, sort_by: Optional[Union[str, "_models.SmartGroupsSortByFields"]] = None, - sort_order: Optional[Union[str, "_models.Enum11"]] = None, - **kwargs + sort_order: Optional[Union[str, "_models.Enum12"]] = None, + **kwargs: Any ) -> AsyncIterable["_models.SmartGroupsList"]: """Get all Smart Groups within a specified subscription. @@ -83,13 +83,13 @@ def get_all( :param page_count: Determines number of alerts returned per page in response. Permissible value is between 1 to 250. When the "includeContent" filter is selected, maximum value allowed is 25. Default value is 25. - :type page_count: int + :type page_count: long :param sort_by: Sort the query results by input field. Default value is sort by 'lastModifiedDateTime'. :type sort_by: str or ~azure.mgmt.alertsmanagement.models.SmartGroupsSortByFields :param sort_order: Sort the query results order in either ascending or descending. Default value is 'desc' for time fields and 'asc' for others. - :type sort_order: str or ~azure.mgmt.alertsmanagement.models.Enum11 + :type sort_order: str or ~azure.mgmt.alertsmanagement.models.Enum12 :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SmartGroupsList or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.alertsmanagement.models.SmartGroupsList] @@ -134,7 +134,7 @@ def prepare_request(next_link=None): if time_range is not None: query_parameters['timeRange'] = self._serialize.query("time_range", time_range, 'str') if page_count is not None: - query_parameters['pageCount'] = self._serialize.query("page_count", page_count, 'int') + query_parameters['pageCount'] = self._serialize.query("page_count", page_count, 'long') if sort_by is not None: query_parameters['sortBy'] = self._serialize.query("sort_by", sort_by, 'str') if sort_order is not None: @@ -162,7 +162,7 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponseAutoGenerated2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -176,7 +176,7 @@ async def get_next(next_link=None): async def get_by_id( self, smart_group_id: str, - **kwargs + **kwargs: Any ) -> "_models.SmartGroup": """Get information related to a specific Smart Group. @@ -219,7 +219,7 @@ async def get_by_id( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -236,7 +236,7 @@ async def change_state( self, smart_group_id: str, new_state: Union[str, "_models.AlertState"], - **kwargs + **kwargs: Any ) -> "_models.SmartGroup": """Change the state of a Smart Group. @@ -280,7 +280,7 @@ async def change_state( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -296,7 +296,7 @@ async def change_state( async def get_history( self, smart_group_id: str, - **kwargs + **kwargs: Any ) -> "_models.SmartGroupModification": """Get the history a smart group, which captures any Smart Group state changes (New/Acknowledged/Closed) . @@ -338,7 +338,7 @@ async def get_history( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SmartGroupModification', pipeline_response) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/__init__.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/__init__.py index bfaf8c6a4805..f5b23c73fdd1 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/__init__.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/__init__.py @@ -7,30 +7,24 @@ # -------------------------------------------------------------------------- try: - from ._models_py3 import ActionGroup - from ._models_py3 import ActionGroupsInformation - from ._models_py3 import ActionRule - from ._models_py3 import ActionRuleProperties - from ._models_py3 import ActionRulesList + from ._models_py3 import Action + from ._models_py3 import AddActionGroups from ._models_py3 import Alert from ._models_py3 import AlertModification from ._models_py3 import AlertModificationItem from ._models_py3 import AlertModificationProperties + from ._models_py3 import AlertProcessingRule + from ._models_py3 import AlertProcessingRuleProperties + from ._models_py3 import AlertProcessingRulesList from ._models_py3 import AlertProperties - from ._models_py3 import AlertRule - from ._models_py3 import AlertRulePatchObject - from ._models_py3 import AlertRulesList from ._models_py3 import AlertsList from ._models_py3 import AlertsMetaData from ._models_py3 import AlertsMetaDataProperties from ._models_py3 import AlertsSummary from ._models_py3 import AlertsSummaryGroup from ._models_py3 import AlertsSummaryGroupItem - from ._models_py3 import AzureResource from ._models_py3 import Condition - from ._models_py3 import Conditions - from ._models_py3 import Detector - from ._models_py3 import Diagnostics + from ._models_py3 import DailyRecurrence from ._models_py3 import ErrorResponse from ._models_py3 import ErrorResponseAutoGenerated from ._models_py3 import ErrorResponseAutoGenerated2 @@ -41,48 +35,42 @@ from ._models_py3 import ManagedResource from ._models_py3 import MonitorServiceDetails from ._models_py3 import MonitorServiceList + from ._models_py3 import MonthlyRecurrence from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationsList from ._models_py3 import PatchObject + from ._models_py3 import Recurrence + from ._models_py3 import RemoveAllActionGroups from ._models_py3 import Resource - from ._models_py3 import Scope - from ._models_py3 import SmartDetectorErrorResponse + from ._models_py3 import Schedule from ._models_py3 import SmartGroup from ._models_py3 import SmartGroupAggregatedProperty from ._models_py3 import SmartGroupModification from ._models_py3 import SmartGroupModificationItem from ._models_py3 import SmartGroupModificationProperties from ._models_py3 import SmartGroupsList - from ._models_py3 import Suppression - from ._models_py3 import SuppressionConfig - from ._models_py3 import SuppressionSchedule - from ._models_py3 import ThrottlingInformation + from ._models_py3 import SystemData + from ._models_py3 import WeeklyRecurrence except (SyntaxError, ImportError): - from ._models import ActionGroup # type: ignore - from ._models import ActionGroupsInformation # type: ignore - from ._models import ActionRule # type: ignore - from ._models import ActionRuleProperties # type: ignore - from ._models import ActionRulesList # type: ignore + from ._models import Action # type: ignore + from ._models import AddActionGroups # type: ignore from ._models import Alert # type: ignore from ._models import AlertModification # type: ignore from ._models import AlertModificationItem # type: ignore from ._models import AlertModificationProperties # type: ignore + from ._models import AlertProcessingRule # type: ignore + from ._models import AlertProcessingRuleProperties # type: ignore + from ._models import AlertProcessingRulesList # type: ignore from ._models import AlertProperties # type: ignore - from ._models import AlertRule # type: ignore - from ._models import AlertRulePatchObject # type: ignore - from ._models import AlertRulesList # type: ignore from ._models import AlertsList # type: ignore from ._models import AlertsMetaData # type: ignore from ._models import AlertsMetaDataProperties # type: ignore from ._models import AlertsSummary # type: ignore from ._models import AlertsSummaryGroup # type: ignore from ._models import AlertsSummaryGroupItem # type: ignore - from ._models import AzureResource # type: ignore from ._models import Condition # type: ignore - from ._models import Conditions # type: ignore - from ._models import Detector # type: ignore - from ._models import Diagnostics # type: ignore + from ._models import DailyRecurrence # type: ignore from ._models import ErrorResponse # type: ignore from ._models import ErrorResponseAutoGenerated # type: ignore from ._models import ErrorResponseAutoGenerated2 # type: ignore @@ -93,73 +81,67 @@ from ._models import ManagedResource # type: ignore from ._models import MonitorServiceDetails # type: ignore from ._models import MonitorServiceList # type: ignore + from ._models import MonthlyRecurrence # type: ignore from ._models import Operation # type: ignore from ._models import OperationDisplay # type: ignore from ._models import OperationsList # type: ignore from ._models import PatchObject # type: ignore + from ._models import Recurrence # type: ignore + from ._models import RemoveAllActionGroups # type: ignore from ._models import Resource # type: ignore - from ._models import Scope # type: ignore - from ._models import SmartDetectorErrorResponse # type: ignore + from ._models import Schedule # type: ignore from ._models import SmartGroup # type: ignore from ._models import SmartGroupAggregatedProperty # type: ignore from ._models import SmartGroupModification # type: ignore from ._models import SmartGroupModificationItem # type: ignore from ._models import SmartGroupModificationProperties # type: ignore from ._models import SmartGroupsList # type: ignore - from ._models import Suppression # type: ignore - from ._models import SuppressionConfig # type: ignore - from ._models import SuppressionSchedule # type: ignore - from ._models import ThrottlingInformation # type: ignore + from ._models import SystemData # type: ignore + from ._models import WeeklyRecurrence # type: ignore from ._alerts_management_client_enums import ( - ActionRuleStatus, - ActionRuleType, + ActionType, AlertModificationEvent, - AlertRuleState, AlertState, AlertsSortByFields, AlertsSummaryGroupByFields, - Enum11, + CreatedByType, + DaysOfWeek, + Enum12, + Field, Identifier, MetadataIdentifier, MonitorCondition, MonitorService, Operator, - ScopeType, + RecurrenceType, Severity, SignalType, SmartGroupModificationEvent, SmartGroupsSortByFields, State, - SuppressionType, TimeRange, ) __all__ = [ - 'ActionGroup', - 'ActionGroupsInformation', - 'ActionRule', - 'ActionRuleProperties', - 'ActionRulesList', + 'Action', + 'AddActionGroups', 'Alert', 'AlertModification', 'AlertModificationItem', 'AlertModificationProperties', + 'AlertProcessingRule', + 'AlertProcessingRuleProperties', + 'AlertProcessingRulesList', 'AlertProperties', - 'AlertRule', - 'AlertRulePatchObject', - 'AlertRulesList', 'AlertsList', 'AlertsMetaData', 'AlertsMetaDataProperties', 'AlertsSummary', 'AlertsSummaryGroup', 'AlertsSummaryGroupItem', - 'AzureResource', 'Condition', - 'Conditions', - 'Detector', - 'Diagnostics', + 'DailyRecurrence', 'ErrorResponse', 'ErrorResponseAutoGenerated', 'ErrorResponseAutoGenerated2', @@ -170,42 +152,42 @@ 'ManagedResource', 'MonitorServiceDetails', 'MonitorServiceList', + 'MonthlyRecurrence', 'Operation', 'OperationDisplay', 'OperationsList', 'PatchObject', + 'Recurrence', + 'RemoveAllActionGroups', 'Resource', - 'Scope', - 'SmartDetectorErrorResponse', + 'Schedule', 'SmartGroup', 'SmartGroupAggregatedProperty', 'SmartGroupModification', 'SmartGroupModificationItem', 'SmartGroupModificationProperties', 'SmartGroupsList', - 'Suppression', - 'SuppressionConfig', - 'SuppressionSchedule', - 'ThrottlingInformation', - 'ActionRuleStatus', - 'ActionRuleType', + 'SystemData', + 'WeeklyRecurrence', + 'ActionType', 'AlertModificationEvent', - 'AlertRuleState', 'AlertState', 'AlertsSortByFields', 'AlertsSummaryGroupByFields', - 'Enum11', + 'CreatedByType', + 'DaysOfWeek', + 'Enum12', + 'Field', 'Identifier', 'MetadataIdentifier', 'MonitorCondition', 'MonitorService', 'Operator', - 'ScopeType', + 'RecurrenceType', 'Severity', 'SignalType', 'SmartGroupModificationEvent', 'SmartGroupsSortByFields', 'State', - 'SuppressionType', 'TimeRange', ] diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_alerts_management_client_enums.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_alerts_management_client_enums.py index 29760b51d199..fb4a308cd43d 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_alerts_management_client_enums.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_alerts_management_client_enums.py @@ -26,20 +26,12 @@ def __getattr__(cls, name): raise AttributeError(name) -class ActionRuleStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Indicates if the given action rule is enabled or disabled +class ActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Action that should be applied. """ - ENABLED = "Enabled" - DISABLED = "Disabled" - -class ActionRuleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Indicates type of action rule - """ - - SUPPRESSION = "Suppression" - ACTION_GROUP = "ActionGroup" - DIAGNOSTICS = "Diagnostics" + ADD_ACTION_GROUPS = "AddActionGroups" + REMOVE_ALL_ACTION_GROUPS = "RemoveAllActionGroups" class AlertModificationEvent(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): """Reason for the modification @@ -55,13 +47,6 @@ class AlertModificationEvent(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum) ACTIONS_SUPPRESSED = "ActionsSuppressed" ACTIONS_FAILED = "ActionsFailed" -class AlertRuleState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """The alert rule state. - """ - - ENABLED = "Enabled" - DISABLED = "Disabled" - class AlertsSortByFields(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): NAME = "name" @@ -90,11 +75,48 @@ class AlertState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ACKNOWLEDGED = "Acknowledged" CLOSED = "Closed" -class Enum11(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class DaysOfWeek(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Days of week. + """ + + SUNDAY = "Sunday" + MONDAY = "Monday" + TUESDAY = "Tuesday" + WEDNESDAY = "Wednesday" + THURSDAY = "Thursday" + FRIDAY = "Friday" + SATURDAY = "Saturday" + +class Enum12(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ASC = "asc" DESC = "desc" +class Field(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Field for a given condition. + """ + + SEVERITY = "Severity" + MONITOR_SERVICE = "MonitorService" + MONITOR_CONDITION = "MonitorCondition" + SIGNAL_TYPE = "SignalType" + TARGET_RESOURCE_TYPE = "TargetResourceType" + TARGET_RESOURCE = "TargetResource" + TARGET_RESOURCE_GROUP = "TargetResourceGroup" + ALERT_RULE_ID = "AlertRuleId" + ALERT_RULE_NAME = "AlertRuleName" + DESCRIPTION = "Description" + ALERT_CONTEXT = "AlertContext" + class Identifier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MONITOR_SERVICE_LIST = "MonitorServiceList" @@ -128,7 +150,7 @@ class MonitorService(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ZABBIX = "Zabbix" class Operator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """operator for a given condition + """Operator for a given condition. """ EQUALS = "Equals" @@ -136,13 +158,13 @@ class Operator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CONTAINS = "Contains" DOES_NOT_CONTAIN = "DoesNotContain" -class ScopeType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """type of target scope +class RecurrenceType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): + """Specifies when the recurrence should be applied. """ - RESOURCE_GROUP = "ResourceGroup" - RESOURCE = "Resource" - SUBSCRIPTION = "Subscription" + DAILY = "Daily" + WEEKLY = "Weekly" + MONTHLY = "Monthly" class Severity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): @@ -185,16 +207,6 @@ class State(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ACKNOWLEDGED = "Acknowledged" CLOSED = "Closed" -class SuppressionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Specifies when the suppression should be applied - """ - - ALWAYS = "Always" - ONCE = "Once" - DAILY = "Daily" - WEEKLY = "Weekly" - MONTHLY = "Monthly" - class TimeRange(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ONE_H = "1h" diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_models.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_models.py index d9f76afbd787..7bcbb957c2f6 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_models.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_models.py @@ -10,172 +10,68 @@ import msrest.serialization -class ActionRuleProperties(msrest.serialization.Model): - """Action rule properties defining scope, conditions, suppression logic for action rule. +class Action(msrest.serialization.Model): + """Action to be applied. You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ActionGroup, Diagnostics, Suppression. - - Variables are only populated by the server, and will be ignored when sending a request. + sub-classes are: AddActionGroups, RemoveAllActionGroups. All required parameters must be populated in order to send to Azure. - :param scope: scope on which action rule will apply. - :type scope: ~azure.mgmt.alertsmanagement.models.Scope - :param conditions: conditions on which alerts will be filtered. - :type conditions: ~azure.mgmt.alertsmanagement.models.Conditions - :param description: Description of action rule. - :type description: str - :ivar created_at: Creation time of action rule. Date-Time in ISO-8601 format. - :vartype created_at: ~datetime.datetime - :ivar last_modified_at: Last updated time of action rule. Date-Time in ISO-8601 format. - :vartype last_modified_at: ~datetime.datetime - :ivar created_by: Created by user name. - :vartype created_by: str - :ivar last_modified_by: Last modified by user name. - :vartype last_modified_by: str - :param status: Indicates if the given action rule is enabled or disabled. Possible values - include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus - :param type: Required. Indicates type of action rule.Constant filled by server. Possible - values include: "Suppression", "ActionGroup", "Diagnostics". - :type type: str or ~azure.mgmt.alertsmanagement.models.ActionRuleType + :param action_type: Required. Action that should be applied.Constant filled by server. + Possible values include: "AddActionGroups", "RemoveAllActionGroups". + :type action_type: str or ~azure.mgmt.alertsmanagement.models.ActionType """ _validation = { - 'created_at': {'readonly': True}, - 'last_modified_at': {'readonly': True}, - 'created_by': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - 'type': {'required': True}, + 'action_type': {'required': True}, } _attribute_map = { - 'scope': {'key': 'scope', 'type': 'Scope'}, - 'conditions': {'key': 'conditions', 'type': 'Conditions'}, - 'description': {'key': 'description', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, } _subtype_map = { - 'type': {'ActionGroup': 'ActionGroup', 'Diagnostics': 'Diagnostics', 'Suppression': 'Suppression'} - } - - def __init__( - self, - **kwargs - ): - super(ActionRuleProperties, self).__init__(**kwargs) - self.scope = kwargs.get('scope', None) - self.conditions = kwargs.get('conditions', None) - self.description = kwargs.get('description', None) - self.created_at = None - self.last_modified_at = None - self.created_by = None - self.last_modified_by = None - self.status = kwargs.get('status', None) - self.type = None # type: Optional[str] - - -class ActionGroup(ActionRuleProperties): - """Action rule with action group configuration. - - 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 scope: scope on which action rule will apply. - :type scope: ~azure.mgmt.alertsmanagement.models.Scope - :param conditions: conditions on which alerts will be filtered. - :type conditions: ~azure.mgmt.alertsmanagement.models.Conditions - :param description: Description of action rule. - :type description: str - :ivar created_at: Creation time of action rule. Date-Time in ISO-8601 format. - :vartype created_at: ~datetime.datetime - :ivar last_modified_at: Last updated time of action rule. Date-Time in ISO-8601 format. - :vartype last_modified_at: ~datetime.datetime - :ivar created_by: Created by user name. - :vartype created_by: str - :ivar last_modified_by: Last modified by user name. - :vartype last_modified_by: str - :param status: Indicates if the given action rule is enabled or disabled. Possible values - include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus - :param type: Required. Indicates type of action rule.Constant filled by server. Possible - values include: "Suppression", "ActionGroup", "Diagnostics". - :type type: str or ~azure.mgmt.alertsmanagement.models.ActionRuleType - :param action_group_id: Required. Action group to trigger if action rule matches. - :type action_group_id: str - """ - - _validation = { - 'created_at': {'readonly': True}, - 'last_modified_at': {'readonly': True}, - 'created_by': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - 'type': {'required': True}, - 'action_group_id': {'required': True}, - } - - _attribute_map = { - 'scope': {'key': 'scope', 'type': 'Scope'}, - 'conditions': {'key': 'conditions', 'type': 'Conditions'}, - 'description': {'key': 'description', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, + 'action_type': {'AddActionGroups': 'AddActionGroups', 'RemoveAllActionGroups': 'RemoveAllActionGroups'} } def __init__( self, **kwargs ): - super(ActionGroup, self).__init__(**kwargs) - self.type = 'ActionGroup' # type: str - self.action_group_id = kwargs['action_group_id'] + super(Action, self).__init__(**kwargs) + self.action_type = None # type: Optional[str] -class ActionGroupsInformation(msrest.serialization.Model): - """The Action Groups information, used by the alert rule. +class AddActionGroups(Action): + """Add action groups to alert processing rule. All required parameters must be populated in order to send to Azure. - :param custom_email_subject: An optional custom email subject to use in email notifications. - :type custom_email_subject: str - :param custom_webhook_payload: An optional custom web-hook payload to use in web-hook - notifications. - :type custom_webhook_payload: str - :param group_ids: Required. The Action Group resource IDs. - :type group_ids: list[str] + :param action_type: Required. Action that should be applied.Constant filled by server. + Possible values include: "AddActionGroups", "RemoveAllActionGroups". + :type action_type: str or ~azure.mgmt.alertsmanagement.models.ActionType + :param action_group_ids: Required. List of action group Ids to add to alert processing rule. + :type action_group_ids: list[str] """ _validation = { - 'group_ids': {'required': True}, + 'action_type': {'required': True}, + 'action_group_ids': {'required': True}, } _attribute_map = { - 'custom_email_subject': {'key': 'customEmailSubject', 'type': 'str'}, - 'custom_webhook_payload': {'key': 'customWebhookPayload', 'type': 'str'}, - 'group_ids': {'key': 'groupIds', 'type': '[str]'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + 'action_group_ids': {'key': 'actionGroupIds', 'type': '[str]'}, } def __init__( self, **kwargs ): - super(ActionGroupsInformation, self).__init__(**kwargs) - self.custom_email_subject = kwargs.get('custom_email_subject', None) - self.custom_webhook_payload = kwargs.get('custom_webhook_payload', None) - self.group_ids = kwargs['group_ids'] + super(AddActionGroups, self).__init__(**kwargs) + self.action_type = 'AddActionGroups' # type: str + self.action_group_ids = kwargs['action_group_ids'] class Resource(msrest.serialization.Model): @@ -213,117 +109,6 @@ def __init__( self.name = None -class ManagedResource(Resource): - """An azure managed resource object. - - 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 location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedResource, self).__init__(**kwargs) - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class ActionRule(ManagedResource): - """Action rule object containing target scope, conditions and suppression logic. - - 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 location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param properties: action rule properties. - :type properties: ~azure.mgmt.alertsmanagement.models.ActionRuleProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'properties': {'key': 'properties', 'type': 'ActionRuleProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionRule, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class ActionRulesList(msrest.serialization.Model): - """List of action rules. - - :param next_link: URL to fetch the next set of action rules. - :type next_link: str - :param value: List of action rules. - :type value: list[~azure.mgmt.alertsmanagement.models.ActionRule] - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[ActionRule]'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionRulesList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs.get('value', None) - - class Alert(Resource): """An alert created in alert management service. @@ -471,54 +256,22 @@ def __init__( self.modifications = kwargs.get('modifications', None) -class AlertProperties(msrest.serialization.Model): - """Alert property bag. +class ManagedResource(Resource): + """An azure managed resource object. Variables are only populated by the server, and will be ignored when sending a request. - :param essentials: This object contains consistent fields across different monitor services. - :type essentials: ~azure.mgmt.alertsmanagement.models.Essentials - :ivar context: Any object. - :vartype context: object - :ivar egress_config: Any object. - :vartype egress_config: object - """ - - _validation = { - 'context': {'readonly': True}, - 'egress_config': {'readonly': True}, - } - - _attribute_map = { - 'essentials': {'key': 'essentials', 'type': 'Essentials'}, - 'context': {'key': 'context', 'type': 'object'}, - 'egress_config': {'key': 'egressConfig', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertProperties, self).__init__(**kwargs) - self.essentials = kwargs.get('essentials', None) - self.context = None - self.egress_config = None - - -class AzureResource(msrest.serialization.Model): - """An Azure resource object. - - 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. + :ivar id: Azure resource Id. :vartype id: str - :ivar type: The resource type. + :ivar type: Azure resource type. :vartype type: str - :ivar name: The resource name. + :ivar name: Azure resource name. :vartype name: str - :param location: The resource location. + :param location: Required. Resource location. :type location: str - :param tags: A set of tags. The resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -526,6 +279,7 @@ class AzureResource(msrest.serialization.Model): 'id': {'readonly': True}, 'type': {'readonly': True}, 'name': {'readonly': True}, + 'location': {'required': True}, } _attribute_map = { @@ -540,53 +294,40 @@ def __init__( self, **kwargs ): - super(AzureResource, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.location = kwargs.get('location', "global") + super(ManagedResource, self).__init__(**kwargs) + self.location = kwargs['location'] self.tags = kwargs.get('tags', None) -class AlertRule(AzureResource): - """The alert rule information. +class AlertProcessingRule(ManagedResource): + """Alert processing rule object containing target scopes, conditions and scheduling logic. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The resource ID. + All required parameters must be populated in order to send to Azure. + + :ivar id: Azure resource Id. :vartype id: str - :ivar type: The resource type. + :ivar type: Azure resource type. :vartype type: str - :ivar name: The resource name. + :ivar name: Azure resource name. :vartype name: str - :param location: The resource location. + :param location: Required. Resource location. :type location: str - :param tags: A set of tags. The resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] - :param description: The alert rule description. - :type description: str - :param state: The alert rule state. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.alertsmanagement.models.AlertRuleState - :param severity: The alert rule severity. Possible values include: "Sev0", "Sev1", "Sev2", - "Sev3", "Sev4". - :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity - :param frequency: The alert rule frequency in ISO8601 format. The time granularity must be in - minutes and minimum value is 5 minutes. - :type frequency: ~datetime.timedelta - :param detector: The alert rule's detector. - :type detector: ~azure.mgmt.alertsmanagement.models.Detector - :param scope: The alert rule resources scope. - :type scope: list[str] - :param action_groups: The alert rule actions. - :type action_groups: ~azure.mgmt.alertsmanagement.models.ActionGroupsInformation - :param throttling: The alert rule throttling information. - :type throttling: ~azure.mgmt.alertsmanagement.models.ThrottlingInformation + :param properties: Alert processing rule properties. + :type properties: ~azure.mgmt.alertsmanagement.models.AlertProcessingRuleProperties + :ivar system_data: Alert processing rule system data. + :vartype system_data: ~azure.mgmt.alertsmanagement.models.SystemData """ _validation = { 'id': {'readonly': True}, 'type': {'readonly': True}, 'name': {'readonly': True}, + 'location': {'required': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -595,117 +336,120 @@ class AlertRule(AzureResource): 'name': {'key': 'name', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'frequency': {'key': 'properties.frequency', 'type': 'duration'}, - 'detector': {'key': 'properties.detector', 'type': 'Detector'}, - 'scope': {'key': 'properties.scope', 'type': '[str]'}, - 'action_groups': {'key': 'properties.actionGroups', 'type': 'ActionGroupsInformation'}, - 'throttling': {'key': 'properties.throttling', 'type': 'ThrottlingInformation'}, + 'properties': {'key': 'properties', 'type': 'AlertProcessingRuleProperties'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( self, **kwargs ): - super(AlertRule, self).__init__(**kwargs) - self.description = kwargs.get('description', None) - self.state = kwargs.get('state', None) - self.severity = kwargs.get('severity', None) - self.frequency = kwargs.get('frequency', None) - self.detector = kwargs.get('detector', None) - self.scope = kwargs.get('scope', None) - self.action_groups = kwargs.get('action_groups', None) - self.throttling = kwargs.get('throttling', None) + super(AlertProcessingRule, self).__init__(**kwargs) + self.properties = kwargs.get('properties', None) + self.system_data = None -class AlertRulePatchObject(msrest.serialization.Model): - """The alert rule patch information. +class AlertProcessingRuleProperties(msrest.serialization.Model): + """Alert processing rule properties defining scopes, conditions and scheduling logic for alert processing 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: The resource ID. - :vartype id: str - :ivar type: The resource type. - :vartype type: str - :ivar name: The resource name. - :vartype name: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param description: The alert rule description. + :param scopes: Required. Scopes on which alert processing rule will apply. + :type scopes: list[str] + :param conditions: Conditions on which alerts will be filtered. + :type conditions: list[~azure.mgmt.alertsmanagement.models.Condition] + :param schedule: Scheduling for alert processing rule. + :type schedule: ~azure.mgmt.alertsmanagement.models.Schedule + :param actions: Required. Actions to be applied. + :type actions: list[~azure.mgmt.alertsmanagement.models.Action] + :param description: Description of alert processing rule. :type description: str - :param state: The alert rule state. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.alertsmanagement.models.AlertRuleState - :param severity: The alert rule severity. Possible values include: "Sev0", "Sev1", "Sev2", - "Sev3", "Sev4". - :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity - :param frequency: The alert rule frequency in ISO8601 format. The time granularity must be in - minutes and minimum value is 5 minutes. - :type frequency: ~datetime.timedelta - :param action_groups: The alert rule actions. - :type action_groups: ~azure.mgmt.alertsmanagement.models.ActionGroupsInformation - :param throttling: The alert rule throttling information. - :type throttling: ~azure.mgmt.alertsmanagement.models.ThrottlingInformation + :param enabled: Indicates if the given alert processing rule is enabled or disabled. + :type enabled: bool """ _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, + 'scopes': {'required': True}, + 'actions': {'required': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'frequency': {'key': 'properties.frequency', 'type': 'duration'}, - 'action_groups': {'key': 'properties.actionGroups', 'type': 'ActionGroupsInformation'}, - 'throttling': {'key': 'properties.throttling', 'type': 'ThrottlingInformation'}, + 'scopes': {'key': 'scopes', 'type': '[str]'}, + 'conditions': {'key': 'conditions', 'type': '[Condition]'}, + 'schedule': {'key': 'schedule', 'type': 'Schedule'}, + 'actions': {'key': 'actions', 'type': '[Action]'}, + 'description': {'key': 'description', 'type': 'str'}, + 'enabled': {'key': 'enabled', 'type': 'bool'}, } def __init__( self, **kwargs ): - super(AlertRulePatchObject, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.tags = kwargs.get('tags', None) + super(AlertProcessingRuleProperties, self).__init__(**kwargs) + self.scopes = kwargs['scopes'] + self.conditions = kwargs.get('conditions', None) + self.schedule = kwargs.get('schedule', None) + self.actions = kwargs['actions'] self.description = kwargs.get('description', None) - self.state = kwargs.get('state', None) - self.severity = kwargs.get('severity', None) - self.frequency = kwargs.get('frequency', None) - self.action_groups = kwargs.get('action_groups', None) - self.throttling = kwargs.get('throttling', None) + self.enabled = kwargs.get('enabled', True) -class AlertRulesList(msrest.serialization.Model): - """List of Smart Detector alert rules. +class AlertProcessingRulesList(msrest.serialization.Model): + """List of alert processing rules. - :param value: List of Smart Detector alert rules. - :type value: list[~azure.mgmt.alertsmanagement.models.AlertRule] - :param next_link: The URL to get the next set of results. + :param next_link: URL to fetch the next set of alert processing rules. :type next_link: str + :param value: List of alert processing rules. + :type value: list[~azure.mgmt.alertsmanagement.models.AlertProcessingRule] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AlertRule]'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[AlertProcessingRule]'}, } def __init__( self, **kwargs ): - super(AlertRulesList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) + super(AlertProcessingRulesList, self).__init__(**kwargs) self.next_link = kwargs.get('next_link', None) + self.value = kwargs.get('value', None) + + +class AlertProperties(msrest.serialization.Model): + """Alert property bag. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param essentials: This object contains consistent fields across different monitor services. + :type essentials: ~azure.mgmt.alertsmanagement.models.Essentials + :ivar context: Any object. + :vartype context: any + :ivar egress_config: Any object. + :vartype egress_config: any + """ + + _validation = { + 'context': {'readonly': True}, + 'egress_config': {'readonly': True}, + } + + _attribute_map = { + 'essentials': {'key': 'essentials', 'type': 'Essentials'}, + 'context': {'key': 'context', 'type': 'object'}, + 'egress_config': {'key': 'egressConfig', 'type': 'object'}, + } + + def __init__( + self, + **kwargs + ): + super(AlertProperties, self).__init__(**kwargs) + self.essentials = kwargs.get('essentials', None) + self.context = None + self.egress_config = None class AlertsList(msrest.serialization.Model): @@ -823,9 +567,9 @@ class AlertsSummaryGroup(msrest.serialization.Model): """Group the result set. :param total: Total count of the result set. - :type total: int + :type total: long :param smart_groups_count: Total count of the smart groups. - :type smart_groups_count: int + :type smart_groups_count: long :param groupedby: Name of the field aggregated. :type groupedby: str :param values: List of the items. @@ -833,8 +577,8 @@ class AlertsSummaryGroup(msrest.serialization.Model): """ _attribute_map = { - 'total': {'key': 'total', 'type': 'int'}, - 'smart_groups_count': {'key': 'smartGroupsCount', 'type': 'int'}, + 'total': {'key': 'total', 'type': 'long'}, + 'smart_groups_count': {'key': 'smartGroupsCount', 'type': 'long'}, 'groupedby': {'key': 'groupedby', 'type': 'str'}, 'values': {'key': 'values', 'type': '[AlertsSummaryGroupItem]'}, } @@ -856,7 +600,7 @@ class AlertsSummaryGroupItem(msrest.serialization.Model): :param name: Value of the aggregated field. :type name: str :param count: Count of the aggregated field. - :type count: int + :type count: long :param groupedby: Name of the field aggregated. :type groupedby: str :param values: List of the items. @@ -865,7 +609,7 @@ class AlertsSummaryGroupItem(msrest.serialization.Model): _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'int'}, + 'count': {'key': 'count', 'type': 'long'}, 'groupedby': {'key': 'groupedby', 'type': 'str'}, 'values': {'key': 'values', 'type': '[AlertsSummaryGroupItem]'}, } @@ -882,16 +626,21 @@ def __init__( class Condition(msrest.serialization.Model): - """condition to trigger an action rule. + """Condition to trigger an alert processing rule. - :param operator: operator for a given condition. Possible values include: "Equals", + :param field: Field for a given condition. Possible values include: "Severity", + "MonitorService", "MonitorCondition", "SignalType", "TargetResourceType", "TargetResource", + "TargetResourceGroup", "AlertRuleId", "AlertRuleName", "Description", "AlertContext". + :type field: str or ~azure.mgmt.alertsmanagement.models.Field + :param operator: Operator for a given condition. Possible values include: "Equals", "NotEquals", "Contains", "DoesNotContain". :type operator: str or ~azure.mgmt.alertsmanagement.models.Operator - :param values: list of values to match for a given condition. + :param values: List of values to match for a given condition. :type values: list[str] """ _attribute_map = { + 'field': {'key': 'field', 'type': 'str'}, 'operator': {'key': 'operator', 'type': 'str'}, 'values': {'key': 'values', 'type': '[str]'}, } @@ -901,157 +650,82 @@ def __init__( **kwargs ): super(Condition, self).__init__(**kwargs) + self.field = kwargs.get('field', None) self.operator = kwargs.get('operator', None) self.values = kwargs.get('values', None) -class Conditions(msrest.serialization.Model): - """Conditions in alert instance to be matched for a given action rule. Default value is all. Multiple values could be provided with comma separation. - - :param severity: filter alerts by severity. - :type severity: ~azure.mgmt.alertsmanagement.models.Condition - :param monitor_service: filter alerts by monitor service. - :type monitor_service: ~azure.mgmt.alertsmanagement.models.Condition - :param monitor_condition: filter alerts by monitor condition. - :type monitor_condition: ~azure.mgmt.alertsmanagement.models.Condition - :param target_resource_type: filter alerts by target resource type. - :type target_resource_type: ~azure.mgmt.alertsmanagement.models.Condition - :param alert_rule_id: filter alerts by alert rule id. - :type alert_rule_id: ~azure.mgmt.alertsmanagement.models.Condition - :param description: filter alerts by alert rule description. - :type description: ~azure.mgmt.alertsmanagement.models.Condition - :param alert_context: filter alerts by alert context (payload). - :type alert_context: ~azure.mgmt.alertsmanagement.models.Condition - """ - - _attribute_map = { - 'severity': {'key': 'severity', 'type': 'Condition'}, - 'monitor_service': {'key': 'monitorService', 'type': 'Condition'}, - 'monitor_condition': {'key': 'monitorCondition', 'type': 'Condition'}, - 'target_resource_type': {'key': 'targetResourceType', 'type': 'Condition'}, - 'alert_rule_id': {'key': 'alertRuleId', 'type': 'Condition'}, - 'description': {'key': 'description', 'type': 'Condition'}, - 'alert_context': {'key': 'alertContext', 'type': 'Condition'}, - } - - def __init__( - self, - **kwargs - ): - super(Conditions, self).__init__(**kwargs) - self.severity = kwargs.get('severity', None) - self.monitor_service = kwargs.get('monitor_service', None) - self.monitor_condition = kwargs.get('monitor_condition', None) - self.target_resource_type = kwargs.get('target_resource_type', None) - self.alert_rule_id = kwargs.get('alert_rule_id', None) - self.description = kwargs.get('description', None) - self.alert_context = kwargs.get('alert_context', None) - +class Recurrence(msrest.serialization.Model): + """Recurrence object. -class Detector(msrest.serialization.Model): - """The detector information. By default this is not populated, unless it's specified in expandDetector. + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: DailyRecurrence, MonthlyRecurrence, WeeklyRecurrence. All required parameters must be populated in order to send to Azure. - :param id: Required. The detector id. - :type id: str - :param parameters: The detector's parameters.'. - :type parameters: dict[str, object] - :param name: The Smart Detector name. By default this is not populated, unless it's specified - in expandDetector. - :type name: str - :param description: The Smart Detector description. By default this is not populated, unless - it's specified in expandDetector. - :type description: str - :param supported_resource_types: The Smart Detector supported resource types. By default this - is not populated, unless it's specified in expandDetector. - :type supported_resource_types: list[str] - :param image_paths: The Smart Detector image path. By default this is not populated, unless - it's specified in expandDetector. - :type image_paths: list[str] + :param recurrence_type: Required. Specifies when the recurrence should be applied.Constant + filled by server. Possible values include: "Daily", "Weekly", "Monthly". + :type recurrence_type: str or ~azure.mgmt.alertsmanagement.models.RecurrenceType + :param start_time: Start time for recurrence. + :type start_time: str + :param end_time: End time for recurrence. + :type end_time: str """ _validation = { - 'id': {'required': True}, + 'recurrence_type': {'required': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '{object}'}, - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'supported_resource_types': {'key': 'supportedResourceTypes', 'type': '[str]'}, - 'image_paths': {'key': 'imagePaths', 'type': '[str]'}, + 'recurrence_type': {'key': 'recurrenceType', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'str'}, + 'end_time': {'key': 'endTime', 'type': 'str'}, + } + + _subtype_map = { + 'recurrence_type': {'Daily': 'DailyRecurrence', 'Monthly': 'MonthlyRecurrence', 'Weekly': 'WeeklyRecurrence'} } def __init__( self, **kwargs ): - super(Detector, self).__init__(**kwargs) - self.id = kwargs['id'] - self.parameters = kwargs.get('parameters', None) - self.name = kwargs.get('name', None) - self.description = kwargs.get('description', None) - self.supported_resource_types = kwargs.get('supported_resource_types', None) - self.image_paths = kwargs.get('image_paths', None) - + super(Recurrence, self).__init__(**kwargs) + self.recurrence_type = None # type: Optional[str] + self.start_time = kwargs.get('start_time', None) + self.end_time = kwargs.get('end_time', None) -class Diagnostics(ActionRuleProperties): - """Action rule with diagnostics configuration. - Variables are only populated by the server, and will be ignored when sending a request. +class DailyRecurrence(Recurrence): + """Daily recurrence object. All required parameters must be populated in order to send to Azure. - :param scope: scope on which action rule will apply. - :type scope: ~azure.mgmt.alertsmanagement.models.Scope - :param conditions: conditions on which alerts will be filtered. - :type conditions: ~azure.mgmt.alertsmanagement.models.Conditions - :param description: Description of action rule. - :type description: str - :ivar created_at: Creation time of action rule. Date-Time in ISO-8601 format. - :vartype created_at: ~datetime.datetime - :ivar last_modified_at: Last updated time of action rule. Date-Time in ISO-8601 format. - :vartype last_modified_at: ~datetime.datetime - :ivar created_by: Created by user name. - :vartype created_by: str - :ivar last_modified_by: Last modified by user name. - :vartype last_modified_by: str - :param status: Indicates if the given action rule is enabled or disabled. Possible values - include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus - :param type: Required. Indicates type of action rule.Constant filled by server. Possible - values include: "Suppression", "ActionGroup", "Diagnostics". - :type type: str or ~azure.mgmt.alertsmanagement.models.ActionRuleType + :param recurrence_type: Required. Specifies when the recurrence should be applied.Constant + filled by server. Possible values include: "Daily", "Weekly", "Monthly". + :type recurrence_type: str or ~azure.mgmt.alertsmanagement.models.RecurrenceType + :param start_time: Start time for recurrence. + :type start_time: str + :param end_time: End time for recurrence. + :type end_time: str """ _validation = { - 'created_at': {'readonly': True}, - 'last_modified_at': {'readonly': True}, - 'created_by': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - 'type': {'required': True}, + 'recurrence_type': {'required': True}, } _attribute_map = { - 'scope': {'key': 'scope', 'type': 'Scope'}, - 'conditions': {'key': 'conditions', 'type': 'Conditions'}, - 'description': {'key': 'description', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + 'recurrence_type': {'key': 'recurrenceType', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'str'}, + 'end_time': {'key': 'endTime', 'type': 'str'}, } def __init__( self, **kwargs ): - super(Diagnostics, self).__init__(**kwargs) - self.type = 'Diagnostics' # type: str + super(DailyRecurrence, self).__init__(**kwargs) + self.recurrence_type = 'Daily' # type: str class ErrorResponse(msrest.serialization.Model): @@ -1374,6 +1048,43 @@ def __init__( self.data = kwargs['data'] +class MonthlyRecurrence(Recurrence): + """Monthly recurrence object. + + All required parameters must be populated in order to send to Azure. + + :param recurrence_type: Required. Specifies when the recurrence should be applied.Constant + filled by server. Possible values include: "Daily", "Weekly", "Monthly". + :type recurrence_type: str or ~azure.mgmt.alertsmanagement.models.RecurrenceType + :param start_time: Start time for recurrence. + :type start_time: str + :param end_time: End time for recurrence. + :type end_time: str + :param days_of_month: Required. Specifies the values for monthly recurrence pattern. + :type days_of_month: list[int] + """ + + _validation = { + 'recurrence_type': {'required': True}, + 'days_of_month': {'required': True}, + } + + _attribute_map = { + 'recurrence_type': {'key': 'recurrenceType', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'str'}, + 'end_time': {'key': 'endTime', 'type': 'str'}, + 'days_of_month': {'key': 'daysOfMonth', 'type': '[int]'}, + } + + def __init__( + self, + **kwargs + ): + super(MonthlyRecurrence, self).__init__(**kwargs) + self.recurrence_type = 'Monthly' # type: str + self.days_of_month = kwargs['days_of_month'] + + class Operation(msrest.serialization.Model): """Operation provided by provider. @@ -1460,16 +1171,15 @@ def __init__( class PatchObject(msrest.serialization.Model): """Data contract for patch. - :param tags: A set of tags. tags to be updated. - :type tags: object - :param status: Indicates if the given action rule is enabled or disabled. Possible values - include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus + :param tags: A set of tags. Tags to be updated. + :type tags: dict[str, str] + :param enabled: Indicates if the given alert processing rule is enabled or disabled. + :type enabled: bool """ _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'status': {'key': 'properties.status', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, } def __init__( @@ -1478,55 +1188,71 @@ def __init__( ): super(PatchObject, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) - self.status = kwargs.get('status', None) + self.enabled = kwargs.get('enabled', None) -class Scope(msrest.serialization.Model): - """Target scope for a given action rule. By default scope will be the subscription. User can also provide list of resource groups or list of resources from the scope subscription as well. +class RemoveAllActionGroups(Action): + """Indicates if all action groups should be removed. - :param scope_type: type of target scope. Possible values include: "ResourceGroup", "Resource", - "Subscription". - :type scope_type: str or ~azure.mgmt.alertsmanagement.models.ScopeType - :param values: list of ARM IDs of the given scope type which will be the target of the given - action rule. - :type values: list[str] + All required parameters must be populated in order to send to Azure. + + :param action_type: Required. Action that should be applied.Constant filled by server. + Possible values include: "AddActionGroups", "RemoveAllActionGroups". + :type action_type: str or ~azure.mgmt.alertsmanagement.models.ActionType """ + _validation = { + 'action_type': {'required': True}, + } + _attribute_map = { - 'scope_type': {'key': 'scopeType', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, } def __init__( self, **kwargs ): - super(Scope, self).__init__(**kwargs) - self.scope_type = kwargs.get('scope_type', None) - self.values = kwargs.get('values', None) - - -class SmartDetectorErrorResponse(msrest.serialization.Model): - """Describe the format of an Error response. - - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + super(RemoveAllActionGroups, self).__init__(**kwargs) + self.action_type = 'RemoveAllActionGroups' # type: str + + +class Schedule(msrest.serialization.Model): + """Scheduling configuration for a given alert processing rule. + + :param effective_from: Scheduling effective from time. Date-Time in ISO-8601 format without + timezone suffix. + :type effective_from: str + :param effective_until: Scheduling effective until time. Date-Time in ISO-8601 format without + timezone suffix. + :type effective_until: str + :param time_zone: Scheduling time zone. + :type time_zone: str + :param recurrences: List of recurrences. + :type recurrences: list[~azure.mgmt.alertsmanagement.models.Recurrence] """ + _validation = { + 'effective_from': {'pattern': r'^(?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))$'}, + 'effective_until': {'pattern': r'^(?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))$'}, + } + _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + 'effective_from': {'key': 'effectiveFrom', 'type': 'str'}, + 'effective_until': {'key': 'effectiveUntil', 'type': 'str'}, + 'time_zone': {'key': 'timeZone', 'type': 'str'}, + 'recurrences': {'key': 'recurrences', 'type': '[Recurrence]'}, } def __init__( self, **kwargs ): - super(SmartDetectorErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) + super(Schedule, self).__init__(**kwargs) + self.effective_from = kwargs.get('effective_from', None) + self.effective_until = kwargs.get('effective_until', None) + self.time_zone = kwargs.get('time_zone', None) + self.recurrences = kwargs.get('recurrences', None) class SmartGroup(Resource): @@ -1541,7 +1267,7 @@ class SmartGroup(Resource): :ivar name: Azure resource name. :vartype name: str :param alerts_count: Total number of alerts in smart group. - :type alerts_count: int + :type alerts_count: long :ivar smart_group_state: Smart group state. Possible values include: "New", "Acknowledged", "Closed". :vartype smart_group_state: str or ~azure.mgmt.alertsmanagement.models.State @@ -1589,7 +1315,7 @@ class SmartGroup(Resource): 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, - 'alerts_count': {'key': 'properties.alertsCount', 'type': 'int'}, + 'alerts_count': {'key': 'properties.alertsCount', 'type': 'long'}, 'smart_group_state': {'key': 'properties.smartGroupState', 'type': 'str'}, 'severity': {'key': 'properties.severity', 'type': 'str'}, 'start_date_time': {'key': 'properties.startDateTime', 'type': 'iso-8601'}, @@ -1632,12 +1358,12 @@ class SmartGroupAggregatedProperty(msrest.serialization.Model): :param name: Name of the type. :type name: str :param count: Total number of items of type. - :type count: int + :type count: long """ _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'int'}, + 'count': {'key': 'count', 'type': 'long'}, } def __init__( @@ -1786,148 +1512,79 @@ def __init__( self.value = kwargs.get('value', None) -class Suppression(ActionRuleProperties): - """Action rule with suppression configuration. - - 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 scope: scope on which action rule will apply. - :type scope: ~azure.mgmt.alertsmanagement.models.Scope - :param conditions: conditions on which alerts will be filtered. - :type conditions: ~azure.mgmt.alertsmanagement.models.Conditions - :param description: Description of action rule. - :type description: str - :ivar created_at: Creation time of action rule. Date-Time in ISO-8601 format. - :vartype created_at: ~datetime.datetime - :ivar last_modified_at: Last updated time of action rule. Date-Time in ISO-8601 format. - :vartype last_modified_at: ~datetime.datetime - :ivar created_by: Created by user name. - :vartype created_by: str - :ivar last_modified_by: Last modified by user name. - :vartype last_modified_by: str - :param status: Indicates if the given action rule is enabled or disabled. Possible values - include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus - :param type: Required. Indicates type of action rule.Constant filled by server. Possible - values include: "Suppression", "ActionGroup", "Diagnostics". - :type type: str or ~azure.mgmt.alertsmanagement.models.ActionRuleType - :param suppression_config: Required. suppression configuration for the action rule. - :type suppression_config: ~azure.mgmt.alertsmanagement.models.SuppressionConfig +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or ~azure.mgmt.alertsmanagement.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or ~azure.mgmt.alertsmanagement.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type last_modified_at: ~datetime.datetime """ - _validation = { - 'created_at': {'readonly': True}, - 'last_modified_at': {'readonly': True}, - 'created_by': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - 'type': {'required': True}, - 'suppression_config': {'required': True}, - } - _attribute_map = { - 'scope': {'key': 'scope', 'type': 'Scope'}, - 'conditions': {'key': 'conditions', 'type': 'Conditions'}, - 'description': {'key': 'description', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'suppression_config': {'key': 'suppressionConfig', 'type': 'SuppressionConfig'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, } def __init__( self, **kwargs ): - super(Suppression, self).__init__(**kwargs) - self.type = 'Suppression' # type: str - self.suppression_config = kwargs['suppression_config'] + super(SystemData, self).__init__(**kwargs) + self.created_by = kwargs.get('created_by', None) + self.created_by_type = kwargs.get('created_by_type', None) + self.created_at = kwargs.get('created_at', None) + self.last_modified_by = kwargs.get('last_modified_by', None) + self.last_modified_by_type = kwargs.get('last_modified_by_type', None) + self.last_modified_at = kwargs.get('last_modified_at', None) -class SuppressionConfig(msrest.serialization.Model): - """Suppression logic for a given action rule. +class WeeklyRecurrence(Recurrence): + """Weekly recurrence object. All required parameters must be populated in order to send to Azure. - :param recurrence_type: Required. Specifies when the suppression should be applied. Possible - values include: "Always", "Once", "Daily", "Weekly", "Monthly". - :type recurrence_type: str or ~azure.mgmt.alertsmanagement.models.SuppressionType - :param schedule: suppression schedule configuration. - :type schedule: ~azure.mgmt.alertsmanagement.models.SuppressionSchedule + :param recurrence_type: Required. Specifies when the recurrence should be applied.Constant + filled by server. Possible values include: "Daily", "Weekly", "Monthly". + :type recurrence_type: str or ~azure.mgmt.alertsmanagement.models.RecurrenceType + :param start_time: Start time for recurrence. + :type start_time: str + :param end_time: End time for recurrence. + :type end_time: str + :param days_of_week: Required. Specifies the values for weekly recurrence pattern. + :type days_of_week: list[str or ~azure.mgmt.alertsmanagement.models.DaysOfWeek] """ _validation = { 'recurrence_type': {'required': True}, + 'days_of_week': {'required': True}, } _attribute_map = { 'recurrence_type': {'key': 'recurrenceType', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': 'SuppressionSchedule'}, - } - - def __init__( - self, - **kwargs - ): - super(SuppressionConfig, self).__init__(**kwargs) - self.recurrence_type = kwargs['recurrence_type'] - self.schedule = kwargs.get('schedule', None) - - -class SuppressionSchedule(msrest.serialization.Model): - """Schedule for a given suppression configuration. - - :param start_date: Start date for suppression. - :type start_date: str - :param end_date: End date for suppression. - :type end_date: str - :param start_time: Start time for suppression. - :type start_time: str - :param end_time: End date for suppression. - :type end_time: str - :param recurrence_values: Specifies the values for recurrence pattern. - :type recurrence_values: list[int] - """ - - _attribute_map = { - 'start_date': {'key': 'startDate', 'type': 'str'}, - 'end_date': {'key': 'endDate', 'type': 'str'}, 'start_time': {'key': 'startTime', 'type': 'str'}, 'end_time': {'key': 'endTime', 'type': 'str'}, - 'recurrence_values': {'key': 'recurrenceValues', 'type': '[int]'}, - } - - def __init__( - self, - **kwargs - ): - super(SuppressionSchedule, self).__init__(**kwargs) - self.start_date = kwargs.get('start_date', None) - self.end_date = kwargs.get('end_date', None) - self.start_time = kwargs.get('start_time', None) - self.end_time = kwargs.get('end_time', None) - self.recurrence_values = kwargs.get('recurrence_values', None) - - -class ThrottlingInformation(msrest.serialization.Model): - """Optional throttling information for the alert rule. - - :param duration: The required duration (in ISO8601 format) to wait before notifying on the - alert rule again. The time granularity must be in minutes and minimum value is 0 minutes. - :type duration: ~datetime.timedelta - """ - - _attribute_map = { - 'duration': {'key': 'duration', 'type': 'duration'}, + 'days_of_week': {'key': 'daysOfWeek', 'type': '[str]'}, } def __init__( self, **kwargs ): - super(ThrottlingInformation, self).__init__(**kwargs) - self.duration = kwargs.get('duration', None) + super(WeeklyRecurrence, self).__init__(**kwargs) + self.recurrence_type = 'Weekly' # type: str + self.days_of_week = kwargs['days_of_week'] diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_models_py3.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_models_py3.py index 9505b1d2be24..85f0b398231c 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_models_py3.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_models_py3.py @@ -15,187 +15,70 @@ from ._alerts_management_client_enums import * -class ActionRuleProperties(msrest.serialization.Model): - """Action rule properties defining scope, conditions, suppression logic for action rule. +class Action(msrest.serialization.Model): + """Action to be applied. You probably want to use the sub-classes and not this class directly. Known - sub-classes are: ActionGroup, Diagnostics, Suppression. - - Variables are only populated by the server, and will be ignored when sending a request. + sub-classes are: AddActionGroups, RemoveAllActionGroups. All required parameters must be populated in order to send to Azure. - :param scope: scope on which action rule will apply. - :type scope: ~azure.mgmt.alertsmanagement.models.Scope - :param conditions: conditions on which alerts will be filtered. - :type conditions: ~azure.mgmt.alertsmanagement.models.Conditions - :param description: Description of action rule. - :type description: str - :ivar created_at: Creation time of action rule. Date-Time in ISO-8601 format. - :vartype created_at: ~datetime.datetime - :ivar last_modified_at: Last updated time of action rule. Date-Time in ISO-8601 format. - :vartype last_modified_at: ~datetime.datetime - :ivar created_by: Created by user name. - :vartype created_by: str - :ivar last_modified_by: Last modified by user name. - :vartype last_modified_by: str - :param status: Indicates if the given action rule is enabled or disabled. Possible values - include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus - :param type: Required. Indicates type of action rule.Constant filled by server. Possible - values include: "Suppression", "ActionGroup", "Diagnostics". - :type type: str or ~azure.mgmt.alertsmanagement.models.ActionRuleType + :param action_type: Required. Action that should be applied.Constant filled by server. + Possible values include: "AddActionGroups", "RemoveAllActionGroups". + :type action_type: str or ~azure.mgmt.alertsmanagement.models.ActionType """ _validation = { - 'created_at': {'readonly': True}, - 'last_modified_at': {'readonly': True}, - 'created_by': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - 'type': {'required': True}, + 'action_type': {'required': True}, } _attribute_map = { - 'scope': {'key': 'scope', 'type': 'Scope'}, - 'conditions': {'key': 'conditions', 'type': 'Conditions'}, - 'description': {'key': 'description', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, } _subtype_map = { - 'type': {'ActionGroup': 'ActionGroup', 'Diagnostics': 'Diagnostics', 'Suppression': 'Suppression'} + 'action_type': {'AddActionGroups': 'AddActionGroups', 'RemoveAllActionGroups': 'RemoveAllActionGroups'} } def __init__( self, - *, - scope: Optional["Scope"] = None, - conditions: Optional["Conditions"] = None, - description: Optional[str] = None, - status: Optional[Union[str, "ActionRuleStatus"]] = None, **kwargs ): - super(ActionRuleProperties, self).__init__(**kwargs) - self.scope = scope - self.conditions = conditions - self.description = description - self.created_at = None - self.last_modified_at = None - self.created_by = None - self.last_modified_by = None - self.status = status - self.type = None # type: Optional[str] + super(Action, self).__init__(**kwargs) + self.action_type = None # type: Optional[str] -class ActionGroup(ActionRuleProperties): - """Action rule with action group configuration. - - Variables are only populated by the server, and will be ignored when sending a request. +class AddActionGroups(Action): + """Add action groups to alert processing rule. All required parameters must be populated in order to send to Azure. - :param scope: scope on which action rule will apply. - :type scope: ~azure.mgmt.alertsmanagement.models.Scope - :param conditions: conditions on which alerts will be filtered. - :type conditions: ~azure.mgmt.alertsmanagement.models.Conditions - :param description: Description of action rule. - :type description: str - :ivar created_at: Creation time of action rule. Date-Time in ISO-8601 format. - :vartype created_at: ~datetime.datetime - :ivar last_modified_at: Last updated time of action rule. Date-Time in ISO-8601 format. - :vartype last_modified_at: ~datetime.datetime - :ivar created_by: Created by user name. - :vartype created_by: str - :ivar last_modified_by: Last modified by user name. - :vartype last_modified_by: str - :param status: Indicates if the given action rule is enabled or disabled. Possible values - include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus - :param type: Required. Indicates type of action rule.Constant filled by server. Possible - values include: "Suppression", "ActionGroup", "Diagnostics". - :type type: str or ~azure.mgmt.alertsmanagement.models.ActionRuleType - :param action_group_id: Required. Action group to trigger if action rule matches. - :type action_group_id: str + :param action_type: Required. Action that should be applied.Constant filled by server. + Possible values include: "AddActionGroups", "RemoveAllActionGroups". + :type action_type: str or ~azure.mgmt.alertsmanagement.models.ActionType + :param action_group_ids: Required. List of action group Ids to add to alert processing rule. + :type action_group_ids: list[str] """ _validation = { - 'created_at': {'readonly': True}, - 'last_modified_at': {'readonly': True}, - 'created_by': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - 'type': {'required': True}, - 'action_group_id': {'required': True}, + 'action_type': {'required': True}, + 'action_group_ids': {'required': True}, } _attribute_map = { - 'scope': {'key': 'scope', 'type': 'Scope'}, - 'conditions': {'key': 'conditions', 'type': 'Conditions'}, - 'description': {'key': 'description', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'action_group_id': {'key': 'actionGroupId', 'type': 'str'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, + 'action_group_ids': {'key': 'actionGroupIds', 'type': '[str]'}, } def __init__( self, *, - action_group_id: str, - scope: Optional["Scope"] = None, - conditions: Optional["Conditions"] = None, - description: Optional[str] = None, - status: Optional[Union[str, "ActionRuleStatus"]] = None, + action_group_ids: List[str], **kwargs ): - super(ActionGroup, self).__init__(scope=scope, conditions=conditions, description=description, status=status, **kwargs) - self.type = 'ActionGroup' # type: str - self.action_group_id = action_group_id - - -class ActionGroupsInformation(msrest.serialization.Model): - """The Action Groups information, used by the alert rule. - - All required parameters must be populated in order to send to Azure. - - :param custom_email_subject: An optional custom email subject to use in email notifications. - :type custom_email_subject: str - :param custom_webhook_payload: An optional custom web-hook payload to use in web-hook - notifications. - :type custom_webhook_payload: str - :param group_ids: Required. The Action Group resource IDs. - :type group_ids: list[str] - """ - - _validation = { - 'group_ids': {'required': True}, - } - - _attribute_map = { - 'custom_email_subject': {'key': 'customEmailSubject', 'type': 'str'}, - 'custom_webhook_payload': {'key': 'customWebhookPayload', 'type': 'str'}, - 'group_ids': {'key': 'groupIds', 'type': '[str]'}, - } - - def __init__( - self, - *, - group_ids: List[str], - custom_email_subject: Optional[str] = None, - custom_webhook_payload: Optional[str] = None, - **kwargs - ): - super(ActionGroupsInformation, self).__init__(**kwargs) - self.custom_email_subject = custom_email_subject - self.custom_webhook_payload = custom_webhook_payload - self.group_ids = group_ids + super(AddActionGroups, self).__init__(**kwargs) + self.action_type = 'AddActionGroups' # type: str + self.action_group_ids = action_group_ids class Resource(msrest.serialization.Model): @@ -233,127 +116,6 @@ def __init__( self.name = None -class ManagedResource(Resource): - """An azure managed resource object. - - 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 location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): - super(ManagedResource, self).__init__(**kwargs) - self.location = location - self.tags = tags - - -class ActionRule(ManagedResource): - """Action rule object containing target scope, conditions and suppression logic. - - 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 location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param properties: action rule properties. - :type properties: ~azure.mgmt.alertsmanagement.models.ActionRuleProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'properties': {'key': 'properties', 'type': 'ActionRuleProperties'}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - properties: Optional["ActionRuleProperties"] = None, - **kwargs - ): - super(ActionRule, self).__init__(location=location, tags=tags, **kwargs) - self.properties = properties - - -class ActionRulesList(msrest.serialization.Model): - """List of action rules. - - :param next_link: URL to fetch the next set of action rules. - :type next_link: str - :param value: List of action rules. - :type value: list[~azure.mgmt.alertsmanagement.models.ActionRule] - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[ActionRule]'}, - } - - def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["ActionRule"]] = None, - **kwargs - ): - super(ActionRulesList, self).__init__(**kwargs) - self.next_link = next_link - self.value = value - - class Alert(Resource): """An alert created in alert management service. @@ -515,56 +277,22 @@ def __init__( self.modifications = modifications -class AlertProperties(msrest.serialization.Model): - """Alert property bag. +class ManagedResource(Resource): + """An azure managed resource object. Variables are only populated by the server, and will be ignored when sending a request. - :param essentials: This object contains consistent fields across different monitor services. - :type essentials: ~azure.mgmt.alertsmanagement.models.Essentials - :ivar context: Any object. - :vartype context: object - :ivar egress_config: Any object. - :vartype egress_config: object - """ - - _validation = { - 'context': {'readonly': True}, - 'egress_config': {'readonly': True}, - } - - _attribute_map = { - 'essentials': {'key': 'essentials', 'type': 'Essentials'}, - 'context': {'key': 'context', 'type': 'object'}, - 'egress_config': {'key': 'egressConfig', 'type': 'object'}, - } - - def __init__( - self, - *, - essentials: Optional["Essentials"] = None, - **kwargs - ): - super(AlertProperties, self).__init__(**kwargs) - self.essentials = essentials - self.context = None - self.egress_config = None - - -class AzureResource(msrest.serialization.Model): - """An Azure resource object. - - 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. + :ivar id: Azure resource Id. :vartype id: str - :ivar type: The resource type. + :ivar type: Azure resource type. :vartype type: str - :ivar name: The resource name. + :ivar name: Azure resource name. :vartype name: str - :param location: The resource location. + :param location: Required. Resource location. :type location: str - :param tags: A set of tags. The resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] """ @@ -572,6 +300,7 @@ class AzureResource(msrest.serialization.Model): 'id': {'readonly': True}, 'type': {'readonly': True}, 'name': {'readonly': True}, + 'location': {'required': True}, } _attribute_map = { @@ -585,57 +314,44 @@ class AzureResource(msrest.serialization.Model): def __init__( self, *, - location: Optional[str] = "global", + location: str, tags: Optional[Dict[str, str]] = None, **kwargs ): - super(AzureResource, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None + super(ManagedResource, self).__init__(**kwargs) self.location = location self.tags = tags -class AlertRule(AzureResource): - """The alert rule information. +class AlertProcessingRule(ManagedResource): + """Alert processing rule object containing target scopes, conditions and scheduling logic. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: The resource ID. + All required parameters must be populated in order to send to Azure. + + :ivar id: Azure resource Id. :vartype id: str - :ivar type: The resource type. + :ivar type: Azure resource type. :vartype type: str - :ivar name: The resource name. + :ivar name: Azure resource name. :vartype name: str - :param location: The resource location. + :param location: Required. Resource location. :type location: str - :param tags: A set of tags. The resource tags. + :param tags: A set of tags. Resource tags. :type tags: dict[str, str] - :param description: The alert rule description. - :type description: str - :param state: The alert rule state. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.alertsmanagement.models.AlertRuleState - :param severity: The alert rule severity. Possible values include: "Sev0", "Sev1", "Sev2", - "Sev3", "Sev4". - :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity - :param frequency: The alert rule frequency in ISO8601 format. The time granularity must be in - minutes and minimum value is 5 minutes. - :type frequency: ~datetime.timedelta - :param detector: The alert rule's detector. - :type detector: ~azure.mgmt.alertsmanagement.models.Detector - :param scope: The alert rule resources scope. - :type scope: list[str] - :param action_groups: The alert rule actions. - :type action_groups: ~azure.mgmt.alertsmanagement.models.ActionGroupsInformation - :param throttling: The alert rule throttling information. - :type throttling: ~azure.mgmt.alertsmanagement.models.ThrottlingInformation + :param properties: Alert processing rule properties. + :type properties: ~azure.mgmt.alertsmanagement.models.AlertProcessingRuleProperties + :ivar system_data: Alert processing rule system data. + :vartype system_data: ~azure.mgmt.alertsmanagement.models.SystemData """ _validation = { 'id': {'readonly': True}, 'type': {'readonly': True}, 'name': {'readonly': True}, + 'location': {'required': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -644,139 +360,136 @@ class AlertRule(AzureResource): 'name': {'key': 'name', 'type': 'str'}, 'location': {'key': 'location', 'type': 'str'}, 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'frequency': {'key': 'properties.frequency', 'type': 'duration'}, - 'detector': {'key': 'properties.detector', 'type': 'Detector'}, - 'scope': {'key': 'properties.scope', 'type': '[str]'}, - 'action_groups': {'key': 'properties.actionGroups', 'type': 'ActionGroupsInformation'}, - 'throttling': {'key': 'properties.throttling', 'type': 'ThrottlingInformation'}, + 'properties': {'key': 'properties', 'type': 'AlertProcessingRuleProperties'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( self, *, - location: Optional[str] = "global", + location: str, tags: Optional[Dict[str, str]] = None, - description: Optional[str] = None, - state: Optional[Union[str, "AlertRuleState"]] = None, - severity: Optional[Union[str, "Severity"]] = None, - frequency: Optional[datetime.timedelta] = None, - detector: Optional["Detector"] = None, - scope: Optional[List[str]] = None, - action_groups: Optional["ActionGroupsInformation"] = None, - throttling: Optional["ThrottlingInformation"] = None, + properties: Optional["AlertProcessingRuleProperties"] = None, **kwargs ): - super(AlertRule, self).__init__(location=location, tags=tags, **kwargs) - self.description = description - self.state = state - self.severity = severity - self.frequency = frequency - self.detector = detector - self.scope = scope - self.action_groups = action_groups - self.throttling = throttling + super(AlertProcessingRule, self).__init__(location=location, tags=tags, **kwargs) + self.properties = properties + self.system_data = None -class AlertRulePatchObject(msrest.serialization.Model): - """The alert rule patch information. +class AlertProcessingRuleProperties(msrest.serialization.Model): + """Alert processing rule properties defining scopes, conditions and scheduling logic for alert processing 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: The resource ID. - :vartype id: str - :ivar type: The resource type. - :vartype type: str - :ivar name: The resource name. - :vartype name: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param description: The alert rule description. + :param scopes: Required. Scopes on which alert processing rule will apply. + :type scopes: list[str] + :param conditions: Conditions on which alerts will be filtered. + :type conditions: list[~azure.mgmt.alertsmanagement.models.Condition] + :param schedule: Scheduling for alert processing rule. + :type schedule: ~azure.mgmt.alertsmanagement.models.Schedule + :param actions: Required. Actions to be applied. + :type actions: list[~azure.mgmt.alertsmanagement.models.Action] + :param description: Description of alert processing rule. :type description: str - :param state: The alert rule state. Possible values include: "Enabled", "Disabled". - :type state: str or ~azure.mgmt.alertsmanagement.models.AlertRuleState - :param severity: The alert rule severity. Possible values include: "Sev0", "Sev1", "Sev2", - "Sev3", "Sev4". - :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity - :param frequency: The alert rule frequency in ISO8601 format. The time granularity must be in - minutes and minimum value is 5 minutes. - :type frequency: ~datetime.timedelta - :param action_groups: The alert rule actions. - :type action_groups: ~azure.mgmt.alertsmanagement.models.ActionGroupsInformation - :param throttling: The alert rule throttling information. - :type throttling: ~azure.mgmt.alertsmanagement.models.ThrottlingInformation + :param enabled: Indicates if the given alert processing rule is enabled or disabled. + :type enabled: bool """ _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, + 'scopes': {'required': True}, + 'actions': {'required': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'description': {'key': 'properties.description', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'frequency': {'key': 'properties.frequency', 'type': 'duration'}, - 'action_groups': {'key': 'properties.actionGroups', 'type': 'ActionGroupsInformation'}, - 'throttling': {'key': 'properties.throttling', 'type': 'ThrottlingInformation'}, + 'scopes': {'key': 'scopes', 'type': '[str]'}, + 'conditions': {'key': 'conditions', 'type': '[Condition]'}, + 'schedule': {'key': 'schedule', 'type': 'Schedule'}, + 'actions': {'key': 'actions', 'type': '[Action]'}, + 'description': {'key': 'description', 'type': 'str'}, + 'enabled': {'key': 'enabled', 'type': 'bool'}, } def __init__( self, *, - tags: Optional[Dict[str, str]] = None, + scopes: List[str], + actions: List["Action"], + conditions: Optional[List["Condition"]] = None, + schedule: Optional["Schedule"] = None, description: Optional[str] = None, - state: Optional[Union[str, "AlertRuleState"]] = None, - severity: Optional[Union[str, "Severity"]] = None, - frequency: Optional[datetime.timedelta] = None, - action_groups: Optional["ActionGroupsInformation"] = None, - throttling: Optional["ThrottlingInformation"] = None, + enabled: Optional[bool] = True, **kwargs ): - super(AlertRulePatchObject, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.tags = tags + super(AlertProcessingRuleProperties, self).__init__(**kwargs) + self.scopes = scopes + self.conditions = conditions + self.schedule = schedule + self.actions = actions self.description = description - self.state = state - self.severity = severity - self.frequency = frequency - self.action_groups = action_groups - self.throttling = throttling + self.enabled = enabled -class AlertRulesList(msrest.serialization.Model): - """List of Smart Detector alert rules. +class AlertProcessingRulesList(msrest.serialization.Model): + """List of alert processing rules. - :param value: List of Smart Detector alert rules. - :type value: list[~azure.mgmt.alertsmanagement.models.AlertRule] - :param next_link: The URL to get the next set of results. + :param next_link: URL to fetch the next set of alert processing rules. :type next_link: str + :param value: List of alert processing rules. + :type value: list[~azure.mgmt.alertsmanagement.models.AlertProcessingRule] """ _attribute_map = { - 'value': {'key': 'value', 'type': '[AlertRule]'}, 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'value': {'key': 'value', 'type': '[AlertProcessingRule]'}, } def __init__( self, *, - value: Optional[List["AlertRule"]] = None, next_link: Optional[str] = None, + value: Optional[List["AlertProcessingRule"]] = None, **kwargs ): - super(AlertRulesList, self).__init__(**kwargs) - self.value = value + super(AlertProcessingRulesList, self).__init__(**kwargs) self.next_link = next_link + self.value = value + + +class AlertProperties(msrest.serialization.Model): + """Alert property bag. + + Variables are only populated by the server, and will be ignored when sending a request. + + :param essentials: This object contains consistent fields across different monitor services. + :type essentials: ~azure.mgmt.alertsmanagement.models.Essentials + :ivar context: Any object. + :vartype context: any + :ivar egress_config: Any object. + :vartype egress_config: any + """ + + _validation = { + 'context': {'readonly': True}, + 'egress_config': {'readonly': True}, + } + + _attribute_map = { + 'essentials': {'key': 'essentials', 'type': 'Essentials'}, + 'context': {'key': 'context', 'type': 'object'}, + 'egress_config': {'key': 'egressConfig', 'type': 'object'}, + } + + def __init__( + self, + *, + essentials: Optional["Essentials"] = None, + **kwargs + ): + super(AlertProperties, self).__init__(**kwargs) + self.essentials = essentials + self.context = None + self.egress_config = None class AlertsList(msrest.serialization.Model): @@ -901,9 +614,9 @@ class AlertsSummaryGroup(msrest.serialization.Model): """Group the result set. :param total: Total count of the result set. - :type total: int + :type total: long :param smart_groups_count: Total count of the smart groups. - :type smart_groups_count: int + :type smart_groups_count: long :param groupedby: Name of the field aggregated. :type groupedby: str :param values: List of the items. @@ -911,8 +624,8 @@ class AlertsSummaryGroup(msrest.serialization.Model): """ _attribute_map = { - 'total': {'key': 'total', 'type': 'int'}, - 'smart_groups_count': {'key': 'smartGroupsCount', 'type': 'int'}, + 'total': {'key': 'total', 'type': 'long'}, + 'smart_groups_count': {'key': 'smartGroupsCount', 'type': 'long'}, 'groupedby': {'key': 'groupedby', 'type': 'str'}, 'values': {'key': 'values', 'type': '[AlertsSummaryGroupItem]'}, } @@ -939,7 +652,7 @@ class AlertsSummaryGroupItem(msrest.serialization.Model): :param name: Value of the aggregated field. :type name: str :param count: Count of the aggregated field. - :type count: int + :type count: long :param groupedby: Name of the field aggregated. :type groupedby: str :param values: List of the items. @@ -948,7 +661,7 @@ class AlertsSummaryGroupItem(msrest.serialization.Model): _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'int'}, + 'count': {'key': 'count', 'type': 'long'}, 'groupedby': {'key': 'groupedby', 'type': 'str'}, 'values': {'key': 'values', 'type': '[AlertsSummaryGroupItem]'}, } @@ -970,16 +683,21 @@ def __init__( class Condition(msrest.serialization.Model): - """condition to trigger an action rule. + """Condition to trigger an alert processing rule. - :param operator: operator for a given condition. Possible values include: "Equals", + :param field: Field for a given condition. Possible values include: "Severity", + "MonitorService", "MonitorCondition", "SignalType", "TargetResourceType", "TargetResource", + "TargetResourceGroup", "AlertRuleId", "AlertRuleName", "Description", "AlertContext". + :type field: str or ~azure.mgmt.alertsmanagement.models.Field + :param operator: Operator for a given condition. Possible values include: "Equals", "NotEquals", "Contains", "DoesNotContain". :type operator: str or ~azure.mgmt.alertsmanagement.models.Operator - :param values: list of values to match for a given condition. + :param values: List of values to match for a given condition. :type values: list[str] """ _attribute_map = { + 'field': {'key': 'field', 'type': 'str'}, 'operator': {'key': 'operator', 'type': 'str'}, 'values': {'key': 'values', 'type': '[str]'}, } @@ -987,182 +705,94 @@ class Condition(msrest.serialization.Model): def __init__( self, *, + field: Optional[Union[str, "Field"]] = None, operator: Optional[Union[str, "Operator"]] = None, values: Optional[List[str]] = None, **kwargs ): super(Condition, self).__init__(**kwargs) + self.field = field self.operator = operator self.values = values -class Conditions(msrest.serialization.Model): - """Conditions in alert instance to be matched for a given action rule. Default value is all. Multiple values could be provided with comma separation. - - :param severity: filter alerts by severity. - :type severity: ~azure.mgmt.alertsmanagement.models.Condition - :param monitor_service: filter alerts by monitor service. - :type monitor_service: ~azure.mgmt.alertsmanagement.models.Condition - :param monitor_condition: filter alerts by monitor condition. - :type monitor_condition: ~azure.mgmt.alertsmanagement.models.Condition - :param target_resource_type: filter alerts by target resource type. - :type target_resource_type: ~azure.mgmt.alertsmanagement.models.Condition - :param alert_rule_id: filter alerts by alert rule id. - :type alert_rule_id: ~azure.mgmt.alertsmanagement.models.Condition - :param description: filter alerts by alert rule description. - :type description: ~azure.mgmt.alertsmanagement.models.Condition - :param alert_context: filter alerts by alert context (payload). - :type alert_context: ~azure.mgmt.alertsmanagement.models.Condition - """ - - _attribute_map = { - 'severity': {'key': 'severity', 'type': 'Condition'}, - 'monitor_service': {'key': 'monitorService', 'type': 'Condition'}, - 'monitor_condition': {'key': 'monitorCondition', 'type': 'Condition'}, - 'target_resource_type': {'key': 'targetResourceType', 'type': 'Condition'}, - 'alert_rule_id': {'key': 'alertRuleId', 'type': 'Condition'}, - 'description': {'key': 'description', 'type': 'Condition'}, - 'alert_context': {'key': 'alertContext', 'type': 'Condition'}, - } - - def __init__( - self, - *, - severity: Optional["Condition"] = None, - monitor_service: Optional["Condition"] = None, - monitor_condition: Optional["Condition"] = None, - target_resource_type: Optional["Condition"] = None, - alert_rule_id: Optional["Condition"] = None, - description: Optional["Condition"] = None, - alert_context: Optional["Condition"] = None, - **kwargs - ): - super(Conditions, self).__init__(**kwargs) - self.severity = severity - self.monitor_service = monitor_service - self.monitor_condition = monitor_condition - self.target_resource_type = target_resource_type - self.alert_rule_id = alert_rule_id - self.description = description - self.alert_context = alert_context +class Recurrence(msrest.serialization.Model): + """Recurrence object. - -class Detector(msrest.serialization.Model): - """The detector information. By default this is not populated, unless it's specified in expandDetector. + You probably want to use the sub-classes and not this class directly. Known + sub-classes are: DailyRecurrence, MonthlyRecurrence, WeeklyRecurrence. All required parameters must be populated in order to send to Azure. - :param id: Required. The detector id. - :type id: str - :param parameters: The detector's parameters.'. - :type parameters: dict[str, object] - :param name: The Smart Detector name. By default this is not populated, unless it's specified - in expandDetector. - :type name: str - :param description: The Smart Detector description. By default this is not populated, unless - it's specified in expandDetector. - :type description: str - :param supported_resource_types: The Smart Detector supported resource types. By default this - is not populated, unless it's specified in expandDetector. - :type supported_resource_types: list[str] - :param image_paths: The Smart Detector image path. By default this is not populated, unless - it's specified in expandDetector. - :type image_paths: list[str] + :param recurrence_type: Required. Specifies when the recurrence should be applied.Constant + filled by server. Possible values include: "Daily", "Weekly", "Monthly". + :type recurrence_type: str or ~azure.mgmt.alertsmanagement.models.RecurrenceType + :param start_time: Start time for recurrence. + :type start_time: str + :param end_time: End time for recurrence. + :type end_time: str """ _validation = { - 'id': {'required': True}, + 'recurrence_type': {'required': True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': '{object}'}, - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'supported_resource_types': {'key': 'supportedResourceTypes', 'type': '[str]'}, - 'image_paths': {'key': 'imagePaths', 'type': '[str]'}, + 'recurrence_type': {'key': 'recurrenceType', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'str'}, + 'end_time': {'key': 'endTime', 'type': 'str'}, + } + + _subtype_map = { + 'recurrence_type': {'Daily': 'DailyRecurrence', 'Monthly': 'MonthlyRecurrence', 'Weekly': 'WeeklyRecurrence'} } def __init__( self, *, - id: str, - parameters: Optional[Dict[str, object]] = None, - name: Optional[str] = None, - description: Optional[str] = None, - supported_resource_types: Optional[List[str]] = None, - image_paths: Optional[List[str]] = None, + start_time: Optional[str] = None, + end_time: Optional[str] = None, **kwargs ): - super(Detector, self).__init__(**kwargs) - self.id = id - self.parameters = parameters - self.name = name - self.description = description - self.supported_resource_types = supported_resource_types - self.image_paths = image_paths - + super(Recurrence, self).__init__(**kwargs) + self.recurrence_type = None # type: Optional[str] + self.start_time = start_time + self.end_time = end_time -class Diagnostics(ActionRuleProperties): - """Action rule with diagnostics configuration. - Variables are only populated by the server, and will be ignored when sending a request. +class DailyRecurrence(Recurrence): + """Daily recurrence object. All required parameters must be populated in order to send to Azure. - :param scope: scope on which action rule will apply. - :type scope: ~azure.mgmt.alertsmanagement.models.Scope - :param conditions: conditions on which alerts will be filtered. - :type conditions: ~azure.mgmt.alertsmanagement.models.Conditions - :param description: Description of action rule. - :type description: str - :ivar created_at: Creation time of action rule. Date-Time in ISO-8601 format. - :vartype created_at: ~datetime.datetime - :ivar last_modified_at: Last updated time of action rule. Date-Time in ISO-8601 format. - :vartype last_modified_at: ~datetime.datetime - :ivar created_by: Created by user name. - :vartype created_by: str - :ivar last_modified_by: Last modified by user name. - :vartype last_modified_by: str - :param status: Indicates if the given action rule is enabled or disabled. Possible values - include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus - :param type: Required. Indicates type of action rule.Constant filled by server. Possible - values include: "Suppression", "ActionGroup", "Diagnostics". - :type type: str or ~azure.mgmt.alertsmanagement.models.ActionRuleType + :param recurrence_type: Required. Specifies when the recurrence should be applied.Constant + filled by server. Possible values include: "Daily", "Weekly", "Monthly". + :type recurrence_type: str or ~azure.mgmt.alertsmanagement.models.RecurrenceType + :param start_time: Start time for recurrence. + :type start_time: str + :param end_time: End time for recurrence. + :type end_time: str """ _validation = { - 'created_at': {'readonly': True}, - 'last_modified_at': {'readonly': True}, - 'created_by': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - 'type': {'required': True}, + 'recurrence_type': {'required': True}, } _attribute_map = { - 'scope': {'key': 'scope', 'type': 'Scope'}, - 'conditions': {'key': 'conditions', 'type': 'Conditions'}, - 'description': {'key': 'description', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + 'recurrence_type': {'key': 'recurrenceType', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'str'}, + 'end_time': {'key': 'endTime', 'type': 'str'}, } def __init__( self, *, - scope: Optional["Scope"] = None, - conditions: Optional["Conditions"] = None, - description: Optional[str] = None, - status: Optional[Union[str, "ActionRuleStatus"]] = None, + start_time: Optional[str] = None, + end_time: Optional[str] = None, **kwargs ): - super(Diagnostics, self).__init__(scope=scope, conditions=conditions, description=description, status=status, **kwargs) - self.type = 'Diagnostics' # type: str + super(DailyRecurrence, self).__init__(start_time=start_time, end_time=end_time, **kwargs) + self.recurrence_type = 'Daily' # type: str class ErrorResponse(msrest.serialization.Model): @@ -1516,6 +1146,47 @@ def __init__( self.data = data +class MonthlyRecurrence(Recurrence): + """Monthly recurrence object. + + All required parameters must be populated in order to send to Azure. + + :param recurrence_type: Required. Specifies when the recurrence should be applied.Constant + filled by server. Possible values include: "Daily", "Weekly", "Monthly". + :type recurrence_type: str or ~azure.mgmt.alertsmanagement.models.RecurrenceType + :param start_time: Start time for recurrence. + :type start_time: str + :param end_time: End time for recurrence. + :type end_time: str + :param days_of_month: Required. Specifies the values for monthly recurrence pattern. + :type days_of_month: list[int] + """ + + _validation = { + 'recurrence_type': {'required': True}, + 'days_of_month': {'required': True}, + } + + _attribute_map = { + 'recurrence_type': {'key': 'recurrenceType', 'type': 'str'}, + 'start_time': {'key': 'startTime', 'type': 'str'}, + 'end_time': {'key': 'endTime', 'type': 'str'}, + 'days_of_month': {'key': 'daysOfMonth', 'type': '[int]'}, + } + + def __init__( + self, + *, + days_of_month: List[int], + start_time: Optional[str] = None, + end_time: Optional[str] = None, + **kwargs + ): + super(MonthlyRecurrence, self).__init__(start_time=start_time, end_time=end_time, **kwargs) + self.recurrence_type = 'Monthly' # type: str + self.days_of_month = days_of_month + + class Operation(msrest.serialization.Model): """Operation provided by provider. @@ -1613,82 +1284,96 @@ def __init__( class PatchObject(msrest.serialization.Model): """Data contract for patch. - :param tags: A set of tags. tags to be updated. - :type tags: object - :param status: Indicates if the given action rule is enabled or disabled. Possible values - include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus + :param tags: A set of tags. Tags to be updated. + :type tags: dict[str, str] + :param enabled: Indicates if the given alert processing rule is enabled or disabled. + :type enabled: bool """ _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'status': {'key': 'properties.status', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'enabled': {'key': 'properties.enabled', 'type': 'bool'}, } def __init__( self, *, - tags: Optional[object] = None, - status: Optional[Union[str, "ActionRuleStatus"]] = None, + tags: Optional[Dict[str, str]] = None, + enabled: Optional[bool] = None, **kwargs ): super(PatchObject, self).__init__(**kwargs) self.tags = tags - self.status = status + self.enabled = enabled -class Scope(msrest.serialization.Model): - """Target scope for a given action rule. By default scope will be the subscription. User can also provide list of resource groups or list of resources from the scope subscription as well. +class RemoveAllActionGroups(Action): + """Indicates if all action groups should be removed. - :param scope_type: type of target scope. Possible values include: "ResourceGroup", "Resource", - "Subscription". - :type scope_type: str or ~azure.mgmt.alertsmanagement.models.ScopeType - :param values: list of ARM IDs of the given scope type which will be the target of the given - action rule. - :type values: list[str] + All required parameters must be populated in order to send to Azure. + + :param action_type: Required. Action that should be applied.Constant filled by server. + Possible values include: "AddActionGroups", "RemoveAllActionGroups". + :type action_type: str or ~azure.mgmt.alertsmanagement.models.ActionType """ + _validation = { + 'action_type': {'required': True}, + } + _attribute_map = { - 'scope_type': {'key': 'scopeType', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, + 'action_type': {'key': 'actionType', 'type': 'str'}, } def __init__( self, - *, - scope_type: Optional[Union[str, "ScopeType"]] = None, - values: Optional[List[str]] = None, **kwargs ): - super(Scope, self).__init__(**kwargs) - self.scope_type = scope_type - self.values = values - - -class SmartDetectorErrorResponse(msrest.serialization.Model): - """Describe the format of an Error response. - - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + super(RemoveAllActionGroups, self).__init__(**kwargs) + self.action_type = 'RemoveAllActionGroups' # type: str + + +class Schedule(msrest.serialization.Model): + """Scheduling configuration for a given alert processing rule. + + :param effective_from: Scheduling effective from time. Date-Time in ISO-8601 format without + timezone suffix. + :type effective_from: str + :param effective_until: Scheduling effective until time. Date-Time in ISO-8601 format without + timezone suffix. + :type effective_until: str + :param time_zone: Scheduling time zone. + :type time_zone: str + :param recurrences: List of recurrences. + :type recurrences: list[~azure.mgmt.alertsmanagement.models.Recurrence] """ + _validation = { + 'effective_from': {'pattern': r'^(?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))$'}, + 'effective_until': {'pattern': r'^(?:(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}(?:\.\d+)?))$'}, + } + _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + 'effective_from': {'key': 'effectiveFrom', 'type': 'str'}, + 'effective_until': {'key': 'effectiveUntil', 'type': 'str'}, + 'time_zone': {'key': 'timeZone', 'type': 'str'}, + 'recurrences': {'key': 'recurrences', 'type': '[Recurrence]'}, } def __init__( self, *, - code: Optional[str] = None, - message: Optional[str] = None, + effective_from: Optional[str] = None, + effective_until: Optional[str] = None, + time_zone: Optional[str] = None, + recurrences: Optional[List["Recurrence"]] = None, **kwargs ): - super(SmartDetectorErrorResponse, self).__init__(**kwargs) - self.code = code - self.message = message + super(Schedule, self).__init__(**kwargs) + self.effective_from = effective_from + self.effective_until = effective_until + self.time_zone = time_zone + self.recurrences = recurrences class SmartGroup(Resource): @@ -1703,7 +1388,7 @@ class SmartGroup(Resource): :ivar name: Azure resource name. :vartype name: str :param alerts_count: Total number of alerts in smart group. - :type alerts_count: int + :type alerts_count: long :ivar smart_group_state: Smart group state. Possible values include: "New", "Acknowledged", "Closed". :vartype smart_group_state: str or ~azure.mgmt.alertsmanagement.models.State @@ -1751,7 +1436,7 @@ class SmartGroup(Resource): 'id': {'key': 'id', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, - 'alerts_count': {'key': 'properties.alertsCount', 'type': 'int'}, + 'alerts_count': {'key': 'properties.alertsCount', 'type': 'long'}, 'smart_group_state': {'key': 'properties.smartGroupState', 'type': 'str'}, 'severity': {'key': 'properties.severity', 'type': 'str'}, 'start_date_time': {'key': 'properties.startDateTime', 'type': 'iso-8601'}, @@ -1804,12 +1489,12 @@ class SmartGroupAggregatedProperty(msrest.serialization.Model): :param name: Name of the type. :type name: str :param count: Total number of items of type. - :type count: int + :type count: long """ _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'int'}, + 'count': {'key': 'count', 'type': 'long'}, } def __init__( @@ -1977,165 +1662,90 @@ def __init__( self.value = value -class Suppression(ActionRuleProperties): - """Action rule with suppression configuration. - - 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 scope: scope on which action rule will apply. - :type scope: ~azure.mgmt.alertsmanagement.models.Scope - :param conditions: conditions on which alerts will be filtered. - :type conditions: ~azure.mgmt.alertsmanagement.models.Conditions - :param description: Description of action rule. - :type description: str - :ivar created_at: Creation time of action rule. Date-Time in ISO-8601 format. - :vartype created_at: ~datetime.datetime - :ivar last_modified_at: Last updated time of action rule. Date-Time in ISO-8601 format. - :vartype last_modified_at: ~datetime.datetime - :ivar created_by: Created by user name. - :vartype created_by: str - :ivar last_modified_by: Last modified by user name. - :vartype last_modified_by: str - :param status: Indicates if the given action rule is enabled or disabled. Possible values - include: "Enabled", "Disabled". - :type status: str or ~azure.mgmt.alertsmanagement.models.ActionRuleStatus - :param type: Required. Indicates type of action rule.Constant filled by server. Possible - values include: "Suppression", "ActionGroup", "Diagnostics". - :type type: str or ~azure.mgmt.alertsmanagement.models.ActionRuleType - :param suppression_config: Required. suppression configuration for the action rule. - :type suppression_config: ~azure.mgmt.alertsmanagement.models.SuppressionConfig +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or ~azure.mgmt.alertsmanagement.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or ~azure.mgmt.alertsmanagement.models.CreatedByType + :param last_modified_at: The timestamp of resource last modification (UTC). + :type last_modified_at: ~datetime.datetime """ - _validation = { - 'created_at': {'readonly': True}, - 'last_modified_at': {'readonly': True}, - 'created_by': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - 'type': {'required': True}, - 'suppression_config': {'required': True}, - } - _attribute_map = { - 'scope': {'key': 'scope', 'type': 'Scope'}, - 'conditions': {'key': 'conditions', 'type': 'Conditions'}, - 'description': {'key': 'description', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'suppression_config': {'key': 'suppressionConfig', 'type': 'SuppressionConfig'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, } def __init__( self, *, - suppression_config: "SuppressionConfig", - scope: Optional["Scope"] = None, - conditions: Optional["Conditions"] = None, - description: Optional[str] = None, - status: Optional[Union[str, "ActionRuleStatus"]] = None, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, **kwargs ): - super(Suppression, self).__init__(scope=scope, conditions=conditions, description=description, status=status, **kwargs) - self.type = 'Suppression' # type: str - self.suppression_config = suppression_config + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at -class SuppressionConfig(msrest.serialization.Model): - """Suppression logic for a given action rule. +class WeeklyRecurrence(Recurrence): + """Weekly recurrence object. All required parameters must be populated in order to send to Azure. - :param recurrence_type: Required. Specifies when the suppression should be applied. Possible - values include: "Always", "Once", "Daily", "Weekly", "Monthly". - :type recurrence_type: str or ~azure.mgmt.alertsmanagement.models.SuppressionType - :param schedule: suppression schedule configuration. - :type schedule: ~azure.mgmt.alertsmanagement.models.SuppressionSchedule + :param recurrence_type: Required. Specifies when the recurrence should be applied.Constant + filled by server. Possible values include: "Daily", "Weekly", "Monthly". + :type recurrence_type: str or ~azure.mgmt.alertsmanagement.models.RecurrenceType + :param start_time: Start time for recurrence. + :type start_time: str + :param end_time: End time for recurrence. + :type end_time: str + :param days_of_week: Required. Specifies the values for weekly recurrence pattern. + :type days_of_week: list[str or ~azure.mgmt.alertsmanagement.models.DaysOfWeek] """ _validation = { 'recurrence_type': {'required': True}, + 'days_of_week': {'required': True}, } _attribute_map = { 'recurrence_type': {'key': 'recurrenceType', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': 'SuppressionSchedule'}, - } - - def __init__( - self, - *, - recurrence_type: Union[str, "SuppressionType"], - schedule: Optional["SuppressionSchedule"] = None, - **kwargs - ): - super(SuppressionConfig, self).__init__(**kwargs) - self.recurrence_type = recurrence_type - self.schedule = schedule - - -class SuppressionSchedule(msrest.serialization.Model): - """Schedule for a given suppression configuration. - - :param start_date: Start date for suppression. - :type start_date: str - :param end_date: End date for suppression. - :type end_date: str - :param start_time: Start time for suppression. - :type start_time: str - :param end_time: End date for suppression. - :type end_time: str - :param recurrence_values: Specifies the values for recurrence pattern. - :type recurrence_values: list[int] - """ - - _attribute_map = { - 'start_date': {'key': 'startDate', 'type': 'str'}, - 'end_date': {'key': 'endDate', 'type': 'str'}, 'start_time': {'key': 'startTime', 'type': 'str'}, 'end_time': {'key': 'endTime', 'type': 'str'}, - 'recurrence_values': {'key': 'recurrenceValues', 'type': '[int]'}, + 'days_of_week': {'key': 'daysOfWeek', 'type': '[str]'}, } def __init__( self, *, - start_date: Optional[str] = None, - end_date: Optional[str] = None, + days_of_week: List[Union[str, "DaysOfWeek"]], start_time: Optional[str] = None, end_time: Optional[str] = None, - recurrence_values: Optional[List[int]] = None, - **kwargs - ): - super(SuppressionSchedule, self).__init__(**kwargs) - self.start_date = start_date - self.end_date = end_date - self.start_time = start_time - self.end_time = end_time - self.recurrence_values = recurrence_values - - -class ThrottlingInformation(msrest.serialization.Model): - """Optional throttling information for the alert rule. - - :param duration: The required duration (in ISO8601 format) to wait before notifying on the - alert rule again. The time granularity must be in minutes and minimum value is 0 minutes. - :type duration: ~datetime.timedelta - """ - - _attribute_map = { - 'duration': {'key': 'duration', 'type': 'duration'}, - } - - def __init__( - self, - *, - duration: Optional[datetime.timedelta] = None, **kwargs ): - super(ThrottlingInformation, self).__init__(**kwargs) - self.duration = duration + super(WeeklyRecurrence, self).__init__(start_time=start_time, end_time=end_time, **kwargs) + self.recurrence_type = 'Weekly' # type: str + self.days_of_week = days_of_week diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/__init__.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/__init__.py index 101018dc2503..7eb086190441 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/__init__.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/__init__.py @@ -6,16 +6,14 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._action_rules_operations import ActionRulesOperations +from ._alert_processing_rules_operations import AlertProcessingRulesOperations from ._operations import Operations from ._alerts_operations import AlertsOperations from ._smart_groups_operations import SmartGroupsOperations -from ._smart_detector_alert_rules_operations import SmartDetectorAlertRulesOperations __all__ = [ - 'ActionRulesOperations', + 'AlertProcessingRulesOperations', 'Operations', 'AlertsOperations', 'SmartGroupsOperations', - 'SmartDetectorAlertRulesOperations', ] diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_action_rules_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_action_rules_operations.py deleted file mode 100644 index 181be6ee583e..000000000000 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_action_rules_operations.py +++ /dev/null @@ -1,571 +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 typing import TYPE_CHECKING -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat - -from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] - -class ActionRulesOperations(object): - """ActionRulesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.alertsmanagement.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. - """ - - models = _models - - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config - - def list_by_subscription( - self, - target_resource_group=None, # type: Optional[str] - target_resource_type=None, # type: Optional[str] - target_resource=None, # type: Optional[str] - severity=None, # type: Optional[Union[str, "_models.Severity"]] - monitor_service=None, # type: Optional[Union[str, "_models.MonitorService"]] - impacted_scope=None, # type: Optional[str] - description=None, # type: Optional[str] - alert_rule_id=None, # type: Optional[str] - action_group=None, # type: Optional[str] - name=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ActionRulesList"] - """Get all action rule in a given subscription. - - List all action rules of the subscription and given input filters. - - :param target_resource_group: Filter by target resource group name. Default value is select - all. - :type target_resource_group: str - :param target_resource_type: Filter by target resource type. Default value is select all. - :type target_resource_type: str - :param target_resource: Filter by target resource( which is full ARM ID) Default value is - select all. - :type target_resource: str - :param severity: Filter by severity. Default value is select all. - :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity - :param monitor_service: Filter by monitor service which generates the alert instance. Default - value is select all. - :type monitor_service: str or ~azure.mgmt.alertsmanagement.models.MonitorService - :param impacted_scope: filter by impacted/target scope (provide comma separated list for - multiple scopes). The value should be an well constructed ARM id of the scope. - :type impacted_scope: str - :param description: filter by alert rule description. - :type description: str - :param alert_rule_id: filter by alert rule id. - :type alert_rule_id: str - :param action_group: filter by action group configured as part of action rule. - :type action_group: str - :param name: filter by action rule name. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionRulesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.alertsmanagement.models.ActionRulesList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionRulesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-05-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - 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 = {} # type: Dict[str, Any] - if target_resource_group is not None: - query_parameters['targetResourceGroup'] = self._serialize.query("target_resource_group", target_resource_group, 'str') - if target_resource_type is not None: - query_parameters['targetResourceType'] = self._serialize.query("target_resource_type", target_resource_type, 'str') - if target_resource is not None: - query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') - if severity is not None: - query_parameters['severity'] = self._serialize.query("severity", severity, 'str') - if monitor_service is not None: - query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') - if impacted_scope is not None: - query_parameters['impactedScope'] = self._serialize.query("impacted_scope", impacted_scope, 'str') - if description is not None: - query_parameters['description'] = self._serialize.query("description", description, 'str') - if alert_rule_id is not None: - query_parameters['alertRuleId'] = self._serialize.query("alert_rule_id", alert_rule_id, 'str') - if action_group is not None: - query_parameters['actionGroup'] = self._serialize.query("action_group", action_group, 'str') - if name is not None: - query_parameters['name'] = self._serialize.query("name", name, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ActionRulesList', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/actionRules'} # type: ignore - - def list_by_resource_group( - self, - resource_group_name, # type: str - target_resource_group=None, # type: Optional[str] - target_resource_type=None, # type: Optional[str] - target_resource=None, # type: Optional[str] - severity=None, # type: Optional[Union[str, "_models.Severity"]] - monitor_service=None, # type: Optional[Union[str, "_models.MonitorService"]] - impacted_scope=None, # type: Optional[str] - description=None, # type: Optional[str] - alert_rule_id=None, # type: Optional[str] - action_group=None, # type: Optional[str] - name=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ActionRulesList"] - """Get all action rules created in a resource group. - - List all action rules of the subscription, created in given resource group and given input - filters. - - :param resource_group_name: Resource group name where the resource is created. - :type resource_group_name: str - :param target_resource_group: Filter by target resource group name. Default value is select - all. - :type target_resource_group: str - :param target_resource_type: Filter by target resource type. Default value is select all. - :type target_resource_type: str - :param target_resource: Filter by target resource( which is full ARM ID) Default value is - select all. - :type target_resource: str - :param severity: Filter by severity. Default value is select all. - :type severity: str or ~azure.mgmt.alertsmanagement.models.Severity - :param monitor_service: Filter by monitor service which generates the alert instance. Default - value is select all. - :type monitor_service: str or ~azure.mgmt.alertsmanagement.models.MonitorService - :param impacted_scope: filter by impacted/target scope (provide comma separated list for - multiple scopes). The value should be an well constructed ARM id of the scope. - :type impacted_scope: str - :param description: filter by alert rule description. - :type description: str - :param alert_rule_id: filter by alert rule id. - :type alert_rule_id: str - :param action_group: filter by action group configured as part of action rule. - :type action_group: str - :param name: filter by action rule name. - :type name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ActionRulesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.alertsmanagement.models.ActionRulesList] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionRulesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-05-preview" - accept = "application/json" - - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - 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'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if target_resource_group is not None: - query_parameters['targetResourceGroup'] = self._serialize.query("target_resource_group", target_resource_group, 'str') - if target_resource_type is not None: - query_parameters['targetResourceType'] = self._serialize.query("target_resource_type", target_resource_type, 'str') - if target_resource is not None: - query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') - if severity is not None: - query_parameters['severity'] = self._serialize.query("severity", severity, 'str') - if monitor_service is not None: - query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') - if impacted_scope is not None: - query_parameters['impactedScope'] = self._serialize.query("impacted_scope", impacted_scope, 'str') - if description is not None: - query_parameters['description'] = self._serialize.query("description", description, 'str') - if alert_rule_id is not None: - query_parameters['alertRuleId'] = self._serialize.query("alert_rule_id", alert_rule_id, 'str') - if action_group is not None: - query_parameters['actionGroup'] = self._serialize.query("action_group", action_group, 'str') - if name is not None: - query_parameters['name'] = self._serialize.query("name", name, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize('ActionRulesList', pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponse, response) - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules'} # type: ignore - - def get_by_name( - self, - resource_group_name, # type: str - action_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionRule" - """Get action rule by name. - - Get a specific action rule. - - :param resource_group_name: Resource group name where the resource is created. - :type resource_group_name: str - :param action_rule_name: The name of action rule that needs to be fetched. - :type action_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionRule, or the result of cls(response) - :rtype: ~azure.mgmt.alertsmanagement.models.ActionRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-05-preview" - accept = "application/json" - - # Construct URL - url = self.get_by_name.metadata['url'] # type: ignore - 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'), - 'actionRuleName': self._serialize.url("action_rule_name", action_rule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) - deserialized = self._deserialize('ActionRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{actionRuleName}'} # type: ignore - - def create_update( - self, - resource_group_name, # type: str - action_rule_name, # type: str - action_rule, # type: "_models.ActionRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionRule" - """Create/update an action rule. - - Creates/Updates a specific action rule. - - :param resource_group_name: Resource group name where the resource is created. - :type resource_group_name: str - :param action_rule_name: The name of action rule that needs to be created/updated. - :type action_rule_name: str - :param action_rule: action rule to be created/updated. - :type action_rule: ~azure.mgmt.alertsmanagement.models.ActionRule - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionRule, or the result of cls(response) - :rtype: ~azure.mgmt.alertsmanagement.models.ActionRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-05-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_update.metadata['url'] # type: ignore - 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'), - 'actionRuleName': self._serialize.url("action_rule_name", action_rule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_rule, 'ActionRule') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) - deserialized = self._deserialize('ActionRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - create_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{actionRuleName}'} # type: ignore - - def delete( - self, - resource_group_name, # type: str - action_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> bool - """Delete action rule. - - Deletes a given action rule. - - :param resource_group_name: Resource group name where the resource is created. - :type resource_group_name: str - :param action_rule_name: The name that needs to be deleted. - :type action_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType[bool] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-05-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - 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'), - 'actionRuleName': self._serialize.url("action_rule_name", action_rule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) - deserialized = self._deserialize('bool', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{actionRuleName}'} # type: ignore - - def update( - self, - resource_group_name, # type: str - action_rule_name, # type: str - action_rule_patch, # type: "_models.PatchObject" - **kwargs # type: Any - ): - # type: (...) -> "_models.ActionRule" - """Patch action rule. - - Update enabled flag and/or tags for the given action rule. - - :param resource_group_name: Resource group name where the resource is created. - :type resource_group_name: str - :param action_rule_name: The name that needs to be updated. - :type action_rule_name: str - :param action_rule_patch: Parameters supplied to the operation. - :type action_rule_patch: ~azure.mgmt.alertsmanagement.models.PatchObject - :keyword callable cls: A custom type or function that will be passed the direct response - :return: ActionRule, or the result of cls(response) - :rtype: ~azure.mgmt.alertsmanagement.models.ActionRule - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-05-05-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - 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'), - 'actionRuleName': self._serialize.url("action_rule_name", action_rule_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_rule_patch, 'PatchObject') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - response_headers = {} - response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) - deserialized = self._deserialize('ActionRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{actionRuleName}'} # type: ignore diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_smart_detector_alert_rules_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alert_processing_rules_operations.py similarity index 66% rename from sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_smart_detector_alert_rules_operations.py rename to sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alert_processing_rules_operations.py index 0eb0820bf1f7..9b70987c5d5e 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_smart_detector_alert_rules_operations.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alert_processing_rules_operations.py @@ -23,8 +23,8 @@ T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -class SmartDetectorAlertRulesOperations(object): - """SmartDetectorAlertRulesOperations operations. +class AlertProcessingRulesOperations(object): + """AlertProcessingRulesOperations operations. You should not instantiate this class directly. Instead, you should create a Client instance that instantiates it for you and attaches it as an attribute. @@ -45,27 +45,24 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config - def list( + def list_by_subscription( self, - expand_detector=None, # type: Optional[bool] **kwargs # type: Any ): - # type: (...) -> Iterable["_models.AlertRulesList"] - """List all the existing Smart Detector alert rules within the subscription. + # type: (...) -> Iterable["_models.AlertProcessingRulesList"] + """List all alert processing rules in a subscription. - :param expand_detector: Indicates if Smart Detector should be expanded. - :type expand_detector: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRulesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.alertsmanagement.models.AlertRulesList] + :return: An iterator like instance of either AlertProcessingRulesList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.alertsmanagement.models.AlertProcessingRulesList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRulesList"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertProcessingRulesList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" + api_version = "2021-08-08-preview" accept = "application/json" def prepare_request(next_link=None): @@ -75,7 +72,7 @@ def prepare_request(next_link=None): if not next_link: # Construct URL - url = self.list.metadata['url'] # type: ignore + url = self.list_by_subscription.metadata['url'] # type: ignore path_format_arguments = { 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), } @@ -83,8 +80,6 @@ def prepare_request(next_link=None): # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand_detector is not None: - query_parameters['expandDetector'] = self._serialize.query("expand_detector", expand_detector, 'bool') request = self._client.get(url, query_parameters, header_parameters) else: @@ -94,7 +89,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = self._deserialize('AlertRulesList', pipeline_response) + deserialized = self._deserialize('AlertProcessingRulesList', pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -107,7 +102,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.SmartDetectorErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -116,32 +111,29 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.alertsManagement/smartDetectorAlertRules'} # type: ignore + list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/actionRules'} # type: ignore def list_by_resource_group( self, resource_group_name, # type: str - expand_detector=None, # type: Optional[bool] **kwargs # type: Any ): - # type: (...) -> Iterable["_models.AlertRulesList"] - """List all the existing Smart Detector alert rules within the subscription and resource group. + # type: (...) -> Iterable["_models.AlertProcessingRulesList"] + """List all alert processing rules in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: Resource group name where the resource is created. :type resource_group_name: str - :param expand_detector: Indicates if Smart Detector should be expanded. - :type expand_detector: bool :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRulesList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.alertsmanagement.models.AlertRulesList] + :return: An iterator like instance of either AlertProcessingRulesList or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.alertsmanagement.models.AlertProcessingRulesList] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRulesList"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertProcessingRulesList"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" + api_version = "2021-08-08-preview" accept = "application/json" def prepare_request(next_link=None): @@ -160,8 +152,6 @@ def prepare_request(next_link=None): # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand_detector is not None: - query_parameters['expandDetector'] = self._serialize.query("expand_detector", expand_detector, 'bool') request = self._client.get(url, query_parameters, header_parameters) else: @@ -171,7 +161,7 @@ def prepare_request(next_link=None): return request def extract_data(pipeline_response): - deserialized = self._deserialize('AlertRulesList', pipeline_response) + deserialized = self._deserialize('AlertProcessingRulesList', pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -184,7 +174,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.SmartDetectorErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -193,51 +183,47 @@ def get_next(next_link=None): return ItemPaged( get_next, extract_data ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules'} # type: ignore + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules'} # type: ignore - def get( + def get_by_name( self, resource_group_name, # type: str - alert_rule_name, # type: str - expand_detector=None, # type: Optional[bool] + alert_processing_rule_name, # type: str **kwargs # type: Any ): - # type: (...) -> "_models.AlertRule" - """Get a specific Smart Detector alert rule. + # type: (...) -> "_models.AlertProcessingRule" + """Get an alert processing rule by name. - :param resource_group_name: The name of the resource group. + :param resource_group_name: Resource group name where the resource is created. :type resource_group_name: str - :param alert_rule_name: The name of the alert rule. - :type alert_rule_name: str - :param expand_detector: Indicates if Smart Detector should be expanded. - :type expand_detector: bool + :param alert_processing_rule_name: The name of the alert processing rule that needs to be + fetched. + :type alert_processing_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRule, or the result of cls(response) - :rtype: ~azure.mgmt.alertsmanagement.models.AlertRule + :return: AlertProcessingRule, or the result of cls(response) + :rtype: ~azure.mgmt.alertsmanagement.models.AlertProcessingRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRule"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertProcessingRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" + api_version = "2021-08-08-preview" accept = "application/json" # Construct URL - url = self.get.metadata['url'] # type: ignore + url = self.get_by_name.metadata['url'] # type: ignore 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'), - 'alertRuleName': self._serialize.url("alert_rule_name", alert_rule_name, 'str'), + 'alertProcessingRuleName': self._serialize.url("alert_processing_rule_name", alert_processing_rule_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # type: Dict[str, Any] query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if expand_detector is not None: - query_parameters['expandDetector'] = self._serialize.query("expand_detector", expand_detector, 'bool') # Construct headers header_parameters = {} # type: Dict[str, Any] @@ -249,44 +235,47 @@ def get( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.SmartDetectorErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AlertRule', pipeline_response) + response_headers = {} + response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) + deserialized = self._deserialize('AlertProcessingRule', pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, response_headers) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} # type: ignore + get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}'} # type: ignore def create_or_update( self, resource_group_name, # type: str - alert_rule_name, # type: str - parameters, # type: "_models.AlertRule" + alert_processing_rule_name, # type: str + alert_processing_rule, # type: "_models.AlertProcessingRule" **kwargs # type: Any ): - # type: (...) -> "_models.AlertRule" - """Create or update a Smart Detector alert rule. + # type: (...) -> "_models.AlertProcessingRule" + """Create or update an alert processing rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: Resource group name where the resource is created. :type resource_group_name: str - :param alert_rule_name: The name of the alert rule. - :type alert_rule_name: str - :param parameters: Parameters supplied to the operation. - :type parameters: ~azure.mgmt.alertsmanagement.models.AlertRule + :param alert_processing_rule_name: The name of the alert processing rule that needs to be + created/updated. + :type alert_processing_rule_name: str + :param alert_processing_rule: Alert processing rule to be created/updated. + :type alert_processing_rule: ~azure.mgmt.alertsmanagement.models.AlertProcessingRule :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRule, or the result of cls(response) - :rtype: ~azure.mgmt.alertsmanagement.models.AlertRule + :return: AlertProcessingRule, or the result of cls(response) + :rtype: ~azure.mgmt.alertsmanagement.models.AlertProcessingRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRule"] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertProcessingRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" + api_version = "2021-08-08-preview" content_type = kwargs.pop("content_type", "application/json") accept = "application/json" @@ -295,7 +284,7 @@ def create_or_update( 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'), - 'alertRuleName': self._serialize.url("alert_rule_name", alert_rule_name, 'str'), + 'alertProcessingRuleName': self._serialize.url("alert_processing_rule_name", alert_processing_rule_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -309,7 +298,7 @@ def create_or_update( header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AlertRule') + body_content = self._serialize.body(alert_processing_rule, 'AlertProcessingRule') body_content_kwargs['content'] = body_content request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) @@ -317,57 +306,57 @@ def create_or_update( if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.SmartDetectorErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('AlertRule', pipeline_response) + response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) + deserialized = self._deserialize('AlertProcessingRule', pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('AlertRule', pipeline_response) + response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) + deserialized = self._deserialize('AlertProcessingRule', pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} # type: ignore + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}'} # type: ignore - def patch( + def delete( self, resource_group_name, # type: str - alert_rule_name, # type: str - parameters, # type: "_models.AlertRulePatchObject" + alert_processing_rule_name, # type: str **kwargs # type: Any ): - # type: (...) -> "_models.AlertRule" - """Patch a specific Smart Detector alert rule. + # type: (...) -> None + """Delete an alert processing rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: Resource group name where the resource is created. :type resource_group_name: str - :param alert_rule_name: The name of the alert rule. - :type alert_rule_name: str - :param parameters: Parameters supplied to the operation. - :type parameters: ~azure.mgmt.alertsmanagement.models.AlertRulePatchObject + :param alert_processing_rule_name: The name of the alert processing rule that needs to be + deleted. + :type alert_processing_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AlertRule, or the result of cls(response) - :rtype: ~azure.mgmt.alertsmanagement.models.AlertRule + :return: None, or the result of cls(response) + :rtype: None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRule"] + cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - content_type = kwargs.pop("content_type", "application/json") + api_version = "2021-08-08-preview" accept = "application/json" # Construct URL - url = self.patch.metadata['url'] # type: ignore + url = self.delete.metadata['url'] # type: ignore 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'), - 'alertRuleName': self._serialize.url("alert_rule_name", alert_rule_name, 'str'), + 'alertProcessingRuleName': self._serialize.url("alert_processing_rule_name", alert_processing_rule_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -377,61 +366,65 @@ def patch( # Construct headers header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AlertRulePatchObject') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.SmartDetectorErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AlertRule', pipeline_response) + response_headers = {} + if response.status_code == 200: + response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) + + if response.status_code == 204: + response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, None, response_headers) - return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} # type: ignore + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}'} # type: ignore - def delete( + def update( self, resource_group_name, # type: str - alert_rule_name, # type: str + alert_processing_rule_name, # type: str + alert_processing_rule_patch, # type: "_models.PatchObject" **kwargs # type: Any ): - # type: (...) -> None - """Delete an existing Smart Detector alert rule. + # type: (...) -> "_models.AlertProcessingRule" + """Enable, disable, or update tags for an alert processing rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: Resource group name where the resource is created. :type resource_group_name: str - :param alert_rule_name: The name of the alert rule. - :type alert_rule_name: str + :param alert_processing_rule_name: The name that needs to be updated. + :type alert_processing_rule_name: str + :param alert_processing_rule_patch: Parameters supplied to the operation. + :type alert_processing_rule_patch: ~azure.mgmt.alertsmanagement.models.PatchObject :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) - :rtype: None + :return: AlertProcessingRule, or the result of cls(response) + :rtype: ~azure.mgmt.alertsmanagement.models.AlertProcessingRule :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[None] + cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertProcessingRule"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" + api_version = "2021-08-08-preview" + content_type = kwargs.pop("content_type", "application/json") accept = "application/json" # Construct URL - url = self.delete.metadata['url'] # type: ignore + url = self.update.metadata['url'] # type: ignore 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'), - 'alertRuleName': self._serialize.url("alert_rule_name", alert_rule_name, 'str'), + 'alertProcessingRuleName': self._serialize.url("alert_processing_rule_name", alert_processing_rule_name, 'str'), } url = self._client.format_url(url, **path_format_arguments) @@ -441,18 +434,27 @@ def delete( # Construct headers header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - request = self._client.delete(url, query_parameters, header_parameters) + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(alert_processing_rule_patch, 'PatchObject') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 204]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.SmartDetectorErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + response_headers = {} + response_headers['x-ms-request-id']=self._deserialize('str', response.headers.get('x-ms-request-id')) + deserialized = self._deserialize('AlertProcessingRule', pipeline_response) + if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, response_headers) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} # type: ignore + return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}'} # type: ignore diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alerts_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alerts_operations.py index a9a11f009898..ee268ec49a06 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alerts_operations.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alerts_operations.py @@ -86,7 +86,8 @@ def meta_data( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertsMetaData', pipeline_response) @@ -111,7 +112,7 @@ def get_all( include_egress_config=None, # type: Optional[bool] page_count=None, # type: Optional[int] sort_by=None, # type: Optional[Union[str, "_models.AlertsSortByFields"]] - sort_order=None, # type: Optional[Union[str, "_models.Enum11"]] + sort_order=None, # type: Optional[Union[str, "_models.Enum12"]] select=None, # type: Optional[str] time_range=None, # type: Optional[Union[str, "_models.TimeRange"]] custom_time_range=None, # type: Optional[str] @@ -153,23 +154,23 @@ def get_all( :param page_count: Determines number of alerts returned per page in response. Permissible value is between 1 to 250. When the "includeContent" filter is selected, maximum value allowed is 25. Default value is 25. - :type page_count: int + :type page_count: long :param sort_by: Sort the query results by input field, Default value is 'lastModifiedDateTime'. :type sort_by: str or ~azure.mgmt.alertsmanagement.models.AlertsSortByFields :param sort_order: Sort the query results order in either ascending or descending. Default value is 'desc' for time fields and 'asc' for others. - :type sort_order: str or ~azure.mgmt.alertsmanagement.models.Enum11 + :type sort_order: str or ~azure.mgmt.alertsmanagement.models.Enum12 :param select: This filter allows to selection of the fields(comma separated) which would be part of the essential section. This would allow to project only the required fields rather than getting entire content. Default is to fetch all the fields in the essentials section. :type select: str :param time_range: Filter by time range by below listed values. Default value is 1 day. :type time_range: str or ~azure.mgmt.alertsmanagement.models.TimeRange - :param custom_time_range: Filter by custom time range in the format :code:``/:code:`` where time is in (ISO-8601 format)'. Permissible values is within 30 - days from query time. Either timeRange or customTimeRange could be used but not both. Default - is none. + :param custom_time_range: Filter by custom time range in the format + :code:``/:code:`` where time is in (ISO-8601 format)'. Permissible + values is within 30 days from query time. Either timeRange or customTimeRange could be used + but not both. Default is none. :type custom_time_range: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertsList or the result of cls(response) @@ -221,7 +222,7 @@ def prepare_request(next_link=None): if include_egress_config is not None: query_parameters['includeEgressConfig'] = self._serialize.query("include_egress_config", include_egress_config, 'bool') if page_count is not None: - query_parameters['pageCount'] = self._serialize.query("page_count", page_count, 'int') + query_parameters['pageCount'] = self._serialize.query("page_count", page_count, 'long') if sort_by is not None: query_parameters['sortBy'] = self._serialize.query("sort_by", sort_by, 'str') if sort_order is not None: @@ -255,7 +256,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -313,7 +314,7 @@ def get_by_id( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Alert', pipeline_response) @@ -373,7 +374,7 @@ def change_state( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Alert', pipeline_response) @@ -430,7 +431,7 @@ def get_history( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertModification', pipeline_response) @@ -490,10 +491,10 @@ def get_summary( :type alert_rule: str :param time_range: Filter by time range by below listed values. Default value is 1 day. :type time_range: str or ~azure.mgmt.alertsmanagement.models.TimeRange - :param custom_time_range: Filter by custom time range in the format :code:``/:code:`` where time is in (ISO-8601 format)'. Permissible values is within 30 - days from query time. Either timeRange or customTimeRange could be used but not both. Default - is none. + :param custom_time_range: Filter by custom time range in the format + :code:``/:code:`` where time is in (ISO-8601 format)'. Permissible + values is within 30 days from query time. Either timeRange or customTimeRange could be used + but not both. Default is none. :type custom_time_range: str :keyword callable cls: A custom type or function that will be passed the direct response :return: AlertsSummary, or the result of cls(response) @@ -552,7 +553,7 @@ def get_summary( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertsSummary', pipeline_response) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_operations.py index 9c6e8d4ebc2e..db221ede3477 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_operations.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_operations.py @@ -98,8 +98,9 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_smart_groups_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_smart_groups_operations.py index 36ca85cbb1c7..0909cb085cae 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_smart_groups_operations.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_smart_groups_operations.py @@ -57,7 +57,7 @@ def get_all( time_range=None, # type: Optional[Union[str, "_models.TimeRange"]] page_count=None, # type: Optional[int] sort_by=None, # type: Optional[Union[str, "_models.SmartGroupsSortByFields"]] - sort_order=None, # type: Optional[Union[str, "_models.Enum11"]] + sort_order=None, # type: Optional[Union[str, "_models.Enum12"]] **kwargs # type: Any ): # type: (...) -> Iterable["_models.SmartGroupsList"] @@ -88,13 +88,13 @@ def get_all( :param page_count: Determines number of alerts returned per page in response. Permissible value is between 1 to 250. When the "includeContent" filter is selected, maximum value allowed is 25. Default value is 25. - :type page_count: int + :type page_count: long :param sort_by: Sort the query results by input field. Default value is sort by 'lastModifiedDateTime'. :type sort_by: str or ~azure.mgmt.alertsmanagement.models.SmartGroupsSortByFields :param sort_order: Sort the query results order in either ascending or descending. Default value is 'desc' for time fields and 'asc' for others. - :type sort_order: str or ~azure.mgmt.alertsmanagement.models.Enum11 + :type sort_order: str or ~azure.mgmt.alertsmanagement.models.Enum12 :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SmartGroupsList or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.alertsmanagement.models.SmartGroupsList] @@ -139,7 +139,7 @@ def prepare_request(next_link=None): if time_range is not None: query_parameters['timeRange'] = self._serialize.query("time_range", time_range, 'str') if page_count is not None: - query_parameters['pageCount'] = self._serialize.query("page_count", page_count, 'int') + query_parameters['pageCount'] = self._serialize.query("page_count", page_count, 'long') if sort_by is not None: query_parameters['sortBy'] = self._serialize.query("sort_by", sort_by, 'str') if sort_order is not None: @@ -167,7 +167,7 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponseAutoGenerated2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) @@ -225,7 +225,7 @@ def get_by_id( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -287,7 +287,7 @@ def change_state( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} @@ -346,7 +346,7 @@ def get_history( if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.ErrorResponseAutoGenerated2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SmartGroupModification', pipeline_response)