diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/_meta.json b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/_meta.json new file mode 100644 index 000000000000..3bc71d8b92b0 --- /dev/null +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/_meta.json @@ -0,0 +1,11 @@ +{ + "autorest": "3.7.2", + "use": [ + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" + ], + "commit": "1197aec6f7a9ef9a5a61891b3004b213f6f3ee70", + "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 --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/alertsmanagement/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/__init__.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/__init__.py index 067104083664..d2d4b9e0cb48 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/__init__.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AlertsManagementClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() 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..cb59ddb74d8c 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 @@ -6,73 +6,86 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import AlertsManagementClientConfiguration +from .operations import AlertProcessingRulesOperations, AlertsOperations, Operations, SmartGroupsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential -from ._configuration import AlertsManagementClientConfiguration -from .operations import ActionRulesOperations -from .operations import Operations -from .operations import AlertsOperations -from .operations import SmartGroupsOperations -from .operations import SmartDetectorAlertRulesOperations -from . import models - - -class AlertsManagementClient(object): +class AlertsManagementClient: """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. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AlertsManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AlertsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.alert_processing_rules = AlertProcessingRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.smart_groups = SmartGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ - self.action_rules = ActionRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - 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) + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_configuration.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_configuration.py index 23526df8aa3b..d70f0b109363 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_configuration.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class AlertsManagementClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(AlertsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(AlertsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -67,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) 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..5f87d332633a --- /dev/null +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_metadata.json @@ -0,0 +1,105 @@ +{ + "chosen_version": "", + "total_api_version_list": ["2019-05-05-preview", "2021-08-08"], + "client": { + "name": "AlertsManagementClient", + "filename": "_alerts_management_client", + "description": "AlertsManagement Client.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": 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\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"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\"]}}}" + }, + "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=\"https://management.azure.com\", # type: 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: str = \"https://management.azure.com\",", + "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_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"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\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"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/_patch.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_vendor.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) 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/__init__.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/__init__.py index 3f6a5e109ff2..f3b3facc1871 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/__init__.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/__init__.py @@ -8,3 +8,8 @@ from ._alerts_management_client import AlertsManagementClient __all__ = ['AlertsManagementClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() 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..017df5d8fb43 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 @@ -6,70 +6,86 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import AlertsManagementClientConfiguration +from .operations import AlertProcessingRulesOperations, AlertsOperations, Operations, SmartGroupsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import AlertsManagementClientConfiguration -from .operations import ActionRulesOperations -from .operations import Operations -from .operations import AlertsOperations -from .operations import SmartGroupsOperations -from .operations import SmartDetectorAlertRulesOperations -from .. import models - - -class AlertsManagementClient(object): +class AlertsManagementClient: """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. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AlertsManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AlertsManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.alert_processing_rules = AlertProcessingRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.alerts = AlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.smart_groups = SmartGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ - self.action_rules = ActionRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.alerts = AlertsOperations( - 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) + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_configuration.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_configuration.py index b2c7d5008a66..936b2868c880 100644 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_configuration.py +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AlertsManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(AlertsManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -63,4 +63,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_patch.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file 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/_alert_processing_rules_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alert_processing_rules_operations.py new file mode 100644 index 000000000000..552f329bdb80 --- /dev/null +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_alert_processing_rules_operations.py @@ -0,0 +1,431 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +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 +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._alert_processing_rules_operations import build_create_or_update_request, build_delete_request, build_get_by_name_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +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. + + :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 + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> AsyncIterable["_models.AlertProcessingRulesList"]: + """List all alert processing rules in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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.AlertProcessingRulesList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AlertProcessingRulesList", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + 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 + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.AlertProcessingRulesList"]: + """List all alert processing rules in a resource group. + + :param resource_group_name: Resource group name where the resource is created. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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.AlertProcessingRulesList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("AlertProcessingRulesList", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + 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 + + @distributed_trace_async + async def get_by_name( + self, + resource_group_name: str, + alert_processing_rule_name: str, + **kwargs: Any + ) -> "_models.AlertProcessingRule": + """Get an alert processing rule by name. + + :param resource_group_name: Resource group name where the resource is created. + :type resource_group_name: str + :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: 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.AlertProcessingRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_by_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + alert_processing_rule_name=alert_processing_rule_name, + template_url=self.get_by_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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.failsafe_deserialize(_models.ErrorResponse, pipeline_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, deserialized, response_headers) + + return deserialized + + get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}'} # type: ignore + + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + 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: Resource group name where the resource is created. + :type resource_group_name: str + :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: 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.AlertProcessingRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(alert_processing_rule, 'AlertProcessingRule') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + alert_processing_rule_name=alert_processing_rule_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + 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: + 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, response_headers) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}'} # type: ignore + + + @distributed_trace_async + async def delete( + self, + resource_group_name: str, + alert_processing_rule_name: str, + **kwargs: Any + ) -> None: + """Delete an alert processing rule. + + :param resource_group_name: Resource group name where the resource is created. + :type resource_group_name: str + :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: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + alert_processing_rule_name=alert_processing_rule_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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, None, response_headers) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}'} # type: ignore + + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + 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: Resource group name where the resource is created. + :type resource_group_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: 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.AlertProcessingRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(alert_processing_rule_patch, 'PatchObject') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + alert_processing_rule_name=alert_processing_rule_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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.failsafe_deserialize(_models.ErrorResponse, pipeline_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, deserialized, response_headers) + + 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..b25454adbf82 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools 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.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._alerts_operations import build_change_state_request, build_get_all_request, build_get_by_id_request, build_get_history_request, build_get_summary_request, build_meta_data_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,10 +46,11 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async 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. @@ -60,28 +66,22 @@ async def meta_data( 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.meta_data.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['identifier'] = self._serialize.query("identifier", identifier, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_meta_data_request( + identifier=identifier, + template_url=self.meta_data.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertsMetaData', pipeline_response) @@ -89,8 +89,11 @@ async def meta_data( return cls(pipeline_response, deserialized, {}) return deserialized + meta_data.metadata = {'url': '/providers/Microsoft.AlertsManagement/alertsMetaData'} # type: ignore + + @distributed_trace def get_all( self, target_resource: Optional[str] = None, @@ -106,11 +109,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.SortOrder"]] = 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 +150,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.SortOrder :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) @@ -175,68 +178,63 @@ def get_all( 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.get_all.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 is not None: - query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') - if target_resource_type is not None: - query_parameters['targetResourceType'] = self._serialize.query("target_resource_type", target_resource_type, 'str') - if target_resource_group is not None: - query_parameters['targetResourceGroup'] = self._serialize.query("target_resource_group", target_resource_group, 'str') - if monitor_service is not None: - query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') - if monitor_condition is not None: - query_parameters['monitorCondition'] = self._serialize.query("monitor_condition", monitor_condition, 'str') - if severity is not None: - query_parameters['severity'] = self._serialize.query("severity", severity, 'str') - if alert_state is not None: - query_parameters['alertState'] = self._serialize.query("alert_state", alert_state, 'str') - if alert_rule is not None: - query_parameters['alertRule'] = self._serialize.query("alert_rule", alert_rule, 'str') - if smart_group_id is not None: - query_parameters['smartGroupId'] = self._serialize.query("smart_group_id", smart_group_id, 'str') - if include_context is not None: - query_parameters['includeContext'] = self._serialize.query("include_context", include_context, 'bool') - 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') - if sort_by is not None: - query_parameters['sortBy'] = self._serialize.query("sort_by", sort_by, 'str') - if sort_order is not None: - query_parameters['sortOrder'] = self._serialize.query("sort_order", sort_order, 'str') - if select is not None: - query_parameters['select'] = self._serialize.query("select", select, 'str') - if time_range is not None: - query_parameters['timeRange'] = self._serialize.query("time_range", time_range, 'str') - if custom_time_range is not None: - query_parameters['customTimeRange'] = self._serialize.query("custom_time_range", custom_time_range, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_all_request( + subscription_id=self._config.subscription_id, + target_resource=target_resource, + target_resource_type=target_resource_type, + target_resource_group=target_resource_group, + monitor_service=monitor_service, + monitor_condition=monitor_condition, + severity=severity, + alert_state=alert_state, + alert_rule=alert_rule, + smart_group_id=smart_group_id, + include_context=include_context, + include_egress_config=include_egress_config, + page_count=page_count, + sort_by=sort_by, + sort_order=sort_order, + select=select, + time_range=time_range, + custom_time_range=custom_time_range, + template_url=self.get_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_all_request( + subscription_id=self._config.subscription_id, + target_resource=target_resource, + target_resource_type=target_resource_type, + target_resource_group=target_resource_group, + monitor_service=monitor_service, + monitor_condition=monitor_condition, + severity=severity, + alert_state=alert_state, + alert_rule=alert_rule, + smart_group_id=smart_group_id, + include_context=include_context, + include_egress_config=include_egress_config, + page_count=page_count, + sort_by=sort_by, + sort_order=sort_order, + select=select, + time_range=time_range, + custom_time_range=custom_time_range, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AlertsList', pipeline_response) + deserialized = self._deserialize("AlertsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -249,21 +247,23 @@ 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) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_all.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts'} # type: ignore + @distributed_trace_async async def get_by_id( self, alert_id: str, - **kwargs + **kwargs: Any ) -> "_models.Alert": """Get a specific alert. @@ -281,32 +281,22 @@ async def get_by_id( 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_id.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'alertId': self._serialize.url("alert_id", alert_id, '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 = build_get_by_id_request( + subscription_id=self._config.subscription_id, + alert_id=alert_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Alert', pipeline_response) @@ -315,13 +305,16 @@ async def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts/{alertId}'} # type: ignore + + @distributed_trace_async 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. @@ -339,33 +332,23 @@ async def change_state( 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.change_state.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'alertId': self._serialize.url("alert_id", alert_id, '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') - query_parameters['newState'] = self._serialize.query("new_state", new_state, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_change_state_request( + subscription_id=self._config.subscription_id, + alert_id=alert_id, + new_state=new_state, + template_url=self.change_state.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(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.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Alert', pipeline_response) @@ -374,12 +357,15 @@ async def change_state( return cls(pipeline_response, deserialized, {}) return deserialized + change_state.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts/{alertId}/changestate'} # type: ignore + + @distributed_trace_async 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). @@ -396,32 +382,22 @@ async def get_history( 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_history.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'alertId': self._serialize.url("alert_id", alert_id, '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 = build_get_history_request( + subscription_id=self._config.subscription_id, + alert_id=alert_id, + template_url=self.get_history.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertModification', pipeline_response) @@ -430,8 +406,11 @@ async def get_history( return cls(pipeline_response, deserialized, {}) return deserialized + get_history.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts/{alertId}/history'} # type: ignore + + @distributed_trace_async async def get_summary( self, groupby: Union[str, "_models.AlertsSummaryGroupByFields"], @@ -446,7 +425,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 +459,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) @@ -495,54 +474,33 @@ async def get_summary( 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_summary.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] - query_parameters['groupby'] = self._serialize.query("groupby", groupby, 'str') - if include_smart_groups_count is not None: - query_parameters['includeSmartGroupsCount'] = self._serialize.query("include_smart_groups_count", include_smart_groups_count, 'bool') - if target_resource is not None: - query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') - if target_resource_type is not None: - query_parameters['targetResourceType'] = self._serialize.query("target_resource_type", target_resource_type, 'str') - if target_resource_group is not None: - query_parameters['targetResourceGroup'] = self._serialize.query("target_resource_group", target_resource_group, 'str') - if monitor_service is not None: - query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') - if monitor_condition is not None: - query_parameters['monitorCondition'] = self._serialize.query("monitor_condition", monitor_condition, 'str') - if severity is not None: - query_parameters['severity'] = self._serialize.query("severity", severity, 'str') - if alert_state is not None: - query_parameters['alertState'] = self._serialize.query("alert_state", alert_state, 'str') - if alert_rule is not None: - query_parameters['alertRule'] = self._serialize.query("alert_rule", alert_rule, 'str') - if time_range is not None: - query_parameters['timeRange'] = self._serialize.query("time_range", time_range, 'str') - if custom_time_range is not None: - query_parameters['customTimeRange'] = self._serialize.query("custom_time_range", custom_time_range, 'str') - 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) + + request = build_get_summary_request( + subscription_id=self._config.subscription_id, + groupby=groupby, + include_smart_groups_count=include_smart_groups_count, + target_resource=target_resource, + target_resource_type=target_resource_type, + target_resource_group=target_resource_group, + monitor_service=monitor_service, + monitor_condition=monitor_condition, + severity=severity, + alert_state=alert_state, + alert_rule=alert_rule, + time_range=time_range, + custom_time_range=custom_time_range, + template_url=self.get_summary.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertsSummary', pipeline_response) @@ -551,4 +509,6 @@ async def get_summary( return cls(pipeline_response, deserialized, {}) return deserialized + get_summary.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alertsSummary'} # type: ignore + 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..59a267f5aa43 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar 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.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,15 +46,17 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs + **kwargs: Any ) -> AsyncIterable["_models.OperationsList"]: """List all operations available through Azure Alerts Management Resource Provider. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.alertsmanagement.models.OperationsList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.alertsmanagement.models.OperationsList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsList"] @@ -57,30 +64,27 @@ def list( 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.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -94,10 +98,12 @@ async def get_next(next_link=None): 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) 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/_smart_detector_alert_rules_operations.py deleted file mode 100644 index 3170a1f68923..000000000000 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/aio/operations/_smart_detector_alert_rules_operations.py +++ /dev/null @@ -1,448 +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 SmartDetectorAlertRulesOperations: - """SmartDetectorAlertRulesOperations 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( - self, - expand_detector: Optional[bool] = None, - **kwargs - ) -> AsyncIterable["_models.AlertRulesList"]: - """List all the existing Smart Detector alert rules within the 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] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRulesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - 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.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] - 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: - 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('AlertRulesList', 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.SmartDetectorErrorResponse, 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.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.alertsManagement/smartDetectorAlertRules'} # 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. - - :param resource_group_name: The name of the resource group. - :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] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRulesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - 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] - 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: - 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('AlertRulesList', 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.SmartDetectorErrorResponse, 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/smartDetectorAlertRules'} # type: ignore - - async def get( - self, - resource_group_name: str, - alert_rule_name: str, - expand_detector: Optional[bool] = None, - **kwargs - ) -> "_models.AlertRule": - """Get a specific Smart Detector alert rule. - - :param resource_group_name: The name of the resource group. - :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 - :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 - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.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'), - } - 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] - 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.SmartDetectorErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AlertRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} # 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. - - :param resource_group_name: The name of the resource group. - :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 - :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 - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRule"] - 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") - accept = "application/json" - - # Construct URL - url = self.create_or_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'), - } - 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(parameters, 'AlertRule') - 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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.SmartDetectorErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('AlertRule', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('AlertRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} # type: ignore - - async def patch( - self, - resource_group_name: str, - alert_rule_name: str, - parameters: "_models.AlertRulePatchObject", - **kwargs - ) -> "_models.AlertRule": - """Patch a specific Smart Detector alert rule. - - :param resource_group_name: The name of the resource group. - :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 - :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 - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRule"] - 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") - accept = "application/json" - - # Construct URL - url = self.patch.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'), - } - 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(parameters, 'AlertRulePatchObject') - 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.SmartDetectorErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AlertRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} # type: ignore - - async def delete( - self, - resource_group_name: str, - alert_rule_name: str, - **kwargs - ) -> None: - """Delete an existing Smart Detector alert rule. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param alert_rule_name: The name of the alert rule. - :type alert_rule_name: str - :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 - :raises: ~azure.core.exceptions.HttpResponseError - """ - 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" - 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'), - 'alertRuleName': self._serialize.url("alert_rule_name", alert_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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.SmartDetectorErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} # type: ignore 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..868b50369617 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 @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools 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.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._smart_groups_operations import build_change_state_request, build_get_all_request, build_get_by_id_request, build_get_history_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def get_all( self, target_resource: Optional[str] = None, @@ -53,8 +59,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.SortOrder"]] = None, + **kwargs: Any ) -> AsyncIterable["_models.SmartGroupsList"]: """Get all Smart Groups within a specified subscription. @@ -83,16 +89,17 @@ 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.SortOrder :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] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.alertsmanagement.models.SmartGroupsList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SmartGroupsList"] @@ -100,56 +107,51 @@ def get_all( 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.get_all.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 is not None: - query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') - 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 monitor_service is not None: - query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') - if monitor_condition is not None: - query_parameters['monitorCondition'] = self._serialize.query("monitor_condition", monitor_condition, 'str') - if severity is not None: - query_parameters['severity'] = self._serialize.query("severity", severity, 'str') - if smart_group_state is not None: - query_parameters['smartGroupState'] = self._serialize.query("smart_group_state", smart_group_state, 'str') - 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') - if sort_by is not None: - query_parameters['sortBy'] = self._serialize.query("sort_by", sort_by, 'str') - if sort_order is not None: - query_parameters['sortOrder'] = self._serialize.query("sort_order", sort_order, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_all_request( + subscription_id=self._config.subscription_id, + target_resource=target_resource, + target_resource_group=target_resource_group, + target_resource_type=target_resource_type, + monitor_service=monitor_service, + monitor_condition=monitor_condition, + severity=severity, + smart_group_state=smart_group_state, + time_range=time_range, + page_count=page_count, + sort_by=sort_by, + sort_order=sort_order, + template_url=self.get_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_all_request( + subscription_id=self._config.subscription_id, + target_resource=target_resource, + target_resource_group=target_resource_group, + target_resource_type=target_resource_type, + monitor_service=monitor_service, + monitor_condition=monitor_condition, + severity=severity, + smart_group_state=smart_group_state, + time_range=time_range, + page_count=page_count, + sort_by=sort_by, + sort_order=sort_order, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SmartGroupsList', pipeline_response) + deserialized = self._deserialize("SmartGroupsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -162,21 +164,23 @@ 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) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_all.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups'} # type: ignore + @distributed_trace_async async def get_by_id( self, smart_group_id: str, - **kwargs + **kwargs: Any ) -> "_models.SmartGroup": """Get information related to a specific Smart Group. @@ -194,49 +198,43 @@ async def get_by_id( 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_id.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'smartGroupId': self._serialize.url("smart_group_id", smart_group_id, '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 = build_get_by_id_request( + subscription_id=self._config.subscription_id, + smart_group_id=smart_group_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.ErrorResponseAutoGenerated2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_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('SmartGroup', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}'} # type: ignore + + @distributed_trace_async 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. @@ -254,49 +252,43 @@ async def change_state( 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.change_state.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'smartGroupId': self._serialize.url("smart_group_id", smart_group_id, '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') - query_parameters['newState'] = self._serialize.query("new_state", new_state, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_change_state_request( + subscription_id=self._config.subscription_id, + smart_group_id=smart_group_id, + new_state=new_state, + template_url=self.change_state.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(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.ErrorResponseAutoGenerated2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_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('SmartGroup', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + change_state.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}/changeState'} # type: ignore + + @distributed_trace_async 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) . @@ -313,32 +305,22 @@ async def get_history( 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_history.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'smartGroupId': self._serialize.url("smart_group_id", smart_group_id, '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 = build_get_history_request( + subscription_id=self._config.subscription_id, + smart_group_id=smart_group_id, + template_url=self.get_history.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.ErrorResponseAutoGenerated2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SmartGroupModification', pipeline_response) @@ -347,4 +329,6 @@ async def get_history( return cls(pipeline_response, deserialized, {}) return deserialized + get_history.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}/history'} # type: ignore + 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..cd8329477316 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 @@ -6,160 +6,98 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -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 Alert - from ._models_py3 import AlertModification - from ._models_py3 import AlertModificationItem - from ._models_py3 import AlertModificationProperties - 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 ErrorResponse - from ._models_py3 import ErrorResponseAutoGenerated - from ._models_py3 import ErrorResponseAutoGenerated2 - from ._models_py3 import ErrorResponseBody - from ._models_py3 import ErrorResponseBodyAutoGenerated - from ._models_py3 import ErrorResponseBodyAutoGenerated2 - from ._models_py3 import Essentials - from ._models_py3 import ManagedResource - from ._models_py3 import MonitorServiceDetails - from ._models_py3 import MonitorServiceList - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationsList - from ._models_py3 import PatchObject - from ._models_py3 import Resource - from ._models_py3 import Scope - from ._models_py3 import SmartDetectorErrorResponse - 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 -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 Alert # type: ignore - from ._models import AlertModification # type: ignore - from ._models import AlertModificationItem # type: ignore - from ._models import AlertModificationProperties # 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 ErrorResponse # type: ignore - from ._models import ErrorResponseAutoGenerated # type: ignore - from ._models import ErrorResponseAutoGenerated2 # type: ignore - from ._models import ErrorResponseBody # type: ignore - from ._models import ErrorResponseBodyAutoGenerated # type: ignore - from ._models import ErrorResponseBodyAutoGenerated2 # type: ignore - from ._models import Essentials # type: ignore - from ._models import ManagedResource # type: ignore - from ._models import MonitorServiceDetails # type: ignore - from ._models import MonitorServiceList # 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 Resource # type: ignore - from ._models import Scope # type: ignore - from ._models import SmartDetectorErrorResponse # 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_py3 import Action +from ._models_py3 import ActionStatus +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 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 Condition +from ._models_py3 import DailyRecurrence +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseAutoGenerated +from ._models_py3 import ErrorResponseAutoGenerated2 +from ._models_py3 import ErrorResponseBody +from ._models_py3 import ErrorResponseBodyAutoGenerated +from ._models_py3 import ErrorResponseBodyAutoGenerated2 +from ._models_py3 import Essentials +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 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 SystemData +from ._models_py3 import WeeklyRecurrence + from ._alerts_management_client_enums import ( - ActionRuleStatus, - ActionRuleType, + ActionType, AlertModificationEvent, - AlertRuleState, AlertState, AlertsSortByFields, AlertsSummaryGroupByFields, - Enum11, + CreatedByType, + DaysOfWeek, + Field, Identifier, MetadataIdentifier, MonitorCondition, MonitorService, Operator, - ScopeType, + RecurrenceType, Severity, SignalType, SmartGroupModificationEvent, SmartGroupsSortByFields, + SortOrder, State, - SuppressionType, TimeRange, ) __all__ = [ - 'ActionGroup', - 'ActionGroupsInformation', - 'ActionRule', - 'ActionRuleProperties', - 'ActionRulesList', + 'Action', + 'ActionStatus', + '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 +108,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', + 'Field', 'Identifier', 'MetadataIdentifier', 'MonitorCondition', 'MonitorService', 'Operator', - 'ScopeType', + 'RecurrenceType', 'Severity', 'SignalType', 'SmartGroupModificationEvent', 'SmartGroupsSortByFields', + 'SortOrder', '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..dbb89595a273 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 @@ -6,42 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class ActionRuleStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Indicates if the given action rule is enabled or disabled - """ - - ENABLED = "Enabled" - DISABLED = "Disabled" -class ActionRuleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Indicates type of action rule +class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Action that should be applied. """ - SUPPRESSION = "Suppression" - ACTION_GROUP = "ActionGroup" - DIAGNOSTICS = "Diagnostics" + ADD_ACTION_GROUPS = "AddActionGroups" + REMOVE_ALL_ACTION_GROUPS = "RemoveAllActionGroups" -class AlertModificationEvent(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AlertModificationEvent(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Reason for the modification """ @@ -55,14 +32,7 @@ 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)): +class AlertsSortByFields(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NAME = "name" SEVERITY = "severity" @@ -75,7 +45,7 @@ class AlertsSortByFields(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): START_DATE_TIME = "startDateTime" LAST_MODIFIED_DATE_TIME = "lastModifiedDateTime" -class AlertsSummaryGroupByFields(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AlertsSummaryGroupByFields(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SEVERITY = "severity" ALERT_STATE = "alertState" @@ -84,33 +54,65 @@ class AlertsSummaryGroupByFields(with_metaclass(_CaseInsensitiveEnumMeta, str, E SIGNAL_TYPE = "signalType" ALERT_RULE = "alertRule" -class AlertState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AlertState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): NEW = "New" 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. + """ - ASC = "asc" - DESC = "desc" + 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 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)): +class Identifier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MONITOR_SERVICE_LIST = "MonitorServiceList" -class MetadataIdentifier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MetadataIdentifier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Identification of the information to be retrieved by API call """ MONITOR_SERVICE_LIST = "MonitorServiceList" -class MonitorCondition(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MonitorCondition(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): FIRED = "Fired" RESOLVED = "Resolved" -class MonitorService(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MonitorService(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): APPLICATION_INSIGHTS = "Application Insights" ACTIVITY_LOG_ADMINISTRATIVE = "ActivityLog Administrative" @@ -127,8 +129,8 @@ class MonitorService(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): VM_INSIGHTS = "VM Insights" ZABBIX = "Zabbix" -class Operator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """operator for a given condition +class Operator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Operator for a given condition. """ EQUALS = "Equals" @@ -136,15 +138,15 @@ 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)): +class Severity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): SEV0 = "Sev0" SEV1 = "Sev1" @@ -152,7 +154,7 @@ class Severity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SEV3 = "Sev3" SEV4 = "Sev4" -class SignalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SignalType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of signal the alert is based on, which could be metrics, logs or activity logs. """ @@ -160,7 +162,7 @@ class SignalType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): LOG = "Log" UNKNOWN = "Unknown" -class SmartGroupModificationEvent(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SmartGroupModificationEvent(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Reason for the modification """ @@ -169,7 +171,7 @@ class SmartGroupModificationEvent(with_metaclass(_CaseInsensitiveEnumMeta, str, ALERT_ADDED = "AlertAdded" ALERT_REMOVED = "AlertRemoved" -class SmartGroupsSortByFields(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SmartGroupsSortByFields(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ALERTS_COUNT = "alertsCount" STATE = "state" @@ -177,7 +179,12 @@ class SmartGroupsSortByFields(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum START_DATE_TIME = "startDateTime" LAST_MODIFIED_DATE_TIME = "lastModifiedDateTime" -class State(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SortOrder(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + + ASC = "asc" + DESC = "desc" + +class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Smart group state """ @@ -185,17 +192,7 @@ 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)): +class TimeRange(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ONE_H = "1h" ONE_D = "1d" 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 deleted file mode 100644 index d9f76afbd787..000000000000 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/models/_models.py +++ /dev/null @@ -1,1933 +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 azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class ActionRuleProperties(msrest.serialization.Model): - """Action rule properties defining scope, conditions, suppression logic for action rule. - - 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. - - 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 - """ - - _validation = { - 'created_at': {'readonly': True}, - 'last_modified_at': {'readonly': True}, - 'created_by': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - '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'}, - } - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(ActionGroup, self).__init__(**kwargs) - self.type = 'ActionGroup' # type: str - self.action_group_id = kwargs['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, - **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'] - - -class Resource(msrest.serialization.Model): - """An azure resource object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar type: Azure resource type. - :vartype type: str - :ivar name: Azure resource name. - :vartype name: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - - -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. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar type: Azure resource type. - :vartype type: str - :ivar name: Azure resource name. - :vartype name: str - :param properties: Alert property bag. - :type properties: ~azure.mgmt.alertsmanagement.models.AlertProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'AlertProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(Alert, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class AlertModification(Resource): - """Alert Modification details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar type: Azure resource type. - :vartype type: str - :ivar name: Azure resource name. - :vartype name: str - :param properties: Properties of the alert modification item. - :type properties: ~azure.mgmt.alertsmanagement.models.AlertModificationProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'AlertModificationProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertModification, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class AlertModificationItem(msrest.serialization.Model): - """Alert modification item. - - :param modification_event: Reason for the modification. Possible values include: - "AlertCreated", "StateChange", "MonitorConditionChange", "SeverityChange", - "ActionRuleTriggered", "ActionRuleSuppressed", "ActionsTriggered", "ActionsSuppressed", - "ActionsFailed". - :type modification_event: str or ~azure.mgmt.alertsmanagement.models.AlertModificationEvent - :param old_value: Old value. - :type old_value: str - :param new_value: New value. - :type new_value: str - :param modified_at: Modified date and time. - :type modified_at: str - :param modified_by: Modified user details (Principal client name). - :type modified_by: str - :param comments: Modification comments. - :type comments: str - :param description: Description of the modification. - :type description: str - """ - - _attribute_map = { - 'modification_event': {'key': 'modificationEvent', 'type': 'str'}, - 'old_value': {'key': 'oldValue', 'type': 'str'}, - 'new_value': {'key': 'newValue', 'type': 'str'}, - 'modified_at': {'key': 'modifiedAt', 'type': 'str'}, - 'modified_by': {'key': 'modifiedBy', 'type': 'str'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertModificationItem, self).__init__(**kwargs) - self.modification_event = kwargs.get('modification_event', None) - self.old_value = kwargs.get('old_value', None) - self.new_value = kwargs.get('new_value', None) - self.modified_at = kwargs.get('modified_at', None) - self.modified_by = kwargs.get('modified_by', None) - self.comments = kwargs.get('comments', None) - self.description = kwargs.get('description', None) - - -class AlertModificationProperties(msrest.serialization.Model): - """Properties of the alert modification item. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar alert_id: Unique Id of the alert for which the history is being retrieved. - :vartype alert_id: str - :param modifications: Modification details. - :type modifications: list[~azure.mgmt.alertsmanagement.models.AlertModificationItem] - """ - - _validation = { - 'alert_id': {'readonly': True}, - } - - _attribute_map = { - 'alert_id': {'key': 'alertId', 'type': 'str'}, - 'modifications': {'key': 'modifications', 'type': '[AlertModificationItem]'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertModificationProperties, self).__init__(**kwargs) - self.alert_id = None - self.modifications = kwargs.get('modifications', 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: 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. - - :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 location: The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureResource, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.location = kwargs.get('location', "global") - self.tags = kwargs.get('tags', None) - - -class AlertRule(AzureResource): - """The alert rule information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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 location: The resource location. - :type location: str - :param tags: A set of tags. The 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 - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - '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'}, - } - - 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) - - -class AlertRulePatchObject(msrest.serialization.Model): - """The alert rule patch information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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. - :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 - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - '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'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertRulePatchObject, self).__init__(**kwargs) - self.id = None - self.type = None - self.name = None - self.tags = kwargs.get('tags', None) - 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) - - -class AlertRulesList(msrest.serialization.Model): - """List of Smart Detector alert 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. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AlertRule]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertRulesList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class AlertsList(msrest.serialization.Model): - """List the alerts. - - :param next_link: URL to fetch the next set of alerts. - :type next_link: str - :param value: List of alerts. - :type value: list[~azure.mgmt.alertsmanagement.models.Alert] - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Alert]'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertsList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs.get('value', None) - - -class AlertsMetaData(msrest.serialization.Model): - """alert meta data information. - - :param properties: alert meta data property bag. - :type properties: ~azure.mgmt.alertsmanagement.models.AlertsMetaDataProperties - """ - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'AlertsMetaDataProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertsMetaData, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class AlertsMetaDataProperties(msrest.serialization.Model): - """alert meta data property bag. - - You probably want to use the sub-classes and not this class directly. Known - sub-classes are: MonitorServiceList. - - All required parameters must be populated in order to send to Azure. - - :param metadata_identifier: Required. Identification of the information to be retrieved by API - call.Constant filled by server. Possible values include: "MonitorServiceList". - :type metadata_identifier: str or ~azure.mgmt.alertsmanagement.models.MetadataIdentifier - """ - - _validation = { - 'metadata_identifier': {'required': True}, - } - - _attribute_map = { - 'metadata_identifier': {'key': 'metadataIdentifier', 'type': 'str'}, - } - - _subtype_map = { - 'metadata_identifier': {'MonitorServiceList': 'MonitorServiceList'} - } - - def __init__( - self, - **kwargs - ): - super(AlertsMetaDataProperties, self).__init__(**kwargs) - self.metadata_identifier = None # type: Optional[str] - - -class AlertsSummary(Resource): - """Summary of alerts based on the input filters and 'groupby' parameters. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar type: Azure resource type. - :vartype type: str - :ivar name: Azure resource name. - :vartype name: str - :param properties: Group the result set. - :type properties: ~azure.mgmt.alertsmanagement.models.AlertsSummaryGroup - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'AlertsSummaryGroup'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertsSummary, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class AlertsSummaryGroup(msrest.serialization.Model): - """Group the result set. - - :param total: Total count of the result set. - :type total: int - :param smart_groups_count: Total count of the smart groups. - :type smart_groups_count: int - :param groupedby: Name of the field aggregated. - :type groupedby: str - :param values: List of the items. - :type values: list[~azure.mgmt.alertsmanagement.models.AlertsSummaryGroupItem] - """ - - _attribute_map = { - 'total': {'key': 'total', 'type': 'int'}, - 'smart_groups_count': {'key': 'smartGroupsCount', 'type': 'int'}, - 'groupedby': {'key': 'groupedby', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[AlertsSummaryGroupItem]'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertsSummaryGroup, self).__init__(**kwargs) - self.total = kwargs.get('total', None) - self.smart_groups_count = kwargs.get('smart_groups_count', None) - self.groupedby = kwargs.get('groupedby', None) - self.values = kwargs.get('values', None) - - -class AlertsSummaryGroupItem(msrest.serialization.Model): - """Alerts summary group item. - - :param name: Value of the aggregated field. - :type name: str - :param count: Count of the aggregated field. - :type count: int - :param groupedby: Name of the field aggregated. - :type groupedby: str - :param values: List of the items. - :type values: list[~azure.mgmt.alertsmanagement.models.AlertsSummaryGroupItem] - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'int'}, - 'groupedby': {'key': 'groupedby', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[AlertsSummaryGroupItem]'}, - } - - def __init__( - self, - **kwargs - ): - super(AlertsSummaryGroupItem, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.count = kwargs.get('count', None) - self.groupedby = kwargs.get('groupedby', None) - self.values = kwargs.get('values', None) - - -class Condition(msrest.serialization.Model): - """condition to trigger an action rule. - - :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. - :type values: list[str] - """ - - _attribute_map = { - 'operator': {'key': 'operator', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(Condition, self).__init__(**kwargs) - 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 Detector(msrest.serialization.Model): - """The detector information. By default this is not populated, unless it's specified in expandDetector. - - 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] - """ - - _validation = { - 'id': {'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]'}, - } - - 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) - - -class Diagnostics(ActionRuleProperties): - """Action rule with diagnostics 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 - """ - - _validation = { - 'created_at': {'readonly': True}, - 'last_modified_at': {'readonly': True}, - 'created_by': {'readonly': True}, - 'last_modified_by': {'readonly': True}, - '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'}, - } - - def __init__( - self, - **kwargs - ): - super(Diagnostics, self).__init__(**kwargs) - self.type = 'Diagnostics' # type: str - - -class ErrorResponse(msrest.serialization.Model): - """An error response from the service. - - :param error: Details of error response. - :type error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBody - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorResponseAutoGenerated(msrest.serialization.Model): - """An error response from the service. - - :param error: Details of error response. - :type error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBodyAutoGenerated - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBodyAutoGenerated'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseAutoGenerated, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorResponseAutoGenerated2(msrest.serialization.Model): - """An error response from the service. - - :param error: Details of error response. - :type error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBodyAutoGenerated2 - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBodyAutoGenerated2'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseAutoGenerated2, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class ErrorResponseBody(msrest.serialization.Model): - """Details of error response. - - :param code: Error code, intended to be consumed programmatically. - :type code: str - :param message: Description of the error, intended for display in user interface. - :type message: str - :param target: Target of the particular error, for example name of the property. - :type target: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.alertsmanagement.models.ErrorResponseBody] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponseBody]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseBody, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - self.details = kwargs.get('details', None) - - -class ErrorResponseBodyAutoGenerated(msrest.serialization.Model): - """Details of error response. - - :param code: Error code, intended to be consumed programmatically. - :type code: str - :param message: Description of the error, intended for display in user interface. - :type message: str - :param target: Target of the particular error, for example name of the property. - :type target: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.alertsmanagement.models.ErrorResponseBodyAutoGenerated] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponseBodyAutoGenerated]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseBodyAutoGenerated, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - self.details = kwargs.get('details', None) - - -class ErrorResponseBodyAutoGenerated2(msrest.serialization.Model): - """Details of error response. - - :param code: Error code, intended to be consumed programmatically. - :type code: str - :param message: Description of the error, intended for display in user interface. - :type message: str - :param target: Target of the particular error, for example name of the property. - :type target: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.alertsmanagement.models.ErrorResponseBodyAutoGenerated2] - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorResponseBodyAutoGenerated2]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponseBodyAutoGenerated2, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.target = kwargs.get('target', None) - self.details = kwargs.get('details', None) - - -class Essentials(msrest.serialization.Model): - """This object contains consistent fields across different monitor services. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar severity: Severity of alert Sev0 being highest and Sev4 being lowest. Possible values - include: "Sev0", "Sev1", "Sev2", "Sev3", "Sev4". - :vartype severity: str or ~azure.mgmt.alertsmanagement.models.Severity - :ivar signal_type: The type of signal the alert is based on, which could be metrics, logs or - activity logs. Possible values include: "Metric", "Log", "Unknown". - :vartype signal_type: str or ~azure.mgmt.alertsmanagement.models.SignalType - :ivar alert_state: Alert object state, which can be modified by the user. Possible values - include: "New", "Acknowledged", "Closed". - :vartype alert_state: str or ~azure.mgmt.alertsmanagement.models.AlertState - :ivar monitor_condition: Condition of the rule at the monitor service. It represents whether - the underlying conditions have crossed the defined alert rule thresholds. Possible values - include: "Fired", "Resolved". - :vartype monitor_condition: str or ~azure.mgmt.alertsmanagement.models.MonitorCondition - :param target_resource: Target ARM resource, on which alert got created. - :type target_resource: str - :param target_resource_name: Name of the target ARM resource name, on which alert got created. - :type target_resource_name: str - :param target_resource_group: Resource group of target ARM resource, on which alert got - created. - :type target_resource_group: str - :param target_resource_type: Resource type of target ARM resource, on which alert got created. - :type target_resource_type: str - :ivar monitor_service: Monitor service on which the rule(monitor) is set. Possible values - include: "Application Insights", "ActivityLog Administrative", "ActivityLog Security", - "ActivityLog Recommendation", "ActivityLog Policy", "ActivityLog Autoscale", "Log Analytics", - "Nagios", "Platform", "SCOM", "ServiceHealth", "SmartDetector", "VM Insights", "Zabbix". - :vartype monitor_service: str or ~azure.mgmt.alertsmanagement.models.MonitorService - :ivar alert_rule: Rule(monitor) which fired alert instance. Depending on the monitor service, - this would be ARM id or name of the rule. - :vartype alert_rule: str - :ivar source_created_id: Unique Id created by monitor service for each alert instance. This - could be used to track the issue at the monitor service, in case of Nagios, Zabbix, SCOM etc. - :vartype source_created_id: str - :ivar smart_group_id: Unique Id of the smart group. - :vartype smart_group_id: str - :ivar smart_grouping_reason: Verbose reason describing the reason why this alert instance is - added to a smart group. - :vartype smart_grouping_reason: str - :ivar start_date_time: Creation time(ISO-8601 format) of alert instance. - :vartype start_date_time: ~datetime.datetime - :ivar last_modified_date_time: Last modification time(ISO-8601 format) of alert instance. - :vartype last_modified_date_time: ~datetime.datetime - :ivar monitor_condition_resolved_date_time: Resolved time(ISO-8601 format) of alert instance. - This will be updated when monitor service resolves the alert instance because the rule - condition is no longer met. - :vartype monitor_condition_resolved_date_time: ~datetime.datetime - :ivar last_modified_user_name: User who last modified the alert, in case of monitor service - updates user would be 'system', otherwise name of the user. - :vartype last_modified_user_name: str - """ - - _validation = { - 'severity': {'readonly': True}, - 'signal_type': {'readonly': True}, - 'alert_state': {'readonly': True}, - 'monitor_condition': {'readonly': True}, - 'monitor_service': {'readonly': True}, - 'alert_rule': {'readonly': True}, - 'source_created_id': {'readonly': True}, - 'smart_group_id': {'readonly': True}, - 'smart_grouping_reason': {'readonly': True}, - 'start_date_time': {'readonly': True}, - 'last_modified_date_time': {'readonly': True}, - 'monitor_condition_resolved_date_time': {'readonly': True}, - 'last_modified_user_name': {'readonly': True}, - } - - _attribute_map = { - 'severity': {'key': 'severity', 'type': 'str'}, - 'signal_type': {'key': 'signalType', 'type': 'str'}, - 'alert_state': {'key': 'alertState', 'type': 'str'}, - 'monitor_condition': {'key': 'monitorCondition', 'type': 'str'}, - 'target_resource': {'key': 'targetResource', 'type': 'str'}, - 'target_resource_name': {'key': 'targetResourceName', 'type': 'str'}, - 'target_resource_group': {'key': 'targetResourceGroup', 'type': 'str'}, - 'target_resource_type': {'key': 'targetResourceType', 'type': 'str'}, - 'monitor_service': {'key': 'monitorService', 'type': 'str'}, - 'alert_rule': {'key': 'alertRule', 'type': 'str'}, - 'source_created_id': {'key': 'sourceCreatedId', 'type': 'str'}, - 'smart_group_id': {'key': 'smartGroupId', 'type': 'str'}, - 'smart_grouping_reason': {'key': 'smartGroupingReason', 'type': 'str'}, - 'start_date_time': {'key': 'startDateTime', 'type': 'iso-8601'}, - 'last_modified_date_time': {'key': 'lastModifiedDateTime', 'type': 'iso-8601'}, - 'monitor_condition_resolved_date_time': {'key': 'monitorConditionResolvedDateTime', 'type': 'iso-8601'}, - 'last_modified_user_name': {'key': 'lastModifiedUserName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Essentials, self).__init__(**kwargs) - self.severity = None - self.signal_type = None - self.alert_state = None - self.monitor_condition = None - self.target_resource = kwargs.get('target_resource', None) - self.target_resource_name = kwargs.get('target_resource_name', None) - self.target_resource_group = kwargs.get('target_resource_group', None) - self.target_resource_type = kwargs.get('target_resource_type', None) - self.monitor_service = None - self.alert_rule = None - self.source_created_id = None - self.smart_group_id = None - self.smart_grouping_reason = None - self.start_date_time = None - self.last_modified_date_time = None - self.monitor_condition_resolved_date_time = None - self.last_modified_user_name = None - - -class MonitorServiceDetails(msrest.serialization.Model): - """Details of a monitor service. - - :param name: Monitor service name. - :type name: str - :param display_name: Monitor service display name. - :type display_name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MonitorServiceDetails, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display_name = kwargs.get('display_name', None) - - -class MonitorServiceList(AlertsMetaDataProperties): - """Monitor service details. - - All required parameters must be populated in order to send to Azure. - - :param metadata_identifier: Required. Identification of the information to be retrieved by API - call.Constant filled by server. Possible values include: "MonitorServiceList". - :type metadata_identifier: str or ~azure.mgmt.alertsmanagement.models.MetadataIdentifier - :param data: Required. Array of operations. - :type data: list[~azure.mgmt.alertsmanagement.models.MonitorServiceDetails] - """ - - _validation = { - 'metadata_identifier': {'required': True}, - 'data': {'required': True}, - } - - _attribute_map = { - 'metadata_identifier': {'key': 'metadataIdentifier', 'type': 'str'}, - 'data': {'key': 'data', 'type': '[MonitorServiceDetails]'}, - } - - def __init__( - self, - **kwargs - ): - super(MonitorServiceList, self).__init__(**kwargs) - self.metadata_identifier = 'MonitorServiceList' # type: str - self.data = kwargs['data'] - - -class Operation(msrest.serialization.Model): - """Operation provided by provider. - - :param name: Name of the operation. - :type name: str - :param display: Properties of the operation. - :type display: ~azure.mgmt.alertsmanagement.models.OperationDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """Properties of the operation. - - :param provider: Provider name. - :type provider: str - :param resource: Resource name. - :type resource: str - :param operation: Operation name. - :type operation: str - :param description: Description of the operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationsList(msrest.serialization.Model): - """Lists the operations available in the AlertsManagement RP. - - All required parameters must be populated in order to send to Azure. - - :param next_link: URL to fetch the next set of alerts. - :type next_link: str - :param value: Required. Array of operations. - :type value: list[~azure.mgmt.alertsmanagement.models.Operation] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Operation]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] - - -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 - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PatchObject, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.status = kwargs.get('status', 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. - - :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] - """ - - _attribute_map = { - 'scope_type': {'key': 'scopeType', 'type': 'str'}, - 'values': {'key': 'values', '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 - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SmartDetectorErrorResponse, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class SmartGroup(Resource): - """Set of related alerts grouped together smartly by AMS. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar type: Azure resource type. - :vartype type: str - :ivar name: Azure resource name. - :vartype name: str - :param alerts_count: Total number of alerts in smart group. - :type alerts_count: int - :ivar smart_group_state: Smart group state. Possible values include: "New", "Acknowledged", - "Closed". - :vartype smart_group_state: str or ~azure.mgmt.alertsmanagement.models.State - :ivar severity: Severity of smart group is the highest(Sev0 >... > Sev4) severity of all the - alerts in the group. Possible values include: "Sev0", "Sev1", "Sev2", "Sev3", "Sev4". - :vartype severity: str or ~azure.mgmt.alertsmanagement.models.Severity - :ivar start_date_time: Creation time of smart group. Date-Time in ISO-8601 format. - :vartype start_date_time: ~datetime.datetime - :ivar last_modified_date_time: Last updated time of smart group. Date-Time in ISO-8601 format. - :vartype last_modified_date_time: ~datetime.datetime - :ivar last_modified_user_name: Last modified by user name. - :vartype last_modified_user_name: str - :param resources: Summary of target resources in the smart group. - :type resources: list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] - :param resource_types: Summary of target resource types in the smart group. - :type resource_types: list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] - :param resource_groups: Summary of target resource groups in the smart group. - :type resource_groups: list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] - :param monitor_services: Summary of monitorServices in the smart group. - :type monitor_services: list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] - :param monitor_conditions: Summary of monitorConditions in the smart group. - :type monitor_conditions: - list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] - :param alert_states: Summary of alertStates in the smart group. - :type alert_states: list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] - :param alert_severities: Summary of alertSeverities in the smart group. - :type alert_severities: list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] - :param next_link: The URI to fetch the next page of alerts. Call ListNext() with this URI to - fetch the next page alerts. - :type next_link: str - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - 'smart_group_state': {'readonly': True}, - 'severity': {'readonly': True}, - 'start_date_time': {'readonly': True}, - 'last_modified_date_time': {'readonly': True}, - 'last_modified_user_name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'alerts_count': {'key': 'properties.alertsCount', 'type': 'int'}, - 'smart_group_state': {'key': 'properties.smartGroupState', 'type': 'str'}, - 'severity': {'key': 'properties.severity', 'type': 'str'}, - 'start_date_time': {'key': 'properties.startDateTime', 'type': 'iso-8601'}, - 'last_modified_date_time': {'key': 'properties.lastModifiedDateTime', 'type': 'iso-8601'}, - 'last_modified_user_name': {'key': 'properties.lastModifiedUserName', 'type': 'str'}, - 'resources': {'key': 'properties.resources', 'type': '[SmartGroupAggregatedProperty]'}, - 'resource_types': {'key': 'properties.resourceTypes', 'type': '[SmartGroupAggregatedProperty]'}, - 'resource_groups': {'key': 'properties.resourceGroups', 'type': '[SmartGroupAggregatedProperty]'}, - 'monitor_services': {'key': 'properties.monitorServices', 'type': '[SmartGroupAggregatedProperty]'}, - 'monitor_conditions': {'key': 'properties.monitorConditions', 'type': '[SmartGroupAggregatedProperty]'}, - 'alert_states': {'key': 'properties.alertStates', 'type': '[SmartGroupAggregatedProperty]'}, - 'alert_severities': {'key': 'properties.alertSeverities', 'type': '[SmartGroupAggregatedProperty]'}, - 'next_link': {'key': 'properties.nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SmartGroup, self).__init__(**kwargs) - self.alerts_count = kwargs.get('alerts_count', None) - self.smart_group_state = None - self.severity = None - self.start_date_time = None - self.last_modified_date_time = None - self.last_modified_user_name = None - self.resources = kwargs.get('resources', None) - self.resource_types = kwargs.get('resource_types', None) - self.resource_groups = kwargs.get('resource_groups', None) - self.monitor_services = kwargs.get('monitor_services', None) - self.monitor_conditions = kwargs.get('monitor_conditions', None) - self.alert_states = kwargs.get('alert_states', None) - self.alert_severities = kwargs.get('alert_severities', None) - self.next_link = kwargs.get('next_link', None) - - -class SmartGroupAggregatedProperty(msrest.serialization.Model): - """Aggregated property of each type. - - :param name: Name of the type. - :type name: str - :param count: Total number of items of type. - :type count: int - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(SmartGroupAggregatedProperty, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.count = kwargs.get('count', None) - - -class SmartGroupModification(Resource): - """Alert Modification details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Azure resource Id. - :vartype id: str - :ivar type: Azure resource type. - :vartype type: str - :ivar name: Azure resource name. - :vartype name: str - :param properties: Properties of the smartGroup modification item. - :type properties: ~azure.mgmt.alertsmanagement.models.SmartGroupModificationProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'type': {'readonly': True}, - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'SmartGroupModificationProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(SmartGroupModification, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class SmartGroupModificationItem(msrest.serialization.Model): - """smartGroup modification item. - - :param modification_event: Reason for the modification. Possible values include: - "SmartGroupCreated", "StateChange", "AlertAdded", "AlertRemoved". - :type modification_event: str or - ~azure.mgmt.alertsmanagement.models.SmartGroupModificationEvent - :param old_value: Old value. - :type old_value: str - :param new_value: New value. - :type new_value: str - :param modified_at: Modified date and time. - :type modified_at: str - :param modified_by: Modified user details (Principal client name). - :type modified_by: str - :param comments: Modification comments. - :type comments: str - :param description: Description of the modification. - :type description: str - """ - - _attribute_map = { - 'modification_event': {'key': 'modificationEvent', 'type': 'str'}, - 'old_value': {'key': 'oldValue', 'type': 'str'}, - 'new_value': {'key': 'newValue', 'type': 'str'}, - 'modified_at': {'key': 'modifiedAt', 'type': 'str'}, - 'modified_by': {'key': 'modifiedBy', 'type': 'str'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SmartGroupModificationItem, self).__init__(**kwargs) - self.modification_event = kwargs.get('modification_event', None) - self.old_value = kwargs.get('old_value', None) - self.new_value = kwargs.get('new_value', None) - self.modified_at = kwargs.get('modified_at', None) - self.modified_by = kwargs.get('modified_by', None) - self.comments = kwargs.get('comments', None) - self.description = kwargs.get('description', None) - - -class SmartGroupModificationProperties(msrest.serialization.Model): - """Properties of the smartGroup modification item. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar smart_group_id: Unique Id of the smartGroup for which the history is being retrieved. - :vartype smart_group_id: str - :param modifications: Modification details. - :type modifications: list[~azure.mgmt.alertsmanagement.models.SmartGroupModificationItem] - :param next_link: URL to fetch the next set of results. - :type next_link: str - """ - - _validation = { - 'smart_group_id': {'readonly': True}, - } - - _attribute_map = { - 'smart_group_id': {'key': 'smartGroupId', 'type': 'str'}, - 'modifications': {'key': 'modifications', 'type': '[SmartGroupModificationItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(SmartGroupModificationProperties, self).__init__(**kwargs) - self.smart_group_id = None - self.modifications = kwargs.get('modifications', None) - self.next_link = kwargs.get('next_link', None) - - -class SmartGroupsList(msrest.serialization.Model): - """List the alerts. - - :param next_link: URL to fetch the next set of alerts. - :type next_link: str - :param value: List of alerts. - :type value: list[~azure.mgmt.alertsmanagement.models.SmartGroup] - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[SmartGroup]'}, - } - - def __init__( - self, - **kwargs - ): - super(SmartGroupsList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - 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 - """ - - _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'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'suppression_config': {'key': 'suppressionConfig', 'type': 'SuppressionConfig'}, - } - - def __init__( - self, - **kwargs - ): - super(Suppression, self).__init__(**kwargs) - self.type = 'Suppression' # type: str - self.suppression_config = kwargs['suppression_config'] - - -class SuppressionConfig(msrest.serialization.Model): - """Suppression logic for a given action rule. - - 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 - """ - - _validation = { - 'recurrence_type': {'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'}, - } - - def __init__( - self, - **kwargs - ): - super(ThrottlingInformation, self).__init__(**kwargs) - self.duration = kwargs.get('duration', None) 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..830127d4dd37 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,101 @@ 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 + :ivar action_type: Required. Action that should be applied.Constant filled by server. Possible + values include: "AddActionGroups", "RemoveAllActionGroups". + :vartype 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. - - All required parameters must be populated in order to send to Azure. +class ActionStatus(msrest.serialization.Model): + """Action status. - :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 + :ivar is_suppressed: Value indicating whether alert is suppressed. + :vartype is_suppressed: bool """ - _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'}, + 'is_suppressed': {'key': 'isSuppressed', 'type': 'bool'}, } 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, + is_suppressed: Optional[bool] = None, **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 + """ + :keyword is_suppressed: Value indicating whether alert is suppressed. + :paramtype is_suppressed: bool + """ + super(ActionStatus, self).__init__(**kwargs) + self.is_suppressed = is_suppressed -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] + :ivar action_type: Required. Action that should be applied.Constant filled by server. Possible + values include: "AddActionGroups", "RemoveAllActionGroups". + :vartype action_type: str or ~azure.mgmt.alertsmanagement.models.ActionType + :ivar action_group_ids: Required. List of action group Ids to add to alert processing rule. + :vartype 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, *, - group_ids: List[str], - custom_email_subject: Optional[str] = None, - custom_webhook_payload: Optional[str] = None, + action_group_ids: List[str], **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 + """ + :keyword action_group_ids: Required. List of action group Ids to add to alert processing rule. + :paramtype action_group_ids: list[str] + """ + super(AddActionGroups, self).__init__(**kwargs) + self.action_type = 'AddActionGroups' # type: str + self.action_group_ids = action_group_ids class Resource(msrest.serialization.Model): @@ -227,133 +141,14 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.type = None 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. @@ -365,8 +160,8 @@ class Alert(Resource): :vartype type: str :ivar name: Azure resource name. :vartype name: str - :param properties: Alert property bag. - :type properties: ~azure.mgmt.alertsmanagement.models.AlertProperties + :ivar properties: Alert property bag. + :vartype properties: ~azure.mgmt.alertsmanagement.models.AlertProperties """ _validation = { @@ -388,6 +183,10 @@ def __init__( properties: Optional["AlertProperties"] = None, **kwargs ): + """ + :keyword properties: Alert property bag. + :paramtype properties: ~azure.mgmt.alertsmanagement.models.AlertProperties + """ super(Alert, self).__init__(**kwargs) self.properties = properties @@ -403,8 +202,8 @@ class AlertModification(Resource): :vartype type: str :ivar name: Azure resource name. :vartype name: str - :param properties: Properties of the alert modification item. - :type properties: ~azure.mgmt.alertsmanagement.models.AlertModificationProperties + :ivar properties: Properties of the alert modification item. + :vartype properties: ~azure.mgmt.alertsmanagement.models.AlertModificationProperties """ _validation = { @@ -426,6 +225,10 @@ def __init__( properties: Optional["AlertModificationProperties"] = None, **kwargs ): + """ + :keyword properties: Properties of the alert modification item. + :paramtype properties: ~azure.mgmt.alertsmanagement.models.AlertModificationProperties + """ super(AlertModification, self).__init__(**kwargs) self.properties = properties @@ -433,23 +236,22 @@ def __init__( class AlertModificationItem(msrest.serialization.Model): """Alert modification item. - :param modification_event: Reason for the modification. Possible values include: - "AlertCreated", "StateChange", "MonitorConditionChange", "SeverityChange", - "ActionRuleTriggered", "ActionRuleSuppressed", "ActionsTriggered", "ActionsSuppressed", - "ActionsFailed". - :type modification_event: str or ~azure.mgmt.alertsmanagement.models.AlertModificationEvent - :param old_value: Old value. - :type old_value: str - :param new_value: New value. - :type new_value: str - :param modified_at: Modified date and time. - :type modified_at: str - :param modified_by: Modified user details (Principal client name). - :type modified_by: str - :param comments: Modification comments. - :type comments: str - :param description: Description of the modification. - :type description: str + :ivar modification_event: Reason for the modification. Possible values include: "AlertCreated", + "StateChange", "MonitorConditionChange", "SeverityChange", "ActionRuleTriggered", + "ActionRuleSuppressed", "ActionsTriggered", "ActionsSuppressed", "ActionsFailed". + :vartype modification_event: str or ~azure.mgmt.alertsmanagement.models.AlertModificationEvent + :ivar old_value: Old value. + :vartype old_value: str + :ivar new_value: New value. + :vartype new_value: str + :ivar modified_at: Modified date and time. + :vartype modified_at: str + :ivar modified_by: Modified user details (Principal client name). + :vartype modified_by: str + :ivar comments: Modification comments. + :vartype comments: str + :ivar description: Description of the modification. + :vartype description: str """ _attribute_map = { @@ -474,6 +276,26 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword modification_event: Reason for the modification. Possible values include: + "AlertCreated", "StateChange", "MonitorConditionChange", "SeverityChange", + "ActionRuleTriggered", "ActionRuleSuppressed", "ActionsTriggered", "ActionsSuppressed", + "ActionsFailed". + :paramtype modification_event: str or + ~azure.mgmt.alertsmanagement.models.AlertModificationEvent + :keyword old_value: Old value. + :paramtype old_value: str + :keyword new_value: New value. + :paramtype new_value: str + :keyword modified_at: Modified date and time. + :paramtype modified_at: str + :keyword modified_by: Modified user details (Principal client name). + :paramtype modified_by: str + :keyword comments: Modification comments. + :paramtype comments: str + :keyword description: Description of the modification. + :paramtype description: str + """ super(AlertModificationItem, self).__init__(**kwargs) self.modification_event = modification_event self.old_value = old_value @@ -491,8 +313,8 @@ class AlertModificationProperties(msrest.serialization.Model): :ivar alert_id: Unique Id of the alert for which the history is being retrieved. :vartype alert_id: str - :param modifications: Modification details. - :type modifications: list[~azure.mgmt.alertsmanagement.models.AlertModificationItem] + :ivar modifications: Modification details. + :vartype modifications: list[~azure.mgmt.alertsmanagement.models.AlertModificationItem] """ _validation = { @@ -510,68 +332,39 @@ def __init__( modifications: Optional[List["AlertModificationItem"]] = None, **kwargs ): + """ + :keyword modifications: Modification details. + :paramtype modifications: list[~azure.mgmt.alertsmanagement.models.AlertModificationItem] + """ super(AlertModificationProperties, self).__init__(**kwargs) self.alert_id = None 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. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _validation = { 'id': {'readonly': True}, 'type': {'readonly': True}, 'name': {'readonly': True}, + 'location': {'required': True}, } _attribute_map = { @@ -585,57 +378,50 @@ 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 + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ + 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. - :type location: str - :param tags: A set of tags. The 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 + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar properties: Alert processing rule properties. + :vartype 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,148 +430,177 @@ 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 + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword properties: Alert processing rule properties. + :paramtype properties: ~azure.mgmt.alertsmanagement.models.AlertProcessingRuleProperties + """ + 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. - :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 + :ivar scopes: Required. Scopes on which alert processing rule will apply. + :vartype scopes: list[str] + :ivar conditions: Conditions on which alerts will be filtered. + :vartype conditions: list[~azure.mgmt.alertsmanagement.models.Condition] + :ivar schedule: Scheduling for alert processing rule. + :vartype schedule: ~azure.mgmt.alertsmanagement.models.Schedule + :ivar actions: Required. Actions to be applied. + :vartype actions: list[~azure.mgmt.alertsmanagement.models.Action] + :ivar description: Description of alert processing rule. + :vartype description: str + :ivar enabled: Indicates if the given alert processing rule is enabled or disabled. + :vartype 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 + """ + :keyword scopes: Required. Scopes on which alert processing rule will apply. + :paramtype scopes: list[str] + :keyword conditions: Conditions on which alerts will be filtered. + :paramtype conditions: list[~azure.mgmt.alertsmanagement.models.Condition] + :keyword schedule: Scheduling for alert processing rule. + :paramtype schedule: ~azure.mgmt.alertsmanagement.models.Schedule + :keyword actions: Required. Actions to be applied. + :paramtype actions: list[~azure.mgmt.alertsmanagement.models.Action] + :keyword description: Description of alert processing rule. + :paramtype description: str + :keyword enabled: Indicates if the given alert processing rule is enabled or disabled. + :paramtype enabled: bool + """ + 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. - :type next_link: str + :ivar next_link: URL to fetch the next set of alert processing rules. + :vartype next_link: str + :ivar value: List of alert processing rules. + :vartype 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 + """ + :keyword next_link: URL to fetch the next set of alert processing rules. + :paramtype next_link: str + :keyword value: List of alert processing rules. + :paramtype value: list[~azure.mgmt.alertsmanagement.models.AlertProcessingRule] + """ + 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. + + :ivar essentials: This object contains consistent fields across different monitor services. + :vartype 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 + ): + """ + :keyword essentials: This object contains consistent fields across different monitor services. + :paramtype essentials: ~azure.mgmt.alertsmanagement.models.Essentials + """ + super(AlertProperties, self).__init__(**kwargs) + self.essentials = essentials + self.context = None + self.egress_config = None class AlertsList(msrest.serialization.Model): """List the alerts. - :param next_link: URL to fetch the next set of alerts. - :type next_link: str - :param value: List of alerts. - :type value: list[~azure.mgmt.alertsmanagement.models.Alert] + :ivar next_link: URL to fetch the next set of alerts. + :vartype next_link: str + :ivar value: List of alerts. + :vartype value: list[~azure.mgmt.alertsmanagement.models.Alert] """ _attribute_map = { @@ -800,6 +615,12 @@ def __init__( value: Optional[List["Alert"]] = None, **kwargs ): + """ + :keyword next_link: URL to fetch the next set of alerts. + :paramtype next_link: str + :keyword value: List of alerts. + :paramtype value: list[~azure.mgmt.alertsmanagement.models.Alert] + """ super(AlertsList, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -808,8 +629,8 @@ def __init__( class AlertsMetaData(msrest.serialization.Model): """alert meta data information. - :param properties: alert meta data property bag. - :type properties: ~azure.mgmt.alertsmanagement.models.AlertsMetaDataProperties + :ivar properties: alert meta data property bag. + :vartype properties: ~azure.mgmt.alertsmanagement.models.AlertsMetaDataProperties """ _attribute_map = { @@ -822,6 +643,10 @@ def __init__( properties: Optional["AlertsMetaDataProperties"] = None, **kwargs ): + """ + :keyword properties: alert meta data property bag. + :paramtype properties: ~azure.mgmt.alertsmanagement.models.AlertsMetaDataProperties + """ super(AlertsMetaData, self).__init__(**kwargs) self.properties = properties @@ -834,9 +659,9 @@ class AlertsMetaDataProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param metadata_identifier: Required. Identification of the information to be retrieved by API - call.Constant filled by server. Possible values include: "MonitorServiceList". - :type metadata_identifier: str or ~azure.mgmt.alertsmanagement.models.MetadataIdentifier + :ivar metadata_identifier: Required. Identification of the information to be retrieved by API + call.Constant filled by server. Possible values include: "MonitorServiceList". + :vartype metadata_identifier: str or ~azure.mgmt.alertsmanagement.models.MetadataIdentifier """ _validation = { @@ -855,6 +680,8 @@ def __init__( self, **kwargs ): + """ + """ super(AlertsMetaDataProperties, self).__init__(**kwargs) self.metadata_identifier = None # type: Optional[str] @@ -870,8 +697,8 @@ class AlertsSummary(Resource): :vartype type: str :ivar name: Azure resource name. :vartype name: str - :param properties: Group the result set. - :type properties: ~azure.mgmt.alertsmanagement.models.AlertsSummaryGroup + :ivar properties: Group the result set. + :vartype properties: ~azure.mgmt.alertsmanagement.models.AlertsSummaryGroup """ _validation = { @@ -893,6 +720,10 @@ def __init__( properties: Optional["AlertsSummaryGroup"] = None, **kwargs ): + """ + :keyword properties: Group the result set. + :paramtype properties: ~azure.mgmt.alertsmanagement.models.AlertsSummaryGroup + """ super(AlertsSummary, self).__init__(**kwargs) self.properties = properties @@ -900,19 +731,19 @@ def __init__( class AlertsSummaryGroup(msrest.serialization.Model): """Group the result set. - :param total: Total count of the result set. - :type total: int - :param smart_groups_count: Total count of the smart groups. - :type smart_groups_count: int - :param groupedby: Name of the field aggregated. - :type groupedby: str - :param values: List of the items. - :type values: list[~azure.mgmt.alertsmanagement.models.AlertsSummaryGroupItem] + :ivar total: Total count of the result set. + :vartype total: long + :ivar smart_groups_count: Total count of the smart groups. + :vartype smart_groups_count: long + :ivar groupedby: Name of the field aggregated. + :vartype groupedby: str + :ivar values: List of the items. + :vartype values: list[~azure.mgmt.alertsmanagement.models.AlertsSummaryGroupItem] """ _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]'}, } @@ -926,6 +757,16 @@ def __init__( values: Optional[List["AlertsSummaryGroupItem"]] = None, **kwargs ): + """ + :keyword total: Total count of the result set. + :paramtype total: long + :keyword smart_groups_count: Total count of the smart groups. + :paramtype smart_groups_count: long + :keyword groupedby: Name of the field aggregated. + :paramtype groupedby: str + :keyword values: List of the items. + :paramtype values: list[~azure.mgmt.alertsmanagement.models.AlertsSummaryGroupItem] + """ super(AlertsSummaryGroup, self).__init__(**kwargs) self.total = total self.smart_groups_count = smart_groups_count @@ -936,19 +777,19 @@ def __init__( class AlertsSummaryGroupItem(msrest.serialization.Model): """Alerts summary group item. - :param name: Value of the aggregated field. - :type name: str - :param count: Count of the aggregated field. - :type count: int - :param groupedby: Name of the field aggregated. - :type groupedby: str - :param values: List of the items. - :type values: list[~azure.mgmt.alertsmanagement.models.AlertsSummaryGroupItem] + :ivar name: Value of the aggregated field. + :vartype name: str + :ivar count: Count of the aggregated field. + :vartype count: long + :ivar groupedby: Name of the field aggregated. + :vartype groupedby: str + :ivar values: List of the items. + :vartype values: list[~azure.mgmt.alertsmanagement.models.AlertsSummaryGroupItem] """ _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]'}, } @@ -962,6 +803,16 @@ def __init__( values: Optional[List["AlertsSummaryGroupItem"]] = None, **kwargs ): + """ + :keyword name: Value of the aggregated field. + :paramtype name: str + :keyword count: Count of the aggregated field. + :paramtype count: long + :keyword groupedby: Name of the field aggregated. + :paramtype groupedby: str + :keyword values: List of the items. + :paramtype values: list[~azure.mgmt.alertsmanagement.models.AlertsSummaryGroupItem] + """ super(AlertsSummaryGroupItem, self).__init__(**kwargs) self.name = name self.count = count @@ -970,16 +821,21 @@ def __init__( class Condition(msrest.serialization.Model): - """condition to trigger an action rule. - - :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. - :type values: list[str] + """Condition to trigger an alert processing rule. + + :ivar field: Field for a given condition. Possible values include: "Severity", + "MonitorService", "MonitorCondition", "SignalType", "TargetResourceType", "TargetResource", + "TargetResourceGroup", "AlertRuleId", "AlertRuleName", "Description", "AlertContext". + :vartype field: str or ~azure.mgmt.alertsmanagement.models.Field + :ivar operator: Operator for a given condition. Possible values include: "Equals", "NotEquals", + "Contains", "DoesNotContain". + :vartype operator: str or ~azure.mgmt.alertsmanagement.models.Operator + :ivar values: List of values to match for a given condition. + :vartype values: list[str] """ _attribute_map = { + 'field': {'key': 'field', 'type': 'str'}, 'operator': {'key': 'operator', 'type': 'str'}, 'values': {'key': 'values', 'type': '[str]'}, } @@ -987,189 +843,124 @@ 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 ): + """ + :keyword field: Field for a given condition. Possible values include: "Severity", + "MonitorService", "MonitorCondition", "SignalType", "TargetResourceType", "TargetResource", + "TargetResourceGroup", "AlertRuleId", "AlertRuleName", "Description", "AlertContext". + :paramtype field: str or ~azure.mgmt.alertsmanagement.models.Field + :keyword operator: Operator for a given condition. Possible values include: "Equals", + "NotEquals", "Contains", "DoesNotContain". + :paramtype operator: str or ~azure.mgmt.alertsmanagement.models.Operator + :keyword values: List of values to match for a given condition. + :paramtype values: list[str] + """ 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] + :ivar recurrence_type: Required. Specifies when the recurrence should be applied.Constant + filled by server. Possible values include: "Daily", "Weekly", "Monthly". + :vartype recurrence_type: str or ~azure.mgmt.alertsmanagement.models.RecurrenceType + :ivar start_time: Start time for recurrence. + :vartype start_time: str + :ivar end_time: End time for recurrence. + :vartype 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 - + """ + :keyword start_time: Start time for recurrence. + :paramtype start_time: str + :keyword end_time: End time for recurrence. + :paramtype end_time: str + """ + 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 + :ivar recurrence_type: Required. Specifies when the recurrence should be applied.Constant + filled by server. Possible values include: "Daily", "Weekly", "Monthly". + :vartype recurrence_type: str or ~azure.mgmt.alertsmanagement.models.RecurrenceType + :ivar start_time: Start time for recurrence. + :vartype start_time: str + :ivar end_time: End time for recurrence. + :vartype 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 + """ + :keyword start_time: Start time for recurrence. + :paramtype start_time: str + :keyword end_time: End time for recurrence. + :paramtype end_time: 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): """An error response from the service. - :param error: Details of error response. - :type error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBody + :ivar error: Details of error response. + :vartype error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBody """ _attribute_map = { @@ -1182,6 +973,10 @@ def __init__( error: Optional["ErrorResponseBody"] = None, **kwargs ): + """ + :keyword error: Details of error response. + :paramtype error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBody + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -1189,8 +984,8 @@ def __init__( class ErrorResponseAutoGenerated(msrest.serialization.Model): """An error response from the service. - :param error: Details of error response. - :type error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBodyAutoGenerated + :ivar error: Details of error response. + :vartype error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBodyAutoGenerated """ _attribute_map = { @@ -1203,6 +998,10 @@ def __init__( error: Optional["ErrorResponseBodyAutoGenerated"] = None, **kwargs ): + """ + :keyword error: Details of error response. + :paramtype error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBodyAutoGenerated + """ super(ErrorResponseAutoGenerated, self).__init__(**kwargs) self.error = error @@ -1210,8 +1009,8 @@ def __init__( class ErrorResponseAutoGenerated2(msrest.serialization.Model): """An error response from the service. - :param error: Details of error response. - :type error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBodyAutoGenerated2 + :ivar error: Details of error response. + :vartype error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBodyAutoGenerated2 """ _attribute_map = { @@ -1224,6 +1023,10 @@ def __init__( error: Optional["ErrorResponseBodyAutoGenerated2"] = None, **kwargs ): + """ + :keyword error: Details of error response. + :paramtype error: ~azure.mgmt.alertsmanagement.models.ErrorResponseBodyAutoGenerated2 + """ super(ErrorResponseAutoGenerated2, self).__init__(**kwargs) self.error = error @@ -1231,14 +1034,14 @@ def __init__( class ErrorResponseBody(msrest.serialization.Model): """Details of error response. - :param code: Error code, intended to be consumed programmatically. - :type code: str - :param message: Description of the error, intended for display in user interface. - :type message: str - :param target: Target of the particular error, for example name of the property. - :type target: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.alertsmanagement.models.ErrorResponseBody] + :ivar code: Error code, intended to be consumed programmatically. + :vartype code: str + :ivar message: Description of the error, intended for display in user interface. + :vartype message: str + :ivar target: Target of the particular error, for example name of the property. + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.alertsmanagement.models.ErrorResponseBody] """ _attribute_map = { @@ -1257,6 +1060,16 @@ def __init__( details: Optional[List["ErrorResponseBody"]] = None, **kwargs ): + """ + :keyword code: Error code, intended to be consumed programmatically. + :paramtype code: str + :keyword message: Description of the error, intended for display in user interface. + :paramtype message: str + :keyword target: Target of the particular error, for example name of the property. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.alertsmanagement.models.ErrorResponseBody] + """ super(ErrorResponseBody, self).__init__(**kwargs) self.code = code self.message = message @@ -1267,14 +1080,14 @@ def __init__( class ErrorResponseBodyAutoGenerated(msrest.serialization.Model): """Details of error response. - :param code: Error code, intended to be consumed programmatically. - :type code: str - :param message: Description of the error, intended for display in user interface. - :type message: str - :param target: Target of the particular error, for example name of the property. - :type target: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.alertsmanagement.models.ErrorResponseBodyAutoGenerated] + :ivar code: Error code, intended to be consumed programmatically. + :vartype code: str + :ivar message: Description of the error, intended for display in user interface. + :vartype message: str + :ivar target: Target of the particular error, for example name of the property. + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.alertsmanagement.models.ErrorResponseBodyAutoGenerated] """ _attribute_map = { @@ -1293,6 +1106,16 @@ def __init__( details: Optional[List["ErrorResponseBodyAutoGenerated"]] = None, **kwargs ): + """ + :keyword code: Error code, intended to be consumed programmatically. + :paramtype code: str + :keyword message: Description of the error, intended for display in user interface. + :paramtype message: str + :keyword target: Target of the particular error, for example name of the property. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.alertsmanagement.models.ErrorResponseBodyAutoGenerated] + """ super(ErrorResponseBodyAutoGenerated, self).__init__(**kwargs) self.code = code self.message = message @@ -1303,14 +1126,14 @@ def __init__( class ErrorResponseBodyAutoGenerated2(msrest.serialization.Model): """Details of error response. - :param code: Error code, intended to be consumed programmatically. - :type code: str - :param message: Description of the error, intended for display in user interface. - :type message: str - :param target: Target of the particular error, for example name of the property. - :type target: str - :param details: A list of additional details about the error. - :type details: list[~azure.mgmt.alertsmanagement.models.ErrorResponseBodyAutoGenerated2] + :ivar code: Error code, intended to be consumed programmatically. + :vartype code: str + :ivar message: Description of the error, intended for display in user interface. + :vartype message: str + :ivar target: Target of the particular error, for example name of the property. + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.alertsmanagement.models.ErrorResponseBodyAutoGenerated2] """ _attribute_map = { @@ -1329,6 +1152,16 @@ def __init__( details: Optional[List["ErrorResponseBodyAutoGenerated2"]] = None, **kwargs ): + """ + :keyword code: Error code, intended to be consumed programmatically. + :paramtype code: str + :keyword message: Description of the error, intended for display in user interface. + :paramtype message: str + :keyword target: Target of the particular error, for example name of the property. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.alertsmanagement.models.ErrorResponseBodyAutoGenerated2] + """ super(ErrorResponseBodyAutoGenerated2, self).__init__(**kwargs) self.code = code self.message = message @@ -1354,15 +1187,14 @@ class Essentials(msrest.serialization.Model): the underlying conditions have crossed the defined alert rule thresholds. Possible values include: "Fired", "Resolved". :vartype monitor_condition: str or ~azure.mgmt.alertsmanagement.models.MonitorCondition - :param target_resource: Target ARM resource, on which alert got created. - :type target_resource: str - :param target_resource_name: Name of the target ARM resource name, on which alert got created. - :type target_resource_name: str - :param target_resource_group: Resource group of target ARM resource, on which alert got - created. - :type target_resource_group: str - :param target_resource_type: Resource type of target ARM resource, on which alert got created. - :type target_resource_type: str + :ivar target_resource: Target ARM resource, on which alert got created. + :vartype target_resource: str + :ivar target_resource_name: Name of the target ARM resource name, on which alert got created. + :vartype target_resource_name: str + :ivar target_resource_group: Resource group of target ARM resource, on which alert got created. + :vartype target_resource_group: str + :ivar target_resource_type: Resource type of target ARM resource, on which alert got created. + :vartype target_resource_type: str :ivar monitor_service: Monitor service on which the rule(monitor) is set. Possible values include: "Application Insights", "ActivityLog Administrative", "ActivityLog Security", "ActivityLog Recommendation", "ActivityLog Policy", "ActivityLog Autoscale", "Log Analytics", @@ -1390,6 +1222,10 @@ class Essentials(msrest.serialization.Model): :ivar last_modified_user_name: User who last modified the alert, in case of monitor service updates user would be 'system', otherwise name of the user. :vartype last_modified_user_name: str + :ivar action_status: Action status. + :vartype action_status: ~azure.mgmt.alertsmanagement.models.ActionStatus + :ivar description: Alert description. + :vartype description: str """ _validation = { @@ -1426,6 +1262,8 @@ class Essentials(msrest.serialization.Model): 'last_modified_date_time': {'key': 'lastModifiedDateTime', 'type': 'iso-8601'}, 'monitor_condition_resolved_date_time': {'key': 'monitorConditionResolvedDateTime', 'type': 'iso-8601'}, 'last_modified_user_name': {'key': 'lastModifiedUserName', 'type': 'str'}, + 'action_status': {'key': 'actionStatus', 'type': 'ActionStatus'}, + 'description': {'key': 'description', 'type': 'str'}, } def __init__( @@ -1435,8 +1273,27 @@ def __init__( target_resource_name: Optional[str] = None, target_resource_group: Optional[str] = None, target_resource_type: Optional[str] = None, + action_status: Optional["ActionStatus"] = None, + description: Optional[str] = None, **kwargs ): + """ + :keyword target_resource: Target ARM resource, on which alert got created. + :paramtype target_resource: str + :keyword target_resource_name: Name of the target ARM resource name, on which alert got + created. + :paramtype target_resource_name: str + :keyword target_resource_group: Resource group of target ARM resource, on which alert got + created. + :paramtype target_resource_group: str + :keyword target_resource_type: Resource type of target ARM resource, on which alert got + created. + :paramtype target_resource_type: str + :keyword action_status: Action status. + :paramtype action_status: ~azure.mgmt.alertsmanagement.models.ActionStatus + :keyword description: Alert description. + :paramtype description: str + """ super(Essentials, self).__init__(**kwargs) self.severity = None self.signal_type = None @@ -1455,15 +1312,17 @@ def __init__( self.last_modified_date_time = None self.monitor_condition_resolved_date_time = None self.last_modified_user_name = None + self.action_status = action_status + self.description = description class MonitorServiceDetails(msrest.serialization.Model): """Details of a monitor service. - :param name: Monitor service name. - :type name: str - :param display_name: Monitor service display name. - :type display_name: str + :ivar name: Monitor service name. + :vartype name: str + :ivar display_name: Monitor service display name. + :vartype display_name: str """ _attribute_map = { @@ -1478,6 +1337,12 @@ def __init__( display_name: Optional[str] = None, **kwargs ): + """ + :keyword name: Monitor service name. + :paramtype name: str + :keyword display_name: Monitor service display name. + :paramtype display_name: str + """ super(MonitorServiceDetails, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -1488,11 +1353,11 @@ class MonitorServiceList(AlertsMetaDataProperties): All required parameters must be populated in order to send to Azure. - :param metadata_identifier: Required. Identification of the information to be retrieved by API - call.Constant filled by server. Possible values include: "MonitorServiceList". - :type metadata_identifier: str or ~azure.mgmt.alertsmanagement.models.MetadataIdentifier - :param data: Required. Array of operations. - :type data: list[~azure.mgmt.alertsmanagement.models.MonitorServiceDetails] + :ivar metadata_identifier: Required. Identification of the information to be retrieved by API + call.Constant filled by server. Possible values include: "MonitorServiceList". + :vartype metadata_identifier: str or ~azure.mgmt.alertsmanagement.models.MetadataIdentifier + :ivar data: Required. Array of operations. + :vartype data: list[~azure.mgmt.alertsmanagement.models.MonitorServiceDetails] """ _validation = { @@ -1511,18 +1376,71 @@ def __init__( data: List["MonitorServiceDetails"], **kwargs ): + """ + :keyword data: Required. Array of operations. + :paramtype data: list[~azure.mgmt.alertsmanagement.models.MonitorServiceDetails] + """ super(MonitorServiceList, self).__init__(**kwargs) self.metadata_identifier = 'MonitorServiceList' # type: str self.data = data +class MonthlyRecurrence(Recurrence): + """Monthly recurrence object. + + All required parameters must be populated in order to send to Azure. + + :ivar recurrence_type: Required. Specifies when the recurrence should be applied.Constant + filled by server. Possible values include: "Daily", "Weekly", "Monthly". + :vartype recurrence_type: str or ~azure.mgmt.alertsmanagement.models.RecurrenceType + :ivar start_time: Start time for recurrence. + :vartype start_time: str + :ivar end_time: End time for recurrence. + :vartype end_time: str + :ivar days_of_month: Required. Specifies the values for monthly recurrence pattern. + :vartype 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 + ): + """ + :keyword start_time: Start time for recurrence. + :paramtype start_time: str + :keyword end_time: End time for recurrence. + :paramtype end_time: str + :keyword days_of_month: Required. Specifies the values for monthly recurrence pattern. + :paramtype days_of_month: list[int] + """ + 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. - :param name: Name of the operation. - :type name: str - :param display: Properties of the operation. - :type display: ~azure.mgmt.alertsmanagement.models.OperationDisplay + :ivar name: Name of the operation. + :vartype name: str + :ivar display: Properties of the operation. + :vartype display: ~azure.mgmt.alertsmanagement.models.OperationDisplay """ _attribute_map = { @@ -1537,6 +1455,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword display: Properties of the operation. + :paramtype display: ~azure.mgmt.alertsmanagement.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -1545,14 +1469,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """Properties of the operation. - :param provider: Provider name. - :type provider: str - :param resource: Resource name. - :type resource: str - :param operation: Operation name. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Provider name. + :vartype provider: str + :ivar resource: Resource name. + :vartype resource: str + :ivar operation: Operation name. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -1571,6 +1495,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Provider name. + :paramtype provider: str + :keyword resource: Resource name. + :paramtype resource: str + :keyword operation: Operation name. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1583,10 +1517,10 @@ class OperationsList(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param next_link: URL to fetch the next set of alerts. - :type next_link: str - :param value: Required. Array of operations. - :type value: list[~azure.mgmt.alertsmanagement.models.Operation] + :ivar next_link: URL to fetch the next set of alerts. + :vartype next_link: str + :ivar value: Required. Array of operations. + :vartype value: list[~azure.mgmt.alertsmanagement.models.Operation] """ _validation = { @@ -1605,6 +1539,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: URL to fetch the next set of alerts. + :paramtype next_link: str + :keyword value: Required. Array of operations. + :paramtype value: list[~azure.mgmt.alertsmanagement.models.Operation] + """ super(OperationsList, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -1613,82 +1553,116 @@ 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 + :ivar tags: A set of tags. Tags to be updated. + :vartype tags: dict[str, str] + :ivar enabled: Indicates if the given alert processing rule is enabled or disabled. + :vartype 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 ): + """ + :keyword tags: A set of tags. Tags to be updated. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates if the given alert processing rule is enabled or disabled. + :paramtype enabled: bool + """ 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. + + :ivar action_type: Required. Action that should be applied.Constant filled by server. Possible + values include: "AddActionGroups", "RemoveAllActionGroups". + :vartype 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. + + :ivar effective_from: Scheduling effective from time. Date-Time in ISO-8601 format without + timezone suffix. + :vartype effective_from: str + :ivar effective_until: Scheduling effective until time. Date-Time in ISO-8601 format without + timezone suffix. + :vartype effective_until: str + :ivar time_zone: Scheduling time zone. + :vartype time_zone: str + :ivar recurrences: List of recurrences. + :vartype 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 + """ + :keyword effective_from: Scheduling effective from time. Date-Time in ISO-8601 format without + timezone suffix. + :paramtype effective_from: str + :keyword effective_until: Scheduling effective until time. Date-Time in ISO-8601 format without + timezone suffix. + :paramtype effective_until: str + :keyword time_zone: Scheduling time zone. + :paramtype time_zone: str + :keyword recurrences: List of recurrences. + :paramtype recurrences: list[~azure.mgmt.alertsmanagement.models.Recurrence] + """ + 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): @@ -1702,8 +1676,8 @@ class SmartGroup(Resource): :vartype type: str :ivar name: Azure resource name. :vartype name: str - :param alerts_count: Total number of alerts in smart group. - :type alerts_count: int + :ivar alerts_count: Total number of alerts in smart group. + :vartype 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 @@ -1716,24 +1690,27 @@ class SmartGroup(Resource): :vartype last_modified_date_time: ~datetime.datetime :ivar last_modified_user_name: Last modified by user name. :vartype last_modified_user_name: str - :param resources: Summary of target resources in the smart group. - :type resources: list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] - :param resource_types: Summary of target resource types in the smart group. - :type resource_types: list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] - :param resource_groups: Summary of target resource groups in the smart group. - :type resource_groups: list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] - :param monitor_services: Summary of monitorServices in the smart group. - :type monitor_services: list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] - :param monitor_conditions: Summary of monitorConditions in the smart group. - :type monitor_conditions: + :ivar resources: Summary of target resources in the smart group. + :vartype resources: list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :ivar resource_types: Summary of target resource types in the smart group. + :vartype resource_types: list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :ivar resource_groups: Summary of target resource groups in the smart group. + :vartype resource_groups: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :ivar monitor_services: Summary of monitorServices in the smart group. + :vartype monitor_services: list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] - :param alert_states: Summary of alertStates in the smart group. - :type alert_states: list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] - :param alert_severities: Summary of alertSeverities in the smart group. - :type alert_severities: list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] - :param next_link: The URI to fetch the next page of alerts. Call ListNext() with this URI to + :ivar monitor_conditions: Summary of monitorConditions in the smart group. + :vartype monitor_conditions: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :ivar alert_states: Summary of alertStates in the smart group. + :vartype alert_states: list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :ivar alert_severities: Summary of alertSeverities in the smart group. + :vartype alert_severities: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :ivar next_link: The URI to fetch the next page of alerts. Call ListNext() with this URI to fetch the next page alerts. - :type next_link: str + :vartype next_link: str """ _validation = { @@ -1751,7 +1728,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'}, @@ -1781,6 +1758,32 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword alerts_count: Total number of alerts in smart group. + :paramtype alerts_count: long + :keyword resources: Summary of target resources in the smart group. + :paramtype resources: list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :keyword resource_types: Summary of target resource types in the smart group. + :paramtype resource_types: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :keyword resource_groups: Summary of target resource groups in the smart group. + :paramtype resource_groups: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :keyword monitor_services: Summary of monitorServices in the smart group. + :paramtype monitor_services: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :keyword monitor_conditions: Summary of monitorConditions in the smart group. + :paramtype monitor_conditions: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :keyword alert_states: Summary of alertStates in the smart group. + :paramtype alert_states: list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :keyword alert_severities: Summary of alertSeverities in the smart group. + :paramtype alert_severities: + list[~azure.mgmt.alertsmanagement.models.SmartGroupAggregatedProperty] + :keyword next_link: The URI to fetch the next page of alerts. Call ListNext() with this URI to + fetch the next page alerts. + :paramtype next_link: str + """ super(SmartGroup, self).__init__(**kwargs) self.alerts_count = alerts_count self.smart_group_state = None @@ -1801,15 +1804,15 @@ def __init__( class SmartGroupAggregatedProperty(msrest.serialization.Model): """Aggregated property of each type. - :param name: Name of the type. - :type name: str - :param count: Total number of items of type. - :type count: int + :ivar name: Name of the type. + :vartype name: str + :ivar count: Total number of items of type. + :vartype count: long """ _attribute_map = { 'name': {'key': 'name', 'type': 'str'}, - 'count': {'key': 'count', 'type': 'int'}, + 'count': {'key': 'count', 'type': 'long'}, } def __init__( @@ -1819,6 +1822,12 @@ def __init__( count: Optional[int] = None, **kwargs ): + """ + :keyword name: Name of the type. + :paramtype name: str + :keyword count: Total number of items of type. + :paramtype count: long + """ super(SmartGroupAggregatedProperty, self).__init__(**kwargs) self.name = name self.count = count @@ -1835,8 +1844,8 @@ class SmartGroupModification(Resource): :vartype type: str :ivar name: Azure resource name. :vartype name: str - :param properties: Properties of the smartGroup modification item. - :type properties: ~azure.mgmt.alertsmanagement.models.SmartGroupModificationProperties + :ivar properties: Properties of the smartGroup modification item. + :vartype properties: ~azure.mgmt.alertsmanagement.models.SmartGroupModificationProperties """ _validation = { @@ -1858,6 +1867,10 @@ def __init__( properties: Optional["SmartGroupModificationProperties"] = None, **kwargs ): + """ + :keyword properties: Properties of the smartGroup modification item. + :paramtype properties: ~azure.mgmt.alertsmanagement.models.SmartGroupModificationProperties + """ super(SmartGroupModification, self).__init__(**kwargs) self.properties = properties @@ -1865,22 +1878,22 @@ def __init__( class SmartGroupModificationItem(msrest.serialization.Model): """smartGroup modification item. - :param modification_event: Reason for the modification. Possible values include: + :ivar modification_event: Reason for the modification. Possible values include: "SmartGroupCreated", "StateChange", "AlertAdded", "AlertRemoved". - :type modification_event: str or + :vartype modification_event: str or ~azure.mgmt.alertsmanagement.models.SmartGroupModificationEvent - :param old_value: Old value. - :type old_value: str - :param new_value: New value. - :type new_value: str - :param modified_at: Modified date and time. - :type modified_at: str - :param modified_by: Modified user details (Principal client name). - :type modified_by: str - :param comments: Modification comments. - :type comments: str - :param description: Description of the modification. - :type description: str + :ivar old_value: Old value. + :vartype old_value: str + :ivar new_value: New value. + :vartype new_value: str + :ivar modified_at: Modified date and time. + :vartype modified_at: str + :ivar modified_by: Modified user details (Principal client name). + :vartype modified_by: str + :ivar comments: Modification comments. + :vartype comments: str + :ivar description: Description of the modification. + :vartype description: str """ _attribute_map = { @@ -1905,6 +1918,24 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword modification_event: Reason for the modification. Possible values include: + "SmartGroupCreated", "StateChange", "AlertAdded", "AlertRemoved". + :paramtype modification_event: str or + ~azure.mgmt.alertsmanagement.models.SmartGroupModificationEvent + :keyword old_value: Old value. + :paramtype old_value: str + :keyword new_value: New value. + :paramtype new_value: str + :keyword modified_at: Modified date and time. + :paramtype modified_at: str + :keyword modified_by: Modified user details (Principal client name). + :paramtype modified_by: str + :keyword comments: Modification comments. + :paramtype comments: str + :keyword description: Description of the modification. + :paramtype description: str + """ super(SmartGroupModificationItem, self).__init__(**kwargs) self.modification_event = modification_event self.old_value = old_value @@ -1922,10 +1953,10 @@ class SmartGroupModificationProperties(msrest.serialization.Model): :ivar smart_group_id: Unique Id of the smartGroup for which the history is being retrieved. :vartype smart_group_id: str - :param modifications: Modification details. - :type modifications: list[~azure.mgmt.alertsmanagement.models.SmartGroupModificationItem] - :param next_link: URL to fetch the next set of results. - :type next_link: str + :ivar modifications: Modification details. + :vartype modifications: list[~azure.mgmt.alertsmanagement.models.SmartGroupModificationItem] + :ivar next_link: URL to fetch the next set of results. + :vartype next_link: str """ _validation = { @@ -1945,6 +1976,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword modifications: Modification details. + :paramtype modifications: list[~azure.mgmt.alertsmanagement.models.SmartGroupModificationItem] + :keyword next_link: URL to fetch the next set of results. + :paramtype next_link: str + """ super(SmartGroupModificationProperties, self).__init__(**kwargs) self.smart_group_id = None self.modifications = modifications @@ -1954,10 +1991,10 @@ def __init__( class SmartGroupsList(msrest.serialization.Model): """List the alerts. - :param next_link: URL to fetch the next set of alerts. - :type next_link: str - :param value: List of alerts. - :type value: list[~azure.mgmt.alertsmanagement.models.SmartGroup] + :ivar next_link: URL to fetch the next set of alerts. + :vartype next_link: str + :ivar value: List of alerts. + :vartype value: list[~azure.mgmt.alertsmanagement.models.SmartGroup] """ _attribute_map = { @@ -1972,170 +2009,125 @@ def __init__( value: Optional[List["SmartGroup"]] = None, **kwargs ): + """ + :keyword next_link: URL to fetch the next set of alerts. + :paramtype next_link: str + :keyword value: List of alerts. + :paramtype value: list[~azure.mgmt.alertsmanagement.models.SmartGroup] + """ super(SmartGroupsList, self).__init__(**kwargs) self.next_link = next_link self.value = value -class Suppression(ActionRuleProperties): - """Action rule with suppression configuration. +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :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. + :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar last_modified_by: Last modified by user name. + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.alertsmanagement.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. :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 + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.alertsmanagement.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype 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 - - -class SuppressionConfig(msrest.serialization.Model): - """Suppression logic for a given action rule. + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.alertsmanagement.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.alertsmanagement.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + 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 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 + :ivar recurrence_type: Required. Specifies when the recurrence should be applied.Constant + filled by server. Possible values include: "Daily", "Weekly", "Monthly". + :vartype recurrence_type: str or ~azure.mgmt.alertsmanagement.models.RecurrenceType + :ivar start_time: Start time for recurrence. + :vartype start_time: str + :ivar end_time: End time for recurrence. + :vartype end_time: str + :ivar days_of_week: Required. Specifies the values for weekly recurrence pattern. + :vartype 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 + """ + :keyword start_time: Start time for recurrence. + :paramtype start_time: str + :keyword end_time: End time for recurrence. + :paramtype end_time: str + :keyword days_of_week: Required. Specifies the values for weekly recurrence pattern. + :paramtype days_of_week: list[str or ~azure.mgmt.alertsmanagement.models.DaysOfWeek] + """ + 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/_alert_processing_rules_operations.py b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alert_processing_rules_operations.py new file mode 100644 index 000000000000..4cc8067862d7 --- /dev/null +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_alert_processing_rules_operations.py @@ -0,0 +1,655 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +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 HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-08" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/actionRules') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-08" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_name_request( + subscription_id: str, + resource_group_name: str, + alert_processing_rule_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-08" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "alertProcessingRuleName": _SERIALIZER.url("alert_processing_rule_name", alert_processing_rule_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + alert_processing_rule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-08-08" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "alertProcessingRuleName": _SERIALIZER.url("alert_processing_rule_name", alert_processing_rule_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + alert_processing_rule_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-08" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "alertProcessingRuleName": _SERIALIZER.url("alert_processing_rule_name", alert_processing_rule_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + alert_processing_rule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-08-08" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "alertProcessingRuleName": _SERIALIZER.url("alert_processing_rule_name", alert_processing_rule_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + +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. + + :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 + + @distributed_trace + def list_by_subscription( + self, + **kwargs: Any + ) -> Iterable["_models.AlertProcessingRulesList"]: + """List all alert processing rules in a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :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.AlertProcessingRulesList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AlertProcessingRulesList", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + 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 + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.AlertProcessingRulesList"]: + """List all alert processing rules in a resource group. + + :param resource_group_name: Resource group name where the resource is created. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :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.AlertProcessingRulesList"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("AlertProcessingRulesList", 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]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + 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 + + @distributed_trace + def get_by_name( + self, + resource_group_name: str, + alert_processing_rule_name: str, + **kwargs: Any + ) -> "_models.AlertProcessingRule": + """Get an alert processing rule by name. + + :param resource_group_name: Resource group name where the resource is created. + :type resource_group_name: str + :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: 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.AlertProcessingRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_by_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + alert_processing_rule_name=alert_processing_rule_name, + template_url=self.get_by_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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.failsafe_deserialize(_models.ErrorResponse, pipeline_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, deserialized, response_headers) + + return deserialized + + get_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}'} # type: ignore + + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + 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: Resource group name where the resource is created. + :type resource_group_name: str + :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: 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.AlertProcessingRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(alert_processing_rule, 'AlertProcessingRule') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + alert_processing_rule_name=alert_processing_rule_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 200: + 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: + 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, response_headers) + + return deserialized + + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}'} # type: ignore + + + @distributed_trace + def delete( + self, + resource_group_name: str, + alert_processing_rule_name: str, + **kwargs: Any + ) -> None: + """Delete an alert processing rule. + + :param resource_group_name: Resource group name where the resource is created. + :type resource_group_name: str + :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: None, or the result of cls(response) + :rtype: None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + alert_processing_rule_name=alert_processing_rule_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + 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, None, response_headers) + + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AlertsManagement/actionRules/{alertProcessingRuleName}'} # type: ignore + + + @distributed_trace + def update( + self, + resource_group_name: str, + 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: Resource group name where the resource is created. + :type resource_group_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: 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.AlertProcessingRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(alert_processing_rule_patch, 'PatchObject') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + alert_processing_rule_name=alert_processing_rule_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + 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.failsafe_deserialize(_models.ErrorResponse, pipeline_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, deserialized, response_headers) + + 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..59bdcbcdf629 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 @@ -5,23 +5,305 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union 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.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer 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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_meta_data_request( + *, + identifier: Union[str, "_models.Identifier"], + **kwargs: Any +) -> HttpRequest: + api_version = "2019-05-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.AlertsManagement/alertsMetaData') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['identifier'] = _SERIALIZER.query("identifier", identifier, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_all_request( + subscription_id: str, + *, + target_resource: Optional[str] = None, + target_resource_type: Optional[str] = None, + target_resource_group: Optional[str] = None, + monitor_service: Optional[Union[str, "_models.MonitorService"]] = None, + monitor_condition: Optional[Union[str, "_models.MonitorCondition"]] = None, + severity: Optional[Union[str, "_models.Severity"]] = None, + alert_state: Optional[Union[str, "_models.AlertState"]] = None, + alert_rule: Optional[str] = None, + smart_group_id: Optional[str] = None, + include_context: Optional[bool] = None, + 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.SortOrder"]] = None, + select: Optional[str] = None, + time_range: Optional[Union[str, "_models.TimeRange"]] = None, + custom_time_range: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-05-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if target_resource is not None: + query_parameters['targetResource'] = _SERIALIZER.query("target_resource", target_resource, 'str') + if target_resource_type is not None: + query_parameters['targetResourceType'] = _SERIALIZER.query("target_resource_type", target_resource_type, 'str') + if target_resource_group is not None: + query_parameters['targetResourceGroup'] = _SERIALIZER.query("target_resource_group", target_resource_group, 'str') + if monitor_service is not None: + query_parameters['monitorService'] = _SERIALIZER.query("monitor_service", monitor_service, 'str') + if monitor_condition is not None: + query_parameters['monitorCondition'] = _SERIALIZER.query("monitor_condition", monitor_condition, 'str') + if severity is not None: + query_parameters['severity'] = _SERIALIZER.query("severity", severity, 'str') + if alert_state is not None: + query_parameters['alertState'] = _SERIALIZER.query("alert_state", alert_state, 'str') + if alert_rule is not None: + query_parameters['alertRule'] = _SERIALIZER.query("alert_rule", alert_rule, 'str') + if smart_group_id is not None: + query_parameters['smartGroupId'] = _SERIALIZER.query("smart_group_id", smart_group_id, 'str') + if include_context is not None: + query_parameters['includeContext'] = _SERIALIZER.query("include_context", include_context, 'bool') + if include_egress_config is not None: + query_parameters['includeEgressConfig'] = _SERIALIZER.query("include_egress_config", include_egress_config, 'bool') + if page_count is not None: + query_parameters['pageCount'] = _SERIALIZER.query("page_count", page_count, 'long') + if sort_by is not None: + query_parameters['sortBy'] = _SERIALIZER.query("sort_by", sort_by, 'str') + if sort_order is not None: + query_parameters['sortOrder'] = _SERIALIZER.query("sort_order", sort_order, 'str') + if select is not None: + query_parameters['select'] = _SERIALIZER.query("select", select, 'str') + if time_range is not None: + query_parameters['timeRange'] = _SERIALIZER.query("time_range", time_range, 'str') + if custom_time_range is not None: + query_parameters['customTimeRange'] = _SERIALIZER.query("custom_time_range", custom_time_range, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + subscription_id: str, + alert_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-05-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts/{alertId}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "alertId": _SERIALIZER.url("alert_id", alert_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_change_state_request( + subscription_id: str, + alert_id: str, + *, + new_state: Union[str, "_models.AlertState"], + **kwargs: Any +) -> HttpRequest: + api_version = "2019-05-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts/{alertId}/changestate') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "alertId": _SERIALIZER.url("alert_id", alert_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['newState'] = _SERIALIZER.query("new_state", new_state, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_history_request( + subscription_id: str, + alert_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-05-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts/{alertId}/history') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "alertId": _SERIALIZER.url("alert_id", alert_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_summary_request( + subscription_id: str, + *, + groupby: Union[str, "_models.AlertsSummaryGroupByFields"], + include_smart_groups_count: Optional[bool] = None, + target_resource: Optional[str] = None, + target_resource_type: Optional[str] = None, + target_resource_group: Optional[str] = None, + monitor_service: Optional[Union[str, "_models.MonitorService"]] = None, + monitor_condition: Optional[Union[str, "_models.MonitorCondition"]] = None, + severity: Optional[Union[str, "_models.Severity"]] = None, + alert_state: Optional[Union[str, "_models.AlertState"]] = None, + alert_rule: Optional[str] = None, + time_range: Optional[Union[str, "_models.TimeRange"]] = None, + custom_time_range: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-05-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alertsSummary') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['groupby'] = _SERIALIZER.query("groupby", groupby, 'str') + if include_smart_groups_count is not None: + query_parameters['includeSmartGroupsCount'] = _SERIALIZER.query("include_smart_groups_count", include_smart_groups_count, 'bool') + if target_resource is not None: + query_parameters['targetResource'] = _SERIALIZER.query("target_resource", target_resource, 'str') + if target_resource_type is not None: + query_parameters['targetResourceType'] = _SERIALIZER.query("target_resource_type", target_resource_type, 'str') + if target_resource_group is not None: + query_parameters['targetResourceGroup'] = _SERIALIZER.query("target_resource_group", target_resource_group, 'str') + if monitor_service is not None: + query_parameters['monitorService'] = _SERIALIZER.query("monitor_service", monitor_service, 'str') + if monitor_condition is not None: + query_parameters['monitorCondition'] = _SERIALIZER.query("monitor_condition", monitor_condition, 'str') + if severity is not None: + query_parameters['severity'] = _SERIALIZER.query("severity", severity, 'str') + if alert_state is not None: + query_parameters['alertState'] = _SERIALIZER.query("alert_state", alert_state, 'str') + if alert_rule is not None: + query_parameters['alertRule'] = _SERIALIZER.query("alert_rule", alert_rule, 'str') + if time_range is not None: + query_parameters['timeRange'] = _SERIALIZER.query("time_range", time_range, 'str') + if custom_time_range is not None: + query_parameters['customTimeRange'] = _SERIALIZER.query("custom_time_range", custom_time_range, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AlertsOperations(object): """AlertsOperations operations. @@ -45,12 +327,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def meta_data( self, - identifier, # type: Union[str, "_models.Identifier"] - **kwargs # type: Any - ): - # type: (...) -> "_models.AlertsMetaData" + identifier: Union[str, "_models.Identifier"], + **kwargs: Any + ) -> "_models.AlertsMetaData": """List alerts meta data information based on value of identifier parameter. :param identifier: Identification of the information to be retrieved by API call. @@ -65,28 +347,22 @@ def meta_data( 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.meta_data.metadata['url'] # type: ignore - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - query_parameters['identifier'] = self._serialize.query("identifier", identifier, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_meta_data_request( + identifier=identifier, + template_url=self.meta_data.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertsMetaData', pipeline_response) @@ -94,30 +370,32 @@ def meta_data( return cls(pipeline_response, deserialized, {}) return deserialized + meta_data.metadata = {'url': '/providers/Microsoft.AlertsManagement/alertsMetaData'} # type: ignore + + @distributed_trace def get_all( self, - target_resource=None, # type: Optional[str] - target_resource_type=None, # type: Optional[str] - target_resource_group=None, # type: Optional[str] - monitor_service=None, # type: Optional[Union[str, "_models.MonitorService"]] - monitor_condition=None, # type: Optional[Union[str, "_models.MonitorCondition"]] - severity=None, # type: Optional[Union[str, "_models.Severity"]] - alert_state=None, # type: Optional[Union[str, "_models.AlertState"]] - alert_rule=None, # type: Optional[str] - smart_group_id=None, # type: Optional[str] - include_context=None, # type: Optional[bool] - 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"]] - select=None, # type: Optional[str] - time_range=None, # type: Optional[Union[str, "_models.TimeRange"]] - custom_time_range=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AlertsList"] + target_resource: Optional[str] = None, + target_resource_type: Optional[str] = None, + target_resource_group: Optional[str] = None, + monitor_service: Optional[Union[str, "_models.MonitorService"]] = None, + monitor_condition: Optional[Union[str, "_models.MonitorCondition"]] = None, + severity: Optional[Union[str, "_models.Severity"]] = None, + alert_state: Optional[Union[str, "_models.AlertState"]] = None, + alert_rule: Optional[str] = None, + smart_group_id: Optional[str] = None, + include_context: Optional[bool] = None, + 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.SortOrder"]] = None, + select: Optional[str] = None, + time_range: Optional[Union[str, "_models.TimeRange"]] = None, + custom_time_range: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_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 default being lastModifiedDateTime. @@ -153,23 +431,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.SortOrder :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) @@ -181,68 +459,63 @@ def get_all( 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.get_all.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 is not None: - query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') - if target_resource_type is not None: - query_parameters['targetResourceType'] = self._serialize.query("target_resource_type", target_resource_type, 'str') - if target_resource_group is not None: - query_parameters['targetResourceGroup'] = self._serialize.query("target_resource_group", target_resource_group, 'str') - if monitor_service is not None: - query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') - if monitor_condition is not None: - query_parameters['monitorCondition'] = self._serialize.query("monitor_condition", monitor_condition, 'str') - if severity is not None: - query_parameters['severity'] = self._serialize.query("severity", severity, 'str') - if alert_state is not None: - query_parameters['alertState'] = self._serialize.query("alert_state", alert_state, 'str') - if alert_rule is not None: - query_parameters['alertRule'] = self._serialize.query("alert_rule", alert_rule, 'str') - if smart_group_id is not None: - query_parameters['smartGroupId'] = self._serialize.query("smart_group_id", smart_group_id, 'str') - if include_context is not None: - query_parameters['includeContext'] = self._serialize.query("include_context", include_context, 'bool') - 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') - if sort_by is not None: - query_parameters['sortBy'] = self._serialize.query("sort_by", sort_by, 'str') - if sort_order is not None: - query_parameters['sortOrder'] = self._serialize.query("sort_order", sort_order, 'str') - if select is not None: - query_parameters['select'] = self._serialize.query("select", select, 'str') - if time_range is not None: - query_parameters['timeRange'] = self._serialize.query("time_range", time_range, 'str') - if custom_time_range is not None: - query_parameters['customTimeRange'] = self._serialize.query("custom_time_range", custom_time_range, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_all_request( + subscription_id=self._config.subscription_id, + target_resource=target_resource, + target_resource_type=target_resource_type, + target_resource_group=target_resource_group, + monitor_service=monitor_service, + monitor_condition=monitor_condition, + severity=severity, + alert_state=alert_state, + alert_rule=alert_rule, + smart_group_id=smart_group_id, + include_context=include_context, + include_egress_config=include_egress_config, + page_count=page_count, + sort_by=sort_by, + sort_order=sort_order, + select=select, + time_range=time_range, + custom_time_range=custom_time_range, + template_url=self.get_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_all_request( + subscription_id=self._config.subscription_id, + target_resource=target_resource, + target_resource_type=target_resource_type, + target_resource_group=target_resource_group, + monitor_service=monitor_service, + monitor_condition=monitor_condition, + severity=severity, + alert_state=alert_state, + alert_rule=alert_rule, + smart_group_id=smart_group_id, + include_context=include_context, + include_egress_config=include_egress_config, + page_count=page_count, + sort_by=sort_by, + sort_order=sort_order, + select=select, + time_range=time_range, + custom_time_range=custom_time_range, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AlertsList', pipeline_response) + deserialized = self._deserialize("AlertsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -255,23 +528,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponseAutoGenerated, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_all.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts'} # type: ignore + @distributed_trace def get_by_id( self, - alert_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.Alert" + alert_id: str, + **kwargs: Any + ) -> "_models.Alert": """Get a specific alert. Get information related to a specific alert. @@ -288,32 +562,22 @@ def get_by_id( 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_id.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'alertId': self._serialize.url("alert_id", alert_id, '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 = build_get_by_id_request( + subscription_id=self._config.subscription_id, + alert_id=alert_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Alert', pipeline_response) @@ -322,15 +586,17 @@ def get_by_id( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts/{alertId}'} # type: ignore + + @distributed_trace def change_state( self, - alert_id, # type: str - new_state, # type: Union[str, "_models.AlertState"] - **kwargs # type: Any - ): - # type: (...) -> "_models.Alert" + alert_id: str, + new_state: Union[str, "_models.AlertState"], + **kwargs: Any + ) -> "_models.Alert": """Change the state of an alert. :param alert_id: Unique ID of an alert instance. @@ -347,33 +613,23 @@ def change_state( 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.change_state.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'alertId': self._serialize.url("alert_id", alert_id, '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') - query_parameters['newState'] = self._serialize.query("new_state", new_state, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_change_state_request( + subscription_id=self._config.subscription_id, + alert_id=alert_id, + new_state=new_state, + template_url=self.change_state.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(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.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Alert', pipeline_response) @@ -382,14 +638,16 @@ def change_state( return cls(pipeline_response, deserialized, {}) return deserialized + change_state.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts/{alertId}/changestate'} # type: ignore + + @distributed_trace def get_history( self, - alert_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AlertModification" + alert_id: str, + **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). @@ -405,32 +663,22 @@ def get_history( 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_history.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'alertId': self._serialize.url("alert_id", alert_id, '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 = build_get_history_request( + subscription_id=self._config.subscription_id, + alert_id=alert_id, + template_url=self.get_history.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertModification', pipeline_response) @@ -439,25 +687,27 @@ def get_history( return cls(pipeline_response, deserialized, {}) return deserialized + get_history.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alerts/{alertId}/history'} # type: ignore + + @distributed_trace def get_summary( self, - groupby, # type: Union[str, "_models.AlertsSummaryGroupByFields"] - include_smart_groups_count=None, # type: Optional[bool] - target_resource=None, # type: Optional[str] - target_resource_type=None, # type: Optional[str] - target_resource_group=None, # type: Optional[str] - monitor_service=None, # type: Optional[Union[str, "_models.MonitorService"]] - monitor_condition=None, # type: Optional[Union[str, "_models.MonitorCondition"]] - severity=None, # type: Optional[Union[str, "_models.Severity"]] - alert_state=None, # type: Optional[Union[str, "_models.AlertState"]] - alert_rule=None, # type: Optional[str] - time_range=None, # type: Optional[Union[str, "_models.TimeRange"]] - custom_time_range=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.AlertsSummary" + groupby: Union[str, "_models.AlertsSummaryGroupByFields"], + include_smart_groups_count: Optional[bool] = None, + target_resource: Optional[str] = None, + target_resource_type: Optional[str] = None, + target_resource_group: Optional[str] = None, + monitor_service: Optional[Union[str, "_models.MonitorService"]] = None, + monitor_condition: Optional[Union[str, "_models.MonitorCondition"]] = None, + severity: Optional[Union[str, "_models.Severity"]] = None, + alert_state: Optional[Union[str, "_models.AlertState"]] = None, + alert_rule: Optional[str] = None, + time_range: Optional[Union[str, "_models.TimeRange"]] = None, + custom_time_range: Optional[str] = None, + **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). @@ -490,10 +740,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) @@ -505,54 +755,33 @@ def get_summary( 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_summary.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] - query_parameters['groupby'] = self._serialize.query("groupby", groupby, 'str') - if include_smart_groups_count is not None: - query_parameters['includeSmartGroupsCount'] = self._serialize.query("include_smart_groups_count", include_smart_groups_count, 'bool') - if target_resource is not None: - query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') - if target_resource_type is not None: - query_parameters['targetResourceType'] = self._serialize.query("target_resource_type", target_resource_type, 'str') - if target_resource_group is not None: - query_parameters['targetResourceGroup'] = self._serialize.query("target_resource_group", target_resource_group, 'str') - if monitor_service is not None: - query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') - if monitor_condition is not None: - query_parameters['monitorCondition'] = self._serialize.query("monitor_condition", monitor_condition, 'str') - if severity is not None: - query_parameters['severity'] = self._serialize.query("severity", severity, 'str') - if alert_state is not None: - query_parameters['alertState'] = self._serialize.query("alert_state", alert_state, 'str') - if alert_rule is not None: - query_parameters['alertRule'] = self._serialize.query("alert_rule", alert_rule, 'str') - if time_range is not None: - query_parameters['timeRange'] = self._serialize.query("time_range", time_range, 'str') - if custom_time_range is not None: - query_parameters['customTimeRange'] = self._serialize.query("custom_time_range", custom_time_range, 'str') - 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) + + request = build_get_summary_request( + subscription_id=self._config.subscription_id, + groupby=groupby, + include_smart_groups_count=include_smart_groups_count, + target_resource=target_resource, + target_resource_type=target_resource_type, + target_resource_group=target_resource_group, + monitor_service=monitor_service, + monitor_condition=monitor_condition, + severity=severity, + alert_state=alert_state, + alert_rule=alert_rule, + time_range=time_range, + custom_time_range=custom_time_range, + template_url=self.get_summary.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + 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.ErrorResponseAutoGenerated, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertsSummary', pipeline_response) @@ -561,4 +790,6 @@ def get_summary( return cls(pipeline_response, deserialized, {}) return deserialized + get_summary.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/alertsSummary'} # type: ignore + 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..980cd8249dd2 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 @@ -5,23 +5,50 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar 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.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2019-05-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.AlertsManagement/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationsList"] + **kwargs: Any + ) -> Iterable["_models.OperationsList"]: """List all operations available through Azure Alerts Management Resource Provider. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 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.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -99,10 +123,12 @@ def get_next(next_link=None): 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, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) 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/_smart_detector_alert_rules_operations.py deleted file mode 100644 index 0eb0820bf1f7..000000000000 --- a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/azure/mgmt/alertsmanagement/operations/_smart_detector_alert_rules_operations.py +++ /dev/null @@ -1,458 +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 SmartDetectorAlertRulesOperations(object): - """SmartDetectorAlertRulesOperations 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( - 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. - - :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] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRulesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - 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.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] - 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: - 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('AlertRulesList', 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.SmartDetectorErrorResponse, 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.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.alertsManagement/smartDetectorAlertRules'} # 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. - - :param resource_group_name: The name of the resource group. - :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] - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRulesList"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - 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] - 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: - 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('AlertRulesList', 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.SmartDetectorErrorResponse, 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/smartDetectorAlertRules'} # type: ignore - - def get( - self, - resource_group_name, # type: str - alert_rule_name, # type: str - expand_detector=None, # type: Optional[bool] - **kwargs # type: Any - ): - # type: (...) -> "_models.AlertRule" - """Get a specific Smart Detector alert rule. - - :param resource_group_name: The name of the resource group. - :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 - :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 - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRule"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-06-01" - accept = "application/json" - - # Construct URL - url = self.get.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'), - } - 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] - 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.SmartDetectorErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AlertRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} # type: ignore - - def create_or_update( - self, - resource_group_name, # type: str - alert_rule_name, # type: str - parameters, # type: "_models.AlertRule" - **kwargs # type: Any - ): - # type: (...) -> "_models.AlertRule" - """Create or update a Smart Detector alert rule. - - :param resource_group_name: The name of the resource group. - :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 - :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 - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRule"] - 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") - accept = "application/json" - - # Construct URL - url = self.create_or_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'), - } - 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(parameters, 'AlertRule') - 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, 201]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.SmartDetectorErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if response.status_code == 200: - deserialized = self._deserialize('AlertRule', pipeline_response) - - if response.status_code == 201: - deserialized = self._deserialize('AlertRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} # type: ignore - - def patch( - self, - resource_group_name, # type: str - alert_rule_name, # type: str - parameters, # type: "_models.AlertRulePatchObject" - **kwargs # type: Any - ): - # type: (...) -> "_models.AlertRule" - """Patch a specific Smart Detector alert rule. - - :param resource_group_name: The name of the resource group. - :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 - :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 - :raises: ~azure.core.exceptions.HttpResponseError - """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRule"] - 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") - accept = "application/json" - - # Construct URL - url = self.patch.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'), - } - 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(parameters, 'AlertRulePatchObject') - 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.SmartDetectorErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - deserialized = self._deserialize('AlertRule', pipeline_response) - - if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized - patch.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} # type: ignore - - def delete( - self, - resource_group_name, # type: str - alert_rule_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None - """Delete an existing Smart Detector alert rule. - - :param resource_group_name: The name of the resource group. - :type resource_group_name: str - :param alert_rule_name: The name of the alert rule. - :type alert_rule_name: str - :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 - :raises: ~azure.core.exceptions.HttpResponseError - """ - 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" - 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'), - 'alertRuleName': self._serialize.url("alert_rule_name", alert_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, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize(_models.SmartDetectorErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) - - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.alertsManagement/smartDetectorAlertRules/{alertRuleName}'} # type: ignore 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..dabe9f18927c 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 @@ -5,23 +5,192 @@ # 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union 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.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer 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]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_all_request( + subscription_id: str, + *, + target_resource: Optional[str] = None, + target_resource_group: Optional[str] = None, + target_resource_type: Optional[str] = None, + monitor_service: Optional[Union[str, "_models.MonitorService"]] = None, + monitor_condition: Optional[Union[str, "_models.MonitorCondition"]] = None, + severity: Optional[Union[str, "_models.Severity"]] = None, + smart_group_state: Optional[Union[str, "_models.AlertState"]] = None, + 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.SortOrder"]] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-05-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if target_resource is not None: + query_parameters['targetResource'] = _SERIALIZER.query("target_resource", target_resource, 'str') + if target_resource_group is not None: + query_parameters['targetResourceGroup'] = _SERIALIZER.query("target_resource_group", target_resource_group, 'str') + if target_resource_type is not None: + query_parameters['targetResourceType'] = _SERIALIZER.query("target_resource_type", target_resource_type, 'str') + if monitor_service is not None: + query_parameters['monitorService'] = _SERIALIZER.query("monitor_service", monitor_service, 'str') + if monitor_condition is not None: + query_parameters['monitorCondition'] = _SERIALIZER.query("monitor_condition", monitor_condition, 'str') + if severity is not None: + query_parameters['severity'] = _SERIALIZER.query("severity", severity, 'str') + if smart_group_state is not None: + query_parameters['smartGroupState'] = _SERIALIZER.query("smart_group_state", smart_group_state, 'str') + if time_range is not None: + query_parameters['timeRange'] = _SERIALIZER.query("time_range", time_range, 'str') + if page_count is not None: + query_parameters['pageCount'] = _SERIALIZER.query("page_count", page_count, 'long') + if sort_by is not None: + query_parameters['sortBy'] = _SERIALIZER.query("sort_by", sort_by, 'str') + if sort_order is not None: + query_parameters['sortOrder'] = _SERIALIZER.query("sort_order", sort_order, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_id_request( + subscription_id: str, + smart_group_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-05-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "smartGroupId": _SERIALIZER.url("smart_group_id", smart_group_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_change_state_request( + subscription_id: str, + smart_group_id: str, + *, + new_state: Union[str, "_models.AlertState"], + **kwargs: Any +) -> HttpRequest: + api_version = "2019-05-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}/changeState') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "smartGroupId": _SERIALIZER.url("smart_group_id", smart_group_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + query_parameters['newState'] = _SERIALIZER.query("new_state", new_state, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_history_request( + subscription_id: str, + smart_group_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-05-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}/history') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "smartGroupId": _SERIALIZER.url("smart_group_id", smart_group_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class SmartGroupsOperations(object): """SmartGroupsOperations operations. @@ -45,22 +214,22 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_all( self, - target_resource=None, # type: Optional[str] - target_resource_group=None, # type: Optional[str] - target_resource_type=None, # type: Optional[str] - monitor_service=None, # type: Optional[Union[str, "_models.MonitorService"]] - monitor_condition=None, # type: Optional[Union[str, "_models.MonitorCondition"]] - severity=None, # type: Optional[Union[str, "_models.Severity"]] - smart_group_state=None, # type: Optional[Union[str, "_models.AlertState"]] - 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"]] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SmartGroupsList"] + target_resource: Optional[str] = None, + target_resource_group: Optional[str] = None, + target_resource_type: Optional[str] = None, + monitor_service: Optional[Union[str, "_models.MonitorService"]] = None, + monitor_condition: Optional[Union[str, "_models.MonitorCondition"]] = None, + severity: Optional[Union[str, "_models.Severity"]] = None, + smart_group_state: Optional[Union[str, "_models.AlertState"]] = None, + 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.SortOrder"]] = None, + **kwargs: Any + ) -> Iterable["_models.SmartGroupsList"]: """Get all Smart Groups within a specified subscription. List all the Smart Groups within a specified subscription. @@ -88,13 +257,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.SortOrder :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] @@ -105,56 +274,51 @@ def get_all( 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.get_all.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 is not None: - query_parameters['targetResource'] = self._serialize.query("target_resource", target_resource, 'str') - 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 monitor_service is not None: - query_parameters['monitorService'] = self._serialize.query("monitor_service", monitor_service, 'str') - if monitor_condition is not None: - query_parameters['monitorCondition'] = self._serialize.query("monitor_condition", monitor_condition, 'str') - if severity is not None: - query_parameters['severity'] = self._serialize.query("severity", severity, 'str') - if smart_group_state is not None: - query_parameters['smartGroupState'] = self._serialize.query("smart_group_state", smart_group_state, 'str') - 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') - if sort_by is not None: - query_parameters['sortBy'] = self._serialize.query("sort_by", sort_by, 'str') - if sort_order is not None: - query_parameters['sortOrder'] = self._serialize.query("sort_order", sort_order, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_all_request( + subscription_id=self._config.subscription_id, + target_resource=target_resource, + target_resource_group=target_resource_group, + target_resource_type=target_resource_type, + monitor_service=monitor_service, + monitor_condition=monitor_condition, + severity=severity, + smart_group_state=smart_group_state, + time_range=time_range, + page_count=page_count, + sort_by=sort_by, + sort_order=sort_order, + template_url=self.get_all.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_all_request( + subscription_id=self._config.subscription_id, + target_resource=target_resource, + target_resource_group=target_resource_group, + target_resource_type=target_resource_type, + monitor_service=monitor_service, + monitor_condition=monitor_condition, + severity=severity, + smart_group_state=smart_group_state, + time_range=time_range, + page_count=page_count, + sort_by=sort_by, + sort_order=sort_order, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SmartGroupsList', pipeline_response) + deserialized = self._deserialize("SmartGroupsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -167,23 +331,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize(_models.ErrorResponseAutoGenerated2, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_all.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups'} # type: ignore + @distributed_trace def get_by_id( self, - smart_group_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SmartGroup" + smart_group_id: str, + **kwargs: Any + ) -> "_models.SmartGroup": """Get information related to a specific Smart Group. Get information related to a specific Smart Group. @@ -200,51 +365,44 @@ def get_by_id( 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_id.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'smartGroupId': self._serialize.url("smart_group_id", smart_group_id, '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 = build_get_by_id_request( + subscription_id=self._config.subscription_id, + smart_group_id=smart_group_id, + template_url=self.get_by_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.ErrorResponseAutoGenerated2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_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('SmartGroup', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + get_by_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}'} # type: ignore + + @distributed_trace def change_state( self, - smart_group_id, # type: str - new_state, # type: Union[str, "_models.AlertState"] - **kwargs # type: Any - ): - # type: (...) -> "_models.SmartGroup" + smart_group_id: str, + new_state: Union[str, "_models.AlertState"], + **kwargs: Any + ) -> "_models.SmartGroup": """Change the state of a Smart Group. :param smart_group_id: Smart group unique id. @@ -261,51 +419,44 @@ def change_state( 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.change_state.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'smartGroupId': self._serialize.url("smart_group_id", smart_group_id, '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') - query_parameters['newState'] = self._serialize.query("new_state", new_state, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_change_state_request( + subscription_id=self._config.subscription_id, + smart_group_id=smart_group_id, + new_state=new_state, + template_url=self.change_state.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(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.ErrorResponseAutoGenerated2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_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('SmartGroup', pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized + change_state.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}/changeState'} # type: ignore + + @distributed_trace def get_history( self, - smart_group_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SmartGroupModification" + smart_group_id: str, + **kwargs: Any + ) -> "_models.SmartGroupModification": """Get the history a smart group, which captures any Smart Group state changes (New/Acknowledged/Closed) . @@ -321,32 +472,22 @@ def get_history( 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_history.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'smartGroupId': self._serialize.url("smart_group_id", smart_group_id, '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 = build_get_history_request( + subscription_id=self._config.subscription_id, + smart_group_id=smart_group_id, + template_url=self.get_history.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.ErrorResponseAutoGenerated2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseAutoGenerated2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SmartGroupModification', pipeline_response) @@ -355,4 +496,6 @@ def get_history( return cls(pipeline_response, deserialized, {}) return deserialized + get_history.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AlertsManagement/smartGroups/{smartGroupId}/history'} # type: ignore +