diff --git a/sdk/monitor/azure-mgmt-monitor/_meta.json b/sdk/monitor/azure-mgmt-monitor/_meta.json index f0638d534bd25..fdcb76f0acc80 100644 --- a/sdk/monitor/azure-mgmt-monitor/_meta.json +++ b/sdk/monitor/azure-mgmt-monitor/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "a81eaccc23c98d2effd62f1a80b81394be30d2c5", + "commit": "c77c6c634dc3644d65d3e35df5d73a9c34d3c956", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/monitor/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/monitor/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/monitor/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py index 3805e3b3d0572..7a92a65b34c63 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_configuration.py @@ -12,7 +12,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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -68,4 +68,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py index 3dcd1e009c20f..137c91121118f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/_monitor_management_client.py @@ -23,7 +23,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): @@ -105,12 +104,10 @@ def __init__( credential, # type: "TokenCredential" subscription_id, # type: str api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - if not base_url: - base_url = 'https://management.azure.com' self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(MonitorManagementClient, self).__init__( diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_configuration.py index ef0b2052527fc..d1088d0ae2a58 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_configuration.py @@ -12,7 +12,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 @@ -64,4 +64,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_monitor_management_client.py index 41a59c75017f8..d864d21a5b375 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/aio/_monitor_management_client.py @@ -11,7 +11,6 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -21,6 +20,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -103,12 +103,10 @@ def __init__( credential: "AsyncTokenCredential", subscription_id: str, api_version: Optional[str] = None, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, **kwargs # type: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(MonitorManagementClient, self).__init__( diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_configuration.py index 224f0bceaf6e9..7b96775991e58 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -67,4 +67,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_metadata.json index c775045988749..3399fadde8828 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "activity_logs": "ActivityLogsOperations", diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_monitor_management_client.py index 030cec917f7b2..c4ffecd776a4e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_monitor_management_client.py @@ -6,27 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ActivityLogsOperations, AlertRulesOperations, AutoscaleSettingsOperations, EventCategoriesOperations, Operations, TenantActivityLogsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActivityLogsOperations -from .operations import AutoscaleSettingsOperations -from .operations import EventCategoriesOperations -from .operations import Operations -from .operations import TenantActivityLogsOperations -from .operations import AlertRulesOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. @@ -34,70 +29,75 @@ class MonitorManagementClient(object): :ivar activity_logs: ActivityLogsOperations operations :vartype activity_logs: $(python-base-namespace).v2015_04_01.operations.ActivityLogsOperations :ivar autoscale_settings: AutoscaleSettingsOperations operations - :vartype autoscale_settings: $(python-base-namespace).v2015_04_01.operations.AutoscaleSettingsOperations + :vartype autoscale_settings: + $(python-base-namespace).v2015_04_01.operations.AutoscaleSettingsOperations :ivar event_categories: EventCategoriesOperations operations - :vartype event_categories: $(python-base-namespace).v2015_04_01.operations.EventCategoriesOperations + :vartype event_categories: + $(python-base-namespace).v2015_04_01.operations.EventCategoriesOperations :ivar operations: Operations operations :vartype operations: $(python-base-namespace).v2015_04_01.operations.Operations :ivar tenant_activity_logs: TenantActivityLogsOperations operations - :vartype tenant_activity_logs: $(python-base-namespace).v2015_04_01.operations.TenantActivityLogsOperations + :vartype tenant_activity_logs: + $(python-base-namespace).v2015_04_01.operations.TenantActivityLogsOperations :ivar alert_rules: AlertRulesOperations operations :vartype alert_rules: $(python-base-namespace).v2015_04_01.operations.AlertRulesOperations :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.activity_logs = ActivityLogsOperations(self._client, self._config, self._serialize, self._deserialize) + self.autoscale_settings = AutoscaleSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.event_categories = EventCategoriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.tenant_activity_logs = TenantActivityLogsOperations(self._client, self._config, self._serialize, self._deserialize) + self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) + - self.activity_logs = ActivityLogsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.autoscale_settings = AutoscaleSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.event_categories = EventCategoriesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.tenant_activity_logs = TenantActivityLogsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alert_rules = AlertRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_configuration.py index a1b513c610d41..34bea0f7b2022 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_monitor_management_client.py index 0e8dd89e73a9b..1859b81d454f4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_monitor_management_client.py @@ -6,94 +6,95 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ActivityLogsOperations, AlertRulesOperations, AutoscaleSettingsOperations, EventCategoriesOperations, Operations, TenantActivityLogsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActivityLogsOperations -from .operations import AutoscaleSettingsOperations -from .operations import EventCategoriesOperations -from .operations import Operations -from .operations import TenantActivityLogsOperations -from .operations import AlertRulesOperations -from .. import models - - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar activity_logs: ActivityLogsOperations operations - :vartype activity_logs: $(python-base-namespace).v2015_04_01.aio.operations.ActivityLogsOperations + :vartype activity_logs: + $(python-base-namespace).v2015_04_01.aio.operations.ActivityLogsOperations :ivar autoscale_settings: AutoscaleSettingsOperations operations - :vartype autoscale_settings: $(python-base-namespace).v2015_04_01.aio.operations.AutoscaleSettingsOperations + :vartype autoscale_settings: + $(python-base-namespace).v2015_04_01.aio.operations.AutoscaleSettingsOperations :ivar event_categories: EventCategoriesOperations operations - :vartype event_categories: $(python-base-namespace).v2015_04_01.aio.operations.EventCategoriesOperations + :vartype event_categories: + $(python-base-namespace).v2015_04_01.aio.operations.EventCategoriesOperations :ivar operations: Operations operations :vartype operations: $(python-base-namespace).v2015_04_01.aio.operations.Operations :ivar tenant_activity_logs: TenantActivityLogsOperations operations - :vartype tenant_activity_logs: $(python-base-namespace).v2015_04_01.aio.operations.TenantActivityLogsOperations + :vartype tenant_activity_logs: + $(python-base-namespace).v2015_04_01.aio.operations.TenantActivityLogsOperations :ivar alert_rules: AlertRulesOperations operations :vartype alert_rules: $(python-base-namespace).v2015_04_01.aio.operations.AlertRulesOperations :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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.activity_logs = ActivityLogsOperations(self._client, self._config, self._serialize, self._deserialize) + self.autoscale_settings = AutoscaleSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.event_categories = EventCategoriesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.tenant_activity_logs = TenantActivityLogsOperations(self._client, self._config, self._serialize, self._deserialize) + self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) + - self.activity_logs = ActivityLogsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.autoscale_settings = AutoscaleSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.event_categories = EventCategoriesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.tenant_activity_logs = TenantActivityLogsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alert_rules = AlertRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_activity_logs_operations.py index 41231e8634521..6ebd670f23bfe 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_activity_logs_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_activity_logs_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._activity_logs_operations import build_list_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 list( self, filter: str, @@ -74,7 +80,8 @@ def list( :type select: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EventDataCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.EventDataCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.EventDataCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventDataCollection"] @@ -82,37 +89,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-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') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if select is not None: - query_parameters['$select'] = self._serialize.query("select", select, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + select=select, + template_url=self.list.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_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + select=select, + 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('EventDataCollection', pipeline_response) + deserialized = self._deserialize("EventDataCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -125,12 +128,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_alert_rules_operations.py index fe527b21b9613..0090b24ecd122 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_alert_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_alert_rules_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._alert_rules_operations import build_create_or_update_request, build_delete_request, build_get_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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -50,7 +56,7 @@ async def create_or_update( ) -> "_models.AlertRuleResource": """Creates or updates a classic metric alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -66,38 +72,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'AlertRuleResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AlertRuleResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -110,8 +106,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -120,7 +119,7 @@ async def delete( ) -> None: """Deletes a classic metric alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -134,33 +133,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -168,6 +157,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -176,7 +167,7 @@ async def get( ) -> "_models.AlertRuleResource": """Gets a classic metric alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -190,33 +181,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertRuleResource', pipeline_response) @@ -225,8 +206,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -237,7 +221,7 @@ async def update( """Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -253,38 +237,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - 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'), - 'ruleName': self._serialize.url("rule_name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') - 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, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -297,8 +271,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -306,11 +283,13 @@ def list_by_resource_group( ) -> AsyncIterable["_models.AlertRuleResourceCollection"]: """List the classic metric alert rules within a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 AlertRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResourceCollection] + :return: An iterator like instance of either AlertRuleResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] @@ -318,35 +297,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('AlertRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -359,17 +334,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Insights/alertrules'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -377,8 +354,10 @@ def list_by_subscription( """List the classic metric alert rules within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResourceCollection] + :return: An iterator like instance of either AlertRuleResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] @@ -386,34 +365,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-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_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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('AlertRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -426,12 +400,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_autoscale_settings_operations.py index d6e489c04fa10..19844d7ade469 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_autoscale_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_autoscale_settings_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._autoscale_settings_operations import build_create_or_update_request, build_delete_request, build_get_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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -48,11 +54,13 @@ def list_by_resource_group( ) -> AsyncIterable["_models.AutoscaleSettingResourceCollection"]: """Lists the autoscale settings for a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 AutoscaleSettingResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourceCollection] + :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResourceCollection"] @@ -60,35 +68,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('AutoscaleSettingResourceCollection', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,17 +105,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Insights/autoscalesettings'} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -121,7 +127,7 @@ async def create_or_update( ) -> "_models.AutoscaleSettingResource": """Creates or updates an autoscale setting. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str @@ -137,38 +143,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'autoscaleSettingName': self._serialize.url("autoscale_setting_name", autoscale_setting_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AutoscaleSettingResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AutoscaleSettingResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -181,8 +177,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -191,7 +190,7 @@ async def delete( ) -> None: """Deletes and autoscale setting. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str @@ -205,33 +204,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'autoscaleSettingName': self._serialize.url("autoscale_setting_name", autoscale_setting_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -239,6 +228,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -247,7 +238,7 @@ async def get( ) -> "_models.AutoscaleSettingResource": """Gets an autoscale setting. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str @@ -261,33 +252,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'autoscaleSettingName': self._serialize.url("autoscale_setting_name", autoscale_setting_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) @@ -296,8 +277,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -308,12 +292,13 @@ async def update( """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str :param autoscale_setting_resource: Parameters supplied to the operation. - :type autoscale_setting_resource: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourcePatch + :type autoscale_setting_resource: + ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourcePatch :keyword callable cls: A custom type or function that will be passed the direct response :return: AutoscaleSettingResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource @@ -324,38 +309,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-01" - 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'), - 'autoscaleSettingName': self._serialize.url("autoscale_setting_name", autoscale_setting_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(autoscale_setting_resource, 'AutoscaleSettingResourcePatch') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(autoscale_setting_resource, 'AutoscaleSettingResourcePatch') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) @@ -364,8 +339,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -373,8 +351,10 @@ def list_by_subscription( """Lists the autoscale settings for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourceCollection] + :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResourceCollection"] @@ -382,34 +362,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-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_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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('AutoscaleSettingResourceCollection', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -422,12 +397,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_event_categories_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_event_categories_operations.py index 288c4bc49327e..16baeea9aeca2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_event_categories_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_event_categories_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._event_categories_operations import build_list_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 list( self, **kwargs: Any @@ -50,8 +56,10 @@ def list( ServiceHealth, Alert, Recommendation, Policy. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventCategoryCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.EventCategoryCollection] + :return: An iterator like instance of either EventCategoryCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.EventCategoryCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventCategoryCollection"] @@ -59,30 +67,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-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 - # 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('EventCategoryCollection', pipeline_response) + deserialized = self._deserialize("EventCategoryCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -95,12 +100,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_operations.py index 53313b5ec127e..2a7b6d9a147a8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_operations.py @@ -5,16 +5,20 @@ # 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, Optional, TypeVar import warnings 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_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]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, **kwargs: Any @@ -56,21 +61,14 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-01" - accept = "application/json" - - # 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, '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) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -84,4 +82,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/providers/Microsoft.Insights/operations'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_tenant_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_tenant_activity_logs_operations.py index 53fd30b722a55..e9a9c1f5aab28 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_tenant_activity_logs_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/aio/operations/_tenant_activity_logs_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._tenant_activity_logs_operations import build_list_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 list( self, filter: Optional[str] = None, @@ -79,7 +85,8 @@ def list( :type select: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EventDataCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.EventDataCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_04_01.models.EventDataCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventDataCollection"] @@ -87,34 +94,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-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 - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if select is not None: - query_parameters['$select'] = self._serialize.query("select", select, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + filter=filter, + select=select, + template_url=self.list.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_list_request( + filter=filter, + select=select, + 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('EventDataCollection', pipeline_response) + deserialized = self._deserialize("EventDataCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -127,12 +131,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models.py index 8996b10f93c82..a7e2ad02b905d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models.py @@ -23,10 +23,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -48,6 +48,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -69,26 +75,26 @@ class AlertRuleResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param name_properties_name: Required. the name of the alert rule. - :type name_properties_name: str - :param description: the description of the alert rule that will be included in the alert email. - :type description: str - :param provisioning_state: the provisioning state. - :type provisioning_state: str - :param is_enabled: Required. the flag that indicates whether the alert rule is enabled. - :type is_enabled: bool - :param condition: Required. the condition that results in the alert rule being activated. - :type condition: ~$(python-base-namespace).v2015_04_01.models.RuleCondition - :param action: action that is performed when the alert rule becomes active, and when an alert + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar name_properties_name: Required. the name of the alert rule. + :vartype name_properties_name: str + :ivar description: the description of the alert rule that will be included in the alert email. + :vartype description: str + :ivar provisioning_state: the provisioning state. + :vartype provisioning_state: str + :ivar is_enabled: Required. the flag that indicates whether the alert rule is enabled. + :vartype is_enabled: bool + :ivar condition: Required. the condition that results in the alert rule being activated. + :vartype condition: ~$(python-base-namespace).v2015_04_01.models.RuleCondition + :ivar action: action that is performed when the alert rule becomes active, and when an alert condition is resolved. - :type action: ~$(python-base-namespace).v2015_04_01.models.RuleAction - :param actions: the array of actions that are performed when the alert rule becomes active, and + :vartype action: ~$(python-base-namespace).v2015_04_01.models.RuleAction + :ivar actions: the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. - :type actions: list[~$(python-base-namespace).v2015_04_01.models.RuleAction] + :vartype actions: list[~$(python-base-namespace).v2015_04_01.models.RuleAction] :ivar last_updated_time: Last time the rule was updated in ISO8601 format. :vartype last_updated_time: ~datetime.datetime """ @@ -124,6 +130,29 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword name_properties_name: Required. the name of the alert rule. + :paramtype name_properties_name: str + :keyword description: the description of the alert rule that will be included in the alert + email. + :paramtype description: str + :keyword provisioning_state: the provisioning state. + :paramtype provisioning_state: str + :keyword is_enabled: Required. the flag that indicates whether the alert rule is enabled. + :paramtype is_enabled: bool + :keyword condition: Required. the condition that results in the alert rule being activated. + :paramtype condition: ~$(python-base-namespace).v2015_04_01.models.RuleCondition + :keyword action: action that is performed when the alert rule becomes active, and when an alert + condition is resolved. + :paramtype action: ~$(python-base-namespace).v2015_04_01.models.RuleAction + :keyword actions: the array of actions that are performed when the alert rule becomes active, + and when an alert condition is resolved. + :paramtype actions: list[~$(python-base-namespace).v2015_04_01.models.RuleAction] + """ super(AlertRuleResource, self).__init__(**kwargs) self.name_properties_name = kwargs['name_properties_name'] self.description = kwargs.get('description', None) @@ -138,8 +167,8 @@ def __init__( class AlertRuleResourceCollection(msrest.serialization.Model): """Represents a collection of alert rule resources. - :param value: the values for the alert rule resources. - :type value: list[~$(python-base-namespace).v2015_04_01.models.AlertRuleResource] + :ivar value: the values for the alert rule resources. + :vartype value: list[~$(python-base-namespace).v2015_04_01.models.AlertRuleResource] """ _attribute_map = { @@ -150,6 +179,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: the values for the alert rule resources. + :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.AlertRuleResource] + """ super(AlertRuleResourceCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -159,24 +192,24 @@ class AlertRuleResourcePatch(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param name: the name of the alert rule. - :type name: str - :param description: the description of the alert rule that will be included in the alert email. - :type description: str - :param provisioning_state: the provisioning state. - :type provisioning_state: str - :param is_enabled: the flag that indicates whether the alert rule is enabled. - :type is_enabled: bool - :param condition: the condition that results in the alert rule being activated. - :type condition: ~$(python-base-namespace).v2015_04_01.models.RuleCondition - :param action: action that is performed when the alert rule becomes active, and when an alert + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar name: the name of the alert rule. + :vartype name: str + :ivar description: the description of the alert rule that will be included in the alert email. + :vartype description: str + :ivar provisioning_state: the provisioning state. + :vartype provisioning_state: str + :ivar is_enabled: the flag that indicates whether the alert rule is enabled. + :vartype is_enabled: bool + :ivar condition: the condition that results in the alert rule being activated. + :vartype condition: ~$(python-base-namespace).v2015_04_01.models.RuleCondition + :ivar action: action that is performed when the alert rule becomes active, and when an alert condition is resolved. - :type action: ~$(python-base-namespace).v2015_04_01.models.RuleAction - :param actions: the array of actions that are performed when the alert rule becomes active, and + :vartype action: ~$(python-base-namespace).v2015_04_01.models.RuleAction + :ivar actions: the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. - :type actions: list[~$(python-base-namespace).v2015_04_01.models.RuleAction] + :vartype actions: list[~$(python-base-namespace).v2015_04_01.models.RuleAction] :ivar last_updated_time: Last time the rule was updated in ISO8601 format. :vartype last_updated_time: ~datetime.datetime """ @@ -201,6 +234,27 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword name: the name of the alert rule. + :paramtype name: str + :keyword description: the description of the alert rule that will be included in the alert + email. + :paramtype description: str + :keyword provisioning_state: the provisioning state. + :paramtype provisioning_state: str + :keyword is_enabled: the flag that indicates whether the alert rule is enabled. + :paramtype is_enabled: bool + :keyword condition: the condition that results in the alert rule being activated. + :paramtype condition: ~$(python-base-namespace).v2015_04_01.models.RuleCondition + :keyword action: action that is performed when the alert rule becomes active, and when an alert + condition is resolved. + :paramtype action: ~$(python-base-namespace).v2015_04_01.models.RuleAction + :keyword actions: the array of actions that are performed when the alert rule becomes active, + and when an alert condition is resolved. + :paramtype actions: list[~$(python-base-namespace).v2015_04_01.models.RuleAction] + """ super(AlertRuleResourcePatch, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.name = kwargs.get('name', None) @@ -223,10 +277,10 @@ class AutoscaleNotification(msrest.serialization.Model): :ivar operation: the operation associated with the notification and its value must be "scale". Has constant value: "Scale". :vartype operation: str - :param email: the email notification. - :type email: ~$(python-base-namespace).v2015_04_01.models.EmailNotification - :param webhooks: the collection of webhook notifications. - :type webhooks: list[~$(python-base-namespace).v2015_04_01.models.WebhookNotification] + :ivar email: the email notification. + :vartype email: ~$(python-base-namespace).v2015_04_01.models.EmailNotification + :ivar webhooks: the collection of webhook notifications. + :vartype webhooks: list[~$(python-base-namespace).v2015_04_01.models.WebhookNotification] """ _validation = { @@ -245,6 +299,12 @@ def __init__( self, **kwargs ): + """ + :keyword email: the email notification. + :paramtype email: ~$(python-base-namespace).v2015_04_01.models.EmailNotification + :keyword webhooks: the collection of webhook notifications. + :paramtype webhooks: list[~$(python-base-namespace).v2015_04_01.models.WebhookNotification] + """ super(AutoscaleNotification, self).__init__(**kwargs) self.email = kwargs.get('email', None) self.webhooks = kwargs.get('webhooks', None) @@ -255,19 +315,19 @@ class AutoscaleProfile(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. the name of the profile. - :type name: str - :param capacity: Required. the number of instances that can be used during this profile. - :type capacity: ~$(python-base-namespace).v2015_04_01.models.ScaleCapacity - :param rules: Required. the collection of rules that provide the triggers and parameters for - the scaling action. A maximum of 10 rules can be specified. - :type rules: list[~$(python-base-namespace).v2015_04_01.models.ScaleRule] - :param fixed_date: the specific date-time for the profile. This element is not used if the + :ivar name: Required. the name of the profile. + :vartype name: str + :ivar capacity: Required. the number of instances that can be used during this profile. + :vartype capacity: ~$(python-base-namespace).v2015_04_01.models.ScaleCapacity + :ivar rules: Required. the collection of rules that provide the triggers and parameters for the + scaling action. A maximum of 10 rules can be specified. + :vartype rules: list[~$(python-base-namespace).v2015_04_01.models.ScaleRule] + :ivar fixed_date: the specific date-time for the profile. This element is not used if the Recurrence element is used. - :type fixed_date: ~$(python-base-namespace).v2015_04_01.models.TimeWindow - :param recurrence: the repeating times at which this profile begins. This element is not used - if the FixedDate element is used. - :type recurrence: ~$(python-base-namespace).v2015_04_01.models.Recurrence + :vartype fixed_date: ~$(python-base-namespace).v2015_04_01.models.TimeWindow + :ivar recurrence: the repeating times at which this profile begins. This element is not used if + the FixedDate element is used. + :vartype recurrence: ~$(python-base-namespace).v2015_04_01.models.Recurrence """ _validation = { @@ -288,6 +348,21 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. the name of the profile. + :paramtype name: str + :keyword capacity: Required. the number of instances that can be used during this profile. + :paramtype capacity: ~$(python-base-namespace).v2015_04_01.models.ScaleCapacity + :keyword rules: Required. the collection of rules that provide the triggers and parameters for + the scaling action. A maximum of 10 rules can be specified. + :paramtype rules: list[~$(python-base-namespace).v2015_04_01.models.ScaleRule] + :keyword fixed_date: the specific date-time for the profile. This element is not used if the + Recurrence element is used. + :paramtype fixed_date: ~$(python-base-namespace).v2015_04_01.models.TimeWindow + :keyword recurrence: the repeating times at which this profile begins. This element is not used + if the FixedDate element is used. + :paramtype recurrence: ~$(python-base-namespace).v2015_04_01.models.Recurrence + """ super(AutoscaleProfile, self).__init__(**kwargs) self.name = kwargs['name'] self.capacity = kwargs['capacity'] @@ -309,26 +384,27 @@ class AutoscaleSettingResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param profiles: Required. the collection of automatic scaling profiles that specify different + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar profiles: Required. the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. - :type profiles: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleProfile] - :param notifications: the collection of notifications. - :type notifications: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleNotification] - :param enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + :vartype profiles: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleProfile] + :ivar notifications: the collection of notifications. + :vartype notifications: + list[~$(python-base-namespace).v2015_04_01.models.AutoscaleNotification] + :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the resource. The default value is 'true'. - :type enabled: bool - :param name_properties_name: the name of the autoscale setting. - :type name_properties_name: str - :param target_resource_uri: the resource identifier of the resource that the autoscale setting + :vartype enabled: bool + :ivar name_properties_name: the name of the autoscale setting. + :vartype name_properties_name: str + :ivar target_resource_uri: the resource identifier of the resource that the autoscale setting should be added to. - :type target_resource_uri: str - :param target_resource_location: the location of the resource that the autoscale setting should + :vartype target_resource_uri: str + :ivar target_resource_location: the location of the resource that the autoscale setting should be added to. - :type target_resource_location: str + :vartype target_resource_location: str """ _validation = { @@ -357,6 +433,30 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword profiles: Required. the collection of automatic scaling profiles that specify + different scaling parameters for different time periods. A maximum of 20 profiles can be + specified. + :paramtype profiles: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleProfile] + :keyword notifications: the collection of notifications. + :paramtype notifications: + list[~$(python-base-namespace).v2015_04_01.models.AutoscaleNotification] + :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + resource. The default value is 'true'. + :paramtype enabled: bool + :keyword name_properties_name: the name of the autoscale setting. + :paramtype name_properties_name: str + :keyword target_resource_uri: the resource identifier of the resource that the autoscale + setting should be added to. + :paramtype target_resource_uri: str + :keyword target_resource_location: the location of the resource that the autoscale setting + should be added to. + :paramtype target_resource_location: str + """ super(AutoscaleSettingResource, self).__init__(**kwargs) self.profiles = kwargs['profiles'] self.notifications = kwargs.get('notifications', None) @@ -371,10 +471,10 @@ class AutoscaleSettingResourceCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the values for the autoscale setting resources. - :type value: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource] - :param next_link: URL to get the next set of results. - :type next_link: str + :ivar value: Required. the values for the autoscale setting resources. + :vartype value: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource] + :ivar next_link: URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -390,6 +490,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. the values for the autoscale setting resources. + :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource] + :keyword next_link: URL to get the next set of results. + :paramtype next_link: str + """ super(AutoscaleSettingResourceCollection, self).__init__(**kwargs) self.value = kwargs['value'] self.next_link = kwargs.get('next_link', None) @@ -398,24 +504,25 @@ def __init__( class AutoscaleSettingResourcePatch(msrest.serialization.Model): """The autoscale setting object for patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param profiles: the collection of automatic scaling profiles that specify different scaling + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar profiles: the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. - :type profiles: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleProfile] - :param notifications: the collection of notifications. - :type notifications: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleNotification] - :param enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + :vartype profiles: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleProfile] + :ivar notifications: the collection of notifications. + :vartype notifications: + list[~$(python-base-namespace).v2015_04_01.models.AutoscaleNotification] + :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the resource. The default value is 'true'. - :type enabled: bool - :param name: the name of the autoscale setting. - :type name: str - :param target_resource_uri: the resource identifier of the resource that the autoscale setting + :vartype enabled: bool + :ivar name: the name of the autoscale setting. + :vartype name: str + :ivar target_resource_uri: the resource identifier of the resource that the autoscale setting should be added to. - :type target_resource_uri: str - :param target_resource_location: the location of the resource that the autoscale setting should + :vartype target_resource_uri: str + :ivar target_resource_location: the location of the resource that the autoscale setting should be added to. - :type target_resource_location: str + :vartype target_resource_location: str """ _validation = { @@ -436,6 +543,27 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword profiles: the collection of automatic scaling profiles that specify different scaling + parameters for different time periods. A maximum of 20 profiles can be specified. + :paramtype profiles: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleProfile] + :keyword notifications: the collection of notifications. + :paramtype notifications: + list[~$(python-base-namespace).v2015_04_01.models.AutoscaleNotification] + :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + resource. The default value is 'true'. + :paramtype enabled: bool + :keyword name: the name of the autoscale setting. + :paramtype name: str + :keyword target_resource_uri: the resource identifier of the resource that the autoscale + setting should be added to. + :paramtype target_resource_uri: str + :keyword target_resource_location: the location of the resource that the autoscale setting + should be added to. + :paramtype target_resource_location: str + """ super(AutoscaleSettingResourcePatch, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.profiles = kwargs.get('profiles', None) @@ -449,15 +577,15 @@ def __init__( class EmailNotification(msrest.serialization.Model): """Email notification of an autoscale event. - :param send_to_subscription_administrator: a value indicating whether to send email to + :ivar send_to_subscription_administrator: a value indicating whether to send email to subscription administrator. - :type send_to_subscription_administrator: bool - :param send_to_subscription_co_administrators: a value indicating whether to send email to + :vartype send_to_subscription_administrator: bool + :ivar send_to_subscription_co_administrators: a value indicating whether to send email to subscription co-administrators. - :type send_to_subscription_co_administrators: bool - :param custom_emails: the custom e-mails list. This value can be null or empty, in which case + :vartype send_to_subscription_co_administrators: bool + :ivar custom_emails: the custom e-mails list. This value can be null or empty, in which case this attribute will be ignored. - :type custom_emails: list[str] + :vartype custom_emails: list[str] """ _attribute_map = { @@ -470,6 +598,17 @@ def __init__( self, **kwargs ): + """ + :keyword send_to_subscription_administrator: a value indicating whether to send email to + subscription administrator. + :paramtype send_to_subscription_administrator: bool + :keyword send_to_subscription_co_administrators: a value indicating whether to send email to + subscription co-administrators. + :paramtype send_to_subscription_co_administrators: bool + :keyword custom_emails: the custom e-mails list. This value can be null or empty, in which case + this attribute will be ignored. + :paramtype custom_emails: list[str] + """ super(EmailNotification, self).__init__(**kwargs) self.send_to_subscription_administrator = kwargs.get('send_to_subscription_administrator', False) self.send_to_subscription_co_administrators = kwargs.get('send_to_subscription_co_administrators', False) @@ -479,10 +618,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -494,6 +633,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -504,8 +649,8 @@ class EventCategoryCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the list that includes the Azure event categories. - :type value: list[~$(python-base-namespace).v2015_04_01.models.LocalizableString] + :ivar value: Required. the list that includes the Azure event categories. + :vartype value: list[~$(python-base-namespace).v2015_04_01.models.LocalizableString] """ _validation = { @@ -520,6 +665,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. the list that includes the Azure event categories. + :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.LocalizableString] + """ super(EventCategoryCollection, self).__init__(**kwargs) self.value = kwargs['value'] @@ -657,6 +806,8 @@ def __init__( self, **kwargs ): + """ + """ super(EventData, self).__init__(**kwargs) self.authorization = None self.claims = None @@ -689,10 +840,10 @@ class EventDataCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. this list that includes the Azure audit logs. - :type value: list[~$(python-base-namespace).v2015_04_01.models.EventData] - :param next_link: Provides the link to retrieve the next set of events. - :type next_link: str + :ivar value: Required. this list that includes the Azure audit logs. + :vartype value: list[~$(python-base-namespace).v2015_04_01.models.EventData] + :ivar next_link: Provides the link to retrieve the next set of events. + :vartype next_link: str """ _validation = { @@ -708,6 +859,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. this list that includes the Azure audit logs. + :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.EventData] + :keyword next_link: Provides the link to retrieve the next set of events. + :paramtype next_link: str + """ super(EventDataCollection, self).__init__(**kwargs) self.value = kwargs['value'] self.next_link = kwargs.get('next_link', None) @@ -716,14 +873,14 @@ def __init__( class HttpRequestInfo(msrest.serialization.Model): """The Http request info. - :param client_request_id: the client request id. - :type client_request_id: str - :param client_ip_address: the client Ip Address. - :type client_ip_address: str - :param method: the Http request method. - :type method: str - :param uri: the Uri. - :type uri: str + :ivar client_request_id: the client request id. + :vartype client_request_id: str + :ivar client_ip_address: the client Ip Address. + :vartype client_ip_address: str + :ivar method: the Http request method. + :vartype method: str + :ivar uri: the Uri. + :vartype uri: str """ _attribute_map = { @@ -737,6 +894,16 @@ def __init__( self, **kwargs ): + """ + :keyword client_request_id: the client request id. + :paramtype client_request_id: str + :keyword client_ip_address: the client Ip Address. + :paramtype client_ip_address: str + :keyword method: the Http request method. + :paramtype method: str + :keyword uri: the Uri. + :paramtype uri: str + """ super(HttpRequestInfo, self).__init__(**kwargs) self.client_request_id = kwargs.get('client_request_id', None) self.client_ip_address = kwargs.get('client_ip_address', None) @@ -749,10 +916,10 @@ class LocalizableString(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the invariant value. - :type value: str - :param localized_value: the locale specific value. - :type localized_value: str + :ivar value: Required. the invariant value. + :vartype value: str + :ivar localized_value: the locale specific value. + :vartype localized_value: str """ _validation = { @@ -768,6 +935,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. the invariant value. + :paramtype value: str + :keyword localized_value: the locale specific value. + :paramtype localized_value: str + """ super(LocalizableString, self).__init__(**kwargs) self.value = kwargs['value'] self.localized_value = kwargs.get('localized_value', None) @@ -781,14 +954,14 @@ class RuleCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource """ _validation = { @@ -808,6 +981,11 @@ def __init__( self, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource + """ super(RuleCondition, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] self.data_source = kwargs.get('data_source', None) @@ -818,21 +996,21 @@ class LocationThresholdRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. - :type window_size: ~datetime.timedelta - :param failed_location_count: Required. the number of locations that must fail to activate the + :vartype window_size: ~datetime.timedelta + :ivar failed_location_count: Required. the number of locations that must fail to activate the alert. - :type failed_location_count: int + :vartype failed_location_count: int """ _validation = { @@ -851,6 +1029,18 @@ def __init__( self, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. If specified then it must be between 5 minutes and 1 + day. + :paramtype window_size: ~datetime.timedelta + :keyword failed_location_count: Required. the number of locations that must fail to activate + the alert. + :paramtype failed_location_count: int + """ super(LocationThresholdRuleCondition, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition' # type: str self.window_size = kwargs.get('window_size', None) @@ -860,15 +1050,15 @@ def __init__( class ManagementEventAggregationCondition(msrest.serialization.Model): """How the data that is collected should be combined over time. - :param operator: the condition operator. Possible values include: "GreaterThan", + :ivar operator: the condition operator. Possible values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator - :param threshold: The threshold value that activates the alert. - :type threshold: float - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator + :ivar threshold: The threshold value that activates the alert. + :vartype threshold: float + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. - :type window_size: ~datetime.timedelta + :vartype window_size: ~datetime.timedelta """ _attribute_map = { @@ -881,6 +1071,17 @@ def __init__( self, **kwargs ): + """ + :keyword operator: the condition operator. Possible values include: "GreaterThan", + "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :paramtype operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator + :keyword threshold: The threshold value that activates the alert. + :paramtype threshold: float + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. If specified then it must be between 5 minutes and 1 + day. + :paramtype window_size: ~datetime.timedelta + """ super(ManagementEventAggregationCondition, self).__init__(**kwargs) self.operator = kwargs.get('operator', None) self.threshold = kwargs.get('threshold', None) @@ -892,18 +1093,18 @@ class ManagementEventRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource - :param aggregation: How the data that is collected should be combined over time and when the + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource + :ivar aggregation: How the data that is collected should be combined over time and when the alert is activated. Note that for management event alerts aggregation is optional – if it is not provided then any event will cause the alert to activate. - :type aggregation: + :vartype aggregation: ~$(python-base-namespace).v2015_04_01.models.ManagementEventAggregationCondition """ @@ -921,6 +1122,16 @@ def __init__( self, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource + :keyword aggregation: How the data that is collected should be combined over time and when the + alert is activated. Note that for management event alerts aggregation is optional – if it is + not provided then any event will cause the alert to activate. + :paramtype aggregation: + ~$(python-base-namespace).v2015_04_01.models.ManagementEventAggregationCondition + """ super(ManagementEventRuleCondition, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition' # type: str self.aggregation = kwargs.get('aggregation', None) @@ -931,41 +1142,42 @@ class MetricTrigger(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param metric_name: Required. the name of the metric that defines what the rule monitors. - :type metric_name: str - :param metric_namespace: the namespace of the metric that defines what the rule monitors. - :type metric_namespace: str - :param metric_resource_uri: Required. the resource identifier of the resource the rule - monitors. - :type metric_resource_uri: str - :param metric_resource_location: the location of the resource the rule monitors. - :type metric_resource_location: str - :param time_grain: Required. the granularity of metrics the rule monitors. Must be one of the + :ivar metric_name: Required. the name of the metric that defines what the rule monitors. + :vartype metric_name: str + :ivar metric_namespace: the namespace of the metric that defines what the rule monitors. + :vartype metric_namespace: str + :ivar metric_resource_uri: Required. the resource identifier of the resource the rule monitors. + :vartype metric_resource_uri: str + :ivar metric_resource_location: the location of the resource the rule monitors. + :vartype metric_resource_location: str + :ivar time_grain: Required. the granularity of metrics the rule monitors. Must be one of the predefined values returned from metric definitions for the metric. Must be between 12 hours and 1 minute. - :type time_grain: ~datetime.timedelta - :param statistic: Required. the metric statistic type. How the metrics from multiple instances + :vartype time_grain: ~datetime.timedelta + :ivar statistic: Required. the metric statistic type. How the metrics from multiple instances are combined. Possible values include: "Average", "Min", "Max", "Sum", "Count". - :type statistic: str or ~$(python-base-namespace).v2015_04_01.models.MetricStatisticType - :param time_window: Required. the range of time in which instance data is collected. This value + :vartype statistic: str or ~$(python-base-namespace).v2015_04_01.models.MetricStatisticType + :ivar time_window: Required. the range of time in which instance data is collected. This value must be greater than the delay in metric collection, which can vary from resource-to-resource. Must be between 12 hours and 5 minutes. - :type time_window: ~datetime.timedelta - :param time_aggregation: Required. time aggregation type. How the data that is collected should + :vartype time_window: ~datetime.timedelta + :ivar time_aggregation: Required. time aggregation type. How the data that is collected should be combined over time. The default value is Average. Possible values include: "Average", "Minimum", "Maximum", "Total", "Count", "Last". - :type time_aggregation: str or ~$(python-base-namespace).v2015_04_01.models.TimeAggregationType - :param operator: Required. the operator that is used to compare the metric data and the + :vartype time_aggregation: str or + ~$(python-base-namespace).v2015_04_01.models.TimeAggregationType + :ivar operator: Required. the operator that is used to compare the metric data and the threshold. Possible values include: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or ~$(python-base-namespace).v2015_04_01.models.ComparisonOperationType - :param threshold: Required. the threshold of the metric that triggers the scale action. - :type threshold: float - :param dimensions: List of dimension conditions. For example: + :vartype operator: str or ~$(python-base-namespace).v2015_04_01.models.ComparisonOperationType + :ivar threshold: Required. the threshold of the metric that triggers the scale action. + :vartype threshold: float + :ivar dimensions: List of dimension conditions. For example: [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. - :type dimensions: list[~$(python-base-namespace).v2015_04_01.models.ScaleRuleMetricDimension] - :param divide_per_instance: a value indicating whether metric should divide per instance. - :type divide_per_instance: bool + :vartype dimensions: + list[~$(python-base-namespace).v2015_04_01.models.ScaleRuleMetricDimension] + :ivar divide_per_instance: a value indicating whether metric should divide per instance. + :vartype divide_per_instance: bool """ _validation = { @@ -998,6 +1210,46 @@ def __init__( self, **kwargs ): + """ + :keyword metric_name: Required. the name of the metric that defines what the rule monitors. + :paramtype metric_name: str + :keyword metric_namespace: the namespace of the metric that defines what the rule monitors. + :paramtype metric_namespace: str + :keyword metric_resource_uri: Required. the resource identifier of the resource the rule + monitors. + :paramtype metric_resource_uri: str + :keyword metric_resource_location: the location of the resource the rule monitors. + :paramtype metric_resource_location: str + :keyword time_grain: Required. the granularity of metrics the rule monitors. Must be one of the + predefined values returned from metric definitions for the metric. Must be between 12 hours and + 1 minute. + :paramtype time_grain: ~datetime.timedelta + :keyword statistic: Required. the metric statistic type. How the metrics from multiple + instances are combined. Possible values include: "Average", "Min", "Max", "Sum", "Count". + :paramtype statistic: str or ~$(python-base-namespace).v2015_04_01.models.MetricStatisticType + :keyword time_window: Required. the range of time in which instance data is collected. This + value must be greater than the delay in metric collection, which can vary from + resource-to-resource. Must be between 12 hours and 5 minutes. + :paramtype time_window: ~datetime.timedelta + :keyword time_aggregation: Required. time aggregation type. How the data that is collected + should be combined over time. The default value is Average. Possible values include: "Average", + "Minimum", "Maximum", "Total", "Count", "Last". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2015_04_01.models.TimeAggregationType + :keyword operator: Required. the operator that is used to compare the metric data and the + threshold. Possible values include: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", + "LessThan", "LessThanOrEqual". + :paramtype operator: str or + ~$(python-base-namespace).v2015_04_01.models.ComparisonOperationType + :keyword threshold: Required. the threshold of the metric that triggers the scale action. + :paramtype threshold: float + :keyword dimensions: List of dimension conditions. For example: + [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. + :paramtype dimensions: + list[~$(python-base-namespace).v2015_04_01.models.ScaleRuleMetricDimension] + :keyword divide_per_instance: a value indicating whether metric should divide per instance. + :paramtype divide_per_instance: bool + """ super(MetricTrigger, self).__init__(**kwargs) self.metric_name = kwargs['metric_name'] self.metric_namespace = kwargs.get('metric_namespace', None) @@ -1016,10 +1268,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft Insights API operation definition. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: Display metadata associated with the operation. - :type display: ~$(python-base-namespace).v2015_04_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: Display metadata associated with the operation. + :vartype display: ~$(python-base-namespace).v2015_04_01.models.OperationDisplay """ _attribute_map = { @@ -1031,6 +1283,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: Display metadata associated with the operation. + :paramtype display: ~$(python-base-namespace).v2015_04_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display = kwargs.get('display', None) @@ -1039,12 +1297,12 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """Display metadata associated with the operation. - :param provider: Service provider: Microsoft.Insights. - :type provider: str - :param resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str + :ivar provider: Service provider: Microsoft.Insights. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str """ _attribute_map = { @@ -1057,6 +1315,14 @@ def __init__( self, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Insights. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = kwargs.get('provider', None) self.resource = kwargs.get('resource', None) @@ -1066,10 +1332,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Insights operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of operations supported by the Microsoft.Insights provider. - :type value: list[~$(python-base-namespace).v2015_04_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of operations supported by the Microsoft.Insights provider. + :vartype value: list[~$(python-base-namespace).v2015_04_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1081,6 +1347,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of operations supported by the Microsoft.Insights provider. + :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -1091,14 +1363,14 @@ class Recurrence(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param frequency: Required. the recurrence frequency. How often the schedule profile should - take effect. This value must be Week, meaning each week will have the same set of profiles. For + :ivar frequency: Required. the recurrence frequency. How often the schedule profile should take + effect. This value must be Week, meaning each week will have the same set of profiles. For example, to set a daily schedule, set **schedule** to every day of the week. The frequency property specifies that the schedule is repeated weekly. Possible values include: "None", "Second", "Minute", "Hour", "Day", "Week", "Month", "Year". - :type frequency: str or ~$(python-base-namespace).v2015_04_01.models.RecurrenceFrequency - :param schedule: Required. the scheduling constraints for when the profile begins. - :type schedule: ~$(python-base-namespace).v2015_04_01.models.RecurrentSchedule + :vartype frequency: str or ~$(python-base-namespace).v2015_04_01.models.RecurrenceFrequency + :ivar schedule: Required. the scheduling constraints for when the profile begins. + :vartype schedule: ~$(python-base-namespace).v2015_04_01.models.RecurrentSchedule """ _validation = { @@ -1115,6 +1387,16 @@ def __init__( self, **kwargs ): + """ + :keyword frequency: Required. the recurrence frequency. How often the schedule profile should + take effect. This value must be Week, meaning each week will have the same set of profiles. For + example, to set a daily schedule, set **schedule** to every day of the week. The frequency + property specifies that the schedule is repeated weekly. Possible values include: "None", + "Second", "Minute", "Hour", "Day", "Week", "Month", "Year". + :paramtype frequency: str or ~$(python-base-namespace).v2015_04_01.models.RecurrenceFrequency + :keyword schedule: Required. the scheduling constraints for when the profile begins. + :paramtype schedule: ~$(python-base-namespace).v2015_04_01.models.RecurrentSchedule + """ super(Recurrence, self).__init__(**kwargs) self.frequency = kwargs['frequency'] self.schedule = kwargs['schedule'] @@ -1125,7 +1407,7 @@ class RecurrentSchedule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_zone: Required. the timezone for the hours of the profile. Some examples of valid + :ivar time_zone: Required. the timezone for the hours of the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard @@ -1155,15 +1437,15 @@ class RecurrentSchedule(msrest.serialization.Model): Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time. - :type time_zone: str - :param days: Required. the collection of days that the profile takes effect on. Possible values + :vartype time_zone: str + :ivar days: Required. the collection of days that the profile takes effect on. Possible values are Sunday through Saturday. - :type days: list[str] - :param hours: Required. A collection of hours that the profile takes effect on. Values - supported are 0 to 23 on the 24-hour clock (AM/PM times are not supported). - :type hours: list[int] - :param minutes: Required. A collection of minutes at which the profile takes effect at. - :type minutes: list[int] + :vartype days: list[str] + :ivar hours: Required. A collection of hours that the profile takes effect on. Values supported + are 0 to 23 on the 24-hour clock (AM/PM times are not supported). + :vartype hours: list[int] + :ivar minutes: Required. A collection of minutes at which the profile takes effect at. + :vartype minutes: list[int] """ _validation = { @@ -1184,6 +1466,47 @@ def __init__( self, **kwargs ): + """ + :keyword time_zone: Required. the timezone for the hours of the profile. Some examples of valid + time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, + Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain + Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard + Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, + Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard + Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, + Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina + Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, + Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde + Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. + Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central European + Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, + GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. + Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, + Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, + Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran + Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius + Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West + Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, + Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard + Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia + Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. + Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, + Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard + Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, + Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, + Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji + Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands + Standard Time. + :paramtype time_zone: str + :keyword days: Required. the collection of days that the profile takes effect on. Possible + values are Sunday through Saturday. + :paramtype days: list[str] + :keyword hours: Required. A collection of hours that the profile takes effect on. Values + supported are 0 to 23 on the 24-hour clock (AM/PM times are not supported). + :paramtype hours: list[int] + :keyword minutes: Required. A collection of minutes at which the profile takes effect at. + :paramtype minutes: list[int] + """ super(RecurrentSchedule, self).__init__(**kwargs) self.time_zone = kwargs['time_zone'] self.days = kwargs['days'] @@ -1199,9 +1522,9 @@ class RuleAction(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of the action. There are two types of actions: + :ivar odata_type: Required. specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str + :vartype odata_type: str """ _validation = { @@ -1220,6 +1543,8 @@ def __init__( self, **kwargs ): + """ + """ super(RuleAction, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] @@ -1232,19 +1557,19 @@ class RuleDataSource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of data source. There are two types of rule - data sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. - :type odata_type: str - :param resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :type resource_uri: str - :param legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + :ivar odata_type: Required. specifies the type of data source. There are two types of rule data + sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :vartype odata_type: str + :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this + property cannot be updated for an existing rule. + :vartype resource_uri: str + :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. - :type legacy_resource_id: str - :param resource_location: the location of the resource. - :type resource_location: str - :param metric_namespace: the namespace of the metric. - :type metric_namespace: str + :vartype legacy_resource_id: str + :ivar resource_location: the location of the resource. + :vartype resource_location: str + :ivar metric_namespace: the namespace of the metric. + :vartype metric_namespace: str """ _validation = { @@ -1267,6 +1592,18 @@ def __init__( self, **kwargs ): + """ + :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : + this property cannot be updated for an existing rule. + :paramtype resource_uri: str + :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + **NOTE**\ : this property cannot be updated for an existing rule. + :paramtype legacy_resource_id: str + :keyword resource_location: the location of the resource. + :paramtype resource_location: str + :keyword metric_namespace: the namespace of the metric. + :paramtype metric_namespace: str + """ super(RuleDataSource, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] self.resource_uri = kwargs.get('resource_uri', None) @@ -1280,15 +1617,15 @@ class RuleEmailAction(RuleAction): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of the action. There are two types of actions: + :ivar odata_type: Required. specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str - :param send_to_service_owners: Whether the administrators (service and co-administrators) of - the service should be notified when the alert is activated. - :type send_to_service_owners: bool - :param custom_emails: the list of administrator's custom email addresses to notify of the + :vartype odata_type: str + :ivar send_to_service_owners: Whether the administrators (service and co-administrators) of the + service should be notified when the alert is activated. + :vartype send_to_service_owners: bool + :ivar custom_emails: the list of administrator's custom email addresses to notify of the activation of the alert. - :type custom_emails: list[str] + :vartype custom_emails: list[str] """ _validation = { @@ -1305,6 +1642,14 @@ def __init__( self, **kwargs ): + """ + :keyword send_to_service_owners: Whether the administrators (service and co-administrators) of + the service should be notified when the alert is activated. + :paramtype send_to_service_owners: bool + :keyword custom_emails: the list of administrator's custom email addresses to notify of the + activation of the alert. + :paramtype custom_emails: list[str] + """ super(RuleEmailAction, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleEmailAction' # type: str self.send_to_service_owners = kwargs.get('send_to_service_owners', None) @@ -1314,8 +1659,8 @@ def __init__( class RuleManagementEventClaimsDataSource(msrest.serialization.Model): """The claims for a rule management event data source. - :param email_address: the email address. - :type email_address: str + :ivar email_address: the email address. + :vartype email_address: str """ _attribute_map = { @@ -1326,6 +1671,10 @@ def __init__( self, **kwargs ): + """ + :keyword email_address: the email address. + :paramtype email_address: str + """ super(RuleManagementEventClaimsDataSource, self).__init__(**kwargs) self.email_address = kwargs.get('email_address', None) @@ -1335,39 +1684,40 @@ class RuleManagementEventDataSource(RuleDataSource): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of data source. There are two types of rule - data sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. - :type odata_type: str - :param resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :type resource_uri: str - :param legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + :ivar odata_type: Required. specifies the type of data source. There are two types of rule data + sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :vartype odata_type: str + :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this + property cannot be updated for an existing rule. + :vartype resource_uri: str + :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. - :type legacy_resource_id: str - :param resource_location: the location of the resource. - :type resource_location: str - :param metric_namespace: the namespace of the metric. - :type metric_namespace: str - :param event_name: the event name. - :type event_name: str - :param event_source: the event source. - :type event_source: str - :param level: the level. - :type level: str - :param operation_name: The name of the operation that should be checked for. If no name is + :vartype legacy_resource_id: str + :ivar resource_location: the location of the resource. + :vartype resource_location: str + :ivar metric_namespace: the namespace of the metric. + :vartype metric_namespace: str + :ivar event_name: the event name. + :vartype event_name: str + :ivar event_source: the event source. + :vartype event_source: str + :ivar level: the level. + :vartype level: str + :ivar operation_name: The name of the operation that should be checked for. If no name is provided, any operation will match. - :type operation_name: str - :param resource_group_name: the resource group name. - :type resource_group_name: str - :param resource_provider_name: the resource provider name. - :type resource_provider_name: str - :param status: The status of the operation that should be checked for. If no status is - provided, any status will match. - :type status: str - :param sub_status: the substatus. - :type sub_status: str - :param claims: the claims. - :type claims: ~$(python-base-namespace).v2015_04_01.models.RuleManagementEventClaimsDataSource + :vartype operation_name: str + :ivar resource_group_name: the resource group name. + :vartype resource_group_name: str + :ivar resource_provider_name: the resource provider name. + :vartype resource_provider_name: str + :ivar status: The status of the operation that should be checked for. If no status is provided, + any status will match. + :vartype status: str + :ivar sub_status: the substatus. + :vartype sub_status: str + :ivar claims: the claims. + :vartype claims: + ~$(python-base-namespace).v2015_04_01.models.RuleManagementEventClaimsDataSource """ _validation = { @@ -1395,6 +1745,39 @@ def __init__( self, **kwargs ): + """ + :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : + this property cannot be updated for an existing rule. + :paramtype resource_uri: str + :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + **NOTE**\ : this property cannot be updated for an existing rule. + :paramtype legacy_resource_id: str + :keyword resource_location: the location of the resource. + :paramtype resource_location: str + :keyword metric_namespace: the namespace of the metric. + :paramtype metric_namespace: str + :keyword event_name: the event name. + :paramtype event_name: str + :keyword event_source: the event source. + :paramtype event_source: str + :keyword level: the level. + :paramtype level: str + :keyword operation_name: The name of the operation that should be checked for. If no name is + provided, any operation will match. + :paramtype operation_name: str + :keyword resource_group_name: the resource group name. + :paramtype resource_group_name: str + :keyword resource_provider_name: the resource provider name. + :paramtype resource_provider_name: str + :keyword status: The status of the operation that should be checked for. If no status is + provided, any status will match. + :paramtype status: str + :keyword sub_status: the substatus. + :paramtype sub_status: str + :keyword claims: the claims. + :paramtype claims: + ~$(python-base-namespace).v2015_04_01.models.RuleManagementEventClaimsDataSource + """ super(RuleManagementEventDataSource, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource' # type: str self.event_name = kwargs.get('event_name', None) @@ -1413,21 +1796,21 @@ class RuleMetricDataSource(RuleDataSource): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of data source. There are two types of rule - data sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. - :type odata_type: str - :param resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :type resource_uri: str - :param legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + :ivar odata_type: Required. specifies the type of data source. There are two types of rule data + sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :vartype odata_type: str + :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this + property cannot be updated for an existing rule. + :vartype resource_uri: str + :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. - :type legacy_resource_id: str - :param resource_location: the location of the resource. - :type resource_location: str - :param metric_namespace: the namespace of the metric. - :type metric_namespace: str - :param metric_name: the name of the metric that defines what the rule monitors. - :type metric_name: str + :vartype legacy_resource_id: str + :ivar resource_location: the location of the resource. + :vartype resource_location: str + :ivar metric_namespace: the namespace of the metric. + :vartype metric_namespace: str + :ivar metric_name: the name of the metric that defines what the rule monitors. + :vartype metric_name: str """ _validation = { @@ -1447,6 +1830,20 @@ def __init__( self, **kwargs ): + """ + :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : + this property cannot be updated for an existing rule. + :paramtype resource_uri: str + :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + **NOTE**\ : this property cannot be updated for an existing rule. + :paramtype legacy_resource_id: str + :keyword resource_location: the location of the resource. + :paramtype resource_location: str + :keyword metric_namespace: the namespace of the metric. + :paramtype metric_namespace: str + :keyword metric_name: the name of the metric that defines what the rule monitors. + :paramtype metric_name: str + """ super(RuleMetricDataSource, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource' # type: str self.metric_name = kwargs.get('metric_name', None) @@ -1457,15 +1854,15 @@ class RuleWebhookAction(RuleAction): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of the action. There are two types of actions: + :ivar odata_type: Required. specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str - :param service_uri: the service uri to Post the notification when the alert activates or + :vartype odata_type: str + :ivar service_uri: the service uri to Post the notification when the alert activates or resolves. - :type service_uri: str - :param properties: the dictionary of custom properties to include with the post operation. - These data are appended to the webhook payload. - :type properties: dict[str, str] + :vartype service_uri: str + :ivar properties: the dictionary of custom properties to include with the post operation. These + data are appended to the webhook payload. + :vartype properties: dict[str, str] """ _validation = { @@ -1482,6 +1879,14 @@ def __init__( self, **kwargs ): + """ + :keyword service_uri: the service uri to Post the notification when the alert activates or + resolves. + :paramtype service_uri: str + :keyword properties: the dictionary of custom properties to include with the post operation. + These data are appended to the webhook payload. + :paramtype properties: dict[str, str] + """ super(RuleWebhookAction, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction' # type: str self.service_uri = kwargs.get('service_uri', None) @@ -1493,18 +1898,18 @@ class ScaleAction(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param direction: Required. the scale direction. Whether the scaling action increases or + :ivar direction: Required. the scale direction. Whether the scaling action increases or decreases the number of instances. Possible values include: "None", "Increase", "Decrease". - :type direction: str or ~$(python-base-namespace).v2015_04_01.models.ScaleDirection - :param type: Required. the type of action that should occur when the scale rule fires. Possible + :vartype direction: str or ~$(python-base-namespace).v2015_04_01.models.ScaleDirection + :ivar type: Required. the type of action that should occur when the scale rule fires. Possible values include: "ChangeCount", "PercentChangeCount", "ExactCount", "ServiceAllowedNextValue". - :type type: str or ~$(python-base-namespace).v2015_04_01.models.ScaleType - :param value: the number of instances that are involved in the scaling action. This value must + :vartype type: str or ~$(python-base-namespace).v2015_04_01.models.ScaleType + :ivar value: the number of instances that are involved in the scaling action. This value must be 1 or greater. The default value is 1. - :type value: str - :param cooldown: Required. the amount of time to wait since the last scaling action before this + :vartype value: str + :ivar cooldown: Required. the amount of time to wait since the last scaling action before this action occurs. It must be between 1 week and 1 minute in ISO 8601 format. - :type cooldown: ~datetime.timedelta + :vartype cooldown: ~datetime.timedelta """ _validation = { @@ -1524,6 +1929,21 @@ def __init__( self, **kwargs ): + """ + :keyword direction: Required. the scale direction. Whether the scaling action increases or + decreases the number of instances. Possible values include: "None", "Increase", "Decrease". + :paramtype direction: str or ~$(python-base-namespace).v2015_04_01.models.ScaleDirection + :keyword type: Required. the type of action that should occur when the scale rule fires. + Possible values include: "ChangeCount", "PercentChangeCount", "ExactCount", + "ServiceAllowedNextValue". + :paramtype type: str or ~$(python-base-namespace).v2015_04_01.models.ScaleType + :keyword value: the number of instances that are involved in the scaling action. This value + must be 1 or greater. The default value is 1. + :paramtype value: str + :keyword cooldown: Required. the amount of time to wait since the last scaling action before + this action occurs. It must be between 1 week and 1 minute in ISO 8601 format. + :paramtype cooldown: ~datetime.timedelta + """ super(ScaleAction, self).__init__(**kwargs) self.direction = kwargs['direction'] self.type = kwargs['type'] @@ -1536,15 +1956,15 @@ class ScaleCapacity(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param minimum: Required. the minimum number of instances for the resource. - :type minimum: str - :param maximum: Required. the maximum number of instances for the resource. The actual maximum + :ivar minimum: Required. the minimum number of instances for the resource. + :vartype minimum: str + :ivar maximum: Required. the maximum number of instances for the resource. The actual maximum number of instances is limited by the cores that are available in the subscription. - :type maximum: str - :param default: Required. the number of instances that will be set if metrics are not available + :vartype maximum: str + :ivar default: Required. the number of instances that will be set if metrics are not available for evaluation. The default is only used if the current instance count is lower than the default. - :type default: str + :vartype default: str """ _validation = { @@ -1563,6 +1983,17 @@ def __init__( self, **kwargs ): + """ + :keyword minimum: Required. the minimum number of instances for the resource. + :paramtype minimum: str + :keyword maximum: Required. the maximum number of instances for the resource. The actual + maximum number of instances is limited by the cores that are available in the subscription. + :paramtype maximum: str + :keyword default: Required. the number of instances that will be set if metrics are not + available for evaluation. The default is only used if the current instance count is lower than + the default. + :paramtype default: str + """ super(ScaleCapacity, self).__init__(**kwargs) self.minimum = kwargs['minimum'] self.maximum = kwargs['maximum'] @@ -1574,10 +2005,10 @@ class ScaleRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param metric_trigger: Required. the trigger that results in a scaling action. - :type metric_trigger: ~$(python-base-namespace).v2015_04_01.models.MetricTrigger - :param scale_action: Required. the parameters for the scaling action. - :type scale_action: ~$(python-base-namespace).v2015_04_01.models.ScaleAction + :ivar metric_trigger: Required. the trigger that results in a scaling action. + :vartype metric_trigger: ~$(python-base-namespace).v2015_04_01.models.MetricTrigger + :ivar scale_action: Required. the parameters for the scaling action. + :vartype scale_action: ~$(python-base-namespace).v2015_04_01.models.ScaleAction """ _validation = { @@ -1594,6 +2025,12 @@ def __init__( self, **kwargs ): + """ + :keyword metric_trigger: Required. the trigger that results in a scaling action. + :paramtype metric_trigger: ~$(python-base-namespace).v2015_04_01.models.MetricTrigger + :keyword scale_action: Required. the parameters for the scaling action. + :paramtype scale_action: ~$(python-base-namespace).v2015_04_01.models.ScaleAction + """ super(ScaleRule, self).__init__(**kwargs) self.metric_trigger = kwargs['metric_trigger'] self.scale_action = kwargs['scale_action'] @@ -1604,15 +2041,15 @@ class ScaleRuleMetricDimension(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param dimension_name: Required. Name of the dimension. - :type dimension_name: str - :param operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are supported. + :ivar dimension_name: Required. Name of the dimension. + :vartype dimension_name: str + :ivar operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values. Possible values include: "Equals", "NotEquals". - :type operator: str or + :vartype operator: str or ~$(python-base-namespace).v2015_04_01.models.ScaleRuleMetricDimensionOperationType - :param values: Required. list of dimension values. For example: ["App1","App2"]. - :type values: list[str] + :ivar values: Required. list of dimension values. For example: ["App1","App2"]. + :vartype values: list[str] """ _validation = { @@ -1631,6 +2068,17 @@ def __init__( self, **kwargs ): + """ + :keyword dimension_name: Required. Name of the dimension. + :paramtype dimension_name: str + :keyword operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are + supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the + values. Possible values include: "Equals", "NotEquals". + :paramtype operator: str or + ~$(python-base-namespace).v2015_04_01.models.ScaleRuleMetricDimensionOperationType + :keyword values: Required. list of dimension values. For example: ["App1","App2"]. + :paramtype values: list[str] + """ super(ScaleRuleMetricDimension, self).__init__(**kwargs) self.dimension_name = kwargs['dimension_name'] self.operator = kwargs['operator'] @@ -1640,12 +2088,12 @@ def __init__( class SenderAuthorization(msrest.serialization.Model): """the authorization used by the user who has performed the operation that led to this event. This captures the RBAC properties of the event. These usually include the 'action', 'role' and the 'scope'. - :param action: the permissible actions. For instance: microsoft.support/supporttickets/write. - :type action: str - :param role: the role of the user. For instance: Subscription Admin. - :type role: str - :param scope: the scope. - :type scope: str + :ivar action: the permissible actions. For instance: microsoft.support/supporttickets/write. + :vartype action: str + :ivar role: the role of the user. For instance: Subscription Admin. + :vartype role: str + :ivar scope: the scope. + :vartype scope: str """ _attribute_map = { @@ -1658,6 +2106,14 @@ def __init__( self, **kwargs ): + """ + :keyword action: the permissible actions. For instance: microsoft.support/supporttickets/write. + :paramtype action: str + :keyword role: the role of the user. For instance: Subscription Admin. + :paramtype role: str + :keyword scope: the scope. + :paramtype scope: str + """ super(SenderAuthorization, self).__init__(**kwargs) self.action = kwargs.get('action', None) self.role = kwargs.get('role', None) @@ -1669,27 +2125,27 @@ class ThresholdRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource - :param operator: Required. the operator used to compare the data and the threshold. Possible + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource + :ivar operator: Required. the operator used to compare the data and the threshold. Possible values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator - :param threshold: Required. the threshold value that activates the alert. - :type threshold: float - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator + :ivar threshold: Required. the threshold value that activates the alert. + :vartype threshold: float + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. - :type window_size: ~datetime.timedelta - :param time_aggregation: the time aggregation operator. How the data that are collected should + :vartype window_size: ~datetime.timedelta + :ivar time_aggregation: the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. Possible values include: "Average", "Minimum", "Maximum", "Total", "Last". - :type time_aggregation: str or + :vartype time_aggregation: str or ~$(python-base-namespace).v2015_04_01.models.TimeAggregationOperator """ @@ -1712,6 +2168,25 @@ def __init__( self, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource + :keyword operator: Required. the operator used to compare the data and the threshold. Possible + values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :paramtype operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator + :keyword threshold: Required. the threshold value that activates the alert. + :paramtype threshold: float + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. If specified then it must be between 5 minutes and 1 + day. + :paramtype window_size: ~datetime.timedelta + :keyword time_aggregation: the time aggregation operator. How the data that are collected + should be combined over time. The default value is the PrimaryAggregationType of the Metric. + Possible values include: "Average", "Minimum", "Maximum", "Total", "Last". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2015_04_01.models.TimeAggregationOperator + """ super(ThresholdRuleCondition, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition' # type: str self.operator = kwargs['operator'] @@ -1725,7 +2200,7 @@ class TimeWindow(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_zone: the timezone of the start and end times for the profile. Some examples of + :ivar time_zone: the timezone of the start and end times for the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central @@ -1755,11 +2230,11 @@ class TimeWindow(msrest.serialization.Model): Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time. - :type time_zone: str - :param start: Required. the start time for the profile in ISO 8601 format. - :type start: ~datetime.datetime - :param end: Required. the end time for the profile in ISO 8601 format. - :type end: ~datetime.datetime + :vartype time_zone: str + :ivar start: Required. the start time for the profile in ISO 8601 format. + :vartype start: ~datetime.datetime + :ivar end: Required. the end time for the profile in ISO 8601 format. + :vartype end: ~datetime.datetime """ _validation = { @@ -1777,6 +2252,43 @@ def __init__( self, **kwargs ): + """ + :keyword time_zone: the timezone of the start and end times for the profile. Some examples of + valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard + Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, + Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central + Standard Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific + Standard Time, Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, + Paraguay Standard Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western + Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard + Time, Argentina Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo + Standard Time, Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, + Cape Verde Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard + Time, W. Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central + European Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard + Time, GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, + E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, + Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, + Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran + Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius + Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West + Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, + Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard + Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia + Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. + Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, + Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard + Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, + Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, + Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji + Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands + Standard Time. + :paramtype time_zone: str + :keyword start: Required. the start time for the profile in ISO 8601 format. + :paramtype start: ~datetime.datetime + :keyword end: Required. the end time for the profile in ISO 8601 format. + :paramtype end: ~datetime.datetime + """ super(TimeWindow, self).__init__(**kwargs) self.time_zone = kwargs.get('time_zone', None) self.start = kwargs['start'] @@ -1786,10 +2298,10 @@ def __init__( class WebhookNotification(msrest.serialization.Model): """Webhook notification of an autoscale event. - :param service_uri: the service address to receive the notification. - :type service_uri: str - :param properties: a property bag of settings. This value can be empty. - :type properties: dict[str, str] + :ivar service_uri: the service address to receive the notification. + :vartype service_uri: str + :ivar properties: a property bag of settings. This value can be empty. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1801,6 +2313,12 @@ def __init__( self, **kwargs ): + """ + :keyword service_uri: the service address to receive the notification. + :paramtype service_uri: str + :keyword properties: a property bag of settings. This value can be empty. + :paramtype properties: dict[str, str] + """ super(WebhookNotification, self).__init__(**kwargs) self.service_uri = kwargs.get('service_uri', None) self.properties = kwargs.get('properties', None) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models_py3.py index 621d5431777a9..56559fa4174d0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_models_py3.py @@ -28,10 +28,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -56,6 +56,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -77,26 +83,26 @@ class AlertRuleResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param name_properties_name: Required. the name of the alert rule. - :type name_properties_name: str - :param description: the description of the alert rule that will be included in the alert email. - :type description: str - :param provisioning_state: the provisioning state. - :type provisioning_state: str - :param is_enabled: Required. the flag that indicates whether the alert rule is enabled. - :type is_enabled: bool - :param condition: Required. the condition that results in the alert rule being activated. - :type condition: ~$(python-base-namespace).v2015_04_01.models.RuleCondition - :param action: action that is performed when the alert rule becomes active, and when an alert + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar name_properties_name: Required. the name of the alert rule. + :vartype name_properties_name: str + :ivar description: the description of the alert rule that will be included in the alert email. + :vartype description: str + :ivar provisioning_state: the provisioning state. + :vartype provisioning_state: str + :ivar is_enabled: Required. the flag that indicates whether the alert rule is enabled. + :vartype is_enabled: bool + :ivar condition: Required. the condition that results in the alert rule being activated. + :vartype condition: ~$(python-base-namespace).v2015_04_01.models.RuleCondition + :ivar action: action that is performed when the alert rule becomes active, and when an alert condition is resolved. - :type action: ~$(python-base-namespace).v2015_04_01.models.RuleAction - :param actions: the array of actions that are performed when the alert rule becomes active, and + :vartype action: ~$(python-base-namespace).v2015_04_01.models.RuleAction + :ivar actions: the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. - :type actions: list[~$(python-base-namespace).v2015_04_01.models.RuleAction] + :vartype actions: list[~$(python-base-namespace).v2015_04_01.models.RuleAction] :ivar last_updated_time: Last time the rule was updated in ISO8601 format. :vartype last_updated_time: ~datetime.datetime """ @@ -142,6 +148,29 @@ def __init__( actions: Optional[List["RuleAction"]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword name_properties_name: Required. the name of the alert rule. + :paramtype name_properties_name: str + :keyword description: the description of the alert rule that will be included in the alert + email. + :paramtype description: str + :keyword provisioning_state: the provisioning state. + :paramtype provisioning_state: str + :keyword is_enabled: Required. the flag that indicates whether the alert rule is enabled. + :paramtype is_enabled: bool + :keyword condition: Required. the condition that results in the alert rule being activated. + :paramtype condition: ~$(python-base-namespace).v2015_04_01.models.RuleCondition + :keyword action: action that is performed when the alert rule becomes active, and when an alert + condition is resolved. + :paramtype action: ~$(python-base-namespace).v2015_04_01.models.RuleAction + :keyword actions: the array of actions that are performed when the alert rule becomes active, + and when an alert condition is resolved. + :paramtype actions: list[~$(python-base-namespace).v2015_04_01.models.RuleAction] + """ super(AlertRuleResource, self).__init__(location=location, tags=tags, **kwargs) self.name_properties_name = name_properties_name self.description = description @@ -156,8 +185,8 @@ def __init__( class AlertRuleResourceCollection(msrest.serialization.Model): """Represents a collection of alert rule resources. - :param value: the values for the alert rule resources. - :type value: list[~$(python-base-namespace).v2015_04_01.models.AlertRuleResource] + :ivar value: the values for the alert rule resources. + :vartype value: list[~$(python-base-namespace).v2015_04_01.models.AlertRuleResource] """ _attribute_map = { @@ -170,6 +199,10 @@ def __init__( value: Optional[List["AlertRuleResource"]] = None, **kwargs ): + """ + :keyword value: the values for the alert rule resources. + :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.AlertRuleResource] + """ super(AlertRuleResourceCollection, self).__init__(**kwargs) self.value = value @@ -179,24 +212,24 @@ class AlertRuleResourcePatch(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param name: the name of the alert rule. - :type name: str - :param description: the description of the alert rule that will be included in the alert email. - :type description: str - :param provisioning_state: the provisioning state. - :type provisioning_state: str - :param is_enabled: the flag that indicates whether the alert rule is enabled. - :type is_enabled: bool - :param condition: the condition that results in the alert rule being activated. - :type condition: ~$(python-base-namespace).v2015_04_01.models.RuleCondition - :param action: action that is performed when the alert rule becomes active, and when an alert + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar name: the name of the alert rule. + :vartype name: str + :ivar description: the description of the alert rule that will be included in the alert email. + :vartype description: str + :ivar provisioning_state: the provisioning state. + :vartype provisioning_state: str + :ivar is_enabled: the flag that indicates whether the alert rule is enabled. + :vartype is_enabled: bool + :ivar condition: the condition that results in the alert rule being activated. + :vartype condition: ~$(python-base-namespace).v2015_04_01.models.RuleCondition + :ivar action: action that is performed when the alert rule becomes active, and when an alert condition is resolved. - :type action: ~$(python-base-namespace).v2015_04_01.models.RuleAction - :param actions: the array of actions that are performed when the alert rule becomes active, and + :vartype action: ~$(python-base-namespace).v2015_04_01.models.RuleAction + :ivar actions: the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. - :type actions: list[~$(python-base-namespace).v2015_04_01.models.RuleAction] + :vartype actions: list[~$(python-base-namespace).v2015_04_01.models.RuleAction] :ivar last_updated_time: Last time the rule was updated in ISO8601 format. :vartype last_updated_time: ~datetime.datetime """ @@ -230,6 +263,27 @@ def __init__( actions: Optional[List["RuleAction"]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword name: the name of the alert rule. + :paramtype name: str + :keyword description: the description of the alert rule that will be included in the alert + email. + :paramtype description: str + :keyword provisioning_state: the provisioning state. + :paramtype provisioning_state: str + :keyword is_enabled: the flag that indicates whether the alert rule is enabled. + :paramtype is_enabled: bool + :keyword condition: the condition that results in the alert rule being activated. + :paramtype condition: ~$(python-base-namespace).v2015_04_01.models.RuleCondition + :keyword action: action that is performed when the alert rule becomes active, and when an alert + condition is resolved. + :paramtype action: ~$(python-base-namespace).v2015_04_01.models.RuleAction + :keyword actions: the array of actions that are performed when the alert rule becomes active, + and when an alert condition is resolved. + :paramtype actions: list[~$(python-base-namespace).v2015_04_01.models.RuleAction] + """ super(AlertRuleResourcePatch, self).__init__(**kwargs) self.tags = tags self.name = name @@ -252,10 +306,10 @@ class AutoscaleNotification(msrest.serialization.Model): :ivar operation: the operation associated with the notification and its value must be "scale". Has constant value: "Scale". :vartype operation: str - :param email: the email notification. - :type email: ~$(python-base-namespace).v2015_04_01.models.EmailNotification - :param webhooks: the collection of webhook notifications. - :type webhooks: list[~$(python-base-namespace).v2015_04_01.models.WebhookNotification] + :ivar email: the email notification. + :vartype email: ~$(python-base-namespace).v2015_04_01.models.EmailNotification + :ivar webhooks: the collection of webhook notifications. + :vartype webhooks: list[~$(python-base-namespace).v2015_04_01.models.WebhookNotification] """ _validation = { @@ -277,6 +331,12 @@ def __init__( webhooks: Optional[List["WebhookNotification"]] = None, **kwargs ): + """ + :keyword email: the email notification. + :paramtype email: ~$(python-base-namespace).v2015_04_01.models.EmailNotification + :keyword webhooks: the collection of webhook notifications. + :paramtype webhooks: list[~$(python-base-namespace).v2015_04_01.models.WebhookNotification] + """ super(AutoscaleNotification, self).__init__(**kwargs) self.email = email self.webhooks = webhooks @@ -287,19 +347,19 @@ class AutoscaleProfile(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. the name of the profile. - :type name: str - :param capacity: Required. the number of instances that can be used during this profile. - :type capacity: ~$(python-base-namespace).v2015_04_01.models.ScaleCapacity - :param rules: Required. the collection of rules that provide the triggers and parameters for - the scaling action. A maximum of 10 rules can be specified. - :type rules: list[~$(python-base-namespace).v2015_04_01.models.ScaleRule] - :param fixed_date: the specific date-time for the profile. This element is not used if the + :ivar name: Required. the name of the profile. + :vartype name: str + :ivar capacity: Required. the number of instances that can be used during this profile. + :vartype capacity: ~$(python-base-namespace).v2015_04_01.models.ScaleCapacity + :ivar rules: Required. the collection of rules that provide the triggers and parameters for the + scaling action. A maximum of 10 rules can be specified. + :vartype rules: list[~$(python-base-namespace).v2015_04_01.models.ScaleRule] + :ivar fixed_date: the specific date-time for the profile. This element is not used if the Recurrence element is used. - :type fixed_date: ~$(python-base-namespace).v2015_04_01.models.TimeWindow - :param recurrence: the repeating times at which this profile begins. This element is not used - if the FixedDate element is used. - :type recurrence: ~$(python-base-namespace).v2015_04_01.models.Recurrence + :vartype fixed_date: ~$(python-base-namespace).v2015_04_01.models.TimeWindow + :ivar recurrence: the repeating times at which this profile begins. This element is not used if + the FixedDate element is used. + :vartype recurrence: ~$(python-base-namespace).v2015_04_01.models.Recurrence """ _validation = { @@ -326,6 +386,21 @@ def __init__( recurrence: Optional["Recurrence"] = None, **kwargs ): + """ + :keyword name: Required. the name of the profile. + :paramtype name: str + :keyword capacity: Required. the number of instances that can be used during this profile. + :paramtype capacity: ~$(python-base-namespace).v2015_04_01.models.ScaleCapacity + :keyword rules: Required. the collection of rules that provide the triggers and parameters for + the scaling action. A maximum of 10 rules can be specified. + :paramtype rules: list[~$(python-base-namespace).v2015_04_01.models.ScaleRule] + :keyword fixed_date: the specific date-time for the profile. This element is not used if the + Recurrence element is used. + :paramtype fixed_date: ~$(python-base-namespace).v2015_04_01.models.TimeWindow + :keyword recurrence: the repeating times at which this profile begins. This element is not used + if the FixedDate element is used. + :paramtype recurrence: ~$(python-base-namespace).v2015_04_01.models.Recurrence + """ super(AutoscaleProfile, self).__init__(**kwargs) self.name = name self.capacity = capacity @@ -347,26 +422,27 @@ class AutoscaleSettingResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param profiles: Required. the collection of automatic scaling profiles that specify different + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar profiles: Required. the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. - :type profiles: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleProfile] - :param notifications: the collection of notifications. - :type notifications: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleNotification] - :param enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + :vartype profiles: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleProfile] + :ivar notifications: the collection of notifications. + :vartype notifications: + list[~$(python-base-namespace).v2015_04_01.models.AutoscaleNotification] + :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the resource. The default value is 'true'. - :type enabled: bool - :param name_properties_name: the name of the autoscale setting. - :type name_properties_name: str - :param target_resource_uri: the resource identifier of the resource that the autoscale setting + :vartype enabled: bool + :ivar name_properties_name: the name of the autoscale setting. + :vartype name_properties_name: str + :ivar target_resource_uri: the resource identifier of the resource that the autoscale setting should be added to. - :type target_resource_uri: str - :param target_resource_location: the location of the resource that the autoscale setting should + :vartype target_resource_uri: str + :ivar target_resource_location: the location of the resource that the autoscale setting should be added to. - :type target_resource_location: str + :vartype target_resource_location: str """ _validation = { @@ -404,6 +480,30 @@ def __init__( target_resource_location: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword profiles: Required. the collection of automatic scaling profiles that specify + different scaling parameters for different time periods. A maximum of 20 profiles can be + specified. + :paramtype profiles: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleProfile] + :keyword notifications: the collection of notifications. + :paramtype notifications: + list[~$(python-base-namespace).v2015_04_01.models.AutoscaleNotification] + :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + resource. The default value is 'true'. + :paramtype enabled: bool + :keyword name_properties_name: the name of the autoscale setting. + :paramtype name_properties_name: str + :keyword target_resource_uri: the resource identifier of the resource that the autoscale + setting should be added to. + :paramtype target_resource_uri: str + :keyword target_resource_location: the location of the resource that the autoscale setting + should be added to. + :paramtype target_resource_location: str + """ super(AutoscaleSettingResource, self).__init__(location=location, tags=tags, **kwargs) self.profiles = profiles self.notifications = notifications @@ -418,10 +518,10 @@ class AutoscaleSettingResourceCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the values for the autoscale setting resources. - :type value: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource] - :param next_link: URL to get the next set of results. - :type next_link: str + :ivar value: Required. the values for the autoscale setting resources. + :vartype value: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource] + :ivar next_link: URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -440,6 +540,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. the values for the autoscale setting resources. + :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource] + :keyword next_link: URL to get the next set of results. + :paramtype next_link: str + """ super(AutoscaleSettingResourceCollection, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -448,24 +554,25 @@ def __init__( class AutoscaleSettingResourcePatch(msrest.serialization.Model): """The autoscale setting object for patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param profiles: the collection of automatic scaling profiles that specify different scaling + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar profiles: the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. - :type profiles: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleProfile] - :param notifications: the collection of notifications. - :type notifications: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleNotification] - :param enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + :vartype profiles: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleProfile] + :ivar notifications: the collection of notifications. + :vartype notifications: + list[~$(python-base-namespace).v2015_04_01.models.AutoscaleNotification] + :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the resource. The default value is 'true'. - :type enabled: bool - :param name: the name of the autoscale setting. - :type name: str - :param target_resource_uri: the resource identifier of the resource that the autoscale setting + :vartype enabled: bool + :ivar name: the name of the autoscale setting. + :vartype name: str + :ivar target_resource_uri: the resource identifier of the resource that the autoscale setting should be added to. - :type target_resource_uri: str - :param target_resource_location: the location of the resource that the autoscale setting should + :vartype target_resource_uri: str + :ivar target_resource_location: the location of the resource that the autoscale setting should be added to. - :type target_resource_location: str + :vartype target_resource_location: str """ _validation = { @@ -494,6 +601,27 @@ def __init__( target_resource_location: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword profiles: the collection of automatic scaling profiles that specify different scaling + parameters for different time periods. A maximum of 20 profiles can be specified. + :paramtype profiles: list[~$(python-base-namespace).v2015_04_01.models.AutoscaleProfile] + :keyword notifications: the collection of notifications. + :paramtype notifications: + list[~$(python-base-namespace).v2015_04_01.models.AutoscaleNotification] + :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + resource. The default value is 'true'. + :paramtype enabled: bool + :keyword name: the name of the autoscale setting. + :paramtype name: str + :keyword target_resource_uri: the resource identifier of the resource that the autoscale + setting should be added to. + :paramtype target_resource_uri: str + :keyword target_resource_location: the location of the resource that the autoscale setting + should be added to. + :paramtype target_resource_location: str + """ super(AutoscaleSettingResourcePatch, self).__init__(**kwargs) self.tags = tags self.profiles = profiles @@ -507,15 +635,15 @@ def __init__( class EmailNotification(msrest.serialization.Model): """Email notification of an autoscale event. - :param send_to_subscription_administrator: a value indicating whether to send email to + :ivar send_to_subscription_administrator: a value indicating whether to send email to subscription administrator. - :type send_to_subscription_administrator: bool - :param send_to_subscription_co_administrators: a value indicating whether to send email to + :vartype send_to_subscription_administrator: bool + :ivar send_to_subscription_co_administrators: a value indicating whether to send email to subscription co-administrators. - :type send_to_subscription_co_administrators: bool - :param custom_emails: the custom e-mails list. This value can be null or empty, in which case + :vartype send_to_subscription_co_administrators: bool + :ivar custom_emails: the custom e-mails list. This value can be null or empty, in which case this attribute will be ignored. - :type custom_emails: list[str] + :vartype custom_emails: list[str] """ _attribute_map = { @@ -532,6 +660,17 @@ def __init__( custom_emails: Optional[List[str]] = None, **kwargs ): + """ + :keyword send_to_subscription_administrator: a value indicating whether to send email to + subscription administrator. + :paramtype send_to_subscription_administrator: bool + :keyword send_to_subscription_co_administrators: a value indicating whether to send email to + subscription co-administrators. + :paramtype send_to_subscription_co_administrators: bool + :keyword custom_emails: the custom e-mails list. This value can be null or empty, in which case + this attribute will be ignored. + :paramtype custom_emails: list[str] + """ super(EmailNotification, self).__init__(**kwargs) self.send_to_subscription_administrator = send_to_subscription_administrator self.send_to_subscription_co_administrators = send_to_subscription_co_administrators @@ -541,10 +680,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -559,6 +698,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -569,8 +714,8 @@ class EventCategoryCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the list that includes the Azure event categories. - :type value: list[~$(python-base-namespace).v2015_04_01.models.LocalizableString] + :ivar value: Required. the list that includes the Azure event categories. + :vartype value: list[~$(python-base-namespace).v2015_04_01.models.LocalizableString] """ _validation = { @@ -587,6 +732,10 @@ def __init__( value: List["LocalizableString"], **kwargs ): + """ + :keyword value: Required. the list that includes the Azure event categories. + :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.LocalizableString] + """ super(EventCategoryCollection, self).__init__(**kwargs) self.value = value @@ -724,6 +873,8 @@ def __init__( self, **kwargs ): + """ + """ super(EventData, self).__init__(**kwargs) self.authorization = None self.claims = None @@ -756,10 +907,10 @@ class EventDataCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. this list that includes the Azure audit logs. - :type value: list[~$(python-base-namespace).v2015_04_01.models.EventData] - :param next_link: Provides the link to retrieve the next set of events. - :type next_link: str + :ivar value: Required. this list that includes the Azure audit logs. + :vartype value: list[~$(python-base-namespace).v2015_04_01.models.EventData] + :ivar next_link: Provides the link to retrieve the next set of events. + :vartype next_link: str """ _validation = { @@ -778,6 +929,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. this list that includes the Azure audit logs. + :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.EventData] + :keyword next_link: Provides the link to retrieve the next set of events. + :paramtype next_link: str + """ super(EventDataCollection, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -786,14 +943,14 @@ def __init__( class HttpRequestInfo(msrest.serialization.Model): """The Http request info. - :param client_request_id: the client request id. - :type client_request_id: str - :param client_ip_address: the client Ip Address. - :type client_ip_address: str - :param method: the Http request method. - :type method: str - :param uri: the Uri. - :type uri: str + :ivar client_request_id: the client request id. + :vartype client_request_id: str + :ivar client_ip_address: the client Ip Address. + :vartype client_ip_address: str + :ivar method: the Http request method. + :vartype method: str + :ivar uri: the Uri. + :vartype uri: str """ _attribute_map = { @@ -812,6 +969,16 @@ def __init__( uri: Optional[str] = None, **kwargs ): + """ + :keyword client_request_id: the client request id. + :paramtype client_request_id: str + :keyword client_ip_address: the client Ip Address. + :paramtype client_ip_address: str + :keyword method: the Http request method. + :paramtype method: str + :keyword uri: the Uri. + :paramtype uri: str + """ super(HttpRequestInfo, self).__init__(**kwargs) self.client_request_id = client_request_id self.client_ip_address = client_ip_address @@ -824,10 +991,10 @@ class LocalizableString(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the invariant value. - :type value: str - :param localized_value: the locale specific value. - :type localized_value: str + :ivar value: Required. the invariant value. + :vartype value: str + :ivar localized_value: the locale specific value. + :vartype localized_value: str """ _validation = { @@ -846,6 +1013,12 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. the invariant value. + :paramtype value: str + :keyword localized_value: the locale specific value. + :paramtype localized_value: str + """ super(LocalizableString, self).__init__(**kwargs) self.value = value self.localized_value = localized_value @@ -859,14 +1032,14 @@ class RuleCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource """ _validation = { @@ -888,6 +1061,11 @@ def __init__( data_source: Optional["RuleDataSource"] = None, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource + """ super(RuleCondition, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] self.data_source = data_source @@ -898,21 +1076,21 @@ class LocationThresholdRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. - :type window_size: ~datetime.timedelta - :param failed_location_count: Required. the number of locations that must fail to activate the + :vartype window_size: ~datetime.timedelta + :ivar failed_location_count: Required. the number of locations that must fail to activate the alert. - :type failed_location_count: int + :vartype failed_location_count: int """ _validation = { @@ -935,6 +1113,18 @@ def __init__( window_size: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. If specified then it must be between 5 minutes and 1 + day. + :paramtype window_size: ~datetime.timedelta + :keyword failed_location_count: Required. the number of locations that must fail to activate + the alert. + :paramtype failed_location_count: int + """ super(LocationThresholdRuleCondition, self).__init__(data_source=data_source, **kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition' # type: str self.window_size = window_size @@ -944,15 +1134,15 @@ def __init__( class ManagementEventAggregationCondition(msrest.serialization.Model): """How the data that is collected should be combined over time. - :param operator: the condition operator. Possible values include: "GreaterThan", + :ivar operator: the condition operator. Possible values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator - :param threshold: The threshold value that activates the alert. - :type threshold: float - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator + :ivar threshold: The threshold value that activates the alert. + :vartype threshold: float + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. - :type window_size: ~datetime.timedelta + :vartype window_size: ~datetime.timedelta """ _attribute_map = { @@ -969,6 +1159,17 @@ def __init__( window_size: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword operator: the condition operator. Possible values include: "GreaterThan", + "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :paramtype operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator + :keyword threshold: The threshold value that activates the alert. + :paramtype threshold: float + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. If specified then it must be between 5 minutes and 1 + day. + :paramtype window_size: ~datetime.timedelta + """ super(ManagementEventAggregationCondition, self).__init__(**kwargs) self.operator = operator self.threshold = threshold @@ -980,18 +1181,18 @@ class ManagementEventRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource - :param aggregation: How the data that is collected should be combined over time and when the + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource + :ivar aggregation: How the data that is collected should be combined over time and when the alert is activated. Note that for management event alerts aggregation is optional – if it is not provided then any event will cause the alert to activate. - :type aggregation: + :vartype aggregation: ~$(python-base-namespace).v2015_04_01.models.ManagementEventAggregationCondition """ @@ -1012,6 +1213,16 @@ def __init__( aggregation: Optional["ManagementEventAggregationCondition"] = None, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource + :keyword aggregation: How the data that is collected should be combined over time and when the + alert is activated. Note that for management event alerts aggregation is optional – if it is + not provided then any event will cause the alert to activate. + :paramtype aggregation: + ~$(python-base-namespace).v2015_04_01.models.ManagementEventAggregationCondition + """ super(ManagementEventRuleCondition, self).__init__(data_source=data_source, **kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition' # type: str self.aggregation = aggregation @@ -1022,41 +1233,42 @@ class MetricTrigger(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param metric_name: Required. the name of the metric that defines what the rule monitors. - :type metric_name: str - :param metric_namespace: the namespace of the metric that defines what the rule monitors. - :type metric_namespace: str - :param metric_resource_uri: Required. the resource identifier of the resource the rule - monitors. - :type metric_resource_uri: str - :param metric_resource_location: the location of the resource the rule monitors. - :type metric_resource_location: str - :param time_grain: Required. the granularity of metrics the rule monitors. Must be one of the + :ivar metric_name: Required. the name of the metric that defines what the rule monitors. + :vartype metric_name: str + :ivar metric_namespace: the namespace of the metric that defines what the rule monitors. + :vartype metric_namespace: str + :ivar metric_resource_uri: Required. the resource identifier of the resource the rule monitors. + :vartype metric_resource_uri: str + :ivar metric_resource_location: the location of the resource the rule monitors. + :vartype metric_resource_location: str + :ivar time_grain: Required. the granularity of metrics the rule monitors. Must be one of the predefined values returned from metric definitions for the metric. Must be between 12 hours and 1 minute. - :type time_grain: ~datetime.timedelta - :param statistic: Required. the metric statistic type. How the metrics from multiple instances + :vartype time_grain: ~datetime.timedelta + :ivar statistic: Required. the metric statistic type. How the metrics from multiple instances are combined. Possible values include: "Average", "Min", "Max", "Sum", "Count". - :type statistic: str or ~$(python-base-namespace).v2015_04_01.models.MetricStatisticType - :param time_window: Required. the range of time in which instance data is collected. This value + :vartype statistic: str or ~$(python-base-namespace).v2015_04_01.models.MetricStatisticType + :ivar time_window: Required. the range of time in which instance data is collected. This value must be greater than the delay in metric collection, which can vary from resource-to-resource. Must be between 12 hours and 5 minutes. - :type time_window: ~datetime.timedelta - :param time_aggregation: Required. time aggregation type. How the data that is collected should + :vartype time_window: ~datetime.timedelta + :ivar time_aggregation: Required. time aggregation type. How the data that is collected should be combined over time. The default value is Average. Possible values include: "Average", "Minimum", "Maximum", "Total", "Count", "Last". - :type time_aggregation: str or ~$(python-base-namespace).v2015_04_01.models.TimeAggregationType - :param operator: Required. the operator that is used to compare the metric data and the + :vartype time_aggregation: str or + ~$(python-base-namespace).v2015_04_01.models.TimeAggregationType + :ivar operator: Required. the operator that is used to compare the metric data and the threshold. Possible values include: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or ~$(python-base-namespace).v2015_04_01.models.ComparisonOperationType - :param threshold: Required. the threshold of the metric that triggers the scale action. - :type threshold: float - :param dimensions: List of dimension conditions. For example: + :vartype operator: str or ~$(python-base-namespace).v2015_04_01.models.ComparisonOperationType + :ivar threshold: Required. the threshold of the metric that triggers the scale action. + :vartype threshold: float + :ivar dimensions: List of dimension conditions. For example: [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. - :type dimensions: list[~$(python-base-namespace).v2015_04_01.models.ScaleRuleMetricDimension] - :param divide_per_instance: a value indicating whether metric should divide per instance. - :type divide_per_instance: bool + :vartype dimensions: + list[~$(python-base-namespace).v2015_04_01.models.ScaleRuleMetricDimension] + :ivar divide_per_instance: a value indicating whether metric should divide per instance. + :vartype divide_per_instance: bool """ _validation = { @@ -1102,6 +1314,46 @@ def __init__( divide_per_instance: Optional[bool] = None, **kwargs ): + """ + :keyword metric_name: Required. the name of the metric that defines what the rule monitors. + :paramtype metric_name: str + :keyword metric_namespace: the namespace of the metric that defines what the rule monitors. + :paramtype metric_namespace: str + :keyword metric_resource_uri: Required. the resource identifier of the resource the rule + monitors. + :paramtype metric_resource_uri: str + :keyword metric_resource_location: the location of the resource the rule monitors. + :paramtype metric_resource_location: str + :keyword time_grain: Required. the granularity of metrics the rule monitors. Must be one of the + predefined values returned from metric definitions for the metric. Must be between 12 hours and + 1 minute. + :paramtype time_grain: ~datetime.timedelta + :keyword statistic: Required. the metric statistic type. How the metrics from multiple + instances are combined. Possible values include: "Average", "Min", "Max", "Sum", "Count". + :paramtype statistic: str or ~$(python-base-namespace).v2015_04_01.models.MetricStatisticType + :keyword time_window: Required. the range of time in which instance data is collected. This + value must be greater than the delay in metric collection, which can vary from + resource-to-resource. Must be between 12 hours and 5 minutes. + :paramtype time_window: ~datetime.timedelta + :keyword time_aggregation: Required. time aggregation type. How the data that is collected + should be combined over time. The default value is Average. Possible values include: "Average", + "Minimum", "Maximum", "Total", "Count", "Last". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2015_04_01.models.TimeAggregationType + :keyword operator: Required. the operator that is used to compare the metric data and the + threshold. Possible values include: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", + "LessThan", "LessThanOrEqual". + :paramtype operator: str or + ~$(python-base-namespace).v2015_04_01.models.ComparisonOperationType + :keyword threshold: Required. the threshold of the metric that triggers the scale action. + :paramtype threshold: float + :keyword dimensions: List of dimension conditions. For example: + [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. + :paramtype dimensions: + list[~$(python-base-namespace).v2015_04_01.models.ScaleRuleMetricDimension] + :keyword divide_per_instance: a value indicating whether metric should divide per instance. + :paramtype divide_per_instance: bool + """ super(MetricTrigger, self).__init__(**kwargs) self.metric_name = metric_name self.metric_namespace = metric_namespace @@ -1120,10 +1372,10 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft Insights API operation definition. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param display: Display metadata associated with the operation. - :type display: ~$(python-base-namespace).v2015_04_01.models.OperationDisplay + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: Display metadata associated with the operation. + :vartype display: ~$(python-base-namespace).v2015_04_01.models.OperationDisplay """ _attribute_map = { @@ -1138,6 +1390,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: Display metadata associated with the operation. + :paramtype display: ~$(python-base-namespace).v2015_04_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -1146,12 +1404,12 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """Display metadata associated with the operation. - :param provider: Service provider: Microsoft.Insights. - :type provider: str - :param resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str + :ivar provider: Service provider: Microsoft.Insights. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str """ _attribute_map = { @@ -1168,6 +1426,14 @@ def __init__( operation: Optional[str] = None, **kwargs ): + """ + :keyword provider: Service provider: Microsoft.Insights. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -1177,10 +1443,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Insights operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of operations supported by the Microsoft.Insights provider. - :type value: list[~$(python-base-namespace).v2015_04_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of operations supported by the Microsoft.Insights provider. + :vartype value: list[~$(python-base-namespace).v2015_04_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -1195,6 +1461,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of operations supported by the Microsoft.Insights provider. + :paramtype value: list[~$(python-base-namespace).v2015_04_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1205,14 +1477,14 @@ class Recurrence(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param frequency: Required. the recurrence frequency. How often the schedule profile should - take effect. This value must be Week, meaning each week will have the same set of profiles. For + :ivar frequency: Required. the recurrence frequency. How often the schedule profile should take + effect. This value must be Week, meaning each week will have the same set of profiles. For example, to set a daily schedule, set **schedule** to every day of the week. The frequency property specifies that the schedule is repeated weekly. Possible values include: "None", "Second", "Minute", "Hour", "Day", "Week", "Month", "Year". - :type frequency: str or ~$(python-base-namespace).v2015_04_01.models.RecurrenceFrequency - :param schedule: Required. the scheduling constraints for when the profile begins. - :type schedule: ~$(python-base-namespace).v2015_04_01.models.RecurrentSchedule + :vartype frequency: str or ~$(python-base-namespace).v2015_04_01.models.RecurrenceFrequency + :ivar schedule: Required. the scheduling constraints for when the profile begins. + :vartype schedule: ~$(python-base-namespace).v2015_04_01.models.RecurrentSchedule """ _validation = { @@ -1232,6 +1504,16 @@ def __init__( schedule: "RecurrentSchedule", **kwargs ): + """ + :keyword frequency: Required. the recurrence frequency. How often the schedule profile should + take effect. This value must be Week, meaning each week will have the same set of profiles. For + example, to set a daily schedule, set **schedule** to every day of the week. The frequency + property specifies that the schedule is repeated weekly. Possible values include: "None", + "Second", "Minute", "Hour", "Day", "Week", "Month", "Year". + :paramtype frequency: str or ~$(python-base-namespace).v2015_04_01.models.RecurrenceFrequency + :keyword schedule: Required. the scheduling constraints for when the profile begins. + :paramtype schedule: ~$(python-base-namespace).v2015_04_01.models.RecurrentSchedule + """ super(Recurrence, self).__init__(**kwargs) self.frequency = frequency self.schedule = schedule @@ -1242,7 +1524,7 @@ class RecurrentSchedule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_zone: Required. the timezone for the hours of the profile. Some examples of valid + :ivar time_zone: Required. the timezone for the hours of the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard @@ -1272,15 +1554,15 @@ class RecurrentSchedule(msrest.serialization.Model): Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time. - :type time_zone: str - :param days: Required. the collection of days that the profile takes effect on. Possible values + :vartype time_zone: str + :ivar days: Required. the collection of days that the profile takes effect on. Possible values are Sunday through Saturday. - :type days: list[str] - :param hours: Required. A collection of hours that the profile takes effect on. Values - supported are 0 to 23 on the 24-hour clock (AM/PM times are not supported). - :type hours: list[int] - :param minutes: Required. A collection of minutes at which the profile takes effect at. - :type minutes: list[int] + :vartype days: list[str] + :ivar hours: Required. A collection of hours that the profile takes effect on. Values supported + are 0 to 23 on the 24-hour clock (AM/PM times are not supported). + :vartype hours: list[int] + :ivar minutes: Required. A collection of minutes at which the profile takes effect at. + :vartype minutes: list[int] """ _validation = { @@ -1306,6 +1588,47 @@ def __init__( minutes: List[int], **kwargs ): + """ + :keyword time_zone: Required. the timezone for the hours of the profile. Some examples of valid + time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, + Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain + Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard + Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, + Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard + Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, + Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina + Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, + Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde + Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. + Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central European + Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, + GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. + Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, + Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, + Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran + Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius + Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West + Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, + Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard + Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia + Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. + Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, + Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard + Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, + Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, + Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji + Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands + Standard Time. + :paramtype time_zone: str + :keyword days: Required. the collection of days that the profile takes effect on. Possible + values are Sunday through Saturday. + :paramtype days: list[str] + :keyword hours: Required. A collection of hours that the profile takes effect on. Values + supported are 0 to 23 on the 24-hour clock (AM/PM times are not supported). + :paramtype hours: list[int] + :keyword minutes: Required. A collection of minutes at which the profile takes effect at. + :paramtype minutes: list[int] + """ super(RecurrentSchedule, self).__init__(**kwargs) self.time_zone = time_zone self.days = days @@ -1321,9 +1644,9 @@ class RuleAction(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of the action. There are two types of actions: + :ivar odata_type: Required. specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str + :vartype odata_type: str """ _validation = { @@ -1342,6 +1665,8 @@ def __init__( self, **kwargs ): + """ + """ super(RuleAction, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] @@ -1354,19 +1679,19 @@ class RuleDataSource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of data source. There are two types of rule - data sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. - :type odata_type: str - :param resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :type resource_uri: str - :param legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + :ivar odata_type: Required. specifies the type of data source. There are two types of rule data + sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :vartype odata_type: str + :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this + property cannot be updated for an existing rule. + :vartype resource_uri: str + :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. - :type legacy_resource_id: str - :param resource_location: the location of the resource. - :type resource_location: str - :param metric_namespace: the namespace of the metric. - :type metric_namespace: str + :vartype legacy_resource_id: str + :ivar resource_location: the location of the resource. + :vartype resource_location: str + :ivar metric_namespace: the namespace of the metric. + :vartype metric_namespace: str """ _validation = { @@ -1394,6 +1719,18 @@ def __init__( metric_namespace: Optional[str] = None, **kwargs ): + """ + :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : + this property cannot be updated for an existing rule. + :paramtype resource_uri: str + :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + **NOTE**\ : this property cannot be updated for an existing rule. + :paramtype legacy_resource_id: str + :keyword resource_location: the location of the resource. + :paramtype resource_location: str + :keyword metric_namespace: the namespace of the metric. + :paramtype metric_namespace: str + """ super(RuleDataSource, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] self.resource_uri = resource_uri @@ -1407,15 +1744,15 @@ class RuleEmailAction(RuleAction): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of the action. There are two types of actions: + :ivar odata_type: Required. specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str - :param send_to_service_owners: Whether the administrators (service and co-administrators) of - the service should be notified when the alert is activated. - :type send_to_service_owners: bool - :param custom_emails: the list of administrator's custom email addresses to notify of the + :vartype odata_type: str + :ivar send_to_service_owners: Whether the administrators (service and co-administrators) of the + service should be notified when the alert is activated. + :vartype send_to_service_owners: bool + :ivar custom_emails: the list of administrator's custom email addresses to notify of the activation of the alert. - :type custom_emails: list[str] + :vartype custom_emails: list[str] """ _validation = { @@ -1435,6 +1772,14 @@ def __init__( custom_emails: Optional[List[str]] = None, **kwargs ): + """ + :keyword send_to_service_owners: Whether the administrators (service and co-administrators) of + the service should be notified when the alert is activated. + :paramtype send_to_service_owners: bool + :keyword custom_emails: the list of administrator's custom email addresses to notify of the + activation of the alert. + :paramtype custom_emails: list[str] + """ super(RuleEmailAction, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleEmailAction' # type: str self.send_to_service_owners = send_to_service_owners @@ -1444,8 +1789,8 @@ def __init__( class RuleManagementEventClaimsDataSource(msrest.serialization.Model): """The claims for a rule management event data source. - :param email_address: the email address. - :type email_address: str + :ivar email_address: the email address. + :vartype email_address: str """ _attribute_map = { @@ -1458,6 +1803,10 @@ def __init__( email_address: Optional[str] = None, **kwargs ): + """ + :keyword email_address: the email address. + :paramtype email_address: str + """ super(RuleManagementEventClaimsDataSource, self).__init__(**kwargs) self.email_address = email_address @@ -1467,39 +1816,40 @@ class RuleManagementEventDataSource(RuleDataSource): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of data source. There are two types of rule - data sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. - :type odata_type: str - :param resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :type resource_uri: str - :param legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + :ivar odata_type: Required. specifies the type of data source. There are two types of rule data + sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :vartype odata_type: str + :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this + property cannot be updated for an existing rule. + :vartype resource_uri: str + :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. - :type legacy_resource_id: str - :param resource_location: the location of the resource. - :type resource_location: str - :param metric_namespace: the namespace of the metric. - :type metric_namespace: str - :param event_name: the event name. - :type event_name: str - :param event_source: the event source. - :type event_source: str - :param level: the level. - :type level: str - :param operation_name: The name of the operation that should be checked for. If no name is + :vartype legacy_resource_id: str + :ivar resource_location: the location of the resource. + :vartype resource_location: str + :ivar metric_namespace: the namespace of the metric. + :vartype metric_namespace: str + :ivar event_name: the event name. + :vartype event_name: str + :ivar event_source: the event source. + :vartype event_source: str + :ivar level: the level. + :vartype level: str + :ivar operation_name: The name of the operation that should be checked for. If no name is provided, any operation will match. - :type operation_name: str - :param resource_group_name: the resource group name. - :type resource_group_name: str - :param resource_provider_name: the resource provider name. - :type resource_provider_name: str - :param status: The status of the operation that should be checked for. If no status is - provided, any status will match. - :type status: str - :param sub_status: the substatus. - :type sub_status: str - :param claims: the claims. - :type claims: ~$(python-base-namespace).v2015_04_01.models.RuleManagementEventClaimsDataSource + :vartype operation_name: str + :ivar resource_group_name: the resource group name. + :vartype resource_group_name: str + :ivar resource_provider_name: the resource provider name. + :vartype resource_provider_name: str + :ivar status: The status of the operation that should be checked for. If no status is provided, + any status will match. + :vartype status: str + :ivar sub_status: the substatus. + :vartype sub_status: str + :ivar claims: the claims. + :vartype claims: + ~$(python-base-namespace).v2015_04_01.models.RuleManagementEventClaimsDataSource """ _validation = { @@ -1541,6 +1891,39 @@ def __init__( claims: Optional["RuleManagementEventClaimsDataSource"] = None, **kwargs ): + """ + :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : + this property cannot be updated for an existing rule. + :paramtype resource_uri: str + :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + **NOTE**\ : this property cannot be updated for an existing rule. + :paramtype legacy_resource_id: str + :keyword resource_location: the location of the resource. + :paramtype resource_location: str + :keyword metric_namespace: the namespace of the metric. + :paramtype metric_namespace: str + :keyword event_name: the event name. + :paramtype event_name: str + :keyword event_source: the event source. + :paramtype event_source: str + :keyword level: the level. + :paramtype level: str + :keyword operation_name: The name of the operation that should be checked for. If no name is + provided, any operation will match. + :paramtype operation_name: str + :keyword resource_group_name: the resource group name. + :paramtype resource_group_name: str + :keyword resource_provider_name: the resource provider name. + :paramtype resource_provider_name: str + :keyword status: The status of the operation that should be checked for. If no status is + provided, any status will match. + :paramtype status: str + :keyword sub_status: the substatus. + :paramtype sub_status: str + :keyword claims: the claims. + :paramtype claims: + ~$(python-base-namespace).v2015_04_01.models.RuleManagementEventClaimsDataSource + """ super(RuleManagementEventDataSource, self).__init__(resource_uri=resource_uri, legacy_resource_id=legacy_resource_id, resource_location=resource_location, metric_namespace=metric_namespace, **kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource' # type: str self.event_name = event_name @@ -1559,21 +1942,21 @@ class RuleMetricDataSource(RuleDataSource): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of data source. There are two types of rule - data sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. - :type odata_type: str - :param resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :type resource_uri: str - :param legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + :ivar odata_type: Required. specifies the type of data source. There are two types of rule data + sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :vartype odata_type: str + :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this + property cannot be updated for an existing rule. + :vartype resource_uri: str + :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. - :type legacy_resource_id: str - :param resource_location: the location of the resource. - :type resource_location: str - :param metric_namespace: the namespace of the metric. - :type metric_namespace: str - :param metric_name: the name of the metric that defines what the rule monitors. - :type metric_name: str + :vartype legacy_resource_id: str + :ivar resource_location: the location of the resource. + :vartype resource_location: str + :ivar metric_namespace: the namespace of the metric. + :vartype metric_namespace: str + :ivar metric_name: the name of the metric that defines what the rule monitors. + :vartype metric_name: str """ _validation = { @@ -1599,6 +1982,20 @@ def __init__( metric_name: Optional[str] = None, **kwargs ): + """ + :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : + this property cannot be updated for an existing rule. + :paramtype resource_uri: str + :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + **NOTE**\ : this property cannot be updated for an existing rule. + :paramtype legacy_resource_id: str + :keyword resource_location: the location of the resource. + :paramtype resource_location: str + :keyword metric_namespace: the namespace of the metric. + :paramtype metric_namespace: str + :keyword metric_name: the name of the metric that defines what the rule monitors. + :paramtype metric_name: str + """ super(RuleMetricDataSource, self).__init__(resource_uri=resource_uri, legacy_resource_id=legacy_resource_id, resource_location=resource_location, metric_namespace=metric_namespace, **kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource' # type: str self.metric_name = metric_name @@ -1609,15 +2006,15 @@ class RuleWebhookAction(RuleAction): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of the action. There are two types of actions: + :ivar odata_type: Required. specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str - :param service_uri: the service uri to Post the notification when the alert activates or + :vartype odata_type: str + :ivar service_uri: the service uri to Post the notification when the alert activates or resolves. - :type service_uri: str - :param properties: the dictionary of custom properties to include with the post operation. - These data are appended to the webhook payload. - :type properties: dict[str, str] + :vartype service_uri: str + :ivar properties: the dictionary of custom properties to include with the post operation. These + data are appended to the webhook payload. + :vartype properties: dict[str, str] """ _validation = { @@ -1637,6 +2034,14 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword service_uri: the service uri to Post the notification when the alert activates or + resolves. + :paramtype service_uri: str + :keyword properties: the dictionary of custom properties to include with the post operation. + These data are appended to the webhook payload. + :paramtype properties: dict[str, str] + """ super(RuleWebhookAction, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction' # type: str self.service_uri = service_uri @@ -1648,18 +2053,18 @@ class ScaleAction(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param direction: Required. the scale direction. Whether the scaling action increases or + :ivar direction: Required. the scale direction. Whether the scaling action increases or decreases the number of instances. Possible values include: "None", "Increase", "Decrease". - :type direction: str or ~$(python-base-namespace).v2015_04_01.models.ScaleDirection - :param type: Required. the type of action that should occur when the scale rule fires. Possible + :vartype direction: str or ~$(python-base-namespace).v2015_04_01.models.ScaleDirection + :ivar type: Required. the type of action that should occur when the scale rule fires. Possible values include: "ChangeCount", "PercentChangeCount", "ExactCount", "ServiceAllowedNextValue". - :type type: str or ~$(python-base-namespace).v2015_04_01.models.ScaleType - :param value: the number of instances that are involved in the scaling action. This value must + :vartype type: str or ~$(python-base-namespace).v2015_04_01.models.ScaleType + :ivar value: the number of instances that are involved in the scaling action. This value must be 1 or greater. The default value is 1. - :type value: str - :param cooldown: Required. the amount of time to wait since the last scaling action before this + :vartype value: str + :ivar cooldown: Required. the amount of time to wait since the last scaling action before this action occurs. It must be between 1 week and 1 minute in ISO 8601 format. - :type cooldown: ~datetime.timedelta + :vartype cooldown: ~datetime.timedelta """ _validation = { @@ -1684,6 +2089,21 @@ def __init__( value: Optional[str] = "1", **kwargs ): + """ + :keyword direction: Required. the scale direction. Whether the scaling action increases or + decreases the number of instances. Possible values include: "None", "Increase", "Decrease". + :paramtype direction: str or ~$(python-base-namespace).v2015_04_01.models.ScaleDirection + :keyword type: Required. the type of action that should occur when the scale rule fires. + Possible values include: "ChangeCount", "PercentChangeCount", "ExactCount", + "ServiceAllowedNextValue". + :paramtype type: str or ~$(python-base-namespace).v2015_04_01.models.ScaleType + :keyword value: the number of instances that are involved in the scaling action. This value + must be 1 or greater. The default value is 1. + :paramtype value: str + :keyword cooldown: Required. the amount of time to wait since the last scaling action before + this action occurs. It must be between 1 week and 1 minute in ISO 8601 format. + :paramtype cooldown: ~datetime.timedelta + """ super(ScaleAction, self).__init__(**kwargs) self.direction = direction self.type = type @@ -1696,15 +2116,15 @@ class ScaleCapacity(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param minimum: Required. the minimum number of instances for the resource. - :type minimum: str - :param maximum: Required. the maximum number of instances for the resource. The actual maximum + :ivar minimum: Required. the minimum number of instances for the resource. + :vartype minimum: str + :ivar maximum: Required. the maximum number of instances for the resource. The actual maximum number of instances is limited by the cores that are available in the subscription. - :type maximum: str - :param default: Required. the number of instances that will be set if metrics are not available + :vartype maximum: str + :ivar default: Required. the number of instances that will be set if metrics are not available for evaluation. The default is only used if the current instance count is lower than the default. - :type default: str + :vartype default: str """ _validation = { @@ -1727,6 +2147,17 @@ def __init__( default: str, **kwargs ): + """ + :keyword minimum: Required. the minimum number of instances for the resource. + :paramtype minimum: str + :keyword maximum: Required. the maximum number of instances for the resource. The actual + maximum number of instances is limited by the cores that are available in the subscription. + :paramtype maximum: str + :keyword default: Required. the number of instances that will be set if metrics are not + available for evaluation. The default is only used if the current instance count is lower than + the default. + :paramtype default: str + """ super(ScaleCapacity, self).__init__(**kwargs) self.minimum = minimum self.maximum = maximum @@ -1738,10 +2169,10 @@ class ScaleRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param metric_trigger: Required. the trigger that results in a scaling action. - :type metric_trigger: ~$(python-base-namespace).v2015_04_01.models.MetricTrigger - :param scale_action: Required. the parameters for the scaling action. - :type scale_action: ~$(python-base-namespace).v2015_04_01.models.ScaleAction + :ivar metric_trigger: Required. the trigger that results in a scaling action. + :vartype metric_trigger: ~$(python-base-namespace).v2015_04_01.models.MetricTrigger + :ivar scale_action: Required. the parameters for the scaling action. + :vartype scale_action: ~$(python-base-namespace).v2015_04_01.models.ScaleAction """ _validation = { @@ -1761,6 +2192,12 @@ def __init__( scale_action: "ScaleAction", **kwargs ): + """ + :keyword metric_trigger: Required. the trigger that results in a scaling action. + :paramtype metric_trigger: ~$(python-base-namespace).v2015_04_01.models.MetricTrigger + :keyword scale_action: Required. the parameters for the scaling action. + :paramtype scale_action: ~$(python-base-namespace).v2015_04_01.models.ScaleAction + """ super(ScaleRule, self).__init__(**kwargs) self.metric_trigger = metric_trigger self.scale_action = scale_action @@ -1771,15 +2208,15 @@ class ScaleRuleMetricDimension(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param dimension_name: Required. Name of the dimension. - :type dimension_name: str - :param operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are supported. + :ivar dimension_name: Required. Name of the dimension. + :vartype dimension_name: str + :ivar operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values. Possible values include: "Equals", "NotEquals". - :type operator: str or + :vartype operator: str or ~$(python-base-namespace).v2015_04_01.models.ScaleRuleMetricDimensionOperationType - :param values: Required. list of dimension values. For example: ["App1","App2"]. - :type values: list[str] + :ivar values: Required. list of dimension values. For example: ["App1","App2"]. + :vartype values: list[str] """ _validation = { @@ -1802,6 +2239,17 @@ def __init__( values: List[str], **kwargs ): + """ + :keyword dimension_name: Required. Name of the dimension. + :paramtype dimension_name: str + :keyword operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are + supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the + values. Possible values include: "Equals", "NotEquals". + :paramtype operator: str or + ~$(python-base-namespace).v2015_04_01.models.ScaleRuleMetricDimensionOperationType + :keyword values: Required. list of dimension values. For example: ["App1","App2"]. + :paramtype values: list[str] + """ super(ScaleRuleMetricDimension, self).__init__(**kwargs) self.dimension_name = dimension_name self.operator = operator @@ -1811,12 +2259,12 @@ def __init__( class SenderAuthorization(msrest.serialization.Model): """the authorization used by the user who has performed the operation that led to this event. This captures the RBAC properties of the event. These usually include the 'action', 'role' and the 'scope'. - :param action: the permissible actions. For instance: microsoft.support/supporttickets/write. - :type action: str - :param role: the role of the user. For instance: Subscription Admin. - :type role: str - :param scope: the scope. - :type scope: str + :ivar action: the permissible actions. For instance: microsoft.support/supporttickets/write. + :vartype action: str + :ivar role: the role of the user. For instance: Subscription Admin. + :vartype role: str + :ivar scope: the scope. + :vartype scope: str """ _attribute_map = { @@ -1833,6 +2281,14 @@ def __init__( scope: Optional[str] = None, **kwargs ): + """ + :keyword action: the permissible actions. For instance: microsoft.support/supporttickets/write. + :paramtype action: str + :keyword role: the role of the user. For instance: Subscription Admin. + :paramtype role: str + :keyword scope: the scope. + :paramtype scope: str + """ super(SenderAuthorization, self).__init__(**kwargs) self.action = action self.role = role @@ -1844,27 +2300,27 @@ class ThresholdRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource - :param operator: Required. the operator used to compare the data and the threshold. Possible + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource + :ivar operator: Required. the operator used to compare the data and the threshold. Possible values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator - :param threshold: Required. the threshold value that activates the alert. - :type threshold: float - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator + :ivar threshold: Required. the threshold value that activates the alert. + :vartype threshold: float + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. - :type window_size: ~datetime.timedelta - :param time_aggregation: the time aggregation operator. How the data that are collected should + :vartype window_size: ~datetime.timedelta + :ivar time_aggregation: the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. Possible values include: "Average", "Minimum", "Maximum", "Total", "Last". - :type time_aggregation: str or + :vartype time_aggregation: str or ~$(python-base-namespace).v2015_04_01.models.TimeAggregationOperator """ @@ -1893,6 +2349,25 @@ def __init__( time_aggregation: Optional[Union[str, "TimeAggregationOperator"]] = None, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2015_04_01.models.RuleDataSource + :keyword operator: Required. the operator used to compare the data and the threshold. Possible + values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :paramtype operator: str or ~$(python-base-namespace).v2015_04_01.models.ConditionOperator + :keyword threshold: Required. the threshold value that activates the alert. + :paramtype threshold: float + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. If specified then it must be between 5 minutes and 1 + day. + :paramtype window_size: ~datetime.timedelta + :keyword time_aggregation: the time aggregation operator. How the data that are collected + should be combined over time. The default value is the PrimaryAggregationType of the Metric. + Possible values include: "Average", "Minimum", "Maximum", "Total", "Last". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2015_04_01.models.TimeAggregationOperator + """ super(ThresholdRuleCondition, self).__init__(data_source=data_source, **kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition' # type: str self.operator = operator @@ -1906,7 +2381,7 @@ class TimeWindow(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_zone: the timezone of the start and end times for the profile. Some examples of + :ivar time_zone: the timezone of the start and end times for the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central @@ -1936,11 +2411,11 @@ class TimeWindow(msrest.serialization.Model): Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time. - :type time_zone: str - :param start: Required. the start time for the profile in ISO 8601 format. - :type start: ~datetime.datetime - :param end: Required. the end time for the profile in ISO 8601 format. - :type end: ~datetime.datetime + :vartype time_zone: str + :ivar start: Required. the start time for the profile in ISO 8601 format. + :vartype start: ~datetime.datetime + :ivar end: Required. the end time for the profile in ISO 8601 format. + :vartype end: ~datetime.datetime """ _validation = { @@ -1962,6 +2437,43 @@ def __init__( time_zone: Optional[str] = None, **kwargs ): + """ + :keyword time_zone: the timezone of the start and end times for the profile. Some examples of + valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard + Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, + Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central + Standard Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific + Standard Time, Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, + Paraguay Standard Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western + Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard + Time, Argentina Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo + Standard Time, Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, + Cape Verde Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard + Time, W. Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central + European Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard + Time, GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, + E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, + Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, + Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran + Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius + Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West + Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, + Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard + Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia + Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. + Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, + Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard + Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, + Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, + Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji + Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands + Standard Time. + :paramtype time_zone: str + :keyword start: Required. the start time for the profile in ISO 8601 format. + :paramtype start: ~datetime.datetime + :keyword end: Required. the end time for the profile in ISO 8601 format. + :paramtype end: ~datetime.datetime + """ super(TimeWindow, self).__init__(**kwargs) self.time_zone = time_zone self.start = start @@ -1971,10 +2483,10 @@ def __init__( class WebhookNotification(msrest.serialization.Model): """Webhook notification of an autoscale event. - :param service_uri: the service address to receive the notification. - :type service_uri: str - :param properties: a property bag of settings. This value can be empty. - :type properties: dict[str, str] + :ivar service_uri: the service address to receive the notification. + :vartype service_uri: str + :ivar properties: a property bag of settings. This value can be empty. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1989,6 +2501,12 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword service_uri: the service address to receive the notification. + :paramtype service_uri: str + :keyword properties: a property bag of settings. This value can be empty. + :paramtype properties: dict[str, str] + """ super(WebhookNotification, self).__init__(**kwargs) self.service_uri = service_uri self.properties = properties diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_monitor_management_client_enums.py index 37b2db1f18f40..9b8ef5463b88c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/models/_monitor_management_client_enums.py @@ -6,27 +6,12 @@ # 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 ComparisonOperationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ComparisonOperationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the operator that is used to compare the metric data and the threshold. """ @@ -37,7 +22,7 @@ class ComparisonOperationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" -class ConditionOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ConditionOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Operators allowed in the rule condition. """ @@ -46,7 +31,7 @@ class ConditionOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" -class EventLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EventLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the event level """ @@ -56,7 +41,7 @@ class EventLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INFORMATIONAL = "Informational" VERBOSE = "Verbose" -class MetricStatisticType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MetricStatisticType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the metric statistic type. How the metrics from multiple instances are combined. """ @@ -66,7 +51,7 @@ class MetricStatisticType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUM = "Sum" COUNT = "Count" -class RecurrenceFrequency(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RecurrenceFrequency(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the recurrence frequency. How often the schedule profile should take effect. This value must be Week, meaning each week will have the same set of profiles. For example, to set a daily schedule, set **schedule** to every day of the week. The frequency property specifies that the @@ -82,7 +67,7 @@ class RecurrenceFrequency(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MONTH = "Month" YEAR = "Year" -class ScaleDirection(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ScaleDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the scale direction. Whether the scaling action increases or decreases the number of instances. """ @@ -90,7 +75,7 @@ class ScaleDirection(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INCREASE = "Increase" DECREASE = "Decrease" -class ScaleRuleMetricDimensionOperationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ScaleRuleMetricDimensionOperationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values """ @@ -98,7 +83,7 @@ class ScaleRuleMetricDimensionOperationType(with_metaclass(_CaseInsensitiveEnumM EQUALS = "Equals" NOT_EQUALS = "NotEquals" -class ScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the type of action that should occur when the scale rule fires. """ @@ -107,7 +92,7 @@ class ScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): EXACT_COUNT = "ExactCount" SERVICE_ALLOWED_NEXT_VALUE = "ServiceAllowedNextValue" -class TimeAggregationOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TimeAggregationOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Aggregation operators allowed in a rule. """ @@ -117,7 +102,7 @@ class TimeAggregationOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum TOTAL = "Total" LAST = "Last" -class TimeAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TimeAggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """time aggregation type. How the data that is collected should be combined over time. The default value is Average. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_activity_logs_operations.py index e83da6d5d60a8..62a8c5415614f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_activity_logs_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_activity_logs_operations.py @@ -5,24 +5,70 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter') # type: str + select = kwargs.pop('select', None) # type: Optional[str] + + api_version = "2015-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/eventtypes/management/values') + 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') + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if select is not None: + query_parameters['$select'] = _SERIALIZER.query("select", select, '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 + ) + +# fmt: on class ActivityLogsOperations(object): """ActivityLogsOperations operations. @@ -45,6 +91,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, filter, # type: str @@ -79,7 +126,8 @@ def list( :type select: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EventDataCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.EventDataCollection] + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.EventDataCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventDataCollection"] @@ -87,37 +135,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-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') - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if select is not None: - query_parameters['$select'] = self._serialize.query("select", select, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + select=select, + template_url=self.list.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_list_request( + subscription_id=self._config.subscription_id, + filter=filter, + select=select, + 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('EventDataCollection', pipeline_response) + deserialized = self._deserialize("EventDataCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -130,12 +174,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_alert_rules_operations.py index b9931cb2c2b97..e1942097f6b49 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_alert_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_alert_rules_operations.py @@ -5,24 +5,250 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + resource_group_name, # type: str + rule_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "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] + 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, + **kwargs + ) + + +def build_delete_request( + resource_group_name, # type: str + rule_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + rule_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "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_update_request( + subscription_id, # type: str + resource_group_name, # type: str + rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", 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, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules') + 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 + ) + +# fmt: on class AlertRulesOperations(object): """AlertRulesOperations operations. @@ -45,6 +271,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -55,7 +282,7 @@ def create_or_update( # type: (...) -> "_models.AlertRuleResource" """Creates or updates a classic metric alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -71,38 +298,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'AlertRuleResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AlertRuleResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -115,8 +332,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -126,7 +346,7 @@ def delete( # type: (...) -> None """Deletes a classic metric alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -140,33 +360,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -174,6 +384,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -183,7 +395,7 @@ def get( # type: (...) -> "_models.AlertRuleResource" """Gets a classic metric alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -197,33 +409,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertRuleResource', pipeline_response) @@ -232,8 +434,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -245,7 +450,7 @@ def update( """Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -261,38 +466,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - 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'), - 'ruleName': self._serialize.url("rule_name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') - 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, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -305,8 +500,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -315,11 +513,13 @@ def list_by_resource_group( # type: (...) -> Iterable["_models.AlertRuleResourceCollection"] """List the classic metric alert rules within a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 AlertRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResourceCollection] + :return: An iterator like instance of either AlertRuleResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] @@ -327,35 +527,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('AlertRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -368,17 +564,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Insights/alertrules'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs # type: Any @@ -387,8 +585,10 @@ def list_by_subscription( """List the classic metric alert rules within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResourceCollection] + :return: An iterator like instance of either AlertRuleResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] @@ -396,34 +596,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-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_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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('AlertRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -436,12 +631,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_autoscale_settings_operations.py index ffd1174490a14..c0fef75f5fd55 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_autoscale_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_autoscale_settings_operations.py @@ -5,24 +5,250 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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_create_or_update_request( + resource_group_name, # type: str + autoscale_setting_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), + "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] + 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, + **kwargs + ) + + +def build_delete_request( + resource_group_name, # type: str + autoscale_setting_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), + "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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + autoscale_setting_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), + "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_update_request( + subscription_id, # type: str + resource_group_name, # type: str + autoscale_setting_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_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, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings') + 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 + ) + +# fmt: on class AutoscaleSettingsOperations(object): """AutoscaleSettingsOperations operations. @@ -45,6 +271,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -53,11 +280,13 @@ def list_by_resource_group( # type: (...) -> Iterable["_models.AutoscaleSettingResourceCollection"] """Lists the autoscale settings for a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 AutoscaleSettingResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourceCollection] + :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResourceCollection"] @@ -65,35 +294,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('AutoscaleSettingResourceCollection', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,17 +331,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Insights/autoscalesettings'} # type: ignore + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -127,7 +354,7 @@ def create_or_update( # type: (...) -> "_models.AutoscaleSettingResource" """Creates or updates an autoscale setting. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str @@ -143,38 +370,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'autoscaleSettingName': self._serialize.url("autoscale_setting_name", autoscale_setting_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AutoscaleSettingResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AutoscaleSettingResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -187,8 +404,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -198,7 +418,7 @@ def delete( # type: (...) -> None """Deletes and autoscale setting. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str @@ -212,33 +432,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'autoscaleSettingName': self._serialize.url("autoscale_setting_name", autoscale_setting_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -246,6 +456,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -255,7 +467,7 @@ def get( # type: (...) -> "_models.AutoscaleSettingResource" """Gets an autoscale setting. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str @@ -269,33 +481,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'autoscaleSettingName': self._serialize.url("autoscale_setting_name", autoscale_setting_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) @@ -304,8 +506,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -317,12 +522,13 @@ def update( """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str :param autoscale_setting_resource: Parameters supplied to the operation. - :type autoscale_setting_resource: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourcePatch + :type autoscale_setting_resource: + ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourcePatch :keyword callable cls: A custom type or function that will be passed the direct response :return: AutoscaleSettingResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResource @@ -333,38 +539,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-01" - 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'), - 'autoscaleSettingName': self._serialize.url("autoscale_setting_name", autoscale_setting_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(autoscale_setting_resource, 'AutoscaleSettingResourcePatch') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(autoscale_setting_resource, 'AutoscaleSettingResourcePatch') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) @@ -373,8 +569,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, **kwargs # type: Any @@ -383,8 +582,10 @@ def list_by_subscription( """Lists the autoscale settings for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourceCollection] + :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.AutoscaleSettingResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResourceCollection"] @@ -392,34 +593,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-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_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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('AutoscaleSettingResourceCollection', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -432,12 +628,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_event_categories_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_event_categories_operations.py index c5d271a71e2c9..253bfa1e7d1a6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_event_categories_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_event_categories_operations.py @@ -5,24 +5,58 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Insights/eventcategories') + + # 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 + ) + +# fmt: on class EventCategoriesOperations(object): """EventCategoriesOperations operations. @@ -45,6 +79,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -55,8 +90,10 @@ def list( ServiceHealth, Alert, Recommendation, Policy. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventCategoryCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.EventCategoryCollection] + :return: An iterator like instance of either EventCategoryCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.EventCategoryCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventCategoryCollection"] @@ -64,30 +101,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-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 - # 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('EventCategoryCollection', pipeline_response) + deserialized = self._deserialize("EventCategoryCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -100,12 +134,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_operations.py index d57820bb6d719..b403a87e8c0fe 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_operations.py @@ -5,23 +5,57 @@ # 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 TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 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 +from .._vendor import _convert_request if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Insights/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -44,6 +78,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -61,21 +96,14 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-01" - accept = "application/json" - - # 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, '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) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -89,4 +117,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/providers/Microsoft.Insights/operations'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_tenant_activity_logs_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_tenant_activity_logs_operations.py index 91d274582a84f..9d44e9934c629 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_tenant_activity_logs_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_04_01/operations/_tenant_activity_logs_operations.py @@ -5,24 +5,65 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + select = kwargs.pop('select', None) # type: Optional[str] + + api_version = "2015-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Insights/eventtypes/management/values') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if select is not None: + query_parameters['$select'] = _SERIALIZER.query("select", select, '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 + ) + +# fmt: on class TenantActivityLogsOperations(object): """TenantActivityLogsOperations operations. @@ -45,6 +86,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, filter=None, # type: Optional[str] @@ -84,7 +126,8 @@ def list( :type select: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EventDataCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.EventDataCollection] + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_04_01.models.EventDataCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventDataCollection"] @@ -92,34 +135,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-04-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 - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if select is not None: - query_parameters['$select'] = self._serialize.query("select", select, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + filter=filter, + select=select, + template_url=self.list.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_list_request( + filter=filter, + select=select, + 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('EventDataCollection', pipeline_response) + deserialized = self._deserialize("EventDataCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -132,12 +172,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_configuration.py index 224f0bceaf6e9..7b96775991e58 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -67,4 +67,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_metadata.json index 01811c9b22b57..d78934a876797 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "service_diagnostic_settings": "ServiceDiagnosticSettingsOperations", diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_monitor_management_client.py index 2f4d172e5c2af..58877a642d373 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_monitor_management_client.py @@ -6,33 +6,32 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import AlertRulesOperations, MetricDefinitionsOperations, Operations, ServiceDiagnosticSettingsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import ServiceDiagnosticSettingsOperations -from .operations import MetricDefinitionsOperations -from .operations import AlertRulesOperations -from .operations import Operations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. :ivar service_diagnostic_settings: ServiceDiagnosticSettingsOperations operations - :vartype service_diagnostic_settings: $(python-base-namespace).v2015_07_01.operations.ServiceDiagnosticSettingsOperations + :vartype service_diagnostic_settings: + $(python-base-namespace).v2015_07_01.operations.ServiceDiagnosticSettingsOperations :ivar metric_definitions: MetricDefinitionsOperations operations - :vartype metric_definitions: $(python-base-namespace).v2015_07_01.operations.MetricDefinitionsOperations + :vartype metric_definitions: + $(python-base-namespace).v2015_07_01.operations.MetricDefinitionsOperations :ivar alert_rules: AlertRulesOperations operations :vartype alert_rules: $(python-base-namespace).v2015_07_01.operations.AlertRulesOperations :ivar operations: Operations operations @@ -41,53 +40,57 @@ class MonitorManagementClient(object): :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_definitions = MetricDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + - self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.metric_definitions = MetricDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alert_rules = AlertRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_configuration.py index a1b513c610d41..34bea0f7b2022 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_monitor_management_client.py index dc53aa1b361b6..022345195ceec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_monitor_management_client.py @@ -6,31 +6,30 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import AlertRulesOperations, MetricDefinitionsOperations, Operations, ServiceDiagnosticSettingsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MonitorManagementClientConfiguration -from .operations import ServiceDiagnosticSettingsOperations -from .operations import MetricDefinitionsOperations -from .operations import AlertRulesOperations -from .operations import Operations -from .. import models - - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar service_diagnostic_settings: ServiceDiagnosticSettingsOperations operations - :vartype service_diagnostic_settings: $(python-base-namespace).v2015_07_01.aio.operations.ServiceDiagnosticSettingsOperations + :vartype service_diagnostic_settings: + $(python-base-namespace).v2015_07_01.aio.operations.ServiceDiagnosticSettingsOperations :ivar metric_definitions: MetricDefinitionsOperations operations - :vartype metric_definitions: $(python-base-namespace).v2015_07_01.aio.operations.MetricDefinitionsOperations + :vartype metric_definitions: + $(python-base-namespace).v2015_07_01.aio.operations.MetricDefinitionsOperations :ivar alert_rules: AlertRulesOperations operations :vartype alert_rules: $(python-base-namespace).v2015_07_01.aio.operations.AlertRulesOperations :ivar operations: Operations operations @@ -39,51 +38,55 @@ class MonitorManagementClient(object): :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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_definitions = MetricDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.metric_definitions = MetricDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alert_rules = AlertRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_alert_rules_operations.py index cd9b17b873eb8..ab9addf709176 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_alert_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_alert_rules_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._alert_rules_operations import build_create_or_update_request, build_delete_request, build_get_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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -50,7 +56,7 @@ async def create_or_update( ) -> "_models.AlertRuleResource": """Creates or updates a classic metric alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -66,38 +72,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'AlertRuleResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AlertRuleResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -110,8 +106,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -120,7 +119,7 @@ async def delete( ) -> None: """Deletes a classic metric alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -134,33 +133,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -168,6 +157,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -176,7 +167,7 @@ async def get( ) -> "_models.AlertRuleResource": """Gets a classic metric alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -190,33 +181,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertRuleResource', pipeline_response) @@ -225,8 +206,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -237,7 +221,7 @@ async def update( """Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -253,38 +237,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - 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'), - 'ruleName': self._serialize.url("rule_name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') - 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, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -297,8 +271,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -306,11 +283,13 @@ def list_by_resource_group( ) -> AsyncIterable["_models.AlertRuleResourceCollection"]: """List the classic metric alert rules within a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 AlertRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResourceCollection] + :return: An iterator like instance of either AlertRuleResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] @@ -318,35 +297,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('AlertRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -359,17 +334,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Insights/alertrules'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -377,8 +354,10 @@ def list_by_subscription( """List the classic metric alert rules within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResourceCollection] + :return: An iterator like instance of either AlertRuleResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] @@ -386,34 +365,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-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_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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('AlertRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -426,12 +400,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_metric_definitions_operations.py index 121d8fa7a388c..77529014142aa 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_metric_definitions_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._metric_definitions_operations import build_list_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 list( self, resource_uri: str, @@ -59,8 +65,10 @@ def list( other syntax is allowed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_07_01.models.MetricDefinitionCollection] + :return: An iterator like instance of either MetricDefinitionCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2015_07_01.models.MetricDefinitionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionCollection"] @@ -68,36 +76,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, '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 filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + template_url=self.list.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_list_request( + resource_uri=resource_uri, + filter=filter, + 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('MetricDefinitionCollection', pipeline_response) + deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,12 +113,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_operations.py index 969fd85250f87..53bc049c9ba63 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_operations.py @@ -5,16 +5,20 @@ # 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, Optional, TypeVar import warnings 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_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]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, **kwargs: Any @@ -56,27 +61,20 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, '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) 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.ErrorContract, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('OperationListResult', pipeline_response) @@ -85,4 +83,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/providers/Microsoft.Insights/operations'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_service_diagnostic_settings_operations.py index 12badcc3e8df8..314d1cc687682 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_service_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/aio/operations/_service_diagnostic_settings_operations.py @@ -5,16 +5,20 @@ # 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, Optional, TypeVar import warnings 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_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._service_diagnostic_settings_operations import build_create_or_update_request, build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_uri: str, @@ -59,31 +64,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, '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') + + request = build_get_request( + resource_uri=resource_uri, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ServiceDiagnosticSettingsResource', pipeline_response) @@ -92,8 +87,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_uri: str, @@ -105,7 +103,8 @@ async def create_or_update( :param resource_uri: The identifier of the resource. :type resource_uri: str :param parameters: Parameters supplied to the operation. - :type parameters: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource + :type parameters: + ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: ServiceDiagnosticSettingsResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource @@ -116,30 +115,20 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ServiceDiagnosticSettingsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_uri=resource_uri, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServiceDiagnosticSettingsResource') - 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 @@ -153,4 +142,6 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models.py index 6381ac0370dc9..6492524a2e0a9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models.py @@ -23,10 +23,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -48,6 +48,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -69,26 +75,26 @@ class AlertRuleResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param name_properties_name: Required. the name of the alert rule. - :type name_properties_name: str - :param description: the description of the alert rule that will be included in the alert email. - :type description: str - :param provisioning_state: the provisioning state. - :type provisioning_state: str - :param is_enabled: Required. the flag that indicates whether the alert rule is enabled. - :type is_enabled: bool - :param condition: Required. the condition that results in the alert rule being activated. - :type condition: ~$(python-base-namespace).v2015_07_01.models.RuleCondition - :param action: action that is performed when the alert rule becomes active, and when an alert + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar name_properties_name: Required. the name of the alert rule. + :vartype name_properties_name: str + :ivar description: the description of the alert rule that will be included in the alert email. + :vartype description: str + :ivar provisioning_state: the provisioning state. + :vartype provisioning_state: str + :ivar is_enabled: Required. the flag that indicates whether the alert rule is enabled. + :vartype is_enabled: bool + :ivar condition: Required. the condition that results in the alert rule being activated. + :vartype condition: ~$(python-base-namespace).v2015_07_01.models.RuleCondition + :ivar action: action that is performed when the alert rule becomes active, and when an alert condition is resolved. - :type action: ~$(python-base-namespace).v2015_07_01.models.RuleAction - :param actions: the array of actions that are performed when the alert rule becomes active, and + :vartype action: ~$(python-base-namespace).v2015_07_01.models.RuleAction + :ivar actions: the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. - :type actions: list[~$(python-base-namespace).v2015_07_01.models.RuleAction] + :vartype actions: list[~$(python-base-namespace).v2015_07_01.models.RuleAction] :ivar last_updated_time: Last time the rule was updated in ISO8601 format. :vartype last_updated_time: ~datetime.datetime """ @@ -124,6 +130,29 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword name_properties_name: Required. the name of the alert rule. + :paramtype name_properties_name: str + :keyword description: the description of the alert rule that will be included in the alert + email. + :paramtype description: str + :keyword provisioning_state: the provisioning state. + :paramtype provisioning_state: str + :keyword is_enabled: Required. the flag that indicates whether the alert rule is enabled. + :paramtype is_enabled: bool + :keyword condition: Required. the condition that results in the alert rule being activated. + :paramtype condition: ~$(python-base-namespace).v2015_07_01.models.RuleCondition + :keyword action: action that is performed when the alert rule becomes active, and when an alert + condition is resolved. + :paramtype action: ~$(python-base-namespace).v2015_07_01.models.RuleAction + :keyword actions: the array of actions that are performed when the alert rule becomes active, + and when an alert condition is resolved. + :paramtype actions: list[~$(python-base-namespace).v2015_07_01.models.RuleAction] + """ super(AlertRuleResource, self).__init__(**kwargs) self.name_properties_name = kwargs['name_properties_name'] self.description = kwargs.get('description', None) @@ -138,8 +167,8 @@ def __init__( class AlertRuleResourceCollection(msrest.serialization.Model): """Represents a collection of alert rule resources. - :param value: the values for the alert rule resources. - :type value: list[~$(python-base-namespace).v2015_07_01.models.AlertRuleResource] + :ivar value: the values for the alert rule resources. + :vartype value: list[~$(python-base-namespace).v2015_07_01.models.AlertRuleResource] """ _attribute_map = { @@ -150,6 +179,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: the values for the alert rule resources. + :paramtype value: list[~$(python-base-namespace).v2015_07_01.models.AlertRuleResource] + """ super(AlertRuleResourceCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -159,24 +192,24 @@ class AlertRuleResourcePatch(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param name: the name of the alert rule. - :type name: str - :param description: the description of the alert rule that will be included in the alert email. - :type description: str - :param provisioning_state: the provisioning state. - :type provisioning_state: str - :param is_enabled: the flag that indicates whether the alert rule is enabled. - :type is_enabled: bool - :param condition: the condition that results in the alert rule being activated. - :type condition: ~$(python-base-namespace).v2015_07_01.models.RuleCondition - :param action: action that is performed when the alert rule becomes active, and when an alert + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar name: the name of the alert rule. + :vartype name: str + :ivar description: the description of the alert rule that will be included in the alert email. + :vartype description: str + :ivar provisioning_state: the provisioning state. + :vartype provisioning_state: str + :ivar is_enabled: the flag that indicates whether the alert rule is enabled. + :vartype is_enabled: bool + :ivar condition: the condition that results in the alert rule being activated. + :vartype condition: ~$(python-base-namespace).v2015_07_01.models.RuleCondition + :ivar action: action that is performed when the alert rule becomes active, and when an alert condition is resolved. - :type action: ~$(python-base-namespace).v2015_07_01.models.RuleAction - :param actions: the array of actions that are performed when the alert rule becomes active, and + :vartype action: ~$(python-base-namespace).v2015_07_01.models.RuleAction + :ivar actions: the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. - :type actions: list[~$(python-base-namespace).v2015_07_01.models.RuleAction] + :vartype actions: list[~$(python-base-namespace).v2015_07_01.models.RuleAction] :ivar last_updated_time: Last time the rule was updated in ISO8601 format. :vartype last_updated_time: ~datetime.datetime """ @@ -201,6 +234,27 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword name: the name of the alert rule. + :paramtype name: str + :keyword description: the description of the alert rule that will be included in the alert + email. + :paramtype description: str + :keyword provisioning_state: the provisioning state. + :paramtype provisioning_state: str + :keyword is_enabled: the flag that indicates whether the alert rule is enabled. + :paramtype is_enabled: bool + :keyword condition: the condition that results in the alert rule being activated. + :paramtype condition: ~$(python-base-namespace).v2015_07_01.models.RuleCondition + :keyword action: action that is performed when the alert rule becomes active, and when an alert + condition is resolved. + :paramtype action: ~$(python-base-namespace).v2015_07_01.models.RuleAction + :keyword actions: the array of actions that are performed when the alert rule becomes active, + and when an alert condition is resolved. + :paramtype actions: list[~$(python-base-namespace).v2015_07_01.models.RuleAction] + """ super(AlertRuleResourcePatch, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.name = kwargs.get('name', None) @@ -216,18 +270,18 @@ def __init__( class DimensionProperties(msrest.serialization.Model): """Type of operation: get, read, delete, etc. - :param name: Name of dimension. - :type name: str - :param display_name: Display name of dimension. - :type display_name: str - :param to_be_exported_for_shoebox: Legacy usage, should not set. - :type to_be_exported_for_shoebox: bool - :param is_hidden: When set, the dimension is hidden from the customer, used in conjunction with + :ivar name: Name of dimension. + :vartype name: str + :ivar display_name: Display name of dimension. + :vartype display_name: str + :ivar to_be_exported_for_shoebox: Legacy usage, should not set. + :vartype to_be_exported_for_shoebox: bool + :ivar is_hidden: When set, the dimension is hidden from the customer, used in conjunction with the defaultDimensionValues field below. - :type is_hidden: bool - :param default_dimension_values: Default dimension value to be sent down for the hidden + :vartype is_hidden: bool + :ivar default_dimension_values: Default dimension value to be sent down for the hidden dimension during query. - :type default_dimension_values: any + :vartype default_dimension_values: any """ _attribute_map = { @@ -242,6 +296,20 @@ def __init__( self, **kwargs ): + """ + :keyword name: Name of dimension. + :paramtype name: str + :keyword display_name: Display name of dimension. + :paramtype display_name: str + :keyword to_be_exported_for_shoebox: Legacy usage, should not set. + :paramtype to_be_exported_for_shoebox: bool + :keyword is_hidden: When set, the dimension is hidden from the customer, used in conjunction + with the defaultDimensionValues field below. + :paramtype is_hidden: bool + :keyword default_dimension_values: Default dimension value to be sent down for the hidden + dimension during query. + :paramtype default_dimension_values: any + """ super(DimensionProperties, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display_name = kwargs.get('display_name', None) @@ -253,8 +321,8 @@ def __init__( class ErrorContract(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~$(python-base-namespace).v2015_07_01.models.ErrorResponse + :ivar error: The error object. + :vartype error: ~$(python-base-namespace).v2015_07_01.models.ErrorResponse """ _attribute_map = { @@ -265,6 +333,10 @@ def __init__( self, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~$(python-base-namespace).v2015_07_01.models.ErrorResponse + """ super(ErrorContract, self).__init__(**kwargs) self.error = kwargs.get('error', None) @@ -272,10 +344,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -287,6 +359,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -297,10 +375,10 @@ class LocalizableString(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the invariant value. - :type value: str - :param localized_value: the locale specific value. - :type localized_value: str + :ivar value: Required. the invariant value. + :vartype value: str + :ivar localized_value: the locale specific value. + :vartype localized_value: str """ _validation = { @@ -316,6 +394,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. the invariant value. + :paramtype value: str + :keyword localized_value: the locale specific value. + :paramtype localized_value: str + """ super(LocalizableString, self).__init__(**kwargs) self.value = kwargs['value'] self.localized_value = kwargs.get('localized_value', None) @@ -329,14 +413,14 @@ class RuleCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource """ _validation = { @@ -356,6 +440,11 @@ def __init__( self, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource + """ super(RuleCondition, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] self.data_source = kwargs.get('data_source', None) @@ -366,21 +455,21 @@ class LocationThresholdRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. - :type window_size: ~datetime.timedelta - :param failed_location_count: Required. the number of locations that must fail to activate the + :vartype window_size: ~datetime.timedelta + :ivar failed_location_count: Required. the number of locations that must fail to activate the alert. - :type failed_location_count: int + :vartype failed_location_count: int """ _validation = { @@ -399,6 +488,18 @@ def __init__( self, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. If specified then it must be between 5 minutes and 1 + day. + :paramtype window_size: ~datetime.timedelta + :keyword failed_location_count: Required. the number of locations that must fail to activate + the alert. + :paramtype failed_location_count: int + """ super(LocationThresholdRuleCondition, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition' # type: str self.window_size = kwargs.get('window_size', None) @@ -410,14 +511,14 @@ class LogSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param category: Name of a Diagnostic Log category for a resource type this setting is applied + :ivar category: Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. - :type category: str - :param enabled: Required. a value indicating whether this log is enabled. - :type enabled: bool - :param retention_policy: the retention policy for this log. - :type retention_policy: ~$(python-base-namespace).v2015_07_01.models.RetentionPolicy + :vartype category: str + :ivar enabled: Required. a value indicating whether this log is enabled. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this log. + :vartype retention_policy: ~$(python-base-namespace).v2015_07_01.models.RetentionPolicy """ _validation = { @@ -434,6 +535,16 @@ def __init__( self, **kwargs ): + """ + :keyword category: Name of a Diagnostic Log category for a resource type this setting is + applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET + diagnostic settings operation. + :paramtype category: str + :keyword enabled: Required. a value indicating whether this log is enabled. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this log. + :paramtype retention_policy: ~$(python-base-namespace).v2015_07_01.models.RetentionPolicy + """ super(LogSettings, self).__init__(**kwargs) self.category = kwargs.get('category', None) self.enabled = kwargs['enabled'] @@ -443,12 +554,12 @@ def __init__( class LogSpecification(msrest.serialization.Model): """Log specification of operation. - :param name: Name of log specification. - :type name: str - :param display_name: Display name of log specification. - :type display_name: str - :param blob_duration: Blob duration of specification. - :type blob_duration: str + :ivar name: Name of log specification. + :vartype name: str + :ivar display_name: Display name of log specification. + :vartype display_name: str + :ivar blob_duration: Blob duration of specification. + :vartype blob_duration: str """ _attribute_map = { @@ -461,6 +572,14 @@ def __init__( self, **kwargs ): + """ + :keyword name: Name of log specification. + :paramtype name: str + :keyword display_name: Display name of log specification. + :paramtype display_name: str + :keyword blob_duration: Blob duration of specification. + :paramtype blob_duration: str + """ super(LogSpecification, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display_name = kwargs.get('display_name', None) @@ -470,15 +589,15 @@ def __init__( class ManagementEventAggregationCondition(msrest.serialization.Model): """How the data that is collected should be combined over time. - :param operator: the condition operator. Possible values include: "GreaterThan", + :ivar operator: the condition operator. Possible values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator - :param threshold: The threshold value that activates the alert. - :type threshold: float - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator + :ivar threshold: The threshold value that activates the alert. + :vartype threshold: float + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. - :type window_size: ~datetime.timedelta + :vartype window_size: ~datetime.timedelta """ _attribute_map = { @@ -491,6 +610,17 @@ def __init__( self, **kwargs ): + """ + :keyword operator: the condition operator. Possible values include: "GreaterThan", + "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :paramtype operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator + :keyword threshold: The threshold value that activates the alert. + :paramtype threshold: float + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. If specified then it must be between 5 minutes and 1 + day. + :paramtype window_size: ~datetime.timedelta + """ super(ManagementEventAggregationCondition, self).__init__(**kwargs) self.operator = kwargs.get('operator', None) self.threshold = kwargs.get('threshold', None) @@ -502,18 +632,18 @@ class ManagementEventRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource - :param aggregation: How the data that is collected should be combined over time and when the + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource + :ivar aggregation: How the data that is collected should be combined over time and when the alert is activated. Note that for management event alerts aggregation is optional – if it is not provided then any event will cause the alert to activate. - :type aggregation: + :vartype aggregation: ~$(python-base-namespace).v2015_07_01.models.ManagementEventAggregationCondition """ @@ -531,6 +661,16 @@ def __init__( self, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource + :keyword aggregation: How the data that is collected should be combined over time and when the + alert is activated. Note that for management event alerts aggregation is optional – if it is + not provided then any event will cause the alert to activate. + :paramtype aggregation: + ~$(python-base-namespace).v2015_07_01.models.ManagementEventAggregationCondition + """ super(ManagementEventRuleCondition, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition' # type: str self.aggregation = kwargs.get('aggregation', None) @@ -539,14 +679,14 @@ def __init__( class MetricAvailability(msrest.serialization.Model): """Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. - :param time_grain: the time grain specifies the aggregation interval for the metric. Expressed + :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. - :type time_grain: ~datetime.timedelta - :param retention: the retention period for the metric at the specified timegrain. Expressed as + :vartype time_grain: ~datetime.timedelta + :ivar retention: the retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc. - :type retention: ~datetime.timedelta - :param location: Info about where the metric data is stored. - :type location: ~$(python-base-namespace).v2015_07_01.models.MetricAvailabilityLocation + :vartype retention: ~datetime.timedelta + :ivar location: Info about where the metric data is stored. + :vartype location: ~$(python-base-namespace).v2015_07_01.models.MetricAvailabilityLocation """ _attribute_map = { @@ -559,6 +699,16 @@ def __init__( self, **kwargs ): + """ + :keyword time_grain: the time grain specifies the aggregation interval for the metric. + Expressed as a duration 'PT1M', 'P1D', etc. + :paramtype time_grain: ~datetime.timedelta + :keyword retention: the retention period for the metric at the specified timegrain. Expressed + as a duration 'PT1M', 'P1D', etc. + :paramtype retention: ~datetime.timedelta + :keyword location: Info about where the metric data is stored. + :paramtype location: ~$(python-base-namespace).v2015_07_01.models.MetricAvailabilityLocation + """ super(MetricAvailability, self).__init__(**kwargs) self.time_grain = kwargs.get('time_grain', None) self.retention = kwargs.get('retention', None) @@ -568,13 +718,12 @@ def __init__( class MetricAvailabilityLocation(msrest.serialization.Model): """Info about where the metric data is stored. - :param table_endpoint: The url for the storage account. - :type table_endpoint: str - :param table_info: Info about the storage tables storing this resources metrics. - :type table_info: list[~$(python-base-namespace).v2015_07_01.models.TableInfoEntry] - :param partition_key: partition key in the table where the metrics for this resource are - stored. - :type partition_key: str + :ivar table_endpoint: The url for the storage account. + :vartype table_endpoint: str + :ivar table_info: Info about the storage tables storing this resources metrics. + :vartype table_info: list[~$(python-base-namespace).v2015_07_01.models.TableInfoEntry] + :ivar partition_key: partition key in the table where the metrics for this resource are stored. + :vartype partition_key: str """ _attribute_map = { @@ -587,6 +736,15 @@ def __init__( self, **kwargs ): + """ + :keyword table_endpoint: The url for the storage account. + :paramtype table_endpoint: str + :keyword table_info: Info about the storage tables storing this resources metrics. + :paramtype table_info: list[~$(python-base-namespace).v2015_07_01.models.TableInfoEntry] + :keyword partition_key: partition key in the table where the metrics for this resource are + stored. + :paramtype partition_key: str + """ super(MetricAvailabilityLocation, self).__init__(**kwargs) self.table_endpoint = kwargs.get('table_endpoint', None) self.table_info = kwargs.get('table_info', None) @@ -596,36 +754,36 @@ def __init__( class MetricDefinition(msrest.serialization.Model): """Metric definition class specifies the metadata for a metric. - :param resource_id: The resource identifier of the resource that emitted the metric. - :type resource_id: str - :param resource_uri: The resource identifier of the resource that emitted the metric. - :type resource_uri: str - :param name: the name and the display name of the metric, i.e. it is a localizable string. - :type name: ~$(python-base-namespace).v2015_07_01.models.LocalizableString - :param category: The category of this metric. - :type category: str - :param unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + :ivar resource_id: The resource identifier of the resource that emitted the metric. + :vartype resource_id: str + :ivar resource_uri: The resource identifier of the resource that emitted the metric. + :vartype resource_uri: str + :ivar name: the name and the display name of the metric, i.e. it is a localizable string. + :vartype name: ~$(python-base-namespace).v2015_07_01.models.LocalizableString + :ivar category: The category of this metric. + :vartype category: str + :ivar unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds". - :type unit: str or ~$(python-base-namespace).v2015_07_01.models.Unit - :param start_time: Start time of the metadata request timespan. - :type start_time: ~datetime.datetime - :param end_time: End time of the metadata request timespan. - :type end_time: ~datetime.datetime - :param primary_aggregation_type: the primary aggregation type value defining how to use the + :vartype unit: str or ~$(python-base-namespace).v2015_07_01.models.Unit + :ivar start_time: Start time of the metadata request timespan. + :vartype start_time: ~datetime.datetime + :ivar end_time: End time of the metadata request timespan. + :vartype end_time: ~datetime.datetime + :ivar primary_aggregation_type: the primary aggregation type value defining how to use the values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", "Total". - :type primary_aggregation_type: str or + :vartype primary_aggregation_type: str or ~$(python-base-namespace).v2015_07_01.models.AggregationType - :param supported_aggregation_types: List of all aggregations that are applicable for this + :ivar supported_aggregation_types: List of all aggregations that are applicable for this metric. - :type supported_aggregation_types: list[str or + :vartype supported_aggregation_types: list[str or ~$(python-base-namespace).v2015_07_01.models.AggregationType] - :param metric_availabilities: the collection of what aggregation intervals are available to be + :ivar metric_availabilities: the collection of what aggregation intervals are available to be queried. - :type metric_availabilities: + :vartype metric_availabilities: list[~$(python-base-namespace).v2015_07_01.models.MetricAvailability] - :param id: the resource identifier of the metric definition. - :type id: str + :ivar id: the resource identifier of the metric definition. + :vartype id: str """ _attribute_map = { @@ -646,6 +804,38 @@ def __init__( self, **kwargs ): + """ + :keyword resource_id: The resource identifier of the resource that emitted the metric. + :paramtype resource_id: str + :keyword resource_uri: The resource identifier of the resource that emitted the metric. + :paramtype resource_uri: str + :keyword name: the name and the display name of the metric, i.e. it is a localizable string. + :paramtype name: ~$(python-base-namespace).v2015_07_01.models.LocalizableString + :keyword category: The category of this metric. + :paramtype category: str + :keyword unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds". + :paramtype unit: str or ~$(python-base-namespace).v2015_07_01.models.Unit + :keyword start_time: Start time of the metadata request timespan. + :paramtype start_time: ~datetime.datetime + :keyword end_time: End time of the metadata request timespan. + :paramtype end_time: ~datetime.datetime + :keyword primary_aggregation_type: the primary aggregation type value defining how to use the + values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", + "Total". + :paramtype primary_aggregation_type: str or + ~$(python-base-namespace).v2015_07_01.models.AggregationType + :keyword supported_aggregation_types: List of all aggregations that are applicable for this + metric. + :paramtype supported_aggregation_types: list[str or + ~$(python-base-namespace).v2015_07_01.models.AggregationType] + :keyword metric_availabilities: the collection of what aggregation intervals are available to + be queried. + :paramtype metric_availabilities: + list[~$(python-base-namespace).v2015_07_01.models.MetricAvailability] + :keyword id: the resource identifier of the metric definition. + :paramtype id: str + """ super(MetricDefinition, self).__init__(**kwargs) self.resource_id = kwargs.get('resource_id', None) self.resource_uri = kwargs.get('resource_uri', None) @@ -665,10 +855,10 @@ class MetricDefinitionCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Resource Id for these metric definitions. - :type id: str - :param value: Required. the values for the metric definitions. - :type value: list[~$(python-base-namespace).v2015_07_01.models.MetricDefinition] + :ivar id: Resource Id for these metric definitions. + :vartype id: str + :ivar value: Required. the values for the metric definitions. + :vartype value: list[~$(python-base-namespace).v2015_07_01.models.MetricDefinition] """ _validation = { @@ -684,6 +874,12 @@ def __init__( self, **kwargs ): + """ + :keyword id: Resource Id for these metric definitions. + :paramtype id: str + :keyword value: Required. the values for the metric definitions. + :paramtype value: list[~$(python-base-namespace).v2015_07_01.models.MetricDefinition] + """ super(MetricDefinitionCollection, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.value = kwargs['value'] @@ -694,12 +890,12 @@ class MetricSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_grain: Required. the timegrain of the metric in ISO8601 format. - :type time_grain: ~datetime.timedelta - :param enabled: Required. a value indicating whether this timegrain is enabled. - :type enabled: bool - :param retention_policy: the retention policy for this timegrain. - :type retention_policy: ~$(python-base-namespace).v2015_07_01.models.RetentionPolicy + :ivar time_grain: Required. the timegrain of the metric in ISO8601 format. + :vartype time_grain: ~datetime.timedelta + :ivar enabled: Required. a value indicating whether this timegrain is enabled. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this timegrain. + :vartype retention_policy: ~$(python-base-namespace).v2015_07_01.models.RetentionPolicy """ _validation = { @@ -717,6 +913,14 @@ def __init__( self, **kwargs ): + """ + :keyword time_grain: Required. the timegrain of the metric in ISO8601 format. + :paramtype time_grain: ~datetime.timedelta + :keyword enabled: Required. a value indicating whether this timegrain is enabled. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this timegrain. + :paramtype retention_policy: ~$(python-base-namespace).v2015_07_01.models.RetentionPolicy + """ super(MetricSettings, self).__init__(**kwargs) self.time_grain = kwargs['time_grain'] self.enabled = kwargs['enabled'] @@ -726,34 +930,34 @@ def __init__( class MetricSpecification(msrest.serialization.Model): """Metric specification of operation. - :param name: The name of the metric. - :type name: str - :param display_name: Display name of the metric. - :type display_name: str - :param display_description: Display description of the metric. - :type display_description: str - :param unit: The metric unit. Possible values include: + :ivar name: The name of the metric. + :vartype name: str + :ivar display_name: Display name of the metric. + :vartype display_name: str + :ivar display_description: Display description of the metric. + :vartype display_description: str + :ivar unit: The metric unit. Possible values include: Count,Bytes,Seconds,Percent,CountPerSecond,BytesPerSecond,MilliSeconds,ByteSeconds,Unspecified,BitsPerSecond,Cores,MilliCores,NanoCores. - :type unit: str - :param aggregation_type: The default metric aggregation type. Possible values include: + :vartype unit: str + :ivar aggregation_type: The default metric aggregation type. Possible values include: Total,Average,Maximum,Minimum,Count. - :type aggregation_type: str - :param supported_aggregation_types: The supported aggregation types for the metrics. - :type supported_aggregation_types: list[str] - :param supported_time_grain_types: The supported time grain types for the metrics. - :type supported_time_grain_types: list[str] - :param availabilities: The supported time grain types for the metrics. - :type availabilities: list[str] - :param lock_aggregation_type: The metric lock aggregation type. - :type lock_aggregation_type: str - :param category: Category or type of metric. - :type category: str - :param dimensions: The dimensions of metric. - :type dimensions: list[~$(python-base-namespace).v2015_07_01.models.DimensionProperties] - :param fill_gap_with_zero: Property to specify whether to fill empty gaps with zero. - :type fill_gap_with_zero: bool - :param internal_metric_name: The internal metric name. - :type internal_metric_name: str + :vartype aggregation_type: str + :ivar supported_aggregation_types: The supported aggregation types for the metrics. + :vartype supported_aggregation_types: list[str] + :ivar supported_time_grain_types: The supported time grain types for the metrics. + :vartype supported_time_grain_types: list[str] + :ivar availabilities: The supported time grain types for the metrics. + :vartype availabilities: list[str] + :ivar lock_aggregation_type: The metric lock aggregation type. + :vartype lock_aggregation_type: str + :ivar category: Category or type of metric. + :vartype category: str + :ivar dimensions: The dimensions of metric. + :vartype dimensions: list[~$(python-base-namespace).v2015_07_01.models.DimensionProperties] + :ivar fill_gap_with_zero: Property to specify whether to fill empty gaps with zero. + :vartype fill_gap_with_zero: bool + :ivar internal_metric_name: The internal metric name. + :vartype internal_metric_name: str """ _attribute_map = { @@ -776,6 +980,36 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the metric. + :paramtype name: str + :keyword display_name: Display name of the metric. + :paramtype display_name: str + :keyword display_description: Display description of the metric. + :paramtype display_description: str + :keyword unit: The metric unit. Possible values include: + Count,Bytes,Seconds,Percent,CountPerSecond,BytesPerSecond,MilliSeconds,ByteSeconds,Unspecified,BitsPerSecond,Cores,MilliCores,NanoCores. + :paramtype unit: str + :keyword aggregation_type: The default metric aggregation type. Possible values include: + Total,Average,Maximum,Minimum,Count. + :paramtype aggregation_type: str + :keyword supported_aggregation_types: The supported aggregation types for the metrics. + :paramtype supported_aggregation_types: list[str] + :keyword supported_time_grain_types: The supported time grain types for the metrics. + :paramtype supported_time_grain_types: list[str] + :keyword availabilities: The supported time grain types for the metrics. + :paramtype availabilities: list[str] + :keyword lock_aggregation_type: The metric lock aggregation type. + :paramtype lock_aggregation_type: str + :keyword category: Category or type of metric. + :paramtype category: str + :keyword dimensions: The dimensions of metric. + :paramtype dimensions: list[~$(python-base-namespace).v2015_07_01.models.DimensionProperties] + :keyword fill_gap_with_zero: Property to specify whether to fill empty gaps with zero. + :paramtype fill_gap_with_zero: bool + :keyword internal_metric_name: The internal metric name. + :paramtype internal_metric_name: str + """ super(MetricSpecification, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.display_name = kwargs.get('display_name', None) @@ -795,14 +1029,15 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft Insights API operation definition. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param is_data_action: Property to specify whether the action is a data action. - :type is_data_action: bool - :param display: Display metadata associated with the operation. - :type display: ~$(python-base-namespace).v2015_07_01.models.OperationDisplay - :param service_specification: One property of operation, include metric specifications. - :type service_specification: ~$(python-base-namespace).v2015_07_01.models.ServiceSpecification + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar is_data_action: Property to specify whether the action is a data action. + :vartype is_data_action: bool + :ivar display: Display metadata associated with the operation. + :vartype display: ~$(python-base-namespace).v2015_07_01.models.OperationDisplay + :ivar service_specification: One property of operation, include metric specifications. + :vartype service_specification: + ~$(python-base-namespace).v2015_07_01.models.ServiceSpecification """ _attribute_map = { @@ -816,6 +1051,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword is_data_action: Property to specify whether the action is a data action. + :paramtype is_data_action: bool + :keyword display: Display metadata associated with the operation. + :paramtype display: ~$(python-base-namespace).v2015_07_01.models.OperationDisplay + :keyword service_specification: One property of operation, include metric specifications. + :paramtype service_specification: + ~$(python-base-namespace).v2015_07_01.models.ServiceSpecification + """ super(Operation, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.is_data_action = kwargs.get('is_data_action', None) @@ -826,16 +1072,16 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """Display metadata associated with the operation. - :param publisher: The publisher of this operation. - :type publisher: str - :param provider: Service provider: Microsoft.Insights. - :type provider: str - :param resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: The description of the operation. - :type description: str + :ivar publisher: The publisher of this operation. + :vartype publisher: str + :ivar provider: Service provider: Microsoft.Insights. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: The description of the operation. + :vartype description: str """ _attribute_map = { @@ -850,6 +1096,18 @@ def __init__( self, **kwargs ): + """ + :keyword publisher: The publisher of this operation. + :paramtype publisher: str + :keyword provider: Service provider: Microsoft.Insights. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: The description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.publisher = kwargs.get('publisher', None) self.provider = kwargs.get('provider', None) @@ -861,10 +1119,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Insights operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of operations supported by the Microsoft.Insights provider. - :type value: list[~$(python-base-namespace).v2015_07_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of operations supported by the Microsoft.Insights provider. + :vartype value: list[~$(python-base-namespace).v2015_07_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -876,6 +1134,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: List of operations supported by the Microsoft.Insights provider. + :paramtype value: list[~$(python-base-namespace).v2015_07_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -886,11 +1150,11 @@ class RetentionPolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param enabled: Required. a value indicating whether the retention policy is enabled. - :type enabled: bool - :param days: Required. the number of days for the retention in days. A value of 0 will retain + :ivar enabled: Required. a value indicating whether the retention policy is enabled. + :vartype enabled: bool + :ivar days: Required. the number of days for the retention in days. A value of 0 will retain the events indefinitely. - :type days: int + :vartype days: int """ _validation = { @@ -907,6 +1171,13 @@ def __init__( self, **kwargs ): + """ + :keyword enabled: Required. a value indicating whether the retention policy is enabled. + :paramtype enabled: bool + :keyword days: Required. the number of days for the retention in days. A value of 0 will retain + the events indefinitely. + :paramtype days: int + """ super(RetentionPolicy, self).__init__(**kwargs) self.enabled = kwargs['enabled'] self.days = kwargs['days'] @@ -920,9 +1191,9 @@ class RuleAction(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of the action. There are two types of actions: + :ivar odata_type: Required. specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str + :vartype odata_type: str """ _validation = { @@ -941,6 +1212,8 @@ def __init__( self, **kwargs ): + """ + """ super(RuleAction, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] @@ -953,19 +1226,19 @@ class RuleDataSource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of data source. There are two types of rule - data sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. - :type odata_type: str - :param resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :type resource_uri: str - :param legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + :ivar odata_type: Required. specifies the type of data source. There are two types of rule data + sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :vartype odata_type: str + :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this + property cannot be updated for an existing rule. + :vartype resource_uri: str + :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. - :type legacy_resource_id: str - :param resource_location: the location of the resource. - :type resource_location: str - :param metric_namespace: the namespace of the metric. - :type metric_namespace: str + :vartype legacy_resource_id: str + :ivar resource_location: the location of the resource. + :vartype resource_location: str + :ivar metric_namespace: the namespace of the metric. + :vartype metric_namespace: str """ _validation = { @@ -988,6 +1261,18 @@ def __init__( self, **kwargs ): + """ + :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : + this property cannot be updated for an existing rule. + :paramtype resource_uri: str + :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + **NOTE**\ : this property cannot be updated for an existing rule. + :paramtype legacy_resource_id: str + :keyword resource_location: the location of the resource. + :paramtype resource_location: str + :keyword metric_namespace: the namespace of the metric. + :paramtype metric_namespace: str + """ super(RuleDataSource, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] self.resource_uri = kwargs.get('resource_uri', None) @@ -1001,15 +1286,15 @@ class RuleEmailAction(RuleAction): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of the action. There are two types of actions: + :ivar odata_type: Required. specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str - :param send_to_service_owners: Whether the administrators (service and co-administrators) of - the service should be notified when the alert is activated. - :type send_to_service_owners: bool - :param custom_emails: the list of administrator's custom email addresses to notify of the + :vartype odata_type: str + :ivar send_to_service_owners: Whether the administrators (service and co-administrators) of the + service should be notified when the alert is activated. + :vartype send_to_service_owners: bool + :ivar custom_emails: the list of administrator's custom email addresses to notify of the activation of the alert. - :type custom_emails: list[str] + :vartype custom_emails: list[str] """ _validation = { @@ -1026,6 +1311,14 @@ def __init__( self, **kwargs ): + """ + :keyword send_to_service_owners: Whether the administrators (service and co-administrators) of + the service should be notified when the alert is activated. + :paramtype send_to_service_owners: bool + :keyword custom_emails: the list of administrator's custom email addresses to notify of the + activation of the alert. + :paramtype custom_emails: list[str] + """ super(RuleEmailAction, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleEmailAction' # type: str self.send_to_service_owners = kwargs.get('send_to_service_owners', None) @@ -1035,8 +1328,8 @@ def __init__( class RuleManagementEventClaimsDataSource(msrest.serialization.Model): """The claims for a rule management event data source. - :param email_address: the email address. - :type email_address: str + :ivar email_address: the email address. + :vartype email_address: str """ _attribute_map = { @@ -1047,6 +1340,10 @@ def __init__( self, **kwargs ): + """ + :keyword email_address: the email address. + :paramtype email_address: str + """ super(RuleManagementEventClaimsDataSource, self).__init__(**kwargs) self.email_address = kwargs.get('email_address', None) @@ -1056,39 +1353,40 @@ class RuleManagementEventDataSource(RuleDataSource): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of data source. There are two types of rule - data sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. - :type odata_type: str - :param resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :type resource_uri: str - :param legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + :ivar odata_type: Required. specifies the type of data source. There are two types of rule data + sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :vartype odata_type: str + :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this + property cannot be updated for an existing rule. + :vartype resource_uri: str + :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. - :type legacy_resource_id: str - :param resource_location: the location of the resource. - :type resource_location: str - :param metric_namespace: the namespace of the metric. - :type metric_namespace: str - :param event_name: the event name. - :type event_name: str - :param event_source: the event source. - :type event_source: str - :param level: the level. - :type level: str - :param operation_name: The name of the operation that should be checked for. If no name is + :vartype legacy_resource_id: str + :ivar resource_location: the location of the resource. + :vartype resource_location: str + :ivar metric_namespace: the namespace of the metric. + :vartype metric_namespace: str + :ivar event_name: the event name. + :vartype event_name: str + :ivar event_source: the event source. + :vartype event_source: str + :ivar level: the level. + :vartype level: str + :ivar operation_name: The name of the operation that should be checked for. If no name is provided, any operation will match. - :type operation_name: str - :param resource_group_name: the resource group name. - :type resource_group_name: str - :param resource_provider_name: the resource provider name. - :type resource_provider_name: str - :param status: The status of the operation that should be checked for. If no status is - provided, any status will match. - :type status: str - :param sub_status: the substatus. - :type sub_status: str - :param claims: the claims. - :type claims: ~$(python-base-namespace).v2015_07_01.models.RuleManagementEventClaimsDataSource + :vartype operation_name: str + :ivar resource_group_name: the resource group name. + :vartype resource_group_name: str + :ivar resource_provider_name: the resource provider name. + :vartype resource_provider_name: str + :ivar status: The status of the operation that should be checked for. If no status is provided, + any status will match. + :vartype status: str + :ivar sub_status: the substatus. + :vartype sub_status: str + :ivar claims: the claims. + :vartype claims: + ~$(python-base-namespace).v2015_07_01.models.RuleManagementEventClaimsDataSource """ _validation = { @@ -1116,6 +1414,39 @@ def __init__( self, **kwargs ): + """ + :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : + this property cannot be updated for an existing rule. + :paramtype resource_uri: str + :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + **NOTE**\ : this property cannot be updated for an existing rule. + :paramtype legacy_resource_id: str + :keyword resource_location: the location of the resource. + :paramtype resource_location: str + :keyword metric_namespace: the namespace of the metric. + :paramtype metric_namespace: str + :keyword event_name: the event name. + :paramtype event_name: str + :keyword event_source: the event source. + :paramtype event_source: str + :keyword level: the level. + :paramtype level: str + :keyword operation_name: The name of the operation that should be checked for. If no name is + provided, any operation will match. + :paramtype operation_name: str + :keyword resource_group_name: the resource group name. + :paramtype resource_group_name: str + :keyword resource_provider_name: the resource provider name. + :paramtype resource_provider_name: str + :keyword status: The status of the operation that should be checked for. If no status is + provided, any status will match. + :paramtype status: str + :keyword sub_status: the substatus. + :paramtype sub_status: str + :keyword claims: the claims. + :paramtype claims: + ~$(python-base-namespace).v2015_07_01.models.RuleManagementEventClaimsDataSource + """ super(RuleManagementEventDataSource, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource' # type: str self.event_name = kwargs.get('event_name', None) @@ -1134,21 +1465,21 @@ class RuleMetricDataSource(RuleDataSource): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of data source. There are two types of rule - data sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. - :type odata_type: str - :param resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :type resource_uri: str - :param legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + :ivar odata_type: Required. specifies the type of data source. There are two types of rule data + sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :vartype odata_type: str + :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this + property cannot be updated for an existing rule. + :vartype resource_uri: str + :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. - :type legacy_resource_id: str - :param resource_location: the location of the resource. - :type resource_location: str - :param metric_namespace: the namespace of the metric. - :type metric_namespace: str - :param metric_name: the name of the metric that defines what the rule monitors. - :type metric_name: str + :vartype legacy_resource_id: str + :ivar resource_location: the location of the resource. + :vartype resource_location: str + :ivar metric_namespace: the namespace of the metric. + :vartype metric_namespace: str + :ivar metric_name: the name of the metric that defines what the rule monitors. + :vartype metric_name: str """ _validation = { @@ -1168,6 +1499,20 @@ def __init__( self, **kwargs ): + """ + :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : + this property cannot be updated for an existing rule. + :paramtype resource_uri: str + :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + **NOTE**\ : this property cannot be updated for an existing rule. + :paramtype legacy_resource_id: str + :keyword resource_location: the location of the resource. + :paramtype resource_location: str + :keyword metric_namespace: the namespace of the metric. + :paramtype metric_namespace: str + :keyword metric_name: the name of the metric that defines what the rule monitors. + :paramtype metric_name: str + """ super(RuleMetricDataSource, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource' # type: str self.metric_name = kwargs.get('metric_name', None) @@ -1178,15 +1523,15 @@ class RuleWebhookAction(RuleAction): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of the action. There are two types of actions: + :ivar odata_type: Required. specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str - :param service_uri: the service uri to Post the notification when the alert activates or + :vartype odata_type: str + :ivar service_uri: the service uri to Post the notification when the alert activates or resolves. - :type service_uri: str - :param properties: the dictionary of custom properties to include with the post operation. - These data are appended to the webhook payload. - :type properties: dict[str, str] + :vartype service_uri: str + :ivar properties: the dictionary of custom properties to include with the post operation. These + data are appended to the webhook payload. + :vartype properties: dict[str, str] """ _validation = { @@ -1203,6 +1548,14 @@ def __init__( self, **kwargs ): + """ + :keyword service_uri: the service uri to Post the notification when the alert activates or + resolves. + :paramtype service_uri: str + :keyword properties: the dictionary of custom properties to include with the post operation. + These data are appended to the webhook payload. + :paramtype properties: dict[str, str] + """ super(RuleWebhookAction, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction' # type: str self.service_uri = kwargs.get('service_uri', None) @@ -1222,25 +1575,25 @@ class ServiceDiagnosticSettingsResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param storage_account_id: The resource ID of the storage account to which you would like to + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. - :type service_bus_rule_id: str - :param metrics: the list of metric settings. - :type metrics: list[~$(python-base-namespace).v2015_07_01.models.MetricSettings] - :param logs: the list of logs settings. - :type logs: list[~$(python-base-namespace).v2015_07_01.models.LogSettings] - :param workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a Log + :vartype service_bus_rule_id: str + :ivar metrics: the list of metric settings. + :vartype metrics: list[~$(python-base-namespace).v2015_07_01.models.MetricSettings] + :ivar logs: the list of logs settings. + :vartype logs: list[~$(python-base-namespace).v2015_07_01.models.LogSettings] + :ivar workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str + :vartype workspace_id: str """ _validation = { @@ -1267,6 +1620,27 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the + format: '{service bus resource ID}/authorizationrules/{key name}'. + :paramtype service_bus_rule_id: str + :keyword metrics: the list of metric settings. + :paramtype metrics: list[~$(python-base-namespace).v2015_07_01.models.MetricSettings] + :keyword logs: the list of logs settings. + :paramtype logs: list[~$(python-base-namespace).v2015_07_01.models.LogSettings] + :keyword workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a Log + Analytics workspace to which you would like to send Diagnostic Logs. Example: + /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + :paramtype workspace_id: str + """ super(ServiceDiagnosticSettingsResource, self).__init__(**kwargs) self.storage_account_id = kwargs.get('storage_account_id', None) self.service_bus_rule_id = kwargs.get('service_bus_rule_id', None) @@ -1278,14 +1652,15 @@ def __init__( class ServiceSpecification(msrest.serialization.Model): """One property of operation, include log specifications. - :param log_specifications: Log specifications of operation. - :type log_specifications: list[~$(python-base-namespace).v2015_07_01.models.LogSpecification] - :param metric_specifications: Metric specifications of operation. - :type metric_specifications: + :ivar log_specifications: Log specifications of operation. + :vartype log_specifications: + list[~$(python-base-namespace).v2015_07_01.models.LogSpecification] + :ivar metric_specifications: Metric specifications of operation. + :vartype metric_specifications: list[~$(python-base-namespace).v2015_07_01.models.MetricSpecification] - :param legacy_metric_specifications: Legacy Metric specifications for operation. Deprecated, do + :ivar legacy_metric_specifications: Legacy Metric specifications for operation. Deprecated, do not use. - :type legacy_metric_specifications: any + :vartype legacy_metric_specifications: any """ _attribute_map = { @@ -1298,6 +1673,17 @@ def __init__( self, **kwargs ): + """ + :keyword log_specifications: Log specifications of operation. + :paramtype log_specifications: + list[~$(python-base-namespace).v2015_07_01.models.LogSpecification] + :keyword metric_specifications: Metric specifications of operation. + :paramtype metric_specifications: + list[~$(python-base-namespace).v2015_07_01.models.MetricSpecification] + :keyword legacy_metric_specifications: Legacy Metric specifications for operation. Deprecated, + do not use. + :paramtype legacy_metric_specifications: any + """ super(ServiceSpecification, self).__init__(**kwargs) self.log_specifications = kwargs.get('log_specifications', None) self.metric_specifications = kwargs.get('metric_specifications', None) @@ -1307,16 +1693,16 @@ def __init__( class TableInfoEntry(msrest.serialization.Model): """Info about a storage table with metric data. - :param table_name: Name of a table with metric data for this resource. - :type table_name: str - :param start_time: Start time of the metrics in this table. - :type start_time: ~datetime.datetime - :param end_time: End time of the metrics in this table. - :type end_time: ~datetime.datetime - :param sas_token: For the storage account with metrics. - :type sas_token: str - :param sas_token_expiration_time: For the storage account with metrics. - :type sas_token_expiration_time: ~datetime.datetime + :ivar table_name: Name of a table with metric data for this resource. + :vartype table_name: str + :ivar start_time: Start time of the metrics in this table. + :vartype start_time: ~datetime.datetime + :ivar end_time: End time of the metrics in this table. + :vartype end_time: ~datetime.datetime + :ivar sas_token: For the storage account with metrics. + :vartype sas_token: str + :ivar sas_token_expiration_time: For the storage account with metrics. + :vartype sas_token_expiration_time: ~datetime.datetime """ _attribute_map = { @@ -1331,6 +1717,18 @@ def __init__( self, **kwargs ): + """ + :keyword table_name: Name of a table with metric data for this resource. + :paramtype table_name: str + :keyword start_time: Start time of the metrics in this table. + :paramtype start_time: ~datetime.datetime + :keyword end_time: End time of the metrics in this table. + :paramtype end_time: ~datetime.datetime + :keyword sas_token: For the storage account with metrics. + :paramtype sas_token: str + :keyword sas_token_expiration_time: For the storage account with metrics. + :paramtype sas_token_expiration_time: ~datetime.datetime + """ super(TableInfoEntry, self).__init__(**kwargs) self.table_name = kwargs.get('table_name', None) self.start_time = kwargs.get('start_time', None) @@ -1344,27 +1742,27 @@ class ThresholdRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource - :param operator: Required. the operator used to compare the data and the threshold. Possible + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource + :ivar operator: Required. the operator used to compare the data and the threshold. Possible values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator - :param threshold: Required. the threshold value that activates the alert. - :type threshold: float - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator + :ivar threshold: Required. the threshold value that activates the alert. + :vartype threshold: float + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. - :type window_size: ~datetime.timedelta - :param time_aggregation: the time aggregation operator. How the data that are collected should + :vartype window_size: ~datetime.timedelta + :ivar time_aggregation: the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. Possible values include: "Average", "Minimum", "Maximum", "Total", "Last". - :type time_aggregation: str or + :vartype time_aggregation: str or ~$(python-base-namespace).v2015_07_01.models.TimeAggregationOperator """ @@ -1387,6 +1785,25 @@ def __init__( self, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource + :keyword operator: Required. the operator used to compare the data and the threshold. Possible + values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :paramtype operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator + :keyword threshold: Required. the threshold value that activates the alert. + :paramtype threshold: float + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. If specified then it must be between 5 minutes and 1 + day. + :paramtype window_size: ~datetime.timedelta + :keyword time_aggregation: the time aggregation operator. How the data that are collected + should be combined over time. The default value is the PrimaryAggregationType of the Metric. + Possible values include: "Average", "Minimum", "Maximum", "Total", "Last". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2015_07_01.models.TimeAggregationOperator + """ super(ThresholdRuleCondition, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition' # type: str self.operator = kwargs['operator'] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models_py3.py index 5b0966ae54965..fd3490a9af699 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_models_py3.py @@ -28,10 +28,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -56,6 +56,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -77,26 +83,26 @@ class AlertRuleResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param name_properties_name: Required. the name of the alert rule. - :type name_properties_name: str - :param description: the description of the alert rule that will be included in the alert email. - :type description: str - :param provisioning_state: the provisioning state. - :type provisioning_state: str - :param is_enabled: Required. the flag that indicates whether the alert rule is enabled. - :type is_enabled: bool - :param condition: Required. the condition that results in the alert rule being activated. - :type condition: ~$(python-base-namespace).v2015_07_01.models.RuleCondition - :param action: action that is performed when the alert rule becomes active, and when an alert + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar name_properties_name: Required. the name of the alert rule. + :vartype name_properties_name: str + :ivar description: the description of the alert rule that will be included in the alert email. + :vartype description: str + :ivar provisioning_state: the provisioning state. + :vartype provisioning_state: str + :ivar is_enabled: Required. the flag that indicates whether the alert rule is enabled. + :vartype is_enabled: bool + :ivar condition: Required. the condition that results in the alert rule being activated. + :vartype condition: ~$(python-base-namespace).v2015_07_01.models.RuleCondition + :ivar action: action that is performed when the alert rule becomes active, and when an alert condition is resolved. - :type action: ~$(python-base-namespace).v2015_07_01.models.RuleAction - :param actions: the array of actions that are performed when the alert rule becomes active, and + :vartype action: ~$(python-base-namespace).v2015_07_01.models.RuleAction + :ivar actions: the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. - :type actions: list[~$(python-base-namespace).v2015_07_01.models.RuleAction] + :vartype actions: list[~$(python-base-namespace).v2015_07_01.models.RuleAction] :ivar last_updated_time: Last time the rule was updated in ISO8601 format. :vartype last_updated_time: ~datetime.datetime """ @@ -142,6 +148,29 @@ def __init__( actions: Optional[List["RuleAction"]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword name_properties_name: Required. the name of the alert rule. + :paramtype name_properties_name: str + :keyword description: the description of the alert rule that will be included in the alert + email. + :paramtype description: str + :keyword provisioning_state: the provisioning state. + :paramtype provisioning_state: str + :keyword is_enabled: Required. the flag that indicates whether the alert rule is enabled. + :paramtype is_enabled: bool + :keyword condition: Required. the condition that results in the alert rule being activated. + :paramtype condition: ~$(python-base-namespace).v2015_07_01.models.RuleCondition + :keyword action: action that is performed when the alert rule becomes active, and when an alert + condition is resolved. + :paramtype action: ~$(python-base-namespace).v2015_07_01.models.RuleAction + :keyword actions: the array of actions that are performed when the alert rule becomes active, + and when an alert condition is resolved. + :paramtype actions: list[~$(python-base-namespace).v2015_07_01.models.RuleAction] + """ super(AlertRuleResource, self).__init__(location=location, tags=tags, **kwargs) self.name_properties_name = name_properties_name self.description = description @@ -156,8 +185,8 @@ def __init__( class AlertRuleResourceCollection(msrest.serialization.Model): """Represents a collection of alert rule resources. - :param value: the values for the alert rule resources. - :type value: list[~$(python-base-namespace).v2015_07_01.models.AlertRuleResource] + :ivar value: the values for the alert rule resources. + :vartype value: list[~$(python-base-namespace).v2015_07_01.models.AlertRuleResource] """ _attribute_map = { @@ -170,6 +199,10 @@ def __init__( value: Optional[List["AlertRuleResource"]] = None, **kwargs ): + """ + :keyword value: the values for the alert rule resources. + :paramtype value: list[~$(python-base-namespace).v2015_07_01.models.AlertRuleResource] + """ super(AlertRuleResourceCollection, self).__init__(**kwargs) self.value = value @@ -179,24 +212,24 @@ class AlertRuleResourcePatch(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param name: the name of the alert rule. - :type name: str - :param description: the description of the alert rule that will be included in the alert email. - :type description: str - :param provisioning_state: the provisioning state. - :type provisioning_state: str - :param is_enabled: the flag that indicates whether the alert rule is enabled. - :type is_enabled: bool - :param condition: the condition that results in the alert rule being activated. - :type condition: ~$(python-base-namespace).v2015_07_01.models.RuleCondition - :param action: action that is performed when the alert rule becomes active, and when an alert + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar name: the name of the alert rule. + :vartype name: str + :ivar description: the description of the alert rule that will be included in the alert email. + :vartype description: str + :ivar provisioning_state: the provisioning state. + :vartype provisioning_state: str + :ivar is_enabled: the flag that indicates whether the alert rule is enabled. + :vartype is_enabled: bool + :ivar condition: the condition that results in the alert rule being activated. + :vartype condition: ~$(python-base-namespace).v2015_07_01.models.RuleCondition + :ivar action: action that is performed when the alert rule becomes active, and when an alert condition is resolved. - :type action: ~$(python-base-namespace).v2015_07_01.models.RuleAction - :param actions: the array of actions that are performed when the alert rule becomes active, and + :vartype action: ~$(python-base-namespace).v2015_07_01.models.RuleAction + :ivar actions: the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. - :type actions: list[~$(python-base-namespace).v2015_07_01.models.RuleAction] + :vartype actions: list[~$(python-base-namespace).v2015_07_01.models.RuleAction] :ivar last_updated_time: Last time the rule was updated in ISO8601 format. :vartype last_updated_time: ~datetime.datetime """ @@ -230,6 +263,27 @@ def __init__( actions: Optional[List["RuleAction"]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword name: the name of the alert rule. + :paramtype name: str + :keyword description: the description of the alert rule that will be included in the alert + email. + :paramtype description: str + :keyword provisioning_state: the provisioning state. + :paramtype provisioning_state: str + :keyword is_enabled: the flag that indicates whether the alert rule is enabled. + :paramtype is_enabled: bool + :keyword condition: the condition that results in the alert rule being activated. + :paramtype condition: ~$(python-base-namespace).v2015_07_01.models.RuleCondition + :keyword action: action that is performed when the alert rule becomes active, and when an alert + condition is resolved. + :paramtype action: ~$(python-base-namespace).v2015_07_01.models.RuleAction + :keyword actions: the array of actions that are performed when the alert rule becomes active, + and when an alert condition is resolved. + :paramtype actions: list[~$(python-base-namespace).v2015_07_01.models.RuleAction] + """ super(AlertRuleResourcePatch, self).__init__(**kwargs) self.tags = tags self.name = name @@ -245,18 +299,18 @@ def __init__( class DimensionProperties(msrest.serialization.Model): """Type of operation: get, read, delete, etc. - :param name: Name of dimension. - :type name: str - :param display_name: Display name of dimension. - :type display_name: str - :param to_be_exported_for_shoebox: Legacy usage, should not set. - :type to_be_exported_for_shoebox: bool - :param is_hidden: When set, the dimension is hidden from the customer, used in conjunction with + :ivar name: Name of dimension. + :vartype name: str + :ivar display_name: Display name of dimension. + :vartype display_name: str + :ivar to_be_exported_for_shoebox: Legacy usage, should not set. + :vartype to_be_exported_for_shoebox: bool + :ivar is_hidden: When set, the dimension is hidden from the customer, used in conjunction with the defaultDimensionValues field below. - :type is_hidden: bool - :param default_dimension_values: Default dimension value to be sent down for the hidden + :vartype is_hidden: bool + :ivar default_dimension_values: Default dimension value to be sent down for the hidden dimension during query. - :type default_dimension_values: any + :vartype default_dimension_values: any """ _attribute_map = { @@ -277,6 +331,20 @@ def __init__( default_dimension_values: Optional[Any] = None, **kwargs ): + """ + :keyword name: Name of dimension. + :paramtype name: str + :keyword display_name: Display name of dimension. + :paramtype display_name: str + :keyword to_be_exported_for_shoebox: Legacy usage, should not set. + :paramtype to_be_exported_for_shoebox: bool + :keyword is_hidden: When set, the dimension is hidden from the customer, used in conjunction + with the defaultDimensionValues field below. + :paramtype is_hidden: bool + :keyword default_dimension_values: Default dimension value to be sent down for the hidden + dimension during query. + :paramtype default_dimension_values: any + """ super(DimensionProperties, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -288,8 +356,8 @@ def __init__( class ErrorContract(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~$(python-base-namespace).v2015_07_01.models.ErrorResponse + :ivar error: The error object. + :vartype error: ~$(python-base-namespace).v2015_07_01.models.ErrorResponse """ _attribute_map = { @@ -302,6 +370,10 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~$(python-base-namespace).v2015_07_01.models.ErrorResponse + """ super(ErrorContract, self).__init__(**kwargs) self.error = error @@ -309,10 +381,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -327,6 +399,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -337,10 +415,10 @@ class LocalizableString(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the invariant value. - :type value: str - :param localized_value: the locale specific value. - :type localized_value: str + :ivar value: Required. the invariant value. + :vartype value: str + :ivar localized_value: the locale specific value. + :vartype localized_value: str """ _validation = { @@ -359,6 +437,12 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. the invariant value. + :paramtype value: str + :keyword localized_value: the locale specific value. + :paramtype localized_value: str + """ super(LocalizableString, self).__init__(**kwargs) self.value = value self.localized_value = localized_value @@ -372,14 +456,14 @@ class RuleCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource """ _validation = { @@ -401,6 +485,11 @@ def __init__( data_source: Optional["RuleDataSource"] = None, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource + """ super(RuleCondition, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] self.data_source = data_source @@ -411,21 +500,21 @@ class LocationThresholdRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. - :type window_size: ~datetime.timedelta - :param failed_location_count: Required. the number of locations that must fail to activate the + :vartype window_size: ~datetime.timedelta + :ivar failed_location_count: Required. the number of locations that must fail to activate the alert. - :type failed_location_count: int + :vartype failed_location_count: int """ _validation = { @@ -448,6 +537,18 @@ def __init__( window_size: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. If specified then it must be between 5 minutes and 1 + day. + :paramtype window_size: ~datetime.timedelta + :keyword failed_location_count: Required. the number of locations that must fail to activate + the alert. + :paramtype failed_location_count: int + """ super(LocationThresholdRuleCondition, self).__init__(data_source=data_source, **kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition' # type: str self.window_size = window_size @@ -459,14 +560,14 @@ class LogSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param category: Name of a Diagnostic Log category for a resource type this setting is applied + :ivar category: Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. - :type category: str - :param enabled: Required. a value indicating whether this log is enabled. - :type enabled: bool - :param retention_policy: the retention policy for this log. - :type retention_policy: ~$(python-base-namespace).v2015_07_01.models.RetentionPolicy + :vartype category: str + :ivar enabled: Required. a value indicating whether this log is enabled. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this log. + :vartype retention_policy: ~$(python-base-namespace).v2015_07_01.models.RetentionPolicy """ _validation = { @@ -487,6 +588,16 @@ def __init__( retention_policy: Optional["RetentionPolicy"] = None, **kwargs ): + """ + :keyword category: Name of a Diagnostic Log category for a resource type this setting is + applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET + diagnostic settings operation. + :paramtype category: str + :keyword enabled: Required. a value indicating whether this log is enabled. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this log. + :paramtype retention_policy: ~$(python-base-namespace).v2015_07_01.models.RetentionPolicy + """ super(LogSettings, self).__init__(**kwargs) self.category = category self.enabled = enabled @@ -496,12 +607,12 @@ def __init__( class LogSpecification(msrest.serialization.Model): """Log specification of operation. - :param name: Name of log specification. - :type name: str - :param display_name: Display name of log specification. - :type display_name: str - :param blob_duration: Blob duration of specification. - :type blob_duration: str + :ivar name: Name of log specification. + :vartype name: str + :ivar display_name: Display name of log specification. + :vartype display_name: str + :ivar blob_duration: Blob duration of specification. + :vartype blob_duration: str """ _attribute_map = { @@ -518,6 +629,14 @@ def __init__( blob_duration: Optional[str] = None, **kwargs ): + """ + :keyword name: Name of log specification. + :paramtype name: str + :keyword display_name: Display name of log specification. + :paramtype display_name: str + :keyword blob_duration: Blob duration of specification. + :paramtype blob_duration: str + """ super(LogSpecification, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -527,15 +646,15 @@ def __init__( class ManagementEventAggregationCondition(msrest.serialization.Model): """How the data that is collected should be combined over time. - :param operator: the condition operator. Possible values include: "GreaterThan", + :ivar operator: the condition operator. Possible values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator - :param threshold: The threshold value that activates the alert. - :type threshold: float - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator + :ivar threshold: The threshold value that activates the alert. + :vartype threshold: float + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. - :type window_size: ~datetime.timedelta + :vartype window_size: ~datetime.timedelta """ _attribute_map = { @@ -552,6 +671,17 @@ def __init__( window_size: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword operator: the condition operator. Possible values include: "GreaterThan", + "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :paramtype operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator + :keyword threshold: The threshold value that activates the alert. + :paramtype threshold: float + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. If specified then it must be between 5 minutes and 1 + day. + :paramtype window_size: ~datetime.timedelta + """ super(ManagementEventAggregationCondition, self).__init__(**kwargs) self.operator = operator self.threshold = threshold @@ -563,18 +693,18 @@ class ManagementEventRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource - :param aggregation: How the data that is collected should be combined over time and when the + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource + :ivar aggregation: How the data that is collected should be combined over time and when the alert is activated. Note that for management event alerts aggregation is optional – if it is not provided then any event will cause the alert to activate. - :type aggregation: + :vartype aggregation: ~$(python-base-namespace).v2015_07_01.models.ManagementEventAggregationCondition """ @@ -595,6 +725,16 @@ def __init__( aggregation: Optional["ManagementEventAggregationCondition"] = None, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource + :keyword aggregation: How the data that is collected should be combined over time and when the + alert is activated. Note that for management event alerts aggregation is optional – if it is + not provided then any event will cause the alert to activate. + :paramtype aggregation: + ~$(python-base-namespace).v2015_07_01.models.ManagementEventAggregationCondition + """ super(ManagementEventRuleCondition, self).__init__(data_source=data_source, **kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition' # type: str self.aggregation = aggregation @@ -603,14 +743,14 @@ def __init__( class MetricAvailability(msrest.serialization.Model): """Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. - :param time_grain: the time grain specifies the aggregation interval for the metric. Expressed + :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. - :type time_grain: ~datetime.timedelta - :param retention: the retention period for the metric at the specified timegrain. Expressed as + :vartype time_grain: ~datetime.timedelta + :ivar retention: the retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc. - :type retention: ~datetime.timedelta - :param location: Info about where the metric data is stored. - :type location: ~$(python-base-namespace).v2015_07_01.models.MetricAvailabilityLocation + :vartype retention: ~datetime.timedelta + :ivar location: Info about where the metric data is stored. + :vartype location: ~$(python-base-namespace).v2015_07_01.models.MetricAvailabilityLocation """ _attribute_map = { @@ -627,6 +767,16 @@ def __init__( location: Optional["MetricAvailabilityLocation"] = None, **kwargs ): + """ + :keyword time_grain: the time grain specifies the aggregation interval for the metric. + Expressed as a duration 'PT1M', 'P1D', etc. + :paramtype time_grain: ~datetime.timedelta + :keyword retention: the retention period for the metric at the specified timegrain. Expressed + as a duration 'PT1M', 'P1D', etc. + :paramtype retention: ~datetime.timedelta + :keyword location: Info about where the metric data is stored. + :paramtype location: ~$(python-base-namespace).v2015_07_01.models.MetricAvailabilityLocation + """ super(MetricAvailability, self).__init__(**kwargs) self.time_grain = time_grain self.retention = retention @@ -636,13 +786,12 @@ def __init__( class MetricAvailabilityLocation(msrest.serialization.Model): """Info about where the metric data is stored. - :param table_endpoint: The url for the storage account. - :type table_endpoint: str - :param table_info: Info about the storage tables storing this resources metrics. - :type table_info: list[~$(python-base-namespace).v2015_07_01.models.TableInfoEntry] - :param partition_key: partition key in the table where the metrics for this resource are - stored. - :type partition_key: str + :ivar table_endpoint: The url for the storage account. + :vartype table_endpoint: str + :ivar table_info: Info about the storage tables storing this resources metrics. + :vartype table_info: list[~$(python-base-namespace).v2015_07_01.models.TableInfoEntry] + :ivar partition_key: partition key in the table where the metrics for this resource are stored. + :vartype partition_key: str """ _attribute_map = { @@ -659,6 +808,15 @@ def __init__( partition_key: Optional[str] = None, **kwargs ): + """ + :keyword table_endpoint: The url for the storage account. + :paramtype table_endpoint: str + :keyword table_info: Info about the storage tables storing this resources metrics. + :paramtype table_info: list[~$(python-base-namespace).v2015_07_01.models.TableInfoEntry] + :keyword partition_key: partition key in the table where the metrics for this resource are + stored. + :paramtype partition_key: str + """ super(MetricAvailabilityLocation, self).__init__(**kwargs) self.table_endpoint = table_endpoint self.table_info = table_info @@ -668,36 +826,36 @@ def __init__( class MetricDefinition(msrest.serialization.Model): """Metric definition class specifies the metadata for a metric. - :param resource_id: The resource identifier of the resource that emitted the metric. - :type resource_id: str - :param resource_uri: The resource identifier of the resource that emitted the metric. - :type resource_uri: str - :param name: the name and the display name of the metric, i.e. it is a localizable string. - :type name: ~$(python-base-namespace).v2015_07_01.models.LocalizableString - :param category: The category of this metric. - :type category: str - :param unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + :ivar resource_id: The resource identifier of the resource that emitted the metric. + :vartype resource_id: str + :ivar resource_uri: The resource identifier of the resource that emitted the metric. + :vartype resource_uri: str + :ivar name: the name and the display name of the metric, i.e. it is a localizable string. + :vartype name: ~$(python-base-namespace).v2015_07_01.models.LocalizableString + :ivar category: The category of this metric. + :vartype category: str + :ivar unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds". - :type unit: str or ~$(python-base-namespace).v2015_07_01.models.Unit - :param start_time: Start time of the metadata request timespan. - :type start_time: ~datetime.datetime - :param end_time: End time of the metadata request timespan. - :type end_time: ~datetime.datetime - :param primary_aggregation_type: the primary aggregation type value defining how to use the + :vartype unit: str or ~$(python-base-namespace).v2015_07_01.models.Unit + :ivar start_time: Start time of the metadata request timespan. + :vartype start_time: ~datetime.datetime + :ivar end_time: End time of the metadata request timespan. + :vartype end_time: ~datetime.datetime + :ivar primary_aggregation_type: the primary aggregation type value defining how to use the values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", "Total". - :type primary_aggregation_type: str or + :vartype primary_aggregation_type: str or ~$(python-base-namespace).v2015_07_01.models.AggregationType - :param supported_aggregation_types: List of all aggregations that are applicable for this + :ivar supported_aggregation_types: List of all aggregations that are applicable for this metric. - :type supported_aggregation_types: list[str or + :vartype supported_aggregation_types: list[str or ~$(python-base-namespace).v2015_07_01.models.AggregationType] - :param metric_availabilities: the collection of what aggregation intervals are available to be + :ivar metric_availabilities: the collection of what aggregation intervals are available to be queried. - :type metric_availabilities: + :vartype metric_availabilities: list[~$(python-base-namespace).v2015_07_01.models.MetricAvailability] - :param id: the resource identifier of the metric definition. - :type id: str + :ivar id: the resource identifier of the metric definition. + :vartype id: str """ _attribute_map = { @@ -730,6 +888,38 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword resource_id: The resource identifier of the resource that emitted the metric. + :paramtype resource_id: str + :keyword resource_uri: The resource identifier of the resource that emitted the metric. + :paramtype resource_uri: str + :keyword name: the name and the display name of the metric, i.e. it is a localizable string. + :paramtype name: ~$(python-base-namespace).v2015_07_01.models.LocalizableString + :keyword category: The category of this metric. + :paramtype category: str + :keyword unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds". + :paramtype unit: str or ~$(python-base-namespace).v2015_07_01.models.Unit + :keyword start_time: Start time of the metadata request timespan. + :paramtype start_time: ~datetime.datetime + :keyword end_time: End time of the metadata request timespan. + :paramtype end_time: ~datetime.datetime + :keyword primary_aggregation_type: the primary aggregation type value defining how to use the + values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", + "Total". + :paramtype primary_aggregation_type: str or + ~$(python-base-namespace).v2015_07_01.models.AggregationType + :keyword supported_aggregation_types: List of all aggregations that are applicable for this + metric. + :paramtype supported_aggregation_types: list[str or + ~$(python-base-namespace).v2015_07_01.models.AggregationType] + :keyword metric_availabilities: the collection of what aggregation intervals are available to + be queried. + :paramtype metric_availabilities: + list[~$(python-base-namespace).v2015_07_01.models.MetricAvailability] + :keyword id: the resource identifier of the metric definition. + :paramtype id: str + """ super(MetricDefinition, self).__init__(**kwargs) self.resource_id = resource_id self.resource_uri = resource_uri @@ -749,10 +939,10 @@ class MetricDefinitionCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Resource Id for these metric definitions. - :type id: str - :param value: Required. the values for the metric definitions. - :type value: list[~$(python-base-namespace).v2015_07_01.models.MetricDefinition] + :ivar id: Resource Id for these metric definitions. + :vartype id: str + :ivar value: Required. the values for the metric definitions. + :vartype value: list[~$(python-base-namespace).v2015_07_01.models.MetricDefinition] """ _validation = { @@ -771,6 +961,12 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource Id for these metric definitions. + :paramtype id: str + :keyword value: Required. the values for the metric definitions. + :paramtype value: list[~$(python-base-namespace).v2015_07_01.models.MetricDefinition] + """ super(MetricDefinitionCollection, self).__init__(**kwargs) self.id = id self.value = value @@ -781,12 +977,12 @@ class MetricSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_grain: Required. the timegrain of the metric in ISO8601 format. - :type time_grain: ~datetime.timedelta - :param enabled: Required. a value indicating whether this timegrain is enabled. - :type enabled: bool - :param retention_policy: the retention policy for this timegrain. - :type retention_policy: ~$(python-base-namespace).v2015_07_01.models.RetentionPolicy + :ivar time_grain: Required. the timegrain of the metric in ISO8601 format. + :vartype time_grain: ~datetime.timedelta + :ivar enabled: Required. a value indicating whether this timegrain is enabled. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this timegrain. + :vartype retention_policy: ~$(python-base-namespace).v2015_07_01.models.RetentionPolicy """ _validation = { @@ -808,6 +1004,14 @@ def __init__( retention_policy: Optional["RetentionPolicy"] = None, **kwargs ): + """ + :keyword time_grain: Required. the timegrain of the metric in ISO8601 format. + :paramtype time_grain: ~datetime.timedelta + :keyword enabled: Required. a value indicating whether this timegrain is enabled. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this timegrain. + :paramtype retention_policy: ~$(python-base-namespace).v2015_07_01.models.RetentionPolicy + """ super(MetricSettings, self).__init__(**kwargs) self.time_grain = time_grain self.enabled = enabled @@ -817,34 +1021,34 @@ def __init__( class MetricSpecification(msrest.serialization.Model): """Metric specification of operation. - :param name: The name of the metric. - :type name: str - :param display_name: Display name of the metric. - :type display_name: str - :param display_description: Display description of the metric. - :type display_description: str - :param unit: The metric unit. Possible values include: + :ivar name: The name of the metric. + :vartype name: str + :ivar display_name: Display name of the metric. + :vartype display_name: str + :ivar display_description: Display description of the metric. + :vartype display_description: str + :ivar unit: The metric unit. Possible values include: Count,Bytes,Seconds,Percent,CountPerSecond,BytesPerSecond,MilliSeconds,ByteSeconds,Unspecified,BitsPerSecond,Cores,MilliCores,NanoCores. - :type unit: str - :param aggregation_type: The default metric aggregation type. Possible values include: + :vartype unit: str + :ivar aggregation_type: The default metric aggregation type. Possible values include: Total,Average,Maximum,Minimum,Count. - :type aggregation_type: str - :param supported_aggregation_types: The supported aggregation types for the metrics. - :type supported_aggregation_types: list[str] - :param supported_time_grain_types: The supported time grain types for the metrics. - :type supported_time_grain_types: list[str] - :param availabilities: The supported time grain types for the metrics. - :type availabilities: list[str] - :param lock_aggregation_type: The metric lock aggregation type. - :type lock_aggregation_type: str - :param category: Category or type of metric. - :type category: str - :param dimensions: The dimensions of metric. - :type dimensions: list[~$(python-base-namespace).v2015_07_01.models.DimensionProperties] - :param fill_gap_with_zero: Property to specify whether to fill empty gaps with zero. - :type fill_gap_with_zero: bool - :param internal_metric_name: The internal metric name. - :type internal_metric_name: str + :vartype aggregation_type: str + :ivar supported_aggregation_types: The supported aggregation types for the metrics. + :vartype supported_aggregation_types: list[str] + :ivar supported_time_grain_types: The supported time grain types for the metrics. + :vartype supported_time_grain_types: list[str] + :ivar availabilities: The supported time grain types for the metrics. + :vartype availabilities: list[str] + :ivar lock_aggregation_type: The metric lock aggregation type. + :vartype lock_aggregation_type: str + :ivar category: Category or type of metric. + :vartype category: str + :ivar dimensions: The dimensions of metric. + :vartype dimensions: list[~$(python-base-namespace).v2015_07_01.models.DimensionProperties] + :ivar fill_gap_with_zero: Property to specify whether to fill empty gaps with zero. + :vartype fill_gap_with_zero: bool + :ivar internal_metric_name: The internal metric name. + :vartype internal_metric_name: str """ _attribute_map = { @@ -881,6 +1085,36 @@ def __init__( internal_metric_name: Optional[str] = None, **kwargs ): + """ + :keyword name: The name of the metric. + :paramtype name: str + :keyword display_name: Display name of the metric. + :paramtype display_name: str + :keyword display_description: Display description of the metric. + :paramtype display_description: str + :keyword unit: The metric unit. Possible values include: + Count,Bytes,Seconds,Percent,CountPerSecond,BytesPerSecond,MilliSeconds,ByteSeconds,Unspecified,BitsPerSecond,Cores,MilliCores,NanoCores. + :paramtype unit: str + :keyword aggregation_type: The default metric aggregation type. Possible values include: + Total,Average,Maximum,Minimum,Count. + :paramtype aggregation_type: str + :keyword supported_aggregation_types: The supported aggregation types for the metrics. + :paramtype supported_aggregation_types: list[str] + :keyword supported_time_grain_types: The supported time grain types for the metrics. + :paramtype supported_time_grain_types: list[str] + :keyword availabilities: The supported time grain types for the metrics. + :paramtype availabilities: list[str] + :keyword lock_aggregation_type: The metric lock aggregation type. + :paramtype lock_aggregation_type: str + :keyword category: Category or type of metric. + :paramtype category: str + :keyword dimensions: The dimensions of metric. + :paramtype dimensions: list[~$(python-base-namespace).v2015_07_01.models.DimensionProperties] + :keyword fill_gap_with_zero: Property to specify whether to fill empty gaps with zero. + :paramtype fill_gap_with_zero: bool + :keyword internal_metric_name: The internal metric name. + :paramtype internal_metric_name: str + """ super(MetricSpecification, self).__init__(**kwargs) self.name = name self.display_name = display_name @@ -900,14 +1134,15 @@ def __init__( class Operation(msrest.serialization.Model): """Microsoft Insights API operation definition. - :param name: Operation name: {provider}/{resource}/{operation}. - :type name: str - :param is_data_action: Property to specify whether the action is a data action. - :type is_data_action: bool - :param display: Display metadata associated with the operation. - :type display: ~$(python-base-namespace).v2015_07_01.models.OperationDisplay - :param service_specification: One property of operation, include metric specifications. - :type service_specification: ~$(python-base-namespace).v2015_07_01.models.ServiceSpecification + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar is_data_action: Property to specify whether the action is a data action. + :vartype is_data_action: bool + :ivar display: Display metadata associated with the operation. + :vartype display: ~$(python-base-namespace).v2015_07_01.models.OperationDisplay + :ivar service_specification: One property of operation, include metric specifications. + :vartype service_specification: + ~$(python-base-namespace).v2015_07_01.models.ServiceSpecification """ _attribute_map = { @@ -926,6 +1161,17 @@ def __init__( service_specification: Optional["ServiceSpecification"] = None, **kwargs ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword is_data_action: Property to specify whether the action is a data action. + :paramtype is_data_action: bool + :keyword display: Display metadata associated with the operation. + :paramtype display: ~$(python-base-namespace).v2015_07_01.models.OperationDisplay + :keyword service_specification: One property of operation, include metric specifications. + :paramtype service_specification: + ~$(python-base-namespace).v2015_07_01.models.ServiceSpecification + """ super(Operation, self).__init__(**kwargs) self.name = name self.is_data_action = is_data_action @@ -936,16 +1182,16 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """Display metadata associated with the operation. - :param publisher: The publisher of this operation. - :type publisher: str - :param provider: Service provider: Microsoft.Insights. - :type provider: str - :param resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. - :type resource: str - :param operation: Operation type: Read, write, delete, etc. - :type operation: str - :param description: The description of the operation. - :type description: str + :ivar publisher: The publisher of this operation. + :vartype publisher: str + :ivar provider: Service provider: Microsoft.Insights. + :vartype provider: str + :ivar resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. + :vartype resource: str + :ivar operation: Operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: The description of the operation. + :vartype description: str """ _attribute_map = { @@ -966,6 +1212,18 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword publisher: The publisher of this operation. + :paramtype publisher: str + :keyword provider: Service provider: Microsoft.Insights. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed: AlertRules, Autoscale, etc. + :paramtype resource: str + :keyword operation: Operation type: Read, write, delete, etc. + :paramtype operation: str + :keyword description: The description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.publisher = publisher self.provider = provider @@ -977,10 +1235,10 @@ def __init__( class OperationListResult(msrest.serialization.Model): """Result of the request to list Microsoft.Insights operations. It contains a list of operations and a URL link to get the next set of results. - :param value: List of operations supported by the Microsoft.Insights provider. - :type value: list[~$(python-base-namespace).v2015_07_01.models.Operation] - :param next_link: URL to get the next set of operation list results if there are any. - :type next_link: str + :ivar value: List of operations supported by the Microsoft.Insights provider. + :vartype value: list[~$(python-base-namespace).v2015_07_01.models.Operation] + :ivar next_link: URL to get the next set of operation list results if there are any. + :vartype next_link: str """ _attribute_map = { @@ -995,6 +1253,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: List of operations supported by the Microsoft.Insights provider. + :paramtype value: list[~$(python-base-namespace).v2015_07_01.models.Operation] + :keyword next_link: URL to get the next set of operation list results if there are any. + :paramtype next_link: str + """ super(OperationListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1005,11 +1269,11 @@ class RetentionPolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param enabled: Required. a value indicating whether the retention policy is enabled. - :type enabled: bool - :param days: Required. the number of days for the retention in days. A value of 0 will retain + :ivar enabled: Required. a value indicating whether the retention policy is enabled. + :vartype enabled: bool + :ivar days: Required. the number of days for the retention in days. A value of 0 will retain the events indefinitely. - :type days: int + :vartype days: int """ _validation = { @@ -1029,6 +1293,13 @@ def __init__( days: int, **kwargs ): + """ + :keyword enabled: Required. a value indicating whether the retention policy is enabled. + :paramtype enabled: bool + :keyword days: Required. the number of days for the retention in days. A value of 0 will retain + the events indefinitely. + :paramtype days: int + """ super(RetentionPolicy, self).__init__(**kwargs) self.enabled = enabled self.days = days @@ -1042,9 +1313,9 @@ class RuleAction(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of the action. There are two types of actions: + :ivar odata_type: Required. specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str + :vartype odata_type: str """ _validation = { @@ -1063,6 +1334,8 @@ def __init__( self, **kwargs ): + """ + """ super(RuleAction, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] @@ -1075,19 +1348,19 @@ class RuleDataSource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of data source. There are two types of rule - data sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. - :type odata_type: str - :param resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :type resource_uri: str - :param legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + :ivar odata_type: Required. specifies the type of data source. There are two types of rule data + sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :vartype odata_type: str + :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this + property cannot be updated for an existing rule. + :vartype resource_uri: str + :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. - :type legacy_resource_id: str - :param resource_location: the location of the resource. - :type resource_location: str - :param metric_namespace: the namespace of the metric. - :type metric_namespace: str + :vartype legacy_resource_id: str + :ivar resource_location: the location of the resource. + :vartype resource_location: str + :ivar metric_namespace: the namespace of the metric. + :vartype metric_namespace: str """ _validation = { @@ -1115,6 +1388,18 @@ def __init__( metric_namespace: Optional[str] = None, **kwargs ): + """ + :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : + this property cannot be updated for an existing rule. + :paramtype resource_uri: str + :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + **NOTE**\ : this property cannot be updated for an existing rule. + :paramtype legacy_resource_id: str + :keyword resource_location: the location of the resource. + :paramtype resource_location: str + :keyword metric_namespace: the namespace of the metric. + :paramtype metric_namespace: str + """ super(RuleDataSource, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] self.resource_uri = resource_uri @@ -1128,15 +1413,15 @@ class RuleEmailAction(RuleAction): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of the action. There are two types of actions: + :ivar odata_type: Required. specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str - :param send_to_service_owners: Whether the administrators (service and co-administrators) of - the service should be notified when the alert is activated. - :type send_to_service_owners: bool - :param custom_emails: the list of administrator's custom email addresses to notify of the + :vartype odata_type: str + :ivar send_to_service_owners: Whether the administrators (service and co-administrators) of the + service should be notified when the alert is activated. + :vartype send_to_service_owners: bool + :ivar custom_emails: the list of administrator's custom email addresses to notify of the activation of the alert. - :type custom_emails: list[str] + :vartype custom_emails: list[str] """ _validation = { @@ -1156,6 +1441,14 @@ def __init__( custom_emails: Optional[List[str]] = None, **kwargs ): + """ + :keyword send_to_service_owners: Whether the administrators (service and co-administrators) of + the service should be notified when the alert is activated. + :paramtype send_to_service_owners: bool + :keyword custom_emails: the list of administrator's custom email addresses to notify of the + activation of the alert. + :paramtype custom_emails: list[str] + """ super(RuleEmailAction, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleEmailAction' # type: str self.send_to_service_owners = send_to_service_owners @@ -1165,8 +1458,8 @@ def __init__( class RuleManagementEventClaimsDataSource(msrest.serialization.Model): """The claims for a rule management event data source. - :param email_address: the email address. - :type email_address: str + :ivar email_address: the email address. + :vartype email_address: str """ _attribute_map = { @@ -1179,6 +1472,10 @@ def __init__( email_address: Optional[str] = None, **kwargs ): + """ + :keyword email_address: the email address. + :paramtype email_address: str + """ super(RuleManagementEventClaimsDataSource, self).__init__(**kwargs) self.email_address = email_address @@ -1188,39 +1485,40 @@ class RuleManagementEventDataSource(RuleDataSource): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of data source. There are two types of rule - data sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. - :type odata_type: str - :param resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :type resource_uri: str - :param legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + :ivar odata_type: Required. specifies the type of data source. There are two types of rule data + sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :vartype odata_type: str + :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this + property cannot be updated for an existing rule. + :vartype resource_uri: str + :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. - :type legacy_resource_id: str - :param resource_location: the location of the resource. - :type resource_location: str - :param metric_namespace: the namespace of the metric. - :type metric_namespace: str - :param event_name: the event name. - :type event_name: str - :param event_source: the event source. - :type event_source: str - :param level: the level. - :type level: str - :param operation_name: The name of the operation that should be checked for. If no name is + :vartype legacy_resource_id: str + :ivar resource_location: the location of the resource. + :vartype resource_location: str + :ivar metric_namespace: the namespace of the metric. + :vartype metric_namespace: str + :ivar event_name: the event name. + :vartype event_name: str + :ivar event_source: the event source. + :vartype event_source: str + :ivar level: the level. + :vartype level: str + :ivar operation_name: The name of the operation that should be checked for. If no name is provided, any operation will match. - :type operation_name: str - :param resource_group_name: the resource group name. - :type resource_group_name: str - :param resource_provider_name: the resource provider name. - :type resource_provider_name: str - :param status: The status of the operation that should be checked for. If no status is - provided, any status will match. - :type status: str - :param sub_status: the substatus. - :type sub_status: str - :param claims: the claims. - :type claims: ~$(python-base-namespace).v2015_07_01.models.RuleManagementEventClaimsDataSource + :vartype operation_name: str + :ivar resource_group_name: the resource group name. + :vartype resource_group_name: str + :ivar resource_provider_name: the resource provider name. + :vartype resource_provider_name: str + :ivar status: The status of the operation that should be checked for. If no status is provided, + any status will match. + :vartype status: str + :ivar sub_status: the substatus. + :vartype sub_status: str + :ivar claims: the claims. + :vartype claims: + ~$(python-base-namespace).v2015_07_01.models.RuleManagementEventClaimsDataSource """ _validation = { @@ -1262,6 +1560,39 @@ def __init__( claims: Optional["RuleManagementEventClaimsDataSource"] = None, **kwargs ): + """ + :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : + this property cannot be updated for an existing rule. + :paramtype resource_uri: str + :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + **NOTE**\ : this property cannot be updated for an existing rule. + :paramtype legacy_resource_id: str + :keyword resource_location: the location of the resource. + :paramtype resource_location: str + :keyword metric_namespace: the namespace of the metric. + :paramtype metric_namespace: str + :keyword event_name: the event name. + :paramtype event_name: str + :keyword event_source: the event source. + :paramtype event_source: str + :keyword level: the level. + :paramtype level: str + :keyword operation_name: The name of the operation that should be checked for. If no name is + provided, any operation will match. + :paramtype operation_name: str + :keyword resource_group_name: the resource group name. + :paramtype resource_group_name: str + :keyword resource_provider_name: the resource provider name. + :paramtype resource_provider_name: str + :keyword status: The status of the operation that should be checked for. If no status is + provided, any status will match. + :paramtype status: str + :keyword sub_status: the substatus. + :paramtype sub_status: str + :keyword claims: the claims. + :paramtype claims: + ~$(python-base-namespace).v2015_07_01.models.RuleManagementEventClaimsDataSource + """ super(RuleManagementEventDataSource, self).__init__(resource_uri=resource_uri, legacy_resource_id=legacy_resource_id, resource_location=resource_location, metric_namespace=metric_namespace, **kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource' # type: str self.event_name = event_name @@ -1280,21 +1611,21 @@ class RuleMetricDataSource(RuleDataSource): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of data source. There are two types of rule - data sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. - :type odata_type: str - :param resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :type resource_uri: str - :param legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + :ivar odata_type: Required. specifies the type of data source. There are two types of rule data + sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :vartype odata_type: str + :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this + property cannot be updated for an existing rule. + :vartype resource_uri: str + :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. - :type legacy_resource_id: str - :param resource_location: the location of the resource. - :type resource_location: str - :param metric_namespace: the namespace of the metric. - :type metric_namespace: str - :param metric_name: the name of the metric that defines what the rule monitors. - :type metric_name: str + :vartype legacy_resource_id: str + :ivar resource_location: the location of the resource. + :vartype resource_location: str + :ivar metric_namespace: the namespace of the metric. + :vartype metric_namespace: str + :ivar metric_name: the name of the metric that defines what the rule monitors. + :vartype metric_name: str """ _validation = { @@ -1320,6 +1651,20 @@ def __init__( metric_name: Optional[str] = None, **kwargs ): + """ + :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : + this property cannot be updated for an existing rule. + :paramtype resource_uri: str + :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + **NOTE**\ : this property cannot be updated for an existing rule. + :paramtype legacy_resource_id: str + :keyword resource_location: the location of the resource. + :paramtype resource_location: str + :keyword metric_namespace: the namespace of the metric. + :paramtype metric_namespace: str + :keyword metric_name: the name of the metric that defines what the rule monitors. + :paramtype metric_name: str + """ super(RuleMetricDataSource, self).__init__(resource_uri=resource_uri, legacy_resource_id=legacy_resource_id, resource_location=resource_location, metric_namespace=metric_namespace, **kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource' # type: str self.metric_name = metric_name @@ -1330,15 +1675,15 @@ class RuleWebhookAction(RuleAction): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of the action. There are two types of actions: + :ivar odata_type: Required. specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str - :param service_uri: the service uri to Post the notification when the alert activates or + :vartype odata_type: str + :ivar service_uri: the service uri to Post the notification when the alert activates or resolves. - :type service_uri: str - :param properties: the dictionary of custom properties to include with the post operation. - These data are appended to the webhook payload. - :type properties: dict[str, str] + :vartype service_uri: str + :ivar properties: the dictionary of custom properties to include with the post operation. These + data are appended to the webhook payload. + :vartype properties: dict[str, str] """ _validation = { @@ -1358,6 +1703,14 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword service_uri: the service uri to Post the notification when the alert activates or + resolves. + :paramtype service_uri: str + :keyword properties: the dictionary of custom properties to include with the post operation. + These data are appended to the webhook payload. + :paramtype properties: dict[str, str] + """ super(RuleWebhookAction, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction' # type: str self.service_uri = service_uri @@ -1377,25 +1730,25 @@ class ServiceDiagnosticSettingsResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param storage_account_id: The resource ID of the storage account to which you would like to + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. - :type service_bus_rule_id: str - :param metrics: the list of metric settings. - :type metrics: list[~$(python-base-namespace).v2015_07_01.models.MetricSettings] - :param logs: the list of logs settings. - :type logs: list[~$(python-base-namespace).v2015_07_01.models.LogSettings] - :param workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a Log + :vartype service_bus_rule_id: str + :ivar metrics: the list of metric settings. + :vartype metrics: list[~$(python-base-namespace).v2015_07_01.models.MetricSettings] + :ivar logs: the list of logs settings. + :vartype logs: list[~$(python-base-namespace).v2015_07_01.models.LogSettings] + :ivar workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str + :vartype workspace_id: str """ _validation = { @@ -1430,6 +1783,27 @@ def __init__( workspace_id: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the + format: '{service bus resource ID}/authorizationrules/{key name}'. + :paramtype service_bus_rule_id: str + :keyword metrics: the list of metric settings. + :paramtype metrics: list[~$(python-base-namespace).v2015_07_01.models.MetricSettings] + :keyword logs: the list of logs settings. + :paramtype logs: list[~$(python-base-namespace).v2015_07_01.models.LogSettings] + :keyword workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a Log + Analytics workspace to which you would like to send Diagnostic Logs. Example: + /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + :paramtype workspace_id: str + """ super(ServiceDiagnosticSettingsResource, self).__init__(location=location, tags=tags, **kwargs) self.storage_account_id = storage_account_id self.service_bus_rule_id = service_bus_rule_id @@ -1441,14 +1815,15 @@ def __init__( class ServiceSpecification(msrest.serialization.Model): """One property of operation, include log specifications. - :param log_specifications: Log specifications of operation. - :type log_specifications: list[~$(python-base-namespace).v2015_07_01.models.LogSpecification] - :param metric_specifications: Metric specifications of operation. - :type metric_specifications: + :ivar log_specifications: Log specifications of operation. + :vartype log_specifications: + list[~$(python-base-namespace).v2015_07_01.models.LogSpecification] + :ivar metric_specifications: Metric specifications of operation. + :vartype metric_specifications: list[~$(python-base-namespace).v2015_07_01.models.MetricSpecification] - :param legacy_metric_specifications: Legacy Metric specifications for operation. Deprecated, do + :ivar legacy_metric_specifications: Legacy Metric specifications for operation. Deprecated, do not use. - :type legacy_metric_specifications: any + :vartype legacy_metric_specifications: any """ _attribute_map = { @@ -1465,6 +1840,17 @@ def __init__( legacy_metric_specifications: Optional[Any] = None, **kwargs ): + """ + :keyword log_specifications: Log specifications of operation. + :paramtype log_specifications: + list[~$(python-base-namespace).v2015_07_01.models.LogSpecification] + :keyword metric_specifications: Metric specifications of operation. + :paramtype metric_specifications: + list[~$(python-base-namespace).v2015_07_01.models.MetricSpecification] + :keyword legacy_metric_specifications: Legacy Metric specifications for operation. Deprecated, + do not use. + :paramtype legacy_metric_specifications: any + """ super(ServiceSpecification, self).__init__(**kwargs) self.log_specifications = log_specifications self.metric_specifications = metric_specifications @@ -1474,16 +1860,16 @@ def __init__( class TableInfoEntry(msrest.serialization.Model): """Info about a storage table with metric data. - :param table_name: Name of a table with metric data for this resource. - :type table_name: str - :param start_time: Start time of the metrics in this table. - :type start_time: ~datetime.datetime - :param end_time: End time of the metrics in this table. - :type end_time: ~datetime.datetime - :param sas_token: For the storage account with metrics. - :type sas_token: str - :param sas_token_expiration_time: For the storage account with metrics. - :type sas_token_expiration_time: ~datetime.datetime + :ivar table_name: Name of a table with metric data for this resource. + :vartype table_name: str + :ivar start_time: Start time of the metrics in this table. + :vartype start_time: ~datetime.datetime + :ivar end_time: End time of the metrics in this table. + :vartype end_time: ~datetime.datetime + :ivar sas_token: For the storage account with metrics. + :vartype sas_token: str + :ivar sas_token_expiration_time: For the storage account with metrics. + :vartype sas_token_expiration_time: ~datetime.datetime """ _attribute_map = { @@ -1504,6 +1890,18 @@ def __init__( sas_token_expiration_time: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword table_name: Name of a table with metric data for this resource. + :paramtype table_name: str + :keyword start_time: Start time of the metrics in this table. + :paramtype start_time: ~datetime.datetime + :keyword end_time: End time of the metrics in this table. + :paramtype end_time: ~datetime.datetime + :keyword sas_token: For the storage account with metrics. + :paramtype sas_token: str + :keyword sas_token_expiration_time: For the storage account with metrics. + :paramtype sas_token_expiration_time: ~datetime.datetime + """ super(TableInfoEntry, self).__init__(**kwargs) self.table_name = table_name self.start_time = start_time @@ -1517,27 +1915,27 @@ class ThresholdRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource - :param operator: Required. the operator used to compare the data and the threshold. Possible + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource + :ivar operator: Required. the operator used to compare the data and the threshold. Possible values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator - :param threshold: Required. the threshold value that activates the alert. - :type threshold: float - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator + :ivar threshold: Required. the threshold value that activates the alert. + :vartype threshold: float + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. - :type window_size: ~datetime.timedelta - :param time_aggregation: the time aggregation operator. How the data that are collected should + :vartype window_size: ~datetime.timedelta + :ivar time_aggregation: the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. Possible values include: "Average", "Minimum", "Maximum", "Total", "Last". - :type time_aggregation: str or + :vartype time_aggregation: str or ~$(python-base-namespace).v2015_07_01.models.TimeAggregationOperator """ @@ -1566,6 +1964,25 @@ def __init__( time_aggregation: Optional[Union[str, "TimeAggregationOperator"]] = None, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2015_07_01.models.RuleDataSource + :keyword operator: Required. the operator used to compare the data and the threshold. Possible + values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :paramtype operator: str or ~$(python-base-namespace).v2015_07_01.models.ConditionOperator + :keyword threshold: Required. the threshold value that activates the alert. + :paramtype threshold: float + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. If specified then it must be between 5 minutes and 1 + day. + :paramtype window_size: ~datetime.timedelta + :keyword time_aggregation: the time aggregation operator. How the data that are collected + should be combined over time. The default value is the PrimaryAggregationType of the Metric. + Possible values include: "Average", "Minimum", "Maximum", "Total", "Last". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2015_07_01.models.TimeAggregationOperator + """ super(ThresholdRuleCondition, self).__init__(data_source=data_source, **kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition' # type: str self.operator = operator diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_monitor_management_client_enums.py index c2b5066b1b064..1404ed3e39166 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/models/_monitor_management_client_enums.py @@ -6,27 +6,12 @@ # 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 AggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Describes how metric values are aggregated """ @@ -37,7 +22,7 @@ class AggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MAXIMUM = "Maximum" TOTAL = "Total" -class ConditionOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ConditionOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Operators allowed in the rule condition. """ @@ -46,7 +31,7 @@ class ConditionOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" -class TimeAggregationOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TimeAggregationOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Aggregation operators allowed in a rule. """ @@ -56,7 +41,7 @@ class TimeAggregationOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum TOTAL = "Total" LAST = "Last" -class Unit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Unit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the unit of the metric. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_alert_rules_operations.py index bfbed600aa58c..848c47abaa0c2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_alert_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_alert_rules_operations.py @@ -5,24 +5,250 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + resource_group_name, # type: str + rule_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "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] + 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, + **kwargs + ) + + +def build_delete_request( + resource_group_name, # type: str + rule_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + rule_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "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_update_request( + subscription_id, # type: str + resource_group_name, # type: str + rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", 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, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2014-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules') + 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 + ) + +# fmt: on class AlertRulesOperations(object): """AlertRulesOperations operations. @@ -45,6 +271,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -55,7 +282,7 @@ def create_or_update( # type: (...) -> "_models.AlertRuleResource" """Creates or updates a classic metric alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -71,38 +298,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'AlertRuleResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AlertRuleResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -115,8 +332,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -126,7 +346,7 @@ def delete( # type: (...) -> None """Deletes a classic metric alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -140,33 +360,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -174,6 +384,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -183,7 +395,7 @@ def get( # type: (...) -> "_models.AlertRuleResource" """Gets a classic metric alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -197,33 +409,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertRuleResource', pipeline_response) @@ -232,8 +434,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -245,7 +450,7 @@ def update( """Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -261,38 +466,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-01" - 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'), - 'ruleName': self._serialize.url("rule_name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') - 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, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -305,8 +500,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -315,11 +513,13 @@ def list_by_resource_group( # type: (...) -> Iterable["_models.AlertRuleResourceCollection"] """List the classic metric alert rules within a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 AlertRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResourceCollection] + :return: An iterator like instance of either AlertRuleResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] @@ -327,35 +527,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('AlertRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -368,17 +564,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Insights/alertrules'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs # type: Any @@ -387,8 +585,10 @@ def list_by_subscription( """List the classic metric alert rules within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResourceCollection] + :return: An iterator like instance of either AlertRuleResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_07_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] @@ -396,34 +596,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2014-04-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_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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('AlertRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -436,12 +631,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_metric_definitions_operations.py index ebae6587c5bd6..acf9cb6f36d7e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_metric_definitions_operations.py @@ -5,24 +5,68 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2015-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/metricDefinitions') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, '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') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, '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 + ) + +# fmt: on class MetricDefinitionsOperations(object): """MetricDefinitionsOperations operations. @@ -45,6 +89,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_uri, # type: str @@ -64,8 +109,10 @@ def list( other syntax is allowed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_07_01.models.MetricDefinitionCollection] + :return: An iterator like instance of either MetricDefinitionCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2015_07_01.models.MetricDefinitionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionCollection"] @@ -73,36 +120,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, '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 filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + template_url=self.list.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_list_request( + resource_uri=resource_uri, + filter=filter, + 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('MetricDefinitionCollection', pipeline_response) + deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,12 +157,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_operations.py index a6d8bd648b532..4cc8613e71aca 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_operations.py @@ -5,23 +5,57 @@ # 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 TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 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 +from .._vendor import _convert_request if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Insights/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 + ) + +# fmt: on class Operations(object): """Operations operations. @@ -44,6 +78,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -61,27 +96,20 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, '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) 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.ErrorContract, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('OperationListResult', pipeline_response) @@ -90,4 +118,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/providers/Microsoft.Insights/operations'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_service_diagnostic_settings_operations.py index 2dc552790fd64..52d1e140c8b07 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_service_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2015_07_01/operations/_service_diagnostic_settings_operations.py @@ -5,23 +5,99 @@ # 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 TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2015-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, '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( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2015-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, '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, + **kwargs + ) + +# fmt: on class ServiceDiagnosticSettingsOperations(object): """ServiceDiagnosticSettingsOperations operations. @@ -44,6 +120,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_uri, # type: str @@ -64,31 +141,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, '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') + + request = build_get_request( + resource_uri=resource_uri, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ServiceDiagnosticSettingsResource', pipeline_response) @@ -97,8 +164,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service'} # type: ignore + + @distributed_trace def create_or_update( self, resource_uri, # type: str @@ -111,7 +181,8 @@ def create_or_update( :param resource_uri: The identifier of the resource. :type resource_uri: str :param parameters: Parameters supplied to the operation. - :type parameters: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource + :type parameters: + ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: ServiceDiagnosticSettingsResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2015_07_01.models.ServiceDiagnosticSettingsResource @@ -122,30 +193,20 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-07-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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ServiceDiagnosticSettingsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_uri=resource_uri, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServiceDiagnosticSettingsResource') - 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 @@ -159,4 +220,6 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_configuration.py index 282a42dca8c1f..c612457a685b6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_metadata.json index 358d4351074f4..8b98756e89571 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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_rule_incidents": "AlertRuleIncidentsOperations", diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_monitor_management_client.py index 8f67a079ad202..4be51f3c1d57e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_monitor_management_client.py @@ -6,88 +6,91 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import AlertRuleIncidentsOperations, AlertRulesOperations, LogProfilesOperations, MetricDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import AlertRuleIncidentsOperations -from .operations import AlertRulesOperations -from .operations import LogProfilesOperations -from .operations import MetricDefinitionsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. :ivar alert_rule_incidents: AlertRuleIncidentsOperations operations - :vartype alert_rule_incidents: $(python-base-namespace).v2016_03_01.operations.AlertRuleIncidentsOperations + :vartype alert_rule_incidents: + $(python-base-namespace).v2016_03_01.operations.AlertRuleIncidentsOperations :ivar alert_rules: AlertRulesOperations operations :vartype alert_rules: $(python-base-namespace).v2016_03_01.operations.AlertRulesOperations :ivar log_profiles: LogProfilesOperations operations :vartype log_profiles: $(python-base-namespace).v2016_03_01.operations.LogProfilesOperations :ivar metric_definitions: MetricDefinitionsOperations operations - :vartype metric_definitions: $(python-base-namespace).v2016_03_01.operations.MetricDefinitionsOperations + :vartype metric_definitions: + $(python-base-namespace).v2016_03_01.operations.MetricDefinitionsOperations :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.alert_rule_incidents = AlertRuleIncidentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.log_profiles = LogProfilesOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_definitions = MetricDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.alert_rule_incidents = AlertRuleIncidentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alert_rules = AlertRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.log_profiles = LogProfilesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.metric_definitions = MetricDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_configuration.py index 4fb94b055a2b1..71d775201fb97 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_monitor_management_client.py index ab351d603d924..acb5d78732548 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_monitor_management_client.py @@ -6,84 +6,88 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import AlertRuleIncidentsOperations, AlertRulesOperations, LogProfilesOperations, MetricDefinitionsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MonitorManagementClientConfiguration -from .operations import AlertRuleIncidentsOperations -from .operations import AlertRulesOperations -from .operations import LogProfilesOperations -from .operations import MetricDefinitionsOperations -from .. import models - - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar alert_rule_incidents: AlertRuleIncidentsOperations operations - :vartype alert_rule_incidents: $(python-base-namespace).v2016_03_01.aio.operations.AlertRuleIncidentsOperations + :vartype alert_rule_incidents: + $(python-base-namespace).v2016_03_01.aio.operations.AlertRuleIncidentsOperations :ivar alert_rules: AlertRulesOperations operations :vartype alert_rules: $(python-base-namespace).v2016_03_01.aio.operations.AlertRulesOperations :ivar log_profiles: LogProfilesOperations operations - :vartype log_profiles: $(python-base-namespace).v2016_03_01.aio.operations.LogProfilesOperations + :vartype log_profiles: + $(python-base-namespace).v2016_03_01.aio.operations.LogProfilesOperations :ivar metric_definitions: MetricDefinitionsOperations operations - :vartype metric_definitions: $(python-base-namespace).v2016_03_01.aio.operations.MetricDefinitionsOperations + :vartype metric_definitions: + $(python-base-namespace).v2016_03_01.aio.operations.MetricDefinitionsOperations :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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.alert_rule_incidents = AlertRuleIncidentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.alert_rules = AlertRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.log_profiles = LogProfilesOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_definitions = MetricDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.alert_rule_incidents = AlertRuleIncidentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.alert_rules = AlertRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.log_profiles = LogProfilesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.metric_definitions = MetricDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rule_incidents_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rule_incidents_operations.py index 958a1b2b8603a..898e4940c3f2f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rule_incidents_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rule_incidents_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._alert_rule_incidents_operations import build_get_request, build_list_by_alert_rule_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_async async def get( self, resource_group_name: str, @@ -50,7 +56,7 @@ async def get( ) -> "_models.Incident": """Gets an incident associated to an alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -66,34 +72,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - 'incidentName': self._serialize.url("incident_name", incident_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + incident_name=incident_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Incident', pipeline_response) @@ -102,8 +98,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}'} # type: ignore + + @distributed_trace def list_by_alert_rule( self, resource_group_name: str, @@ -112,13 +111,14 @@ def list_by_alert_rule( ) -> AsyncIterable["_models.IncidentListResult"]: """Gets a list of incidents associated to an alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either IncidentListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.IncidentListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.IncidentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IncidentListResult"] @@ -126,36 +126,33 @@ def list_by_alert_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-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_alert_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_alert_rule_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_alert_rule.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_list_by_alert_rule_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + 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('IncidentListResult', pipeline_response) + deserialized = self._deserialize("IncidentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -173,6 +170,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rules_operations.py index a62a6ec672168..5e191eff2dc5c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_alert_rules_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._alert_rules_operations import build_create_or_update_request, build_delete_request, build_get_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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -50,7 +56,7 @@ async def create_or_update( ) -> "_models.AlertRuleResource": """Creates or updates a classic metric alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -66,38 +72,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'AlertRuleResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AlertRuleResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -110,8 +106,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -120,7 +119,7 @@ async def delete( ) -> None: """Deletes a classic metric alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -134,33 +133,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -168,6 +157,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -176,7 +167,7 @@ async def get( ) -> "_models.AlertRuleResource": """Gets a classic metric alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -190,33 +181,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertRuleResource', pipeline_response) @@ -225,8 +206,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -237,7 +221,7 @@ async def update( """Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -253,38 +237,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-01" - 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'), - 'ruleName': self._serialize.url("rule_name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') - 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, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -297,8 +271,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -306,11 +283,13 @@ def list_by_resource_group( ) -> AsyncIterable["_models.AlertRuleResourceCollection"]: """List the classic metric alert rules within a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 AlertRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResourceCollection] + :return: An iterator like instance of either AlertRuleResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] @@ -318,35 +297,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('AlertRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -359,17 +334,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Insights/alertrules'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -377,8 +354,10 @@ def list_by_subscription( """List the classic metric alert rules within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResourceCollection] + :return: An iterator like instance of either AlertRuleResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] @@ -386,34 +365,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-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_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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('AlertRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -426,12 +400,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_log_profiles_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_log_profiles_operations.py index 5c218a864c227..6247251a07ecf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_log_profiles_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_log_profiles_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._log_profiles_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request, build_update_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_async async def delete( self, log_profile_name: str, @@ -60,24 +66,16 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'logProfileName': self._serialize.url("log_profile_name", log_profile_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + log_profile_name=log_profile_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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 @@ -90,6 +88,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}'} # type: ignore + + @distributed_trace_async async def get( self, log_profile_name: str, @@ -109,32 +109,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'logProfileName': self._serialize.url("log_profile_name", log_profile_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + log_profile_name=log_profile_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('LogProfileResource', pipeline_response) @@ -143,8 +133,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, log_profile_name: str, @@ -167,31 +160,21 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-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 = { - 'logProfileName': self._serialize.url("log_profile_name", log_profile_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'LogProfileResource') + + request = build_create_or_update_request( + log_profile_name=log_profile_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'LogProfileResource') - 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 @@ -205,8 +188,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}'} # type: ignore + + @distributed_trace_async async def update( self, log_profile_name: str, @@ -218,7 +204,8 @@ async def update( :param log_profile_name: The name of the log profile. :type log_profile_name: str :param log_profiles_resource: Parameters supplied to the operation. - :type log_profiles_resource: ~$(python-base-namespace).v2016_03_01.models.LogProfileResourcePatch + :type log_profiles_resource: + ~$(python-base-namespace).v2016_03_01.models.LogProfileResourcePatch :keyword callable cls: A custom type or function that will be passed the direct response :return: LogProfileResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource @@ -229,37 +216,27 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-01" - 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), - 'logProfileName': self._serialize.url("log_profile_name", log_profile_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(log_profiles_resource, 'LogProfileResourcePatch') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + log_profile_name=log_profile_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(log_profiles_resource, 'LogProfileResourcePatch') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('LogProfileResource', pipeline_response) @@ -268,8 +245,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -277,8 +257,10 @@ def list( """List the log profiles. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogProfileCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.LogProfileCollection] + :return: An iterator like instance of either LogProfileCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.LogProfileCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LogProfileCollection"] @@ -286,34 +268,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_list_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('LogProfileCollection', pipeline_response) + deserialized = self._deserialize("LogProfileCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -331,6 +308,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_metric_definitions_operations.py index 12bbcf4c9cc12..f198e2f4c7b63 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/aio/operations/_metric_definitions_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._metric_definitions_operations import build_list_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 list( self, resource_uri: str, @@ -59,8 +65,10 @@ def list( other syntax is allowed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.MetricDefinitionCollection] + :return: An iterator like instance of either MetricDefinitionCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_03_01.models.MetricDefinitionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionCollection"] @@ -68,36 +76,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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 filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + template_url=self.list.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_list_request( + resource_uri=resource_uri, + filter=filter, + 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('MetricDefinitionCollection', pipeline_response) + deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,12 +113,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models.py index d737ca3227e16..aba1f7da2f0a1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models.py @@ -23,10 +23,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -48,6 +48,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -69,26 +75,26 @@ class AlertRuleResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param name_properties_name: Required. the name of the alert rule. - :type name_properties_name: str - :param description: the description of the alert rule that will be included in the alert email. - :type description: str - :param provisioning_state: the provisioning state. - :type provisioning_state: str - :param is_enabled: Required. the flag that indicates whether the alert rule is enabled. - :type is_enabled: bool - :param condition: Required. the condition that results in the alert rule being activated. - :type condition: ~$(python-base-namespace).v2016_03_01.models.RuleCondition - :param action: action that is performed when the alert rule becomes active, and when an alert + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar name_properties_name: Required. the name of the alert rule. + :vartype name_properties_name: str + :ivar description: the description of the alert rule that will be included in the alert email. + :vartype description: str + :ivar provisioning_state: the provisioning state. + :vartype provisioning_state: str + :ivar is_enabled: Required. the flag that indicates whether the alert rule is enabled. + :vartype is_enabled: bool + :ivar condition: Required. the condition that results in the alert rule being activated. + :vartype condition: ~$(python-base-namespace).v2016_03_01.models.RuleCondition + :ivar action: action that is performed when the alert rule becomes active, and when an alert condition is resolved. - :type action: ~$(python-base-namespace).v2016_03_01.models.RuleAction - :param actions: the array of actions that are performed when the alert rule becomes active, and + :vartype action: ~$(python-base-namespace).v2016_03_01.models.RuleAction + :ivar actions: the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. - :type actions: list[~$(python-base-namespace).v2016_03_01.models.RuleAction] + :vartype actions: list[~$(python-base-namespace).v2016_03_01.models.RuleAction] :ivar last_updated_time: Last time the rule was updated in ISO8601 format. :vartype last_updated_time: ~datetime.datetime """ @@ -124,6 +130,29 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword name_properties_name: Required. the name of the alert rule. + :paramtype name_properties_name: str + :keyword description: the description of the alert rule that will be included in the alert + email. + :paramtype description: str + :keyword provisioning_state: the provisioning state. + :paramtype provisioning_state: str + :keyword is_enabled: Required. the flag that indicates whether the alert rule is enabled. + :paramtype is_enabled: bool + :keyword condition: Required. the condition that results in the alert rule being activated. + :paramtype condition: ~$(python-base-namespace).v2016_03_01.models.RuleCondition + :keyword action: action that is performed when the alert rule becomes active, and when an alert + condition is resolved. + :paramtype action: ~$(python-base-namespace).v2016_03_01.models.RuleAction + :keyword actions: the array of actions that are performed when the alert rule becomes active, + and when an alert condition is resolved. + :paramtype actions: list[~$(python-base-namespace).v2016_03_01.models.RuleAction] + """ super(AlertRuleResource, self).__init__(**kwargs) self.name_properties_name = kwargs['name_properties_name'] self.description = kwargs.get('description', None) @@ -138,8 +167,8 @@ def __init__( class AlertRuleResourceCollection(msrest.serialization.Model): """Represents a collection of alert rule resources. - :param value: the values for the alert rule resources. - :type value: list[~$(python-base-namespace).v2016_03_01.models.AlertRuleResource] + :ivar value: the values for the alert rule resources. + :vartype value: list[~$(python-base-namespace).v2016_03_01.models.AlertRuleResource] """ _attribute_map = { @@ -150,6 +179,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: the values for the alert rule resources. + :paramtype value: list[~$(python-base-namespace).v2016_03_01.models.AlertRuleResource] + """ super(AlertRuleResourceCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -159,24 +192,24 @@ class AlertRuleResourcePatch(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param name: the name of the alert rule. - :type name: str - :param description: the description of the alert rule that will be included in the alert email. - :type description: str - :param provisioning_state: the provisioning state. - :type provisioning_state: str - :param is_enabled: the flag that indicates whether the alert rule is enabled. - :type is_enabled: bool - :param condition: the condition that results in the alert rule being activated. - :type condition: ~$(python-base-namespace).v2016_03_01.models.RuleCondition - :param action: action that is performed when the alert rule becomes active, and when an alert + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar name: the name of the alert rule. + :vartype name: str + :ivar description: the description of the alert rule that will be included in the alert email. + :vartype description: str + :ivar provisioning_state: the provisioning state. + :vartype provisioning_state: str + :ivar is_enabled: the flag that indicates whether the alert rule is enabled. + :vartype is_enabled: bool + :ivar condition: the condition that results in the alert rule being activated. + :vartype condition: ~$(python-base-namespace).v2016_03_01.models.RuleCondition + :ivar action: action that is performed when the alert rule becomes active, and when an alert condition is resolved. - :type action: ~$(python-base-namespace).v2016_03_01.models.RuleAction - :param actions: the array of actions that are performed when the alert rule becomes active, and + :vartype action: ~$(python-base-namespace).v2016_03_01.models.RuleAction + :ivar actions: the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. - :type actions: list[~$(python-base-namespace).v2016_03_01.models.RuleAction] + :vartype actions: list[~$(python-base-namespace).v2016_03_01.models.RuleAction] :ivar last_updated_time: Last time the rule was updated in ISO8601 format. :vartype last_updated_time: ~datetime.datetime """ @@ -201,6 +234,27 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword name: the name of the alert rule. + :paramtype name: str + :keyword description: the description of the alert rule that will be included in the alert + email. + :paramtype description: str + :keyword provisioning_state: the provisioning state. + :paramtype provisioning_state: str + :keyword is_enabled: the flag that indicates whether the alert rule is enabled. + :paramtype is_enabled: bool + :keyword condition: the condition that results in the alert rule being activated. + :paramtype condition: ~$(python-base-namespace).v2016_03_01.models.RuleCondition + :keyword action: action that is performed when the alert rule becomes active, and when an alert + condition is resolved. + :paramtype action: ~$(python-base-namespace).v2016_03_01.models.RuleAction + :keyword actions: the array of actions that are performed when the alert rule becomes active, + and when an alert condition is resolved. + :paramtype actions: list[~$(python-base-namespace).v2016_03_01.models.RuleAction] + """ super(AlertRuleResourcePatch, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.name = kwargs.get('name', None) @@ -216,10 +270,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -231,6 +285,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -274,6 +334,8 @@ def __init__( self, **kwargs ): + """ + """ super(Incident, self).__init__(**kwargs) self.name = None self.rule_name = None @@ -285,8 +347,8 @@ def __init__( class IncidentListResult(msrest.serialization.Model): """The List incidents operation response. - :param value: the incident collection. - :type value: list[~$(python-base-namespace).v2016_03_01.models.Incident] + :ivar value: the incident collection. + :vartype value: list[~$(python-base-namespace).v2016_03_01.models.Incident] """ _attribute_map = { @@ -297,6 +359,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: the incident collection. + :paramtype value: list[~$(python-base-namespace).v2016_03_01.models.Incident] + """ super(IncidentListResult, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -306,10 +372,10 @@ class LocalizableString(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the invariant value. - :type value: str - :param localized_value: the locale specific value. - :type localized_value: str + :ivar value: Required. the invariant value. + :vartype value: str + :ivar localized_value: the locale specific value. + :vartype localized_value: str """ _validation = { @@ -325,6 +391,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. the invariant value. + :paramtype value: str + :keyword localized_value: the locale specific value. + :paramtype localized_value: str + """ super(LocalizableString, self).__init__(**kwargs) self.value = kwargs['value'] self.localized_value = kwargs.get('localized_value', None) @@ -338,14 +410,14 @@ class RuleCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource """ _validation = { @@ -365,6 +437,11 @@ def __init__( self, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource + """ super(RuleCondition, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] self.data_source = kwargs.get('data_source', None) @@ -375,21 +452,21 @@ class LocationThresholdRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. - :type window_size: ~datetime.timedelta - :param failed_location_count: Required. the number of locations that must fail to activate the + :vartype window_size: ~datetime.timedelta + :ivar failed_location_count: Required. the number of locations that must fail to activate the alert. - :type failed_location_count: int + :vartype failed_location_count: int """ _validation = { @@ -408,6 +485,18 @@ def __init__( self, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. If specified then it must be between 5 minutes and 1 + day. + :paramtype window_size: ~datetime.timedelta + :keyword failed_location_count: Required. the number of locations that must fail to activate + the alert. + :paramtype failed_location_count: int + """ super(LocationThresholdRuleCondition, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition' # type: str self.window_size = kwargs.get('window_size', None) @@ -419,8 +508,8 @@ class LogProfileCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the values of the log profiles. - :type value: list[~$(python-base-namespace).v2016_03_01.models.LogProfileResource] + :ivar value: Required. the values of the log profiles. + :vartype value: list[~$(python-base-namespace).v2016_03_01.models.LogProfileResource] """ _validation = { @@ -435,6 +524,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. the values of the log profiles. + :paramtype value: list[~$(python-base-namespace).v2016_03_01.models.LogProfileResource] + """ super(LogProfileCollection, self).__init__(**kwargs) self.value = kwargs['value'] @@ -452,25 +545,25 @@ class LogProfileResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param storage_account_id: the resource id of the storage account to which you would like to + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar storage_account_id: the resource id of the storage account to which you would like to send the Activity Log. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. - :type service_bus_rule_id: str - :param locations: Required. List of regions for which Activity Log events should be stored or + :vartype service_bus_rule_id: str + :ivar locations: Required. List of regions for which Activity Log events should be stored or streamed. It is a comma separated list of valid ARM locations including the 'global' location. - :type locations: list[str] - :param categories: Required. the categories of the logs. These categories are created as is + :vartype locations: list[str] + :ivar categories: Required. the categories of the logs. These categories are created as is convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. - :type categories: list[str] - :param retention_policy: Required. the retention policy for the events in the log. - :type retention_policy: ~$(python-base-namespace).v2016_03_01.models.RetentionPolicy + :vartype categories: list[str] + :ivar retention_policy: Required. the retention policy for the events in the log. + :vartype retention_policy: ~$(python-base-namespace).v2016_03_01.models.RetentionPolicy """ _validation = { @@ -500,6 +593,27 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword storage_account_id: the resource id of the storage account to which you would like to + send the Activity Log. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the + format: '{service bus resource ID}/authorizationrules/{key name}'. + :paramtype service_bus_rule_id: str + :keyword locations: Required. List of regions for which Activity Log events should be stored or + streamed. It is a comma separated list of valid ARM locations including the 'global' location. + :paramtype locations: list[str] + :keyword categories: Required. the categories of the logs. These categories are created as is + convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. + :paramtype categories: list[str] + :keyword retention_policy: Required. the retention policy for the events in the log. + :paramtype retention_policy: ~$(python-base-namespace).v2016_03_01.models.RetentionPolicy + """ super(LogProfileResource, self).__init__(**kwargs) self.storage_account_id = kwargs.get('storage_account_id', None) self.service_bus_rule_id = kwargs.get('service_bus_rule_id', None) @@ -511,23 +625,23 @@ def __init__( class LogProfileResourcePatch(msrest.serialization.Model): """The log profile resource for patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param storage_account_id: the resource id of the storage account to which you would like to + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar storage_account_id: the resource id of the storage account to which you would like to send the Activity Log. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. - :type service_bus_rule_id: str - :param locations: List of regions for which Activity Log events should be stored or streamed. - It is a comma separated list of valid ARM locations including the 'global' location. - :type locations: list[str] - :param categories: the categories of the logs. These categories are created as is convenient to + :vartype service_bus_rule_id: str + :ivar locations: List of regions for which Activity Log events should be stored or streamed. It + is a comma separated list of valid ARM locations including the 'global' location. + :vartype locations: list[str] + :ivar categories: the categories of the logs. These categories are created as is convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. - :type categories: list[str] - :param retention_policy: the retention policy for the events in the log. - :type retention_policy: ~$(python-base-namespace).v2016_03_01.models.RetentionPolicy + :vartype categories: list[str] + :ivar retention_policy: the retention policy for the events in the log. + :vartype retention_policy: ~$(python-base-namespace).v2016_03_01.models.RetentionPolicy """ _attribute_map = { @@ -543,6 +657,25 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword storage_account_id: the resource id of the storage account to which you would like to + send the Activity Log. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the + format: '{service bus resource ID}/authorizationrules/{key name}'. + :paramtype service_bus_rule_id: str + :keyword locations: List of regions for which Activity Log events should be stored or streamed. + It is a comma separated list of valid ARM locations including the 'global' location. + :paramtype locations: list[str] + :keyword categories: the categories of the logs. These categories are created as is convenient + to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. + :paramtype categories: list[str] + :keyword retention_policy: the retention policy for the events in the log. + :paramtype retention_policy: ~$(python-base-namespace).v2016_03_01.models.RetentionPolicy + """ super(LogProfileResourcePatch, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.storage_account_id = kwargs.get('storage_account_id', None) @@ -555,15 +688,15 @@ def __init__( class ManagementEventAggregationCondition(msrest.serialization.Model): """How the data that is collected should be combined over time. - :param operator: the condition operator. Possible values include: "GreaterThan", + :ivar operator: the condition operator. Possible values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator - :param threshold: The threshold value that activates the alert. - :type threshold: float - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator + :ivar threshold: The threshold value that activates the alert. + :vartype threshold: float + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. - :type window_size: ~datetime.timedelta + :vartype window_size: ~datetime.timedelta """ _attribute_map = { @@ -576,6 +709,17 @@ def __init__( self, **kwargs ): + """ + :keyword operator: the condition operator. Possible values include: "GreaterThan", + "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :paramtype operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator + :keyword threshold: The threshold value that activates the alert. + :paramtype threshold: float + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. If specified then it must be between 5 minutes and 1 + day. + :paramtype window_size: ~datetime.timedelta + """ super(ManagementEventAggregationCondition, self).__init__(**kwargs) self.operator = kwargs.get('operator', None) self.threshold = kwargs.get('threshold', None) @@ -587,18 +731,18 @@ class ManagementEventRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource - :param aggregation: How the data that is collected should be combined over time and when the + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource + :ivar aggregation: How the data that is collected should be combined over time and when the alert is activated. Note that for management event alerts aggregation is optional – if it is not provided then any event will cause the alert to activate. - :type aggregation: + :vartype aggregation: ~$(python-base-namespace).v2016_03_01.models.ManagementEventAggregationCondition """ @@ -616,6 +760,16 @@ def __init__( self, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource + :keyword aggregation: How the data that is collected should be combined over time and when the + alert is activated. Note that for management event alerts aggregation is optional – if it is + not provided then any event will cause the alert to activate. + :paramtype aggregation: + ~$(python-base-namespace).v2016_03_01.models.ManagementEventAggregationCondition + """ super(ManagementEventRuleCondition, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition' # type: str self.aggregation = kwargs.get('aggregation', None) @@ -624,12 +778,12 @@ def __init__( class MetricAvailability(msrest.serialization.Model): """Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. - :param time_grain: the time grain specifies the aggregation interval for the metric. Expressed + :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. - :type time_grain: ~datetime.timedelta - :param retention: the retention period for the metric at the specified timegrain. Expressed as + :vartype time_grain: ~datetime.timedelta + :ivar retention: the retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc. - :type retention: ~datetime.timedelta + :vartype retention: ~datetime.timedelta """ _attribute_map = { @@ -641,6 +795,14 @@ def __init__( self, **kwargs ): + """ + :keyword time_grain: the time grain specifies the aggregation interval for the metric. + Expressed as a duration 'PT1M', 'P1D', etc. + :paramtype time_grain: ~datetime.timedelta + :keyword retention: the retention period for the metric at the specified timegrain. Expressed + as a duration 'PT1M', 'P1D', etc. + :paramtype retention: ~datetime.timedelta + """ super(MetricAvailability, self).__init__(**kwargs) self.time_grain = kwargs.get('time_grain', None) self.retention = kwargs.get('retention', None) @@ -649,25 +811,25 @@ def __init__( class MetricDefinition(msrest.serialization.Model): """Metric definition class specifies the metadata for a metric. - :param resource_id: the resource identifier of the resource that emitted the metric. - :type resource_id: str - :param name: the name and the display name of the metric, i.e. it is a localizable string. - :type name: ~$(python-base-namespace).v2016_03_01.models.LocalizableString - :param unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + :ivar resource_id: the resource identifier of the resource that emitted the metric. + :vartype resource_id: str + :ivar name: the name and the display name of the metric, i.e. it is a localizable string. + :vartype name: ~$(python-base-namespace).v2016_03_01.models.LocalizableString + :ivar unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". - :type unit: str or ~$(python-base-namespace).v2016_03_01.models.Unit - :param primary_aggregation_type: the primary aggregation type value defining how to use the + :vartype unit: str or ~$(python-base-namespace).v2016_03_01.models.Unit + :ivar primary_aggregation_type: the primary aggregation type value defining how to use the values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", "Total". - :type primary_aggregation_type: str or + :vartype primary_aggregation_type: str or ~$(python-base-namespace).v2016_03_01.models.AggregationType - :param metric_availabilities: the collection of what aggregation intervals are available to be + :ivar metric_availabilities: the collection of what aggregation intervals are available to be queried. - :type metric_availabilities: + :vartype metric_availabilities: list[~$(python-base-namespace).v2016_03_01.models.MetricAvailability] - :param id: the resource identifier of the metric definition. - :type id: str + :ivar id: the resource identifier of the metric definition. + :vartype id: str """ _attribute_map = { @@ -683,6 +845,27 @@ def __init__( self, **kwargs ): + """ + :keyword resource_id: the resource identifier of the resource that emitted the metric. + :paramtype resource_id: str + :keyword name: the name and the display name of the metric, i.e. it is a localizable string. + :paramtype name: ~$(python-base-namespace).v2016_03_01.models.LocalizableString + :keyword unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", + "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + :paramtype unit: str or ~$(python-base-namespace).v2016_03_01.models.Unit + :keyword primary_aggregation_type: the primary aggregation type value defining how to use the + values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", + "Total". + :paramtype primary_aggregation_type: str or + ~$(python-base-namespace).v2016_03_01.models.AggregationType + :keyword metric_availabilities: the collection of what aggregation intervals are available to + be queried. + :paramtype metric_availabilities: + list[~$(python-base-namespace).v2016_03_01.models.MetricAvailability] + :keyword id: the resource identifier of the metric definition. + :paramtype id: str + """ super(MetricDefinition, self).__init__(**kwargs) self.resource_id = kwargs.get('resource_id', None) self.name = kwargs.get('name', None) @@ -697,8 +880,8 @@ class MetricDefinitionCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the values for the metric definitions. - :type value: list[~$(python-base-namespace).v2016_03_01.models.MetricDefinition] + :ivar value: Required. the values for the metric definitions. + :vartype value: list[~$(python-base-namespace).v2016_03_01.models.MetricDefinition] """ _validation = { @@ -713,6 +896,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. the values for the metric definitions. + :paramtype value: list[~$(python-base-namespace).v2016_03_01.models.MetricDefinition] + """ super(MetricDefinitionCollection, self).__init__(**kwargs) self.value = kwargs['value'] @@ -722,11 +909,11 @@ class RetentionPolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param enabled: Required. a value indicating whether the retention policy is enabled. - :type enabled: bool - :param days: Required. the number of days for the retention in days. A value of 0 will retain + :ivar enabled: Required. a value indicating whether the retention policy is enabled. + :vartype enabled: bool + :ivar days: Required. the number of days for the retention in days. A value of 0 will retain the events indefinitely. - :type days: int + :vartype days: int """ _validation = { @@ -743,6 +930,13 @@ def __init__( self, **kwargs ): + """ + :keyword enabled: Required. a value indicating whether the retention policy is enabled. + :paramtype enabled: bool + :keyword days: Required. the number of days for the retention in days. A value of 0 will retain + the events indefinitely. + :paramtype days: int + """ super(RetentionPolicy, self).__init__(**kwargs) self.enabled = kwargs['enabled'] self.days = kwargs['days'] @@ -756,9 +950,9 @@ class RuleAction(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of the action. There are two types of actions: + :ivar odata_type: Required. specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str + :vartype odata_type: str """ _validation = { @@ -777,6 +971,8 @@ def __init__( self, **kwargs ): + """ + """ super(RuleAction, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] @@ -789,19 +985,19 @@ class RuleDataSource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of data source. There are two types of rule - data sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. - :type odata_type: str - :param resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :type resource_uri: str - :param legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + :ivar odata_type: Required. specifies the type of data source. There are two types of rule data + sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :vartype odata_type: str + :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this + property cannot be updated for an existing rule. + :vartype resource_uri: str + :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. - :type legacy_resource_id: str - :param resource_location: the location of the resource. - :type resource_location: str - :param metric_namespace: the namespace of the metric. - :type metric_namespace: str + :vartype legacy_resource_id: str + :ivar resource_location: the location of the resource. + :vartype resource_location: str + :ivar metric_namespace: the namespace of the metric. + :vartype metric_namespace: str """ _validation = { @@ -824,6 +1020,18 @@ def __init__( self, **kwargs ): + """ + :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : + this property cannot be updated for an existing rule. + :paramtype resource_uri: str + :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + **NOTE**\ : this property cannot be updated for an existing rule. + :paramtype legacy_resource_id: str + :keyword resource_location: the location of the resource. + :paramtype resource_location: str + :keyword metric_namespace: the namespace of the metric. + :paramtype metric_namespace: str + """ super(RuleDataSource, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] self.resource_uri = kwargs.get('resource_uri', None) @@ -837,15 +1045,15 @@ class RuleEmailAction(RuleAction): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of the action. There are two types of actions: + :ivar odata_type: Required. specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str - :param send_to_service_owners: Whether the administrators (service and co-administrators) of - the service should be notified when the alert is activated. - :type send_to_service_owners: bool - :param custom_emails: the list of administrator's custom email addresses to notify of the + :vartype odata_type: str + :ivar send_to_service_owners: Whether the administrators (service and co-administrators) of the + service should be notified when the alert is activated. + :vartype send_to_service_owners: bool + :ivar custom_emails: the list of administrator's custom email addresses to notify of the activation of the alert. - :type custom_emails: list[str] + :vartype custom_emails: list[str] """ _validation = { @@ -862,6 +1070,14 @@ def __init__( self, **kwargs ): + """ + :keyword send_to_service_owners: Whether the administrators (service and co-administrators) of + the service should be notified when the alert is activated. + :paramtype send_to_service_owners: bool + :keyword custom_emails: the list of administrator's custom email addresses to notify of the + activation of the alert. + :paramtype custom_emails: list[str] + """ super(RuleEmailAction, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleEmailAction' # type: str self.send_to_service_owners = kwargs.get('send_to_service_owners', None) @@ -871,8 +1087,8 @@ def __init__( class RuleManagementEventClaimsDataSource(msrest.serialization.Model): """The claims for a rule management event data source. - :param email_address: the email address. - :type email_address: str + :ivar email_address: the email address. + :vartype email_address: str """ _attribute_map = { @@ -883,6 +1099,10 @@ def __init__( self, **kwargs ): + """ + :keyword email_address: the email address. + :paramtype email_address: str + """ super(RuleManagementEventClaimsDataSource, self).__init__(**kwargs) self.email_address = kwargs.get('email_address', None) @@ -892,39 +1112,40 @@ class RuleManagementEventDataSource(RuleDataSource): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of data source. There are two types of rule - data sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. - :type odata_type: str - :param resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :type resource_uri: str - :param legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + :ivar odata_type: Required. specifies the type of data source. There are two types of rule data + sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :vartype odata_type: str + :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this + property cannot be updated for an existing rule. + :vartype resource_uri: str + :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. - :type legacy_resource_id: str - :param resource_location: the location of the resource. - :type resource_location: str - :param metric_namespace: the namespace of the metric. - :type metric_namespace: str - :param event_name: the event name. - :type event_name: str - :param event_source: the event source. - :type event_source: str - :param level: the level. - :type level: str - :param operation_name: The name of the operation that should be checked for. If no name is + :vartype legacy_resource_id: str + :ivar resource_location: the location of the resource. + :vartype resource_location: str + :ivar metric_namespace: the namespace of the metric. + :vartype metric_namespace: str + :ivar event_name: the event name. + :vartype event_name: str + :ivar event_source: the event source. + :vartype event_source: str + :ivar level: the level. + :vartype level: str + :ivar operation_name: The name of the operation that should be checked for. If no name is provided, any operation will match. - :type operation_name: str - :param resource_group_name: the resource group name. - :type resource_group_name: str - :param resource_provider_name: the resource provider name. - :type resource_provider_name: str - :param status: The status of the operation that should be checked for. If no status is - provided, any status will match. - :type status: str - :param sub_status: the substatus. - :type sub_status: str - :param claims: the claims. - :type claims: ~$(python-base-namespace).v2016_03_01.models.RuleManagementEventClaimsDataSource + :vartype operation_name: str + :ivar resource_group_name: the resource group name. + :vartype resource_group_name: str + :ivar resource_provider_name: the resource provider name. + :vartype resource_provider_name: str + :ivar status: The status of the operation that should be checked for. If no status is provided, + any status will match. + :vartype status: str + :ivar sub_status: the substatus. + :vartype sub_status: str + :ivar claims: the claims. + :vartype claims: + ~$(python-base-namespace).v2016_03_01.models.RuleManagementEventClaimsDataSource """ _validation = { @@ -952,6 +1173,39 @@ def __init__( self, **kwargs ): + """ + :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : + this property cannot be updated for an existing rule. + :paramtype resource_uri: str + :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + **NOTE**\ : this property cannot be updated for an existing rule. + :paramtype legacy_resource_id: str + :keyword resource_location: the location of the resource. + :paramtype resource_location: str + :keyword metric_namespace: the namespace of the metric. + :paramtype metric_namespace: str + :keyword event_name: the event name. + :paramtype event_name: str + :keyword event_source: the event source. + :paramtype event_source: str + :keyword level: the level. + :paramtype level: str + :keyword operation_name: The name of the operation that should be checked for. If no name is + provided, any operation will match. + :paramtype operation_name: str + :keyword resource_group_name: the resource group name. + :paramtype resource_group_name: str + :keyword resource_provider_name: the resource provider name. + :paramtype resource_provider_name: str + :keyword status: The status of the operation that should be checked for. If no status is + provided, any status will match. + :paramtype status: str + :keyword sub_status: the substatus. + :paramtype sub_status: str + :keyword claims: the claims. + :paramtype claims: + ~$(python-base-namespace).v2016_03_01.models.RuleManagementEventClaimsDataSource + """ super(RuleManagementEventDataSource, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource' # type: str self.event_name = kwargs.get('event_name', None) @@ -970,21 +1224,21 @@ class RuleMetricDataSource(RuleDataSource): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of data source. There are two types of rule - data sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. - :type odata_type: str - :param resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :type resource_uri: str - :param legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + :ivar odata_type: Required. specifies the type of data source. There are two types of rule data + sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :vartype odata_type: str + :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this + property cannot be updated for an existing rule. + :vartype resource_uri: str + :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. - :type legacy_resource_id: str - :param resource_location: the location of the resource. - :type resource_location: str - :param metric_namespace: the namespace of the metric. - :type metric_namespace: str - :param metric_name: the name of the metric that defines what the rule monitors. - :type metric_name: str + :vartype legacy_resource_id: str + :ivar resource_location: the location of the resource. + :vartype resource_location: str + :ivar metric_namespace: the namespace of the metric. + :vartype metric_namespace: str + :ivar metric_name: the name of the metric that defines what the rule monitors. + :vartype metric_name: str """ _validation = { @@ -1004,6 +1258,20 @@ def __init__( self, **kwargs ): + """ + :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : + this property cannot be updated for an existing rule. + :paramtype resource_uri: str + :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + **NOTE**\ : this property cannot be updated for an existing rule. + :paramtype legacy_resource_id: str + :keyword resource_location: the location of the resource. + :paramtype resource_location: str + :keyword metric_namespace: the namespace of the metric. + :paramtype metric_namespace: str + :keyword metric_name: the name of the metric that defines what the rule monitors. + :paramtype metric_name: str + """ super(RuleMetricDataSource, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource' # type: str self.metric_name = kwargs.get('metric_name', None) @@ -1014,15 +1282,15 @@ class RuleWebhookAction(RuleAction): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of the action. There are two types of actions: + :ivar odata_type: Required. specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str - :param service_uri: the service uri to Post the notification when the alert activates or + :vartype odata_type: str + :ivar service_uri: the service uri to Post the notification when the alert activates or resolves. - :type service_uri: str - :param properties: the dictionary of custom properties to include with the post operation. - These data are appended to the webhook payload. - :type properties: dict[str, str] + :vartype service_uri: str + :ivar properties: the dictionary of custom properties to include with the post operation. These + data are appended to the webhook payload. + :vartype properties: dict[str, str] """ _validation = { @@ -1039,6 +1307,14 @@ def __init__( self, **kwargs ): + """ + :keyword service_uri: the service uri to Post the notification when the alert activates or + resolves. + :paramtype service_uri: str + :keyword properties: the dictionary of custom properties to include with the post operation. + These data are appended to the webhook payload. + :paramtype properties: dict[str, str] + """ super(RuleWebhookAction, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction' # type: str self.service_uri = kwargs.get('service_uri', None) @@ -1050,27 +1326,27 @@ class ThresholdRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource - :param operator: Required. the operator used to compare the data and the threshold. Possible + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource + :ivar operator: Required. the operator used to compare the data and the threshold. Possible values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator - :param threshold: Required. the threshold value that activates the alert. - :type threshold: float - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator + :ivar threshold: Required. the threshold value that activates the alert. + :vartype threshold: float + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. - :type window_size: ~datetime.timedelta - :param time_aggregation: the time aggregation operator. How the data that are collected should + :vartype window_size: ~datetime.timedelta + :ivar time_aggregation: the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. Possible values include: "Average", "Minimum", "Maximum", "Total", "Last". - :type time_aggregation: str or + :vartype time_aggregation: str or ~$(python-base-namespace).v2016_03_01.models.TimeAggregationOperator """ @@ -1093,6 +1369,25 @@ def __init__( self, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource + :keyword operator: Required. the operator used to compare the data and the threshold. Possible + values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :paramtype operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator + :keyword threshold: Required. the threshold value that activates the alert. + :paramtype threshold: float + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. If specified then it must be between 5 minutes and 1 + day. + :paramtype window_size: ~datetime.timedelta + :keyword time_aggregation: the time aggregation operator. How the data that are collected + should be combined over time. The default value is the PrimaryAggregationType of the Metric. + Possible values include: "Average", "Minimum", "Maximum", "Total", "Last". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2016_03_01.models.TimeAggregationOperator + """ super(ThresholdRuleCondition, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition' # type: str self.operator = kwargs['operator'] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models_py3.py index f9a35585fc3af..abb472b8f34a7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_models_py3.py @@ -28,10 +28,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -56,6 +56,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -77,26 +83,26 @@ class AlertRuleResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param name_properties_name: Required. the name of the alert rule. - :type name_properties_name: str - :param description: the description of the alert rule that will be included in the alert email. - :type description: str - :param provisioning_state: the provisioning state. - :type provisioning_state: str - :param is_enabled: Required. the flag that indicates whether the alert rule is enabled. - :type is_enabled: bool - :param condition: Required. the condition that results in the alert rule being activated. - :type condition: ~$(python-base-namespace).v2016_03_01.models.RuleCondition - :param action: action that is performed when the alert rule becomes active, and when an alert + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar name_properties_name: Required. the name of the alert rule. + :vartype name_properties_name: str + :ivar description: the description of the alert rule that will be included in the alert email. + :vartype description: str + :ivar provisioning_state: the provisioning state. + :vartype provisioning_state: str + :ivar is_enabled: Required. the flag that indicates whether the alert rule is enabled. + :vartype is_enabled: bool + :ivar condition: Required. the condition that results in the alert rule being activated. + :vartype condition: ~$(python-base-namespace).v2016_03_01.models.RuleCondition + :ivar action: action that is performed when the alert rule becomes active, and when an alert condition is resolved. - :type action: ~$(python-base-namespace).v2016_03_01.models.RuleAction - :param actions: the array of actions that are performed when the alert rule becomes active, and + :vartype action: ~$(python-base-namespace).v2016_03_01.models.RuleAction + :ivar actions: the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. - :type actions: list[~$(python-base-namespace).v2016_03_01.models.RuleAction] + :vartype actions: list[~$(python-base-namespace).v2016_03_01.models.RuleAction] :ivar last_updated_time: Last time the rule was updated in ISO8601 format. :vartype last_updated_time: ~datetime.datetime """ @@ -142,6 +148,29 @@ def __init__( actions: Optional[List["RuleAction"]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword name_properties_name: Required. the name of the alert rule. + :paramtype name_properties_name: str + :keyword description: the description of the alert rule that will be included in the alert + email. + :paramtype description: str + :keyword provisioning_state: the provisioning state. + :paramtype provisioning_state: str + :keyword is_enabled: Required. the flag that indicates whether the alert rule is enabled. + :paramtype is_enabled: bool + :keyword condition: Required. the condition that results in the alert rule being activated. + :paramtype condition: ~$(python-base-namespace).v2016_03_01.models.RuleCondition + :keyword action: action that is performed when the alert rule becomes active, and when an alert + condition is resolved. + :paramtype action: ~$(python-base-namespace).v2016_03_01.models.RuleAction + :keyword actions: the array of actions that are performed when the alert rule becomes active, + and when an alert condition is resolved. + :paramtype actions: list[~$(python-base-namespace).v2016_03_01.models.RuleAction] + """ super(AlertRuleResource, self).__init__(location=location, tags=tags, **kwargs) self.name_properties_name = name_properties_name self.description = description @@ -156,8 +185,8 @@ def __init__( class AlertRuleResourceCollection(msrest.serialization.Model): """Represents a collection of alert rule resources. - :param value: the values for the alert rule resources. - :type value: list[~$(python-base-namespace).v2016_03_01.models.AlertRuleResource] + :ivar value: the values for the alert rule resources. + :vartype value: list[~$(python-base-namespace).v2016_03_01.models.AlertRuleResource] """ _attribute_map = { @@ -170,6 +199,10 @@ def __init__( value: Optional[List["AlertRuleResource"]] = None, **kwargs ): + """ + :keyword value: the values for the alert rule resources. + :paramtype value: list[~$(python-base-namespace).v2016_03_01.models.AlertRuleResource] + """ super(AlertRuleResourceCollection, self).__init__(**kwargs) self.value = value @@ -179,24 +212,24 @@ class AlertRuleResourcePatch(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param name: the name of the alert rule. - :type name: str - :param description: the description of the alert rule that will be included in the alert email. - :type description: str - :param provisioning_state: the provisioning state. - :type provisioning_state: str - :param is_enabled: the flag that indicates whether the alert rule is enabled. - :type is_enabled: bool - :param condition: the condition that results in the alert rule being activated. - :type condition: ~$(python-base-namespace).v2016_03_01.models.RuleCondition - :param action: action that is performed when the alert rule becomes active, and when an alert + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar name: the name of the alert rule. + :vartype name: str + :ivar description: the description of the alert rule that will be included in the alert email. + :vartype description: str + :ivar provisioning_state: the provisioning state. + :vartype provisioning_state: str + :ivar is_enabled: the flag that indicates whether the alert rule is enabled. + :vartype is_enabled: bool + :ivar condition: the condition that results in the alert rule being activated. + :vartype condition: ~$(python-base-namespace).v2016_03_01.models.RuleCondition + :ivar action: action that is performed when the alert rule becomes active, and when an alert condition is resolved. - :type action: ~$(python-base-namespace).v2016_03_01.models.RuleAction - :param actions: the array of actions that are performed when the alert rule becomes active, and + :vartype action: ~$(python-base-namespace).v2016_03_01.models.RuleAction + :ivar actions: the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. - :type actions: list[~$(python-base-namespace).v2016_03_01.models.RuleAction] + :vartype actions: list[~$(python-base-namespace).v2016_03_01.models.RuleAction] :ivar last_updated_time: Last time the rule was updated in ISO8601 format. :vartype last_updated_time: ~datetime.datetime """ @@ -230,6 +263,27 @@ def __init__( actions: Optional[List["RuleAction"]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword name: the name of the alert rule. + :paramtype name: str + :keyword description: the description of the alert rule that will be included in the alert + email. + :paramtype description: str + :keyword provisioning_state: the provisioning state. + :paramtype provisioning_state: str + :keyword is_enabled: the flag that indicates whether the alert rule is enabled. + :paramtype is_enabled: bool + :keyword condition: the condition that results in the alert rule being activated. + :paramtype condition: ~$(python-base-namespace).v2016_03_01.models.RuleCondition + :keyword action: action that is performed when the alert rule becomes active, and when an alert + condition is resolved. + :paramtype action: ~$(python-base-namespace).v2016_03_01.models.RuleAction + :keyword actions: the array of actions that are performed when the alert rule becomes active, + and when an alert condition is resolved. + :paramtype actions: list[~$(python-base-namespace).v2016_03_01.models.RuleAction] + """ super(AlertRuleResourcePatch, self).__init__(**kwargs) self.tags = tags self.name = name @@ -245,10 +299,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -263,6 +317,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -306,6 +366,8 @@ def __init__( self, **kwargs ): + """ + """ super(Incident, self).__init__(**kwargs) self.name = None self.rule_name = None @@ -317,8 +379,8 @@ def __init__( class IncidentListResult(msrest.serialization.Model): """The List incidents operation response. - :param value: the incident collection. - :type value: list[~$(python-base-namespace).v2016_03_01.models.Incident] + :ivar value: the incident collection. + :vartype value: list[~$(python-base-namespace).v2016_03_01.models.Incident] """ _attribute_map = { @@ -331,6 +393,10 @@ def __init__( value: Optional[List["Incident"]] = None, **kwargs ): + """ + :keyword value: the incident collection. + :paramtype value: list[~$(python-base-namespace).v2016_03_01.models.Incident] + """ super(IncidentListResult, self).__init__(**kwargs) self.value = value @@ -340,10 +406,10 @@ class LocalizableString(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the invariant value. - :type value: str - :param localized_value: the locale specific value. - :type localized_value: str + :ivar value: Required. the invariant value. + :vartype value: str + :ivar localized_value: the locale specific value. + :vartype localized_value: str """ _validation = { @@ -362,6 +428,12 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. the invariant value. + :paramtype value: str + :keyword localized_value: the locale specific value. + :paramtype localized_value: str + """ super(LocalizableString, self).__init__(**kwargs) self.value = value self.localized_value = localized_value @@ -375,14 +447,14 @@ class RuleCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource """ _validation = { @@ -404,6 +476,11 @@ def __init__( data_source: Optional["RuleDataSource"] = None, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource + """ super(RuleCondition, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] self.data_source = data_source @@ -414,21 +491,21 @@ class LocationThresholdRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. - :type window_size: ~datetime.timedelta - :param failed_location_count: Required. the number of locations that must fail to activate the + :vartype window_size: ~datetime.timedelta + :ivar failed_location_count: Required. the number of locations that must fail to activate the alert. - :type failed_location_count: int + :vartype failed_location_count: int """ _validation = { @@ -451,6 +528,18 @@ def __init__( window_size: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. If specified then it must be between 5 minutes and 1 + day. + :paramtype window_size: ~datetime.timedelta + :keyword failed_location_count: Required. the number of locations that must fail to activate + the alert. + :paramtype failed_location_count: int + """ super(LocationThresholdRuleCondition, self).__init__(data_source=data_source, **kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.LocationThresholdRuleCondition' # type: str self.window_size = window_size @@ -462,8 +551,8 @@ class LogProfileCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the values of the log profiles. - :type value: list[~$(python-base-namespace).v2016_03_01.models.LogProfileResource] + :ivar value: Required. the values of the log profiles. + :vartype value: list[~$(python-base-namespace).v2016_03_01.models.LogProfileResource] """ _validation = { @@ -480,6 +569,10 @@ def __init__( value: List["LogProfileResource"], **kwargs ): + """ + :keyword value: Required. the values of the log profiles. + :paramtype value: list[~$(python-base-namespace).v2016_03_01.models.LogProfileResource] + """ super(LogProfileCollection, self).__init__(**kwargs) self.value = value @@ -497,25 +590,25 @@ class LogProfileResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param storage_account_id: the resource id of the storage account to which you would like to + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar storage_account_id: the resource id of the storage account to which you would like to send the Activity Log. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. - :type service_bus_rule_id: str - :param locations: Required. List of regions for which Activity Log events should be stored or + :vartype service_bus_rule_id: str + :ivar locations: Required. List of regions for which Activity Log events should be stored or streamed. It is a comma separated list of valid ARM locations including the 'global' location. - :type locations: list[str] - :param categories: Required. the categories of the logs. These categories are created as is + :vartype locations: list[str] + :ivar categories: Required. the categories of the logs. These categories are created as is convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. - :type categories: list[str] - :param retention_policy: Required. the retention policy for the events in the log. - :type retention_policy: ~$(python-base-namespace).v2016_03_01.models.RetentionPolicy + :vartype categories: list[str] + :ivar retention_policy: Required. the retention policy for the events in the log. + :vartype retention_policy: ~$(python-base-namespace).v2016_03_01.models.RetentionPolicy """ _validation = { @@ -553,6 +646,27 @@ def __init__( service_bus_rule_id: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword storage_account_id: the resource id of the storage account to which you would like to + send the Activity Log. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the + format: '{service bus resource ID}/authorizationrules/{key name}'. + :paramtype service_bus_rule_id: str + :keyword locations: Required. List of regions for which Activity Log events should be stored or + streamed. It is a comma separated list of valid ARM locations including the 'global' location. + :paramtype locations: list[str] + :keyword categories: Required. the categories of the logs. These categories are created as is + convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. + :paramtype categories: list[str] + :keyword retention_policy: Required. the retention policy for the events in the log. + :paramtype retention_policy: ~$(python-base-namespace).v2016_03_01.models.RetentionPolicy + """ super(LogProfileResource, self).__init__(location=location, tags=tags, **kwargs) self.storage_account_id = storage_account_id self.service_bus_rule_id = service_bus_rule_id @@ -564,23 +678,23 @@ def __init__( class LogProfileResourcePatch(msrest.serialization.Model): """The log profile resource for patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param storage_account_id: the resource id of the storage account to which you would like to + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar storage_account_id: the resource id of the storage account to which you would like to send the Activity Log. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. - :type service_bus_rule_id: str - :param locations: List of regions for which Activity Log events should be stored or streamed. - It is a comma separated list of valid ARM locations including the 'global' location. - :type locations: list[str] - :param categories: the categories of the logs. These categories are created as is convenient to + :vartype service_bus_rule_id: str + :ivar locations: List of regions for which Activity Log events should be stored or streamed. It + is a comma separated list of valid ARM locations including the 'global' location. + :vartype locations: list[str] + :ivar categories: the categories of the logs. These categories are created as is convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. - :type categories: list[str] - :param retention_policy: the retention policy for the events in the log. - :type retention_policy: ~$(python-base-namespace).v2016_03_01.models.RetentionPolicy + :vartype categories: list[str] + :ivar retention_policy: the retention policy for the events in the log. + :vartype retention_policy: ~$(python-base-namespace).v2016_03_01.models.RetentionPolicy """ _attribute_map = { @@ -603,6 +717,25 @@ def __init__( retention_policy: Optional["RetentionPolicy"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword storage_account_id: the resource id of the storage account to which you would like to + send the Activity Log. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the + format: '{service bus resource ID}/authorizationrules/{key name}'. + :paramtype service_bus_rule_id: str + :keyword locations: List of regions for which Activity Log events should be stored or streamed. + It is a comma separated list of valid ARM locations including the 'global' location. + :paramtype locations: list[str] + :keyword categories: the categories of the logs. These categories are created as is convenient + to the user. Some values are: 'Write', 'Delete', and/or 'Action.'. + :paramtype categories: list[str] + :keyword retention_policy: the retention policy for the events in the log. + :paramtype retention_policy: ~$(python-base-namespace).v2016_03_01.models.RetentionPolicy + """ super(LogProfileResourcePatch, self).__init__(**kwargs) self.tags = tags self.storage_account_id = storage_account_id @@ -615,15 +748,15 @@ def __init__( class ManagementEventAggregationCondition(msrest.serialization.Model): """How the data that is collected should be combined over time. - :param operator: the condition operator. Possible values include: "GreaterThan", + :ivar operator: the condition operator. Possible values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator - :param threshold: The threshold value that activates the alert. - :type threshold: float - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator + :ivar threshold: The threshold value that activates the alert. + :vartype threshold: float + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. - :type window_size: ~datetime.timedelta + :vartype window_size: ~datetime.timedelta """ _attribute_map = { @@ -640,6 +773,17 @@ def __init__( window_size: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword operator: the condition operator. Possible values include: "GreaterThan", + "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :paramtype operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator + :keyword threshold: The threshold value that activates the alert. + :paramtype threshold: float + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. If specified then it must be between 5 minutes and 1 + day. + :paramtype window_size: ~datetime.timedelta + """ super(ManagementEventAggregationCondition, self).__init__(**kwargs) self.operator = operator self.threshold = threshold @@ -651,18 +795,18 @@ class ManagementEventRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource - :param aggregation: How the data that is collected should be combined over time and when the + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource + :ivar aggregation: How the data that is collected should be combined over time and when the alert is activated. Note that for management event alerts aggregation is optional – if it is not provided then any event will cause the alert to activate. - :type aggregation: + :vartype aggregation: ~$(python-base-namespace).v2016_03_01.models.ManagementEventAggregationCondition """ @@ -683,6 +827,16 @@ def __init__( aggregation: Optional["ManagementEventAggregationCondition"] = None, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource + :keyword aggregation: How the data that is collected should be combined over time and when the + alert is activated. Note that for management event alerts aggregation is optional – if it is + not provided then any event will cause the alert to activate. + :paramtype aggregation: + ~$(python-base-namespace).v2016_03_01.models.ManagementEventAggregationCondition + """ super(ManagementEventRuleCondition, self).__init__(data_source=data_source, **kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ManagementEventRuleCondition' # type: str self.aggregation = aggregation @@ -691,12 +845,12 @@ def __init__( class MetricAvailability(msrest.serialization.Model): """Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. - :param time_grain: the time grain specifies the aggregation interval for the metric. Expressed + :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. - :type time_grain: ~datetime.timedelta - :param retention: the retention period for the metric at the specified timegrain. Expressed as + :vartype time_grain: ~datetime.timedelta + :ivar retention: the retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc. - :type retention: ~datetime.timedelta + :vartype retention: ~datetime.timedelta """ _attribute_map = { @@ -711,6 +865,14 @@ def __init__( retention: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword time_grain: the time grain specifies the aggregation interval for the metric. + Expressed as a duration 'PT1M', 'P1D', etc. + :paramtype time_grain: ~datetime.timedelta + :keyword retention: the retention period for the metric at the specified timegrain. Expressed + as a duration 'PT1M', 'P1D', etc. + :paramtype retention: ~datetime.timedelta + """ super(MetricAvailability, self).__init__(**kwargs) self.time_grain = time_grain self.retention = retention @@ -719,25 +881,25 @@ def __init__( class MetricDefinition(msrest.serialization.Model): """Metric definition class specifies the metadata for a metric. - :param resource_id: the resource identifier of the resource that emitted the metric. - :type resource_id: str - :param name: the name and the display name of the metric, i.e. it is a localizable string. - :type name: ~$(python-base-namespace).v2016_03_01.models.LocalizableString - :param unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + :ivar resource_id: the resource identifier of the resource that emitted the metric. + :vartype resource_id: str + :ivar name: the name and the display name of the metric, i.e. it is a localizable string. + :vartype name: ~$(python-base-namespace).v2016_03_01.models.LocalizableString + :ivar unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". - :type unit: str or ~$(python-base-namespace).v2016_03_01.models.Unit - :param primary_aggregation_type: the primary aggregation type value defining how to use the + :vartype unit: str or ~$(python-base-namespace).v2016_03_01.models.Unit + :ivar primary_aggregation_type: the primary aggregation type value defining how to use the values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", "Total". - :type primary_aggregation_type: str or + :vartype primary_aggregation_type: str or ~$(python-base-namespace).v2016_03_01.models.AggregationType - :param metric_availabilities: the collection of what aggregation intervals are available to be + :ivar metric_availabilities: the collection of what aggregation intervals are available to be queried. - :type metric_availabilities: + :vartype metric_availabilities: list[~$(python-base-namespace).v2016_03_01.models.MetricAvailability] - :param id: the resource identifier of the metric definition. - :type id: str + :ivar id: the resource identifier of the metric definition. + :vartype id: str """ _attribute_map = { @@ -760,6 +922,27 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword resource_id: the resource identifier of the resource that emitted the metric. + :paramtype resource_id: str + :keyword name: the name and the display name of the metric, i.e. it is a localizable string. + :paramtype name: ~$(python-base-namespace).v2016_03_01.models.LocalizableString + :keyword unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", + "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + :paramtype unit: str or ~$(python-base-namespace).v2016_03_01.models.Unit + :keyword primary_aggregation_type: the primary aggregation type value defining how to use the + values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", + "Total". + :paramtype primary_aggregation_type: str or + ~$(python-base-namespace).v2016_03_01.models.AggregationType + :keyword metric_availabilities: the collection of what aggregation intervals are available to + be queried. + :paramtype metric_availabilities: + list[~$(python-base-namespace).v2016_03_01.models.MetricAvailability] + :keyword id: the resource identifier of the metric definition. + :paramtype id: str + """ super(MetricDefinition, self).__init__(**kwargs) self.resource_id = resource_id self.name = name @@ -774,8 +957,8 @@ class MetricDefinitionCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the values for the metric definitions. - :type value: list[~$(python-base-namespace).v2016_03_01.models.MetricDefinition] + :ivar value: Required. the values for the metric definitions. + :vartype value: list[~$(python-base-namespace).v2016_03_01.models.MetricDefinition] """ _validation = { @@ -792,6 +975,10 @@ def __init__( value: List["MetricDefinition"], **kwargs ): + """ + :keyword value: Required. the values for the metric definitions. + :paramtype value: list[~$(python-base-namespace).v2016_03_01.models.MetricDefinition] + """ super(MetricDefinitionCollection, self).__init__(**kwargs) self.value = value @@ -801,11 +988,11 @@ class RetentionPolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param enabled: Required. a value indicating whether the retention policy is enabled. - :type enabled: bool - :param days: Required. the number of days for the retention in days. A value of 0 will retain + :ivar enabled: Required. a value indicating whether the retention policy is enabled. + :vartype enabled: bool + :ivar days: Required. the number of days for the retention in days. A value of 0 will retain the events indefinitely. - :type days: int + :vartype days: int """ _validation = { @@ -825,6 +1012,13 @@ def __init__( days: int, **kwargs ): + """ + :keyword enabled: Required. a value indicating whether the retention policy is enabled. + :paramtype enabled: bool + :keyword days: Required. the number of days for the retention in days. A value of 0 will retain + the events indefinitely. + :paramtype days: int + """ super(RetentionPolicy, self).__init__(**kwargs) self.enabled = enabled self.days = days @@ -838,9 +1032,9 @@ class RuleAction(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of the action. There are two types of actions: + :ivar odata_type: Required. specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str + :vartype odata_type: str """ _validation = { @@ -859,6 +1053,8 @@ def __init__( self, **kwargs ): + """ + """ super(RuleAction, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] @@ -871,19 +1067,19 @@ class RuleDataSource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of data source. There are two types of rule - data sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. - :type odata_type: str - :param resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :type resource_uri: str - :param legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + :ivar odata_type: Required. specifies the type of data source. There are two types of rule data + sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :vartype odata_type: str + :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this + property cannot be updated for an existing rule. + :vartype resource_uri: str + :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. - :type legacy_resource_id: str - :param resource_location: the location of the resource. - :type resource_location: str - :param metric_namespace: the namespace of the metric. - :type metric_namespace: str + :vartype legacy_resource_id: str + :ivar resource_location: the location of the resource. + :vartype resource_location: str + :ivar metric_namespace: the namespace of the metric. + :vartype metric_namespace: str """ _validation = { @@ -911,6 +1107,18 @@ def __init__( metric_namespace: Optional[str] = None, **kwargs ): + """ + :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : + this property cannot be updated for an existing rule. + :paramtype resource_uri: str + :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + **NOTE**\ : this property cannot be updated for an existing rule. + :paramtype legacy_resource_id: str + :keyword resource_location: the location of the resource. + :paramtype resource_location: str + :keyword metric_namespace: the namespace of the metric. + :paramtype metric_namespace: str + """ super(RuleDataSource, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] self.resource_uri = resource_uri @@ -924,15 +1132,15 @@ class RuleEmailAction(RuleAction): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of the action. There are two types of actions: + :ivar odata_type: Required. specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str - :param send_to_service_owners: Whether the administrators (service and co-administrators) of - the service should be notified when the alert is activated. - :type send_to_service_owners: bool - :param custom_emails: the list of administrator's custom email addresses to notify of the + :vartype odata_type: str + :ivar send_to_service_owners: Whether the administrators (service and co-administrators) of the + service should be notified when the alert is activated. + :vartype send_to_service_owners: bool + :ivar custom_emails: the list of administrator's custom email addresses to notify of the activation of the alert. - :type custom_emails: list[str] + :vartype custom_emails: list[str] """ _validation = { @@ -952,6 +1160,14 @@ def __init__( custom_emails: Optional[List[str]] = None, **kwargs ): + """ + :keyword send_to_service_owners: Whether the administrators (service and co-administrators) of + the service should be notified when the alert is activated. + :paramtype send_to_service_owners: bool + :keyword custom_emails: the list of administrator's custom email addresses to notify of the + activation of the alert. + :paramtype custom_emails: list[str] + """ super(RuleEmailAction, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleEmailAction' # type: str self.send_to_service_owners = send_to_service_owners @@ -961,8 +1177,8 @@ def __init__( class RuleManagementEventClaimsDataSource(msrest.serialization.Model): """The claims for a rule management event data source. - :param email_address: the email address. - :type email_address: str + :ivar email_address: the email address. + :vartype email_address: str """ _attribute_map = { @@ -975,6 +1191,10 @@ def __init__( email_address: Optional[str] = None, **kwargs ): + """ + :keyword email_address: the email address. + :paramtype email_address: str + """ super(RuleManagementEventClaimsDataSource, self).__init__(**kwargs) self.email_address = email_address @@ -984,39 +1204,40 @@ class RuleManagementEventDataSource(RuleDataSource): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of data source. There are two types of rule - data sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. - :type odata_type: str - :param resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :type resource_uri: str - :param legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + :ivar odata_type: Required. specifies the type of data source. There are two types of rule data + sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :vartype odata_type: str + :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this + property cannot be updated for an existing rule. + :vartype resource_uri: str + :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. - :type legacy_resource_id: str - :param resource_location: the location of the resource. - :type resource_location: str - :param metric_namespace: the namespace of the metric. - :type metric_namespace: str - :param event_name: the event name. - :type event_name: str - :param event_source: the event source. - :type event_source: str - :param level: the level. - :type level: str - :param operation_name: The name of the operation that should be checked for. If no name is + :vartype legacy_resource_id: str + :ivar resource_location: the location of the resource. + :vartype resource_location: str + :ivar metric_namespace: the namespace of the metric. + :vartype metric_namespace: str + :ivar event_name: the event name. + :vartype event_name: str + :ivar event_source: the event source. + :vartype event_source: str + :ivar level: the level. + :vartype level: str + :ivar operation_name: The name of the operation that should be checked for. If no name is provided, any operation will match. - :type operation_name: str - :param resource_group_name: the resource group name. - :type resource_group_name: str - :param resource_provider_name: the resource provider name. - :type resource_provider_name: str - :param status: The status of the operation that should be checked for. If no status is - provided, any status will match. - :type status: str - :param sub_status: the substatus. - :type sub_status: str - :param claims: the claims. - :type claims: ~$(python-base-namespace).v2016_03_01.models.RuleManagementEventClaimsDataSource + :vartype operation_name: str + :ivar resource_group_name: the resource group name. + :vartype resource_group_name: str + :ivar resource_provider_name: the resource provider name. + :vartype resource_provider_name: str + :ivar status: The status of the operation that should be checked for. If no status is provided, + any status will match. + :vartype status: str + :ivar sub_status: the substatus. + :vartype sub_status: str + :ivar claims: the claims. + :vartype claims: + ~$(python-base-namespace).v2016_03_01.models.RuleManagementEventClaimsDataSource """ _validation = { @@ -1058,6 +1279,39 @@ def __init__( claims: Optional["RuleManagementEventClaimsDataSource"] = None, **kwargs ): + """ + :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : + this property cannot be updated for an existing rule. + :paramtype resource_uri: str + :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + **NOTE**\ : this property cannot be updated for an existing rule. + :paramtype legacy_resource_id: str + :keyword resource_location: the location of the resource. + :paramtype resource_location: str + :keyword metric_namespace: the namespace of the metric. + :paramtype metric_namespace: str + :keyword event_name: the event name. + :paramtype event_name: str + :keyword event_source: the event source. + :paramtype event_source: str + :keyword level: the level. + :paramtype level: str + :keyword operation_name: The name of the operation that should be checked for. If no name is + provided, any operation will match. + :paramtype operation_name: str + :keyword resource_group_name: the resource group name. + :paramtype resource_group_name: str + :keyword resource_provider_name: the resource provider name. + :paramtype resource_provider_name: str + :keyword status: The status of the operation that should be checked for. If no status is + provided, any status will match. + :paramtype status: str + :keyword sub_status: the substatus. + :paramtype sub_status: str + :keyword claims: the claims. + :paramtype claims: + ~$(python-base-namespace).v2016_03_01.models.RuleManagementEventClaimsDataSource + """ super(RuleManagementEventDataSource, self).__init__(resource_uri=resource_uri, legacy_resource_id=legacy_resource_id, resource_location=resource_location, metric_namespace=metric_namespace, **kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleManagementEventDataSource' # type: str self.event_name = event_name @@ -1076,21 +1330,21 @@ class RuleMetricDataSource(RuleDataSource): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of data source. There are two types of rule - data sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. - :type odata_type: str - :param resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : - this property cannot be updated for an existing rule. - :type resource_uri: str - :param legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + :ivar odata_type: Required. specifies the type of data source. There are two types of rule data + sources: RuleMetricDataSource and RuleManagementEventDataSource.Constant filled by server. + :vartype odata_type: str + :ivar resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : this + property cannot be updated for an existing rule. + :vartype resource_uri: str + :ivar legacy_resource_id: the legacy resource identifier of the resource the rule monitors. **NOTE**\ : this property cannot be updated for an existing rule. - :type legacy_resource_id: str - :param resource_location: the location of the resource. - :type resource_location: str - :param metric_namespace: the namespace of the metric. - :type metric_namespace: str - :param metric_name: the name of the metric that defines what the rule monitors. - :type metric_name: str + :vartype legacy_resource_id: str + :ivar resource_location: the location of the resource. + :vartype resource_location: str + :ivar metric_namespace: the namespace of the metric. + :vartype metric_namespace: str + :ivar metric_name: the name of the metric that defines what the rule monitors. + :vartype metric_name: str """ _validation = { @@ -1116,6 +1370,20 @@ def __init__( metric_name: Optional[str] = None, **kwargs ): + """ + :keyword resource_uri: the resource identifier of the resource the rule monitors. **NOTE**\ : + this property cannot be updated for an existing rule. + :paramtype resource_uri: str + :keyword legacy_resource_id: the legacy resource identifier of the resource the rule monitors. + **NOTE**\ : this property cannot be updated for an existing rule. + :paramtype legacy_resource_id: str + :keyword resource_location: the location of the resource. + :paramtype resource_location: str + :keyword metric_namespace: the namespace of the metric. + :paramtype metric_namespace: str + :keyword metric_name: the name of the metric that defines what the rule monitors. + :paramtype metric_name: str + """ super(RuleMetricDataSource, self).__init__(resource_uri=resource_uri, legacy_resource_id=legacy_resource_id, resource_location=resource_location, metric_namespace=metric_namespace, **kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource' # type: str self.metric_name = metric_name @@ -1126,15 +1394,15 @@ class RuleWebhookAction(RuleAction): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of the action. There are two types of actions: + :ivar odata_type: Required. specifies the type of the action. There are two types of actions: RuleEmailAction and RuleWebhookAction.Constant filled by server. - :type odata_type: str - :param service_uri: the service uri to Post the notification when the alert activates or + :vartype odata_type: str + :ivar service_uri: the service uri to Post the notification when the alert activates or resolves. - :type service_uri: str - :param properties: the dictionary of custom properties to include with the post operation. - These data are appended to the webhook payload. - :type properties: dict[str, str] + :vartype service_uri: str + :ivar properties: the dictionary of custom properties to include with the post operation. These + data are appended to the webhook payload. + :vartype properties: dict[str, str] """ _validation = { @@ -1154,6 +1422,14 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword service_uri: the service uri to Post the notification when the alert activates or + resolves. + :paramtype service_uri: str + :keyword properties: the dictionary of custom properties to include with the post operation. + These data are appended to the webhook payload. + :paramtype properties: dict[str, str] + """ super(RuleWebhookAction, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.RuleWebhookAction' # type: str self.service_uri = service_uri @@ -1165,27 +1441,27 @@ class ThresholdRuleCondition(RuleCondition): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. specifies the type of condition. This can be one of three types: + :ivar odata_type: Required. specifies the type of condition. This can be one of three types: ManagementEventRuleCondition (occurrences of management events), LocationThresholdRuleCondition (based on the number of failures of a web test), and ThresholdRuleCondition (based on the threshold of a metric).Constant filled by server. - :type odata_type: str - :param data_source: the resource from which the rule collects its data. For this type - dataSource will always be of type RuleMetricDataSource. - :type data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource - :param operator: Required. the operator used to compare the data and the threshold. Possible + :vartype odata_type: str + :ivar data_source: the resource from which the rule collects its data. For this type dataSource + will always be of type RuleMetricDataSource. + :vartype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource + :ivar operator: Required. the operator used to compare the data and the threshold. Possible values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator - :param threshold: Required. the threshold value that activates the alert. - :type threshold: float - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator + :ivar threshold: Required. the threshold value that activates the alert. + :vartype threshold: float + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day. - :type window_size: ~datetime.timedelta - :param time_aggregation: the time aggregation operator. How the data that are collected should + :vartype window_size: ~datetime.timedelta + :ivar time_aggregation: the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. Possible values include: "Average", "Minimum", "Maximum", "Total", "Last". - :type time_aggregation: str or + :vartype time_aggregation: str or ~$(python-base-namespace).v2016_03_01.models.TimeAggregationOperator """ @@ -1214,6 +1490,25 @@ def __init__( time_aggregation: Optional[Union[str, "TimeAggregationOperator"]] = None, **kwargs ): + """ + :keyword data_source: the resource from which the rule collects its data. For this type + dataSource will always be of type RuleMetricDataSource. + :paramtype data_source: ~$(python-base-namespace).v2016_03_01.models.RuleDataSource + :keyword operator: Required. the operator used to compare the data and the threshold. Possible + values include: "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :paramtype operator: str or ~$(python-base-namespace).v2016_03_01.models.ConditionOperator + :keyword threshold: Required. the threshold value that activates the alert. + :paramtype threshold: float + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. If specified then it must be between 5 minutes and 1 + day. + :paramtype window_size: ~datetime.timedelta + :keyword time_aggregation: the time aggregation operator. How the data that are collected + should be combined over time. The default value is the PrimaryAggregationType of the Metric. + Possible values include: "Average", "Minimum", "Maximum", "Total", "Last". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2016_03_01.models.TimeAggregationOperator + """ super(ThresholdRuleCondition, self).__init__(data_source=data_source, **kwargs) self.odata_type = 'Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition' # type: str self.operator = operator diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_monitor_management_client_enums.py index 42b2bb7d2507c..46f418eaac302 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/models/_monitor_management_client_enums.py @@ -6,27 +6,12 @@ # 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 AggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the primary aggregation type value defining how to use the values for display. """ @@ -37,7 +22,7 @@ class AggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MAXIMUM = "Maximum" TOTAL = "Total" -class ConditionOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ConditionOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Operators allowed in the rule condition. """ @@ -46,7 +31,7 @@ class ConditionOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" -class TimeAggregationOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TimeAggregationOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Aggregation operators allowed in a rule. """ @@ -56,7 +41,7 @@ class TimeAggregationOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum TOTAL = "Total" LAST = "Last" -class Unit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Unit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The unit of the metric. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rule_incidents_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rule_incidents_operations.py index e852df95c9010..e700024c78bea 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rule_incidents_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rule_incidents_operations.py @@ -5,24 +5,106 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + resource_group_name, # type: str + rule_name, # type: str + incident_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "incidentName": _SERIALIZER.url("incident_name", incident_name, 'str'), + "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_alert_rule_request( + resource_group_name, # type: str + rule_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "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 + ) + +# fmt: on class AlertRuleIncidentsOperations(object): """AlertRuleIncidentsOperations operations. @@ -45,6 +127,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_group_name, # type: str @@ -55,7 +138,7 @@ def get( # type: (...) -> "_models.Incident" """Gets an incident associated to an alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -71,34 +154,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - 'incidentName': self._serialize.url("incident_name", incident_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + incident_name=incident_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Incident', pipeline_response) @@ -107,8 +180,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/alertrules/{ruleName}/incidents/{incidentName}'} # type: ignore + + @distributed_trace def list_by_alert_rule( self, resource_group_name, # type: str @@ -118,13 +194,14 @@ def list_by_alert_rule( # type: (...) -> Iterable["_models.IncidentListResult"] """Gets a list of incidents associated to an alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either IncidentListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.IncidentListResult] + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.IncidentListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IncidentListResult"] @@ -132,36 +209,33 @@ def list_by_alert_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-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_alert_rule.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_alert_rule_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_alert_rule.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_list_by_alert_rule_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + 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('IncidentListResult', pipeline_response) + deserialized = self._deserialize("IncidentListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -179,6 +253,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rules_operations.py index 82bc82bee3de1..3f0ecb60588af 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_alert_rules_operations.py @@ -5,24 +5,250 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + resource_group_name, # type: str + rule_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "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] + 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, + **kwargs + ) + + +def build_delete_request( + resource_group_name, # type: str + rule_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + rule_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "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_update_request( + subscription_id, # type: str + resource_group_name, # type: str + rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", 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, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/alertrules') + 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 + ) + +# fmt: on class AlertRulesOperations(object): """AlertRulesOperations operations. @@ -45,6 +271,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -55,7 +282,7 @@ def create_or_update( # type: (...) -> "_models.AlertRuleResource" """Creates or updates a classic metric alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -71,38 +298,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'AlertRuleResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AlertRuleResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -115,8 +332,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -126,7 +346,7 @@ def delete( # type: (...) -> None """Deletes a classic metric alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -140,33 +360,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -174,6 +384,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -183,7 +395,7 @@ def get( # type: (...) -> "_models.AlertRuleResource" """Gets a classic metric alert rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -197,33 +409,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AlertRuleResource', pipeline_response) @@ -232,8 +434,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -245,7 +450,7 @@ def update( """Updates an existing classic metric AlertRuleResource. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -261,38 +466,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-01" - 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'), - 'ruleName': self._serialize.url("rule_name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(alert_rules_resource, 'AlertRuleResourcePatch') - 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, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -305,8 +500,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/alertrules/{ruleName}'} # type: ignore + + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -315,11 +513,13 @@ def list_by_resource_group( # type: (...) -> Iterable["_models.AlertRuleResourceCollection"] """List the classic metric alert rules within a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 AlertRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResourceCollection] + :return: An iterator like instance of either AlertRuleResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] @@ -327,35 +527,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('AlertRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -368,17 +564,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Insights/alertrules'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs # type: Any @@ -387,8 +585,10 @@ def list_by_subscription( """List the classic metric alert rules within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AlertRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResourceCollection] + :return: An iterator like instance of either AlertRuleResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.AlertRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleResourceCollection"] @@ -396,34 +596,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-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_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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('AlertRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("AlertRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -436,12 +631,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_log_profiles_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_log_profiles_operations.py index 84bedb59ac2c0..bbbc2f08680e3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_log_profiles_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_log_profiles_operations.py @@ -5,24 +5,202 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_delete_request( + log_profile_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-03-01" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}') + path_format_arguments = { + "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, 'str'), + "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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + log_profile_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}') + path_format_arguments = { + "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, 'str'), + "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_create_or_update_request( + log_profile_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}') + path_format_arguments = { + "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_name, 'str'), + "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] + 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, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + log_profile_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "logProfileName": _SERIALIZER.url("log_profile_name", log_profile_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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles') + 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 + ) + +# fmt: on class LogProfilesOperations(object): """LogProfilesOperations operations. @@ -45,6 +223,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def delete( self, log_profile_name, # type: str @@ -65,24 +244,16 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-01" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'logProfileName': self._serialize.url("log_profile_name", log_profile_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] + + request = build_delete_request( + log_profile_name=log_profile_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -95,6 +266,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}'} # type: ignore + + @distributed_trace def get( self, log_profile_name, # type: str @@ -115,32 +288,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'logProfileName': self._serialize.url("log_profile_name", log_profile_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + log_profile_name=log_profile_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('LogProfileResource', pipeline_response) @@ -149,8 +312,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}'} # type: ignore + + @distributed_trace def create_or_update( self, log_profile_name, # type: str @@ -174,31 +340,21 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-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 = { - 'logProfileName': self._serialize.url("log_profile_name", log_profile_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'LogProfileResource') + + request = build_create_or_update_request( + log_profile_name=log_profile_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'LogProfileResource') - 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 @@ -212,8 +368,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}'} # type: ignore + + @distributed_trace def update( self, log_profile_name, # type: str @@ -226,7 +385,8 @@ def update( :param log_profile_name: The name of the log profile. :type log_profile_name: str :param log_profiles_resource: Parameters supplied to the operation. - :type log_profiles_resource: ~$(python-base-namespace).v2016_03_01.models.LogProfileResourcePatch + :type log_profiles_resource: + ~$(python-base-namespace).v2016_03_01.models.LogProfileResourcePatch :keyword callable cls: A custom type or function that will be passed the direct response :return: LogProfileResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_03_01.models.LogProfileResource @@ -237,37 +397,27 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-01" - 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), - 'logProfileName': self._serialize.url("log_profile_name", log_profile_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(log_profiles_resource, 'LogProfileResourcePatch') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + log_profile_name=log_profile_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(log_profiles_resource, 'LogProfileResourcePatch') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('LogProfileResource', pipeline_response) @@ -276,8 +426,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/logprofiles/{logProfileName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -286,8 +439,10 @@ def list( """List the log profiles. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogProfileCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.LogProfileCollection] + :return: An iterator like instance of either LogProfileCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.LogProfileCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LogProfileCollection"] @@ -295,34 +450,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_list_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('LogProfileCollection', pipeline_response) + deserialized = self._deserialize("LogProfileCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -340,6 +490,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_metric_definitions_operations.py index 70e65461a6a87..87599be23ab8e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_03_01/operations/_metric_definitions_operations.py @@ -5,24 +5,68 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2016-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/metricDefinitions') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + 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') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, '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 + ) + +# fmt: on class MetricDefinitionsOperations(object): """MetricDefinitionsOperations operations. @@ -45,6 +89,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_uri, # type: str @@ -64,8 +109,10 @@ def list( other syntax is allowed. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.MetricDefinitionCollection] + :return: An iterator like instance of either MetricDefinitionCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_03_01.models.MetricDefinitionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionCollection"] @@ -73,36 +120,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-03-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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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 filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + template_url=self.list.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_list_request( + resource_uri=resource_uri, + filter=filter, + 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('MetricDefinitionCollection', pipeline_response) + deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,12 +157,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_configuration.py index 49eeeacfbf315..08e35162d3663 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -37,9 +37,9 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2016-09-01" @@ -62,4 +62,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_metadata.json index 16c3223a2e2fb..056ea76a8642f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,11 +79,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "metrics": "MetricsOperations", diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_monitor_management_client.py index 894c99e965147..7a6d0ef9cb6c3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_monitor_management_client.py @@ -6,23 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import MetricsOperations, ServiceDiagnosticSettingsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import MetricsOperations -from .operations import ServiceDiagnosticSettingsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. @@ -30,48 +29,58 @@ class MonitorManagementClient(object): :ivar metrics: MetricsOperations operations :vartype metrics: $(python-base-namespace).v2016_09_01.operations.MetricsOperations :ivar service_diagnostic_settings: ServiceDiagnosticSettingsOperations operations - :vartype service_diagnostic_settings: $(python-base-namespace).v2016_09_01.operations.ServiceDiagnosticSettingsOperations + :vartype service_diagnostic_settings: + $(python-base-namespace).v2016_09_01.operations.ServiceDiagnosticSettingsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :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" - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, **kwargs) + self._config = MonitorManagementClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) + self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metrics = MetricsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_configuration.py index 6e6da199d6361..e050303155784 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/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 @@ -34,9 +34,9 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(MonitorManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2016-09-01" @@ -58,4 +58,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_monitor_management_client.py index c050f4b4aa8fc..fc77dcd16de01 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_monitor_management_client.py @@ -6,68 +6,77 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import MetricsOperations, ServiceDiagnosticSettingsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MonitorManagementClientConfiguration -from .operations import MetricsOperations -from .operations import ServiceDiagnosticSettingsOperations -from .. import models - - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar metrics: MetricsOperations operations :vartype metrics: $(python-base-namespace).v2016_09_01.aio.operations.MetricsOperations :ivar service_diagnostic_settings: ServiceDiagnosticSettingsOperations operations - :vartype service_diagnostic_settings: $(python-base-namespace).v2016_09_01.aio.operations.ServiceDiagnosticSettingsOperations + :vartype service_diagnostic_settings: + $(python-base-namespace).v2016_09_01.aio.operations.ServiceDiagnosticSettingsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :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", - 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 = MonitorManagementClientConfiguration(credential, **kwargs) + self._config = MonitorManagementClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) + self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metrics = MetricsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.service_diagnostic_settings = ServiceDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_metrics_operations.py index 4e6584b0e1d95..f608928956038 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_metrics_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_metrics_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._metrics_operations import build_list_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 list( self, resource_uri: str, @@ -72,7 +78,8 @@ def list( :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MetricCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_09_01.models.MetricCollection] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2016_09_01.models.MetricCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricCollection"] @@ -80,36 +87,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + template_url=self.list.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_list_request( + resource_uri=resource_uri, + filter=filter, + 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('MetricCollection', pipeline_response) + deserialized = self._deserialize("MetricCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -122,12 +124,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_service_diagnostic_settings_operations.py index 18fcacb6e3f4a..39efc93f4a2c2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_service_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/aio/operations/_service_diagnostic_settings_operations.py @@ -5,16 +5,20 @@ # 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, Optional, TypeVar import warnings 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_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._service_diagnostic_settings_operations import build_create_or_update_request, build_get_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_uri: str, @@ -60,31 +65,21 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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_request( + resource_uri=resource_uri, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ServiceDiagnosticSettingsResource', pipeline_response) @@ -93,8 +88,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_uri: str, @@ -107,7 +105,8 @@ async def create_or_update( :param resource_uri: The identifier of the resource. :type resource_uri: str :param parameters: Parameters supplied to the operation. - :type parameters: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource + :type parameters: + ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: ServiceDiagnosticSettingsResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource @@ -118,30 +117,20 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'ServiceDiagnosticSettingsResource') + + request = build_create_or_update_request( + resource_uri=resource_uri, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServiceDiagnosticSettingsResource') - 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 @@ -155,8 +144,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service'} # type: ignore + + @distributed_trace_async async def update( self, resource_uri: str, @@ -169,7 +161,8 @@ async def update( :param resource_uri: The identifier of the resource. :type resource_uri: str :param service_diagnostic_settings_resource: Parameters supplied to the operation. - :type service_diagnostic_settings_resource: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResourcePatch + :type service_diagnostic_settings_resource: + ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResourcePatch :keyword callable cls: A custom type or function that will be passed the direct response :return: ServiceDiagnosticSettingsResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource @@ -180,36 +173,26 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(service_diagnostic_settings_resource, 'ServiceDiagnosticSettingsResourcePatch') + + request = build_update_request( + resource_uri=resource_uri, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(service_diagnostic_settings_resource, 'ServiceDiagnosticSettingsResourcePatch') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ServiceDiagnosticSettingsResource', pipeline_response) @@ -218,4 +201,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models.py index d5842d8f0aec8..7aa4485594eff 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models.py @@ -13,10 +13,10 @@ class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -28,6 +28,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -38,10 +44,10 @@ class LocalizableString(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the invariant value. - :type value: str - :param localized_value: the locale specific value. - :type localized_value: str + :ivar value: Required. the invariant value. + :vartype value: str + :ivar localized_value: the locale specific value. + :vartype localized_value: str """ _validation = { @@ -57,6 +63,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. the invariant value. + :paramtype value: str + :keyword localized_value: the locale specific value. + :paramtype localized_value: str + """ super(LocalizableString, self).__init__(**kwargs) self.value = kwargs['value'] self.localized_value = kwargs.get('localized_value', None) @@ -67,14 +79,14 @@ class LogSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param category: Name of a Diagnostic Log category for a resource type this setting is applied + :ivar category: Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. - :type category: str - :param enabled: Required. a value indicating whether this log is enabled. - :type enabled: bool - :param retention_policy: the retention policy for this log. - :type retention_policy: ~$(python-base-namespace).v2016_09_01.models.RetentionPolicy + :vartype category: str + :ivar enabled: Required. a value indicating whether this log is enabled. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this log. + :vartype retention_policy: ~$(python-base-namespace).v2016_09_01.models.RetentionPolicy """ _validation = { @@ -91,6 +103,16 @@ def __init__( self, **kwargs ): + """ + :keyword category: Name of a Diagnostic Log category for a resource type this setting is + applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET + diagnostic settings operation. + :paramtype category: str + :keyword enabled: Required. a value indicating whether this log is enabled. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this log. + :paramtype retention_policy: ~$(python-base-namespace).v2016_09_01.models.RetentionPolicy + """ super(LogSettings, self).__init__(**kwargs) self.category = kwargs.get('category', None) self.enabled = kwargs['enabled'] @@ -102,19 +124,19 @@ class Metric(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: the id, resourceId, of the metric. - :type id: str - :param type: the resource type of the metric resource. - :type type: str - :param name: Required. the name and the display name of the metric, i.e. it is localizable + :ivar id: the id, resourceId, of the metric. + :vartype id: str + :ivar type: the resource type of the metric resource. + :vartype type: str + :ivar name: Required. the name and the display name of the metric, i.e. it is localizable string. - :type name: ~$(python-base-namespace).v2016_09_01.models.LocalizableString - :param unit: Required. the unit of the metric. Possible values include: "Count", "Bytes", + :vartype name: ~$(python-base-namespace).v2016_09_01.models.LocalizableString + :ivar unit: Required. the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". - :type unit: str or ~$(python-base-namespace).v2016_09_01.models.Unit - :param data: Required. Array of data points representing the metric values. - :type data: list[~$(python-base-namespace).v2016_09_01.models.MetricValue] + :vartype unit: str or ~$(python-base-namespace).v2016_09_01.models.Unit + :ivar data: Required. Array of data points representing the metric values. + :vartype data: list[~$(python-base-namespace).v2016_09_01.models.MetricValue] """ _validation = { @@ -135,6 +157,21 @@ def __init__( self, **kwargs ): + """ + :keyword id: the id, resourceId, of the metric. + :paramtype id: str + :keyword type: the resource type of the metric resource. + :paramtype type: str + :keyword name: Required. the name and the display name of the metric, i.e. it is localizable + string. + :paramtype name: ~$(python-base-namespace).v2016_09_01.models.LocalizableString + :keyword unit: Required. the unit of the metric. Possible values include: "Count", "Bytes", + "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", + "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + :paramtype unit: str or ~$(python-base-namespace).v2016_09_01.models.Unit + :keyword data: Required. Array of data points representing the metric values. + :paramtype data: list[~$(python-base-namespace).v2016_09_01.models.MetricValue] + """ super(Metric, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.type = kwargs.get('type', None) @@ -148,8 +185,8 @@ class MetricCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the value of the collection. - :type value: list[~$(python-base-namespace).v2016_09_01.models.Metric] + :ivar value: Required. the value of the collection. + :vartype value: list[~$(python-base-namespace).v2016_09_01.models.Metric] """ _validation = { @@ -164,6 +201,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. the value of the collection. + :paramtype value: list[~$(python-base-namespace).v2016_09_01.models.Metric] + """ super(MetricCollection, self).__init__(**kwargs) self.value = kwargs['value'] @@ -173,12 +214,12 @@ class MetricSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_grain: Required. the timegrain of the metric in ISO8601 format. - :type time_grain: ~datetime.timedelta - :param enabled: Required. a value indicating whether this timegrain is enabled. - :type enabled: bool - :param retention_policy: the retention policy for this timegrain. - :type retention_policy: ~$(python-base-namespace).v2016_09_01.models.RetentionPolicy + :ivar time_grain: Required. the timegrain of the metric in ISO8601 format. + :vartype time_grain: ~datetime.timedelta + :ivar enabled: Required. a value indicating whether this timegrain is enabled. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this timegrain. + :vartype retention_policy: ~$(python-base-namespace).v2016_09_01.models.RetentionPolicy """ _validation = { @@ -196,6 +237,14 @@ def __init__( self, **kwargs ): + """ + :keyword time_grain: Required. the timegrain of the metric in ISO8601 format. + :paramtype time_grain: ~datetime.timedelta + :keyword enabled: Required. a value indicating whether this timegrain is enabled. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this timegrain. + :paramtype retention_policy: ~$(python-base-namespace).v2016_09_01.models.RetentionPolicy + """ super(MetricSettings, self).__init__(**kwargs) self.time_grain = kwargs['time_grain'] self.enabled = kwargs['enabled'] @@ -207,19 +256,19 @@ class MetricValue(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_stamp: Required. the timestamp for the metric value in ISO 8601 format. - :type time_stamp: ~datetime.datetime - :param average: the average value in the time range. - :type average: float - :param minimum: the least value in the time range. - :type minimum: float - :param maximum: the greatest value in the time range. - :type maximum: float - :param total: the sum of all of the values in the time range. - :type total: float - :param count: the number of samples in the time range. Can be used to determine the number of + :ivar time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :vartype time_stamp: ~datetime.datetime + :ivar average: the average value in the time range. + :vartype average: float + :ivar minimum: the least value in the time range. + :vartype minimum: float + :ivar maximum: the greatest value in the time range. + :vartype maximum: float + :ivar total: the sum of all of the values in the time range. + :vartype total: float + :ivar count: the number of samples in the time range. Can be used to determine the number of values that contributed to the average value. - :type count: long + :vartype count: long """ _validation = { @@ -239,6 +288,21 @@ def __init__( self, **kwargs ): + """ + :keyword time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :paramtype time_stamp: ~datetime.datetime + :keyword average: the average value in the time range. + :paramtype average: float + :keyword minimum: the least value in the time range. + :paramtype minimum: float + :keyword maximum: the greatest value in the time range. + :paramtype maximum: float + :keyword total: the sum of all of the values in the time range. + :paramtype total: float + :keyword count: the number of samples in the time range. Can be used to determine the number of + values that contributed to the average value. + :paramtype count: long + """ super(MetricValue, self).__init__(**kwargs) self.time_stamp = kwargs['time_stamp'] self.average = kwargs.get('average', None) @@ -261,10 +325,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -286,6 +350,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -299,11 +369,11 @@ class RetentionPolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param enabled: Required. a value indicating whether the retention policy is enabled. - :type enabled: bool - :param days: Required. the number of days for the retention in days. A value of 0 will retain + :ivar enabled: Required. a value indicating whether the retention policy is enabled. + :vartype enabled: bool + :ivar days: Required. the number of days for the retention in days. A value of 0 will retain the events indefinitely. - :type days: int + :vartype days: int """ _validation = { @@ -320,6 +390,13 @@ def __init__( self, **kwargs ): + """ + :keyword enabled: Required. a value indicating whether the retention policy is enabled. + :paramtype enabled: bool + :keyword days: Required. the number of days for the retention in days. A value of 0 will retain + the events indefinitely. + :paramtype days: int + """ super(RetentionPolicy, self).__init__(**kwargs) self.enabled = kwargs['enabled'] self.days = kwargs['days'] @@ -338,28 +415,28 @@ class ServiceDiagnosticSettingsResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param storage_account_id: The resource ID of the storage account to which you would like to + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. - :type service_bus_rule_id: str - :param event_hub_authorization_rule_id: The resource Id for the event hub namespace + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub namespace authorization rule. - :type event_hub_authorization_rule_id: str - :param metrics: the list of metric settings. - :type metrics: list[~$(python-base-namespace).v2016_09_01.models.MetricSettings] - :param logs: the list of logs settings. - :type logs: list[~$(python-base-namespace).v2016_09_01.models.LogSettings] - :param workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a Log + :vartype event_hub_authorization_rule_id: str + :ivar metrics: the list of metric settings. + :vartype metrics: list[~$(python-base-namespace).v2016_09_01.models.MetricSettings] + :ivar logs: the list of logs settings. + :vartype logs: list[~$(python-base-namespace).v2016_09_01.models.LogSettings] + :ivar workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str + :vartype workspace_id: str """ _validation = { @@ -387,6 +464,30 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the + format: '{service bus resource ID}/authorizationrules/{key name}'. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub namespace + authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword metrics: the list of metric settings. + :paramtype metrics: list[~$(python-base-namespace).v2016_09_01.models.MetricSettings] + :keyword logs: the list of logs settings. + :paramtype logs: list[~$(python-base-namespace).v2016_09_01.models.LogSettings] + :keyword workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a Log + Analytics workspace to which you would like to send Diagnostic Logs. Example: + /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + :paramtype workspace_id: str + """ super(ServiceDiagnosticSettingsResource, self).__init__(**kwargs) self.storage_account_id = kwargs.get('storage_account_id', None) self.service_bus_rule_id = kwargs.get('service_bus_rule_id', None) @@ -399,26 +500,26 @@ def __init__( class ServiceDiagnosticSettingsResourcePatch(msrest.serialization.Model): """Service diagnostic setting resource for patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param storage_account_id: The resource ID of the storage account to which you would like to + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. - :type service_bus_rule_id: str - :param event_hub_authorization_rule_id: The resource Id for the event hub namespace + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub namespace authorization rule. - :type event_hub_authorization_rule_id: str - :param metrics: the list of metric settings. - :type metrics: list[~$(python-base-namespace).v2016_09_01.models.MetricSettings] - :param logs: the list of logs settings. - :type logs: list[~$(python-base-namespace).v2016_09_01.models.LogSettings] - :param workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a Log + :vartype event_hub_authorization_rule_id: str + :ivar metrics: the list of metric settings. + :vartype metrics: list[~$(python-base-namespace).v2016_09_01.models.MetricSettings] + :ivar logs: the list of logs settings. + :vartype logs: list[~$(python-base-namespace).v2016_09_01.models.LogSettings] + :ivar workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str + :vartype workspace_id: str """ _attribute_map = { @@ -435,6 +536,28 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the + format: '{service bus resource ID}/authorizationrules/{key name}'. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub namespace + authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword metrics: the list of metric settings. + :paramtype metrics: list[~$(python-base-namespace).v2016_09_01.models.MetricSettings] + :keyword logs: the list of logs settings. + :paramtype logs: list[~$(python-base-namespace).v2016_09_01.models.LogSettings] + :keyword workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a Log + Analytics workspace to which you would like to send Diagnostic Logs. Example: + /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + :paramtype workspace_id: str + """ super(ServiceDiagnosticSettingsResourcePatch, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.storage_account_id = kwargs.get('storage_account_id', None) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models_py3.py index 44a91f381556d..99a177ae114db 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_models_py3.py @@ -18,10 +18,10 @@ class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -36,6 +36,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -46,10 +52,10 @@ class LocalizableString(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the invariant value. - :type value: str - :param localized_value: the locale specific value. - :type localized_value: str + :ivar value: Required. the invariant value. + :vartype value: str + :ivar localized_value: the locale specific value. + :vartype localized_value: str """ _validation = { @@ -68,6 +74,12 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. the invariant value. + :paramtype value: str + :keyword localized_value: the locale specific value. + :paramtype localized_value: str + """ super(LocalizableString, self).__init__(**kwargs) self.value = value self.localized_value = localized_value @@ -78,14 +90,14 @@ class LogSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param category: Name of a Diagnostic Log category for a resource type this setting is applied + :ivar category: Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. - :type category: str - :param enabled: Required. a value indicating whether this log is enabled. - :type enabled: bool - :param retention_policy: the retention policy for this log. - :type retention_policy: ~$(python-base-namespace).v2016_09_01.models.RetentionPolicy + :vartype category: str + :ivar enabled: Required. a value indicating whether this log is enabled. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this log. + :vartype retention_policy: ~$(python-base-namespace).v2016_09_01.models.RetentionPolicy """ _validation = { @@ -106,6 +118,16 @@ def __init__( retention_policy: Optional["RetentionPolicy"] = None, **kwargs ): + """ + :keyword category: Name of a Diagnostic Log category for a resource type this setting is + applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET + diagnostic settings operation. + :paramtype category: str + :keyword enabled: Required. a value indicating whether this log is enabled. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this log. + :paramtype retention_policy: ~$(python-base-namespace).v2016_09_01.models.RetentionPolicy + """ super(LogSettings, self).__init__(**kwargs) self.category = category self.enabled = enabled @@ -117,19 +139,19 @@ class Metric(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: the id, resourceId, of the metric. - :type id: str - :param type: the resource type of the metric resource. - :type type: str - :param name: Required. the name and the display name of the metric, i.e. it is localizable + :ivar id: the id, resourceId, of the metric. + :vartype id: str + :ivar type: the resource type of the metric resource. + :vartype type: str + :ivar name: Required. the name and the display name of the metric, i.e. it is localizable string. - :type name: ~$(python-base-namespace).v2016_09_01.models.LocalizableString - :param unit: Required. the unit of the metric. Possible values include: "Count", "Bytes", + :vartype name: ~$(python-base-namespace).v2016_09_01.models.LocalizableString + :ivar unit: Required. the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". - :type unit: str or ~$(python-base-namespace).v2016_09_01.models.Unit - :param data: Required. Array of data points representing the metric values. - :type data: list[~$(python-base-namespace).v2016_09_01.models.MetricValue] + :vartype unit: str or ~$(python-base-namespace).v2016_09_01.models.Unit + :ivar data: Required. Array of data points representing the metric values. + :vartype data: list[~$(python-base-namespace).v2016_09_01.models.MetricValue] """ _validation = { @@ -156,6 +178,21 @@ def __init__( type: Optional[str] = None, **kwargs ): + """ + :keyword id: the id, resourceId, of the metric. + :paramtype id: str + :keyword type: the resource type of the metric resource. + :paramtype type: str + :keyword name: Required. the name and the display name of the metric, i.e. it is localizable + string. + :paramtype name: ~$(python-base-namespace).v2016_09_01.models.LocalizableString + :keyword unit: Required. the unit of the metric. Possible values include: "Count", "Bytes", + "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", + "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + :paramtype unit: str or ~$(python-base-namespace).v2016_09_01.models.Unit + :keyword data: Required. Array of data points representing the metric values. + :paramtype data: list[~$(python-base-namespace).v2016_09_01.models.MetricValue] + """ super(Metric, self).__init__(**kwargs) self.id = id self.type = type @@ -169,8 +206,8 @@ class MetricCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the value of the collection. - :type value: list[~$(python-base-namespace).v2016_09_01.models.Metric] + :ivar value: Required. the value of the collection. + :vartype value: list[~$(python-base-namespace).v2016_09_01.models.Metric] """ _validation = { @@ -187,6 +224,10 @@ def __init__( value: List["Metric"], **kwargs ): + """ + :keyword value: Required. the value of the collection. + :paramtype value: list[~$(python-base-namespace).v2016_09_01.models.Metric] + """ super(MetricCollection, self).__init__(**kwargs) self.value = value @@ -196,12 +237,12 @@ class MetricSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_grain: Required. the timegrain of the metric in ISO8601 format. - :type time_grain: ~datetime.timedelta - :param enabled: Required. a value indicating whether this timegrain is enabled. - :type enabled: bool - :param retention_policy: the retention policy for this timegrain. - :type retention_policy: ~$(python-base-namespace).v2016_09_01.models.RetentionPolicy + :ivar time_grain: Required. the timegrain of the metric in ISO8601 format. + :vartype time_grain: ~datetime.timedelta + :ivar enabled: Required. a value indicating whether this timegrain is enabled. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this timegrain. + :vartype retention_policy: ~$(python-base-namespace).v2016_09_01.models.RetentionPolicy """ _validation = { @@ -223,6 +264,14 @@ def __init__( retention_policy: Optional["RetentionPolicy"] = None, **kwargs ): + """ + :keyword time_grain: Required. the timegrain of the metric in ISO8601 format. + :paramtype time_grain: ~datetime.timedelta + :keyword enabled: Required. a value indicating whether this timegrain is enabled. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this timegrain. + :paramtype retention_policy: ~$(python-base-namespace).v2016_09_01.models.RetentionPolicy + """ super(MetricSettings, self).__init__(**kwargs) self.time_grain = time_grain self.enabled = enabled @@ -234,19 +283,19 @@ class MetricValue(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_stamp: Required. the timestamp for the metric value in ISO 8601 format. - :type time_stamp: ~datetime.datetime - :param average: the average value in the time range. - :type average: float - :param minimum: the least value in the time range. - :type minimum: float - :param maximum: the greatest value in the time range. - :type maximum: float - :param total: the sum of all of the values in the time range. - :type total: float - :param count: the number of samples in the time range. Can be used to determine the number of + :ivar time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :vartype time_stamp: ~datetime.datetime + :ivar average: the average value in the time range. + :vartype average: float + :ivar minimum: the least value in the time range. + :vartype minimum: float + :ivar maximum: the greatest value in the time range. + :vartype maximum: float + :ivar total: the sum of all of the values in the time range. + :vartype total: float + :ivar count: the number of samples in the time range. Can be used to determine the number of values that contributed to the average value. - :type count: long + :vartype count: long """ _validation = { @@ -273,6 +322,21 @@ def __init__( count: Optional[int] = None, **kwargs ): + """ + :keyword time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :paramtype time_stamp: ~datetime.datetime + :keyword average: the average value in the time range. + :paramtype average: float + :keyword minimum: the least value in the time range. + :paramtype minimum: float + :keyword maximum: the greatest value in the time range. + :paramtype maximum: float + :keyword total: the sum of all of the values in the time range. + :paramtype total: float + :keyword count: the number of samples in the time range. Can be used to determine the number of + values that contributed to the average value. + :paramtype count: long + """ super(MetricValue, self).__init__(**kwargs) self.time_stamp = time_stamp self.average = average @@ -295,10 +359,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -323,6 +387,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -336,11 +406,11 @@ class RetentionPolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param enabled: Required. a value indicating whether the retention policy is enabled. - :type enabled: bool - :param days: Required. the number of days for the retention in days. A value of 0 will retain + :ivar enabled: Required. a value indicating whether the retention policy is enabled. + :vartype enabled: bool + :ivar days: Required. the number of days for the retention in days. A value of 0 will retain the events indefinitely. - :type days: int + :vartype days: int """ _validation = { @@ -360,6 +430,13 @@ def __init__( days: int, **kwargs ): + """ + :keyword enabled: Required. a value indicating whether the retention policy is enabled. + :paramtype enabled: bool + :keyword days: Required. the number of days for the retention in days. A value of 0 will retain + the events indefinitely. + :paramtype days: int + """ super(RetentionPolicy, self).__init__(**kwargs) self.enabled = enabled self.days = days @@ -378,28 +455,28 @@ class ServiceDiagnosticSettingsResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param storage_account_id: The resource ID of the storage account to which you would like to + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. - :type service_bus_rule_id: str - :param event_hub_authorization_rule_id: The resource Id for the event hub namespace + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub namespace authorization rule. - :type event_hub_authorization_rule_id: str - :param metrics: the list of metric settings. - :type metrics: list[~$(python-base-namespace).v2016_09_01.models.MetricSettings] - :param logs: the list of logs settings. - :type logs: list[~$(python-base-namespace).v2016_09_01.models.LogSettings] - :param workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a Log + :vartype event_hub_authorization_rule_id: str + :ivar metrics: the list of metric settings. + :vartype metrics: list[~$(python-base-namespace).v2016_09_01.models.MetricSettings] + :ivar logs: the list of logs settings. + :vartype logs: list[~$(python-base-namespace).v2016_09_01.models.LogSettings] + :ivar workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str + :vartype workspace_id: str """ _validation = { @@ -436,6 +513,30 @@ def __init__( workspace_id: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the + format: '{service bus resource ID}/authorizationrules/{key name}'. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub namespace + authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword metrics: the list of metric settings. + :paramtype metrics: list[~$(python-base-namespace).v2016_09_01.models.MetricSettings] + :keyword logs: the list of logs settings. + :paramtype logs: list[~$(python-base-namespace).v2016_09_01.models.LogSettings] + :keyword workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a Log + Analytics workspace to which you would like to send Diagnostic Logs. Example: + /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + :paramtype workspace_id: str + """ super(ServiceDiagnosticSettingsResource, self).__init__(location=location, tags=tags, **kwargs) self.storage_account_id = storage_account_id self.service_bus_rule_id = service_bus_rule_id @@ -448,26 +549,26 @@ def __init__( class ServiceDiagnosticSettingsResourcePatch(msrest.serialization.Model): """Service diagnostic setting resource for patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param storage_account_id: The resource ID of the storage account to which you would like to + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'. - :type service_bus_rule_id: str - :param event_hub_authorization_rule_id: The resource Id for the event hub namespace + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub namespace authorization rule. - :type event_hub_authorization_rule_id: str - :param metrics: the list of metric settings. - :type metrics: list[~$(python-base-namespace).v2016_09_01.models.MetricSettings] - :param logs: the list of logs settings. - :type logs: list[~$(python-base-namespace).v2016_09_01.models.LogSettings] - :param workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a Log + :vartype event_hub_authorization_rule_id: str + :ivar metrics: the list of metric settings. + :vartype metrics: list[~$(python-base-namespace).v2016_09_01.models.MetricSettings] + :ivar logs: the list of logs settings. + :vartype logs: list[~$(python-base-namespace).v2016_09_01.models.LogSettings] + :ivar workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str + :vartype workspace_id: str """ _attribute_map = { @@ -492,6 +593,28 @@ def __init__( workspace_id: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule ID of the service bus namespace in which you + would like to have Event Hubs created for streaming Diagnostic Logs. The rule ID is of the + format: '{service bus resource ID}/authorizationrules/{key name}'. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub namespace + authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword metrics: the list of metric settings. + :paramtype metrics: list[~$(python-base-namespace).v2016_09_01.models.MetricSettings] + :keyword logs: the list of logs settings. + :paramtype logs: list[~$(python-base-namespace).v2016_09_01.models.LogSettings] + :keyword workspace_id: The workspace ID (resource ID of a Log Analytics workspace) for a Log + Analytics workspace to which you would like to send Diagnostic Logs. Example: + /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + :paramtype workspace_id: str + """ super(ServiceDiagnosticSettingsResourcePatch, self).__init__(**kwargs) self.tags = tags self.storage_account_id = storage_account_id diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_monitor_management_client_enums.py index a8d1b59c86f25..1b9cb5dfb067c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/models/_monitor_management_client_enums.py @@ -6,27 +6,12 @@ # 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 Unit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Unit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The unit of the metric. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_metrics_operations.py index 09facc2424abd..e6f07b6dce770 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_metrics_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_metrics_operations.py @@ -5,24 +5,68 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/metrics') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, '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 + ) + +# fmt: on class MetricsOperations(object): """MetricsOperations operations. @@ -45,6 +89,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_uri, # type: str @@ -77,7 +122,8 @@ def list( :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MetricCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_09_01.models.MetricCollection] + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2016_09_01.models.MetricCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricCollection"] @@ -85,36 +131,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + template_url=self.list.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_list_request( + resource_uri=resource_uri, + filter=filter, + 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('MetricCollection', pipeline_response) + deserialized = self._deserialize("MetricCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -127,12 +168,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_service_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_service_diagnostic_settings_operations.py index aa768782b641c..d1b56605a8dc2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_service_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2016_09_01/operations/_service_diagnostic_settings_operations.py @@ -5,23 +5,135 @@ # 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 TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + 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( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + 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, + **kwargs + ) + + +def build_update_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + 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, + **kwargs + ) + +# fmt: on class ServiceDiagnosticSettingsOperations(object): """ServiceDiagnosticSettingsOperations operations. @@ -44,6 +156,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_uri, # type: str @@ -65,31 +178,21 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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_request( + resource_uri=resource_uri, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ServiceDiagnosticSettingsResource', pipeline_response) @@ -98,8 +201,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service'} # type: ignore + + @distributed_trace def create_or_update( self, resource_uri, # type: str @@ -113,7 +219,8 @@ def create_or_update( :param resource_uri: The identifier of the resource. :type resource_uri: str :param parameters: Parameters supplied to the operation. - :type parameters: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource + :type parameters: + ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: ServiceDiagnosticSettingsResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource @@ -124,30 +231,20 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'ServiceDiagnosticSettingsResource') + + request = build_create_or_update_request( + resource_uri=resource_uri, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ServiceDiagnosticSettingsResource') - 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 @@ -161,8 +258,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service'} # type: ignore + + @distributed_trace def update( self, resource_uri, # type: str @@ -176,7 +276,8 @@ def update( :param resource_uri: The identifier of the resource. :type resource_uri: str :param service_diagnostic_settings_resource: Parameters supplied to the operation. - :type service_diagnostic_settings_resource: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResourcePatch + :type service_diagnostic_settings_resource: + ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResourcePatch :keyword callable cls: A custom type or function that will be passed the direct response :return: ServiceDiagnosticSettingsResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2016_09_01.models.ServiceDiagnosticSettingsResource @@ -187,36 +288,26 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(service_diagnostic_settings_resource, 'ServiceDiagnosticSettingsResourcePatch') + + request = build_update_request( + resource_uri=resource_uri, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(service_diagnostic_settings_resource, 'ServiceDiagnosticSettingsResourcePatch') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ServiceDiagnosticSettingsResource', pipeline_response) @@ -225,4 +316,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/diagnosticSettings/service'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_configuration.py index 20b896410adb2..9731c7edad820 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_metadata.json index fbd1af47ff222..877e90f7a5f9d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "activity_log_alerts": "ActivityLogAlertsOperations" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_monitor_management_client.py index 2fd4b9348900d..9102734594a90 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_monitor_management_client.py @@ -6,73 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ActivityLogAlertsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActivityLogAlertsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. :ivar activity_log_alerts: ActivityLogAlertsOperations operations - :vartype activity_log_alerts: $(python-base-namespace).v2017_03_01_preview.operations.ActivityLogAlertsOperations + :vartype activity_log_alerts: + $(python-base-namespace).v2017_03_01_preview.operations.ActivityLogAlertsOperations :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.activity_log_alerts = ActivityLogAlertsOperations(self._client, self._config, self._serialize, self._deserialize) - self.activity_log_alerts = ActivityLogAlertsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_configuration.py index bdfb3a86feb4d..79386b6bd3508 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_monitor_management_client.py index 75051515bdf32..ffe1322a32a49 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_monitor_management_client.py @@ -6,69 +6,77 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import MonitorManagementClientConfiguration from .operations import ActivityLogAlertsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar activity_log_alerts: ActivityLogAlertsOperations operations - :vartype activity_log_alerts: $(python-base-namespace).v2017_03_01_preview.aio.operations.ActivityLogAlertsOperations + :vartype activity_log_alerts: + $(python-base-namespace).v2017_03_01_preview.aio.operations.ActivityLogAlertsOperations :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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.activity_log_alerts = ActivityLogAlertsOperations(self._client, self._config, self._serialize, self._deserialize) - self.activity_log_alerts = ActivityLogAlertsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_activity_log_alerts_operations.py index 13d3752a35708..d040201f8eea2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_activity_log_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/aio/operations/_activity_log_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._activity_log_alerts_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_update_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_async async def create_or_update( self, resource_group_name: str, @@ -50,12 +56,13 @@ async def create_or_update( ) -> "_models.ActivityLogAlertResource": """Create a new activity log alert or update an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. :type activity_log_alert_name: str :param activity_log_alert: The activity log alert to create or use for the update. - :type activity_log_alert: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource + :type activity_log_alert: + ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource :keyword callable cls: A custom type or function that will be passed the direct response :return: ActivityLogAlertResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource @@ -66,38 +73,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - 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'), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(activity_log_alert, 'ActivityLogAlertResource') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(activity_log_alert, 'ActivityLogAlertResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -110,8 +107,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -120,7 +120,7 @@ async def get( ) -> "_models.ActivityLogAlertResource": """Get an activity log alert. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. :type activity_log_alert_name: str @@ -134,33 +134,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - 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'), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # 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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) @@ -169,8 +159,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -179,7 +172,7 @@ async def delete( ) -> None: """Delete an activity log alert. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. :type activity_log_alert_name: str @@ -193,33 +186,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-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'), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # 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_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -227,6 +210,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -237,12 +222,13 @@ async def update( """Updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. :type activity_log_alert_name: str :param activity_log_alert_patch: Parameters supplied to the operation. - :type activity_log_alert_patch: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResourcePatch + :type activity_log_alert_patch: + ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResourcePatch :keyword callable cls: A custom type or function that will be passed the direct response :return: ActivityLogAlertResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource @@ -253,38 +239,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-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'), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(activity_log_alert_patch, 'ActivityLogAlertResourcePatch') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(activity_log_alert_patch, 'ActivityLogAlertResourcePatch') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) @@ -293,8 +269,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace def list_by_subscription_id( self, **kwargs: Any @@ -302,8 +281,10 @@ def list_by_subscription_id( """Get a list of all activity log alerts 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 ActivityLogAlertList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertList] + :return: An iterator like instance of either ActivityLogAlertList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertList"] @@ -311,34 +292,29 @@ def list_by_subscription_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-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_id.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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription_id.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_list_by_subscription_id_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('ActivityLogAlertList', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -351,17 +327,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -369,11 +347,13 @@ def list_by_resource_group( ) -> AsyncIterable["_models.ActivityLogAlertList"]: """Get a list of all activity log alerts in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 ActivityLogAlertList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertList] + :return: An iterator like instance of either ActivityLogAlertList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertList"] @@ -381,35 +361,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('ActivityLogAlertList', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -422,12 +398,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models.py index c8f2e52df3ed6..f1c8d6095f512 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models.py @@ -15,12 +15,12 @@ class ActivityLogAlertActionGroup(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param action_group_id: Required. The resourceId of the action group. This cannot be null or + :ivar action_group_id: Required. The resourceId of the action group. This cannot be null or empty. - :type action_group_id: str - :param webhook_properties: The dictionary of custom properties to include with the post + :vartype action_group_id: str + :ivar webhook_properties: The dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. - :type webhook_properties: dict[str, str] + :vartype webhook_properties: dict[str, str] """ _validation = { @@ -36,6 +36,14 @@ def __init__( self, **kwargs ): + """ + :keyword action_group_id: Required. The resourceId of the action group. This cannot be null or + empty. + :paramtype action_group_id: str + :keyword webhook_properties: The dictionary of custom properties to include with the post + operation. These data are appended to the webhook payload. + :paramtype webhook_properties: dict[str, str] + """ super(ActivityLogAlertActionGroup, self).__init__(**kwargs) self.action_group_id = kwargs['action_group_id'] self.webhook_properties = kwargs.get('webhook_properties', None) @@ -44,8 +52,8 @@ def __init__( class ActivityLogAlertActionList(msrest.serialization.Model): """A list of activity log alert actions. - :param action_groups: The list of activity log alerts. - :type action_groups: + :ivar action_groups: The list of activity log alerts. + :vartype action_groups: list[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertActionGroup] """ @@ -57,6 +65,11 @@ def __init__( self, **kwargs ): + """ + :keyword action_groups: The list of activity log alerts. + :paramtype action_groups: + list[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertActionGroup] + """ super(ActivityLogAlertActionList, self).__init__(**kwargs) self.action_groups = kwargs.get('action_groups', None) @@ -66,8 +79,8 @@ class ActivityLogAlertAllOfCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param all_of: Required. The list of activity log alert conditions. - :type all_of: + :ivar all_of: Required. The list of activity log alert conditions. + :vartype all_of: list[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertLeafCondition] """ @@ -83,6 +96,11 @@ def __init__( self, **kwargs ): + """ + :keyword all_of: Required. The list of activity log alert conditions. + :paramtype all_of: + list[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertLeafCondition] + """ super(ActivityLogAlertAllOfCondition, self).__init__(**kwargs) self.all_of = kwargs['all_of'] @@ -92,14 +110,14 @@ class ActivityLogAlertLeafCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param field: Required. The name of the field that this condition will examine. The possible + :ivar field: Required. The name of the field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties.'. - :type field: str - :param equals: Required. The field value will be compared to this value (case-insensitive) to + :vartype field: str + :ivar equals: Required. The field value will be compared to this value (case-insensitive) to determine if the condition is met. - :type equals: str + :vartype equals: str """ _validation = { @@ -116,6 +134,16 @@ def __init__( self, **kwargs ): + """ + :keyword field: Required. The name of the field that this condition will examine. The possible + values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', + 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or + anything beginning with 'properties.'. + :paramtype field: str + :keyword equals: Required. The field value will be compared to this value (case-insensitive) to + determine if the condition is met. + :paramtype equals: str + """ super(ActivityLogAlertLeafCondition, self).__init__(**kwargs) self.field = kwargs['field'] self.equals = kwargs['equals'] @@ -124,8 +152,8 @@ def __init__( class ActivityLogAlertList(msrest.serialization.Model): """A list of activity log alerts. - :param value: The list of activity log alerts. - :type value: + :ivar value: The list of activity log alerts. + :vartype value: list[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource] """ @@ -137,6 +165,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of activity log alerts. + :paramtype value: + list[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource] + """ super(ActivityLogAlertList, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -154,10 +187,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -179,6 +212,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -200,24 +239,25 @@ class ActivityLogAlertResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param scopes: A list of resourceIds that will be used as prefixes. The alert will only apply - to activityLogs with resourceIds that fall under one of these prefixes. This list must include - at least one item. - :type scopes: list[str] - :param enabled: Indicates whether this activity log alert is enabled. If an activity log alert + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar scopes: A list of resourceIds that will be used as prefixes. The alert will only apply to + activityLogs with resourceIds that fall under one of these prefixes. This list must include at + least one item. + :vartype scopes: list[str] + :ivar enabled: Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. - :type enabled: bool - :param condition: The condition that will cause this alert to activate. - :type condition: + :vartype enabled: bool + :ivar condition: The condition that will cause this alert to activate. + :vartype condition: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertAllOfCondition - :param actions: The actions that will activate when the condition is met. - :type actions: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertActionList - :param description: A description of this activity log alert. - :type description: str + :ivar actions: The actions that will activate when the condition is met. + :vartype actions: + ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertActionList + :ivar description: A description of this activity log alert. + :vartype description: str """ _validation = { @@ -244,6 +284,27 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword scopes: A list of resourceIds that will be used as prefixes. The alert will only apply + to activityLogs with resourceIds that fall under one of these prefixes. This list must include + at least one item. + :paramtype scopes: list[str] + :keyword enabled: Indicates whether this activity log alert is enabled. If an activity log + alert is not enabled, then none of its actions will be activated. + :paramtype enabled: bool + :keyword condition: The condition that will cause this alert to activate. + :paramtype condition: + ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertAllOfCondition + :keyword actions: The actions that will activate when the condition is met. + :paramtype actions: + ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertActionList + :keyword description: A description of this activity log alert. + :paramtype description: str + """ super(ActivityLogAlertResource, self).__init__(**kwargs) self.scopes = kwargs.get('scopes', None) self.enabled = kwargs.get('enabled', True) @@ -265,13 +326,13 @@ class ActivityLogAlertResourcePatch(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param enabled: Indicates whether this activity log alert is enabled. If an activity log alert + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. - :type enabled: bool + :vartype enabled: bool """ _validation = { @@ -294,6 +355,15 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this activity log alert is enabled. If an activity log + alert is not enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ super(ActivityLogAlertResourcePatch, self).__init__(**kwargs) self.enabled = kwargs.get('enabled', True) @@ -301,10 +371,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -316,6 +386,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models_py3.py index e22fb206fcee7..42196378038c4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/models/_models_py3.py @@ -17,12 +17,12 @@ class ActivityLogAlertActionGroup(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param action_group_id: Required. The resourceId of the action group. This cannot be null or + :ivar action_group_id: Required. The resourceId of the action group. This cannot be null or empty. - :type action_group_id: str - :param webhook_properties: The dictionary of custom properties to include with the post + :vartype action_group_id: str + :ivar webhook_properties: The dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. - :type webhook_properties: dict[str, str] + :vartype webhook_properties: dict[str, str] """ _validation = { @@ -41,6 +41,14 @@ def __init__( webhook_properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword action_group_id: Required. The resourceId of the action group. This cannot be null or + empty. + :paramtype action_group_id: str + :keyword webhook_properties: The dictionary of custom properties to include with the post + operation. These data are appended to the webhook payload. + :paramtype webhook_properties: dict[str, str] + """ super(ActivityLogAlertActionGroup, self).__init__(**kwargs) self.action_group_id = action_group_id self.webhook_properties = webhook_properties @@ -49,8 +57,8 @@ def __init__( class ActivityLogAlertActionList(msrest.serialization.Model): """A list of activity log alert actions. - :param action_groups: The list of activity log alerts. - :type action_groups: + :ivar action_groups: The list of activity log alerts. + :vartype action_groups: list[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertActionGroup] """ @@ -64,6 +72,11 @@ def __init__( action_groups: Optional[List["ActivityLogAlertActionGroup"]] = None, **kwargs ): + """ + :keyword action_groups: The list of activity log alerts. + :paramtype action_groups: + list[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertActionGroup] + """ super(ActivityLogAlertActionList, self).__init__(**kwargs) self.action_groups = action_groups @@ -73,8 +86,8 @@ class ActivityLogAlertAllOfCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param all_of: Required. The list of activity log alert conditions. - :type all_of: + :ivar all_of: Required. The list of activity log alert conditions. + :vartype all_of: list[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertLeafCondition] """ @@ -92,6 +105,11 @@ def __init__( all_of: List["ActivityLogAlertLeafCondition"], **kwargs ): + """ + :keyword all_of: Required. The list of activity log alert conditions. + :paramtype all_of: + list[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertLeafCondition] + """ super(ActivityLogAlertAllOfCondition, self).__init__(**kwargs) self.all_of = all_of @@ -101,14 +119,14 @@ class ActivityLogAlertLeafCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param field: Required. The name of the field that this condition will examine. The possible + :ivar field: Required. The name of the field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties.'. - :type field: str - :param equals: Required. The field value will be compared to this value (case-insensitive) to + :vartype field: str + :ivar equals: Required. The field value will be compared to this value (case-insensitive) to determine if the condition is met. - :type equals: str + :vartype equals: str """ _validation = { @@ -128,6 +146,16 @@ def __init__( equals: str, **kwargs ): + """ + :keyword field: Required. The name of the field that this condition will examine. The possible + values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', + 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or + anything beginning with 'properties.'. + :paramtype field: str + :keyword equals: Required. The field value will be compared to this value (case-insensitive) to + determine if the condition is met. + :paramtype equals: str + """ super(ActivityLogAlertLeafCondition, self).__init__(**kwargs) self.field = field self.equals = equals @@ -136,8 +164,8 @@ def __init__( class ActivityLogAlertList(msrest.serialization.Model): """A list of activity log alerts. - :param value: The list of activity log alerts. - :type value: + :ivar value: The list of activity log alerts. + :vartype value: list[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource] """ @@ -151,6 +179,11 @@ def __init__( value: Optional[List["ActivityLogAlertResource"]] = None, **kwargs ): + """ + :keyword value: The list of activity log alerts. + :paramtype value: + list[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource] + """ super(ActivityLogAlertList, self).__init__(**kwargs) self.value = value @@ -168,10 +201,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -196,6 +229,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -217,24 +256,25 @@ class ActivityLogAlertResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param scopes: A list of resourceIds that will be used as prefixes. The alert will only apply - to activityLogs with resourceIds that fall under one of these prefixes. This list must include - at least one item. - :type scopes: list[str] - :param enabled: Indicates whether this activity log alert is enabled. If an activity log alert + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar scopes: A list of resourceIds that will be used as prefixes. The alert will only apply to + activityLogs with resourceIds that fall under one of these prefixes. This list must include at + least one item. + :vartype scopes: list[str] + :ivar enabled: Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. - :type enabled: bool - :param condition: The condition that will cause this alert to activate. - :type condition: + :vartype enabled: bool + :ivar condition: The condition that will cause this alert to activate. + :vartype condition: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertAllOfCondition - :param actions: The actions that will activate when the condition is met. - :type actions: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertActionList - :param description: A description of this activity log alert. - :type description: str + :ivar actions: The actions that will activate when the condition is met. + :vartype actions: + ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertActionList + :ivar description: A description of this activity log alert. + :vartype description: str """ _validation = { @@ -269,6 +309,27 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword scopes: A list of resourceIds that will be used as prefixes. The alert will only apply + to activityLogs with resourceIds that fall under one of these prefixes. This list must include + at least one item. + :paramtype scopes: list[str] + :keyword enabled: Indicates whether this activity log alert is enabled. If an activity log + alert is not enabled, then none of its actions will be activated. + :paramtype enabled: bool + :keyword condition: The condition that will cause this alert to activate. + :paramtype condition: + ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertAllOfCondition + :keyword actions: The actions that will activate when the condition is met. + :paramtype actions: + ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertActionList + :keyword description: A description of this activity log alert. + :paramtype description: str + """ super(ActivityLogAlertResource, self).__init__(location=location, tags=tags, **kwargs) self.scopes = scopes self.enabled = enabled @@ -290,13 +351,13 @@ class ActivityLogAlertResourcePatch(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param enabled: Indicates whether this activity log alert is enabled. If an activity log alert + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. - :type enabled: bool + :vartype enabled: bool """ _validation = { @@ -323,6 +384,15 @@ def __init__( enabled: Optional[bool] = True, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this activity log alert is enabled. If an activity log + alert is not enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ super(ActivityLogAlertResourcePatch, self).__init__(location=location, tags=tags, **kwargs) self.enabled = enabled @@ -330,10 +400,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -348,6 +418,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_activity_log_alerts_operations.py index c820ce837e517..4ff0545d626c5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_activity_log_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_03_01_preview/operations/_activity_log_alerts_operations.py @@ -5,24 +5,250 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + subscription_id, # type: str + resource_group_name, # type: str + activity_log_alert_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_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, + **kwargs + ) + + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + activity_log_alert_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_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_delete_request( + subscription_id, # type: str + resource_group_name, # type: str + activity_log_alert_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_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, # type: str + resource_group_name, # type: str + activity_log_alert_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_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, + **kwargs + ) + + +def build_list_by_subscription_id_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts') + 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, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-03-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, 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 + ) + +# fmt: on class ActivityLogAlertsOperations(object): """ActivityLogAlertsOperations operations. @@ -45,6 +271,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -55,12 +282,13 @@ def create_or_update( # type: (...) -> "_models.ActivityLogAlertResource" """Create a new activity log alert or update an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. :type activity_log_alert_name: str :param activity_log_alert: The activity log alert to create or use for the update. - :type activity_log_alert: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource + :type activity_log_alert: + ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource :keyword callable cls: A custom type or function that will be passed the direct response :return: ActivityLogAlertResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource @@ -71,38 +299,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - 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'), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(activity_log_alert, 'ActivityLogAlertResource') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(activity_log_alert, 'ActivityLogAlertResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -115,8 +333,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -126,7 +347,7 @@ def get( # type: (...) -> "_models.ActivityLogAlertResource" """Get an activity log alert. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. :type activity_log_alert_name: str @@ -140,33 +361,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-preview" - 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'), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # 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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) @@ -175,8 +386,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -186,7 +400,7 @@ def delete( # type: (...) -> None """Delete an activity log alert. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. :type activity_log_alert_name: str @@ -200,33 +414,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-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'), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # 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_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -234,6 +438,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -245,12 +451,13 @@ def update( """Updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. :type activity_log_alert_name: str :param activity_log_alert_patch: Parameters supplied to the operation. - :type activity_log_alert_patch: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResourcePatch + :type activity_log_alert_patch: + ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResourcePatch :keyword callable cls: A custom type or function that will be passed the direct response :return: ActivityLogAlertResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertResource @@ -261,38 +468,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-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'), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(activity_log_alert_patch, 'ActivityLogAlertResourcePatch') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(activity_log_alert_patch, 'ActivityLogAlertResourcePatch') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) @@ -301,8 +498,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace def list_by_subscription_id( self, **kwargs # type: Any @@ -311,8 +511,10 @@ def list_by_subscription_id( """Get a list of all activity log alerts 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 ActivityLogAlertList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertList] + :return: An iterator like instance of either ActivityLogAlertList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertList"] @@ -320,34 +522,29 @@ def list_by_subscription_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-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_id.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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription_id.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_list_by_subscription_id_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('ActivityLogAlertList', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -360,17 +557,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -379,11 +578,13 @@ def list_by_resource_group( # type: (...) -> Iterable["_models.ActivityLogAlertList"] """Get a list of all activity log alerts in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 ActivityLogAlertList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertList] + :return: An iterator like instance of either ActivityLogAlertList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_03_01_preview.models.ActivityLogAlertList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertList"] @@ -391,35 +592,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-03-01-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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('ActivityLogAlertList', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -432,12 +629,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_configuration.py index 5f2a86e565f74..0abdd9ff37cda 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_metadata.json index 9eb75d5214178..93b8dd8db8766 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "action_groups": "ActionGroupsOperations", diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_monitor_management_client.py index c030a475a77b5..bb5b37ca26b91 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_monitor_management_client.py @@ -6,23 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ActionGroupsOperations, ActivityLogAlertsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations -from .operations import ActivityLogAlertsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. @@ -30,54 +29,61 @@ class MonitorManagementClient(object): :ivar action_groups: ActionGroupsOperations operations :vartype action_groups: $(python-base-namespace).v2017_04_01.operations.ActionGroupsOperations :ivar activity_log_alerts: ActivityLogAlertsOperations operations - :vartype activity_log_alerts: $(python-base-namespace).v2017_04_01.operations.ActivityLogAlertsOperations + :vartype activity_log_alerts: + $(python-base-namespace).v2017_04_01.operations.ActivityLogAlertsOperations :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.activity_log_alerts = ActivityLogAlertsOperations(self._client, self._config, self._serialize, self._deserialize) - self.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.activity_log_alerts = ActivityLogAlertsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_configuration.py index 77ab731e4a416..9d93745c9a825 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_monitor_management_client.py index b23f3b73ad1ab..e74e70f31cff8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_monitor_management_client.py @@ -6,74 +6,81 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ActionGroupsOperations, ActivityLogAlertsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations -from .operations import ActivityLogAlertsOperations -from .. import models - - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: $(python-base-namespace).v2017_04_01.aio.operations.ActionGroupsOperations + :vartype action_groups: + $(python-base-namespace).v2017_04_01.aio.operations.ActionGroupsOperations :ivar activity_log_alerts: ActivityLogAlertsOperations operations - :vartype activity_log_alerts: $(python-base-namespace).v2017_04_01.aio.operations.ActivityLogAlertsOperations + :vartype activity_log_alerts: + $(python-base-namespace).v2017_04_01.aio.operations.ActivityLogAlertsOperations :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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.activity_log_alerts = ActivityLogAlertsOperations(self._client, self._config, self._serialize, self._deserialize) - self.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.activity_log_alerts = ActivityLogAlertsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_action_groups_operations.py index 8dcaae576727f..6d47fbde7702f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_action_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._action_groups_operations import build_create_or_update_request, build_delete_request, build_enable_receiver_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_update_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_async async def create_or_update( self, resource_group_name: str, @@ -50,7 +56,7 @@ async def create_or_update( ) -> "_models.ActionGroupResource": """Create a new action group or update an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -66,38 +72,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group, 'ActionGroupResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group, 'ActionGroupResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -110,8 +106,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -120,7 +119,7 @@ async def get( ) -> "_models.ActionGroupResource": """Get an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -134,33 +133,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -169,8 +158,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -179,7 +171,7 @@ async def delete( ) -> None: """Delete an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -193,33 +185,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -227,6 +209,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -236,7 +220,7 @@ async def update( ) -> "_models.ActionGroupResource": """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -252,38 +236,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - 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'), - 'actionGroupName': self._serialize.url("action_group_name", action_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -292,8 +266,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def list_by_subscription_id( self, **kwargs: Any @@ -302,7 +279,8 @@ def list_by_subscription_id( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ActionGroupList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -310,34 +288,29 @@ def list_by_subscription_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-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_subscription_id.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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription_id.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_list_by_subscription_id_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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -350,17 +323,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -368,11 +343,12 @@ def list_by_resource_group( ) -> AsyncIterable["_models.ActionGroupList"]: """Get a list of all action groups in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 ActionGroupList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -380,35 +356,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -421,17 +393,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.insights/actionGroups'} # type: ignore + @distributed_trace_async async def enable_receiver( self, resource_group_name: str, @@ -442,7 +416,7 @@ async def enable_receiver( """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -458,41 +432,32 @@ async def enable_receiver( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.enable_receiver.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(enable_request, 'EnableRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_enable_receiver_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.enable_receiver.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(enable_request, 'EnableRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(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, 409]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) enable_receiver.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_activity_log_alerts_operations.py index f58a8bf3f2a1f..80e66fb77d490 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_activity_log_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/aio/operations/_activity_log_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._activity_log_alerts_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_update_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_async async def create_or_update( self, resource_group_name: str, @@ -50,7 +56,7 @@ async def create_or_update( ) -> "_models.ActivityLogAlertResource": """Create a new activity log alert or update an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. :type activity_log_alert_name: str @@ -66,38 +72,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-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'), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(activity_log_alert, 'ActivityLogAlertResource') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(activity_log_alert, 'ActivityLogAlertResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -110,8 +106,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -120,7 +119,7 @@ async def get( ) -> "_models.ActivityLogAlertResource": """Get an activity log alert. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. :type activity_log_alert_name: str @@ -134,33 +133,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-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'), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # 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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) @@ -169,8 +158,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -179,7 +171,7 @@ async def delete( ) -> None: """Delete an activity log alert. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. :type activity_log_alert_name: str @@ -193,33 +185,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-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'), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # 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_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -227,6 +209,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -237,12 +221,13 @@ async def update( """Updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. :type activity_log_alert_name: str :param activity_log_alert_patch: Parameters supplied to the operation. - :type activity_log_alert_patch: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertPatchBody + :type activity_log_alert_patch: + ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertPatchBody :keyword callable cls: A custom type or function that will be passed the direct response :return: ActivityLogAlertResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource @@ -253,38 +238,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - 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'), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(activity_log_alert_patch, 'ActivityLogAlertPatchBody') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(activity_log_alert_patch, 'ActivityLogAlertPatchBody') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) @@ -293,8 +268,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace def list_by_subscription_id( self, **kwargs: Any @@ -302,8 +280,10 @@ def list_by_subscription_id( """Get a list of all activity log alerts 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 ActivityLogAlertList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertList] + :return: An iterator like instance of either ActivityLogAlertList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertList"] @@ -311,34 +291,29 @@ def list_by_subscription_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-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_subscription_id.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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription_id.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_list_by_subscription_id_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('ActivityLogAlertList', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -351,17 +326,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -369,11 +346,13 @@ def list_by_resource_group( ) -> AsyncIterable["_models.ActivityLogAlertList"]: """Get a list of all activity log alerts in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 ActivityLogAlertList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertList] + :return: An iterator like instance of either ActivityLogAlertList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertList"] @@ -381,35 +360,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-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') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('ActivityLogAlertList', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -422,12 +397,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models.py index a4233a3199459..20e684e8860c8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models.py @@ -13,10 +13,10 @@ class ActionGroupList(msrest.serialization.Model): """A list of action groups. - :param value: The list of action groups. - :type value: list[~$(python-base-namespace).v2017_04_01.models.ActionGroupResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar value: The list of action groups. + :vartype value: list[~$(python-base-namespace).v2017_04_01.models.ActionGroupResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -28,6 +28,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of action groups. + :paramtype value: list[~$(python-base-namespace).v2017_04_01.models.ActionGroupResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(ActionGroupList, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -36,11 +42,11 @@ def __init__( class ActionGroupPatchBody(msrest.serialization.Model): """An action group object for the body of patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. - :type enabled: bool + :vartype enabled: bool """ _attribute_map = { @@ -52,6 +58,13 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ super(ActionGroupPatchBody, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.enabled = kwargs.get('enabled', True) @@ -70,10 +83,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -95,6 +108,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -116,30 +135,30 @@ class ActionGroupResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param group_short_name: The short name of the action group. This will be used in SMS messages. - :type group_short_name: str - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar group_short_name: The short name of the action group. This will be used in SMS messages. + :vartype group_short_name: str + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. - :type enabled: bool - :param email_receivers: The list of email receivers that are part of this action group. - :type email_receivers: list[~$(python-base-namespace).v2017_04_01.models.EmailReceiver] - :param sms_receivers: The list of SMS receivers that are part of this action group. - :type sms_receivers: list[~$(python-base-namespace).v2017_04_01.models.SmsReceiver] - :param webhook_receivers: The list of webhook receivers that are part of this action group. - :type webhook_receivers: list[~$(python-base-namespace).v2017_04_01.models.WebhookReceiver] - :param itsm_receivers: The list of ITSM receivers that are part of this action group. - :type itsm_receivers: list[~$(python-base-namespace).v2017_04_01.models.ItsmReceiver] - :param azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :type azure_app_push_receivers: + :vartype enabled: bool + :ivar email_receivers: The list of email receivers that are part of this action group. + :vartype email_receivers: list[~$(python-base-namespace).v2017_04_01.models.EmailReceiver] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~$(python-base-namespace).v2017_04_01.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~$(python-base-namespace).v2017_04_01.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~$(python-base-namespace).v2017_04_01.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: list[~$(python-base-namespace).v2017_04_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of this action group. - :type automation_runbook_receivers: + :vartype automation_runbook_receivers: list[~$(python-base-namespace).v2017_04_01.models.AutomationRunbookReceiver] """ @@ -171,6 +190,35 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword group_short_name: The short name of the action group. This will be used in SMS + messages. + :paramtype group_short_name: str + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its receivers will receive communications. + :paramtype enabled: bool + :keyword email_receivers: The list of email receivers that are part of this action group. + :paramtype email_receivers: list[~$(python-base-namespace).v2017_04_01.models.EmailReceiver] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~$(python-base-namespace).v2017_04_01.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: + list[~$(python-base-namespace).v2017_04_01.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~$(python-base-namespace).v2017_04_01.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: + list[~$(python-base-namespace).v2017_04_01.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~$(python-base-namespace).v2017_04_01.models.AutomationRunbookReceiver] + """ super(ActionGroupResource, self).__init__(**kwargs) self.group_short_name = kwargs.get('group_short_name', None) self.enabled = kwargs.get('enabled', True) @@ -187,12 +235,12 @@ class ActivityLogAlertActionGroup(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param action_group_id: Required. The resourceId of the action group. This cannot be null or + :ivar action_group_id: Required. The resourceId of the action group. This cannot be null or empty. - :type action_group_id: str - :param webhook_properties: the dictionary of custom properties to include with the post + :vartype action_group_id: str + :ivar webhook_properties: the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. - :type webhook_properties: dict[str, str] + :vartype webhook_properties: dict[str, str] """ _validation = { @@ -208,6 +256,14 @@ def __init__( self, **kwargs ): + """ + :keyword action_group_id: Required. The resourceId of the action group. This cannot be null or + empty. + :paramtype action_group_id: str + :keyword webhook_properties: the dictionary of custom properties to include with the post + operation. These data are appended to the webhook payload. + :paramtype webhook_properties: dict[str, str] + """ super(ActivityLogAlertActionGroup, self).__init__(**kwargs) self.action_group_id = kwargs['action_group_id'] self.webhook_properties = kwargs.get('webhook_properties', None) @@ -216,8 +272,8 @@ def __init__( class ActivityLogAlertActionList(msrest.serialization.Model): """A list of activity log alert actions. - :param action_groups: The list of activity log alerts. - :type action_groups: + :ivar action_groups: The list of activity log alerts. + :vartype action_groups: list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertActionGroup] """ @@ -229,6 +285,11 @@ def __init__( self, **kwargs ): + """ + :keyword action_groups: The list of activity log alerts. + :paramtype action_groups: + list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertActionGroup] + """ super(ActivityLogAlertActionList, self).__init__(**kwargs) self.action_groups = kwargs.get('action_groups', None) @@ -238,8 +299,9 @@ class ActivityLogAlertAllOfCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param all_of: Required. The list of activity log alert conditions. - :type all_of: list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertLeafCondition] + :ivar all_of: Required. The list of activity log alert conditions. + :vartype all_of: + list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertLeafCondition] """ _validation = { @@ -254,6 +316,11 @@ def __init__( self, **kwargs ): + """ + :keyword all_of: Required. The list of activity log alert conditions. + :paramtype all_of: + list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertLeafCondition] + """ super(ActivityLogAlertAllOfCondition, self).__init__(**kwargs) self.all_of = kwargs['all_of'] @@ -263,14 +330,14 @@ class ActivityLogAlertLeafCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param field: Required. The name of the field that this condition will examine. The possible + :ivar field: Required. The name of the field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties.'. - :type field: str - :param equals: Required. The field value will be compared to this value (case-insensitive) to + :vartype field: str + :ivar equals: Required. The field value will be compared to this value (case-insensitive) to determine if the condition is met. - :type equals: str + :vartype equals: str """ _validation = { @@ -287,6 +354,16 @@ def __init__( self, **kwargs ): + """ + :keyword field: Required. The name of the field that this condition will examine. The possible + values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', + 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or + anything beginning with 'properties.'. + :paramtype field: str + :keyword equals: Required. The field value will be compared to this value (case-insensitive) to + determine if the condition is met. + :paramtype equals: str + """ super(ActivityLogAlertLeafCondition, self).__init__(**kwargs) self.field = kwargs['field'] self.equals = kwargs['equals'] @@ -295,10 +372,10 @@ def __init__( class ActivityLogAlertList(msrest.serialization.Model): """A list of activity log alerts. - :param value: The list of activity log alerts. - :type value: list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar value: The list of activity log alerts. + :vartype value: list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -310,6 +387,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of activity log alerts. + :paramtype value: list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(ActivityLogAlertList, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -318,11 +401,11 @@ def __init__( class ActivityLogAlertPatchBody(msrest.serialization.Model): """An activity log alert object for the body of patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param enabled: Indicates whether this activity log alert is enabled. If an activity log alert + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. - :type enabled: bool + :vartype enabled: bool """ _attribute_map = { @@ -334,6 +417,13 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this activity log alert is enabled. If an activity log + alert is not enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ super(ActivityLogAlertPatchBody, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.enabled = kwargs.get('enabled', True) @@ -352,23 +442,23 @@ class ActivityLogAlertResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param scopes: A list of resourceIds that will be used as prefixes. The alert will only apply - to activityLogs with resourceIds that fall under one of these prefixes. This list must include - at least one item. - :type scopes: list[str] - :param enabled: Indicates whether this activity log alert is enabled. If an activity log alert + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar scopes: A list of resourceIds that will be used as prefixes. The alert will only apply to + activityLogs with resourceIds that fall under one of these prefixes. This list must include at + least one item. + :vartype scopes: list[str] + :ivar enabled: Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. - :type enabled: bool - :param condition: The condition that will cause this alert to activate. - :type condition: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertAllOfCondition - :param actions: The actions that will activate when the condition is met. - :type actions: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertActionList - :param description: A description of this activity log alert. - :type description: str + :vartype enabled: bool + :ivar condition: The condition that will cause this alert to activate. + :vartype condition: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertAllOfCondition + :ivar actions: The actions that will activate when the condition is met. + :vartype actions: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertActionList + :ivar description: A description of this activity log alert. + :vartype description: str """ _validation = { @@ -395,6 +485,26 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword scopes: A list of resourceIds that will be used as prefixes. The alert will only apply + to activityLogs with resourceIds that fall under one of these prefixes. This list must include + at least one item. + :paramtype scopes: list[str] + :keyword enabled: Indicates whether this activity log alert is enabled. If an activity log + alert is not enabled, then none of its actions will be activated. + :paramtype enabled: bool + :keyword condition: The condition that will cause this alert to activate. + :paramtype condition: + ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertAllOfCondition + :keyword actions: The actions that will activate when the condition is met. + :paramtype actions: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertActionList + :keyword description: A description of this activity log alert. + :paramtype description: str + """ super(ActivityLogAlertResource, self).__init__(**kwargs) self.scopes = kwargs.get('scopes', None) self.enabled = kwargs.get('enabled', True) @@ -408,19 +518,19 @@ class AutomationRunbookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. - :type automation_account_id: str - :param runbook_name: Required. The name for this runbook. - :type runbook_name: str - :param webhook_resource_id: Required. The resource id for webhook linked to this runbook. - :type webhook_resource_id: str - :param is_global_runbook: Required. Indicates whether this instance is global runbook. - :type is_global_runbook: bool - :param name: Indicates name of the webhook. - :type name: str - :param service_uri: The URI where webhooks should be sent. - :type service_uri: str + :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook + and authenticate to Azure resource. + :vartype automation_account_id: str + :ivar runbook_name: Required. The name for this runbook. + :vartype runbook_name: str + :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :vartype webhook_resource_id: str + :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :vartype is_global_runbook: bool + :ivar name: Indicates name of the webhook. + :vartype name: str + :ivar service_uri: The URI where webhooks should be sent. + :vartype service_uri: str """ _validation = { @@ -443,6 +553,21 @@ def __init__( self, **kwargs ): + """ + :keyword automation_account_id: Required. The Azure automation account Id which holds this + runbook and authenticate to Azure resource. + :paramtype automation_account_id: str + :keyword runbook_name: Required. The name for this runbook. + :paramtype runbook_name: str + :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :paramtype webhook_resource_id: str + :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :paramtype is_global_runbook: bool + :keyword name: Indicates name of the webhook. + :paramtype name: str + :keyword service_uri: The URI where webhooks should be sent. + :paramtype service_uri: str + """ super(AutomationRunbookReceiver, self).__init__(**kwargs) self.automation_account_id = kwargs['automation_account_id'] self.runbook_name = kwargs['runbook_name'] @@ -457,11 +582,11 @@ class AzureAppPushReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Azure mobile app push receiver. Names must be unique + :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. - :type name: str - :param email_address: Required. The email address registered for the Azure mobile app. - :type email_address: str + :vartype name: str + :ivar email_address: Required. The email address registered for the Azure mobile app. + :vartype email_address: str """ _validation = { @@ -478,6 +603,13 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique + across all receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address registered for the Azure mobile app. + :paramtype email_address: str + """ super(AzureAppPushReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.email_address = kwargs['email_address'] @@ -490,11 +622,11 @@ class EmailReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param email_address: Required. The email address of this receiver. - :type email_address: str + :ivar name: Required. The name of the email receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar email_address: Required. The email address of this receiver. + :vartype email_address: str :ivar status: The receiver status of the e-mail. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2017_04_01.models.ReceiverStatus @@ -516,6 +648,13 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the email receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address of this receiver. + :paramtype email_address: str + """ super(EmailReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.email_address = kwargs['email_address'] @@ -527,8 +666,8 @@ class EnableRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param receiver_name: Required. The name of the receiver to resubscribe. - :type receiver_name: str + :ivar receiver_name: Required. The name of the receiver to resubscribe. + :vartype receiver_name: str """ _validation = { @@ -543,6 +682,10 @@ def __init__( self, **kwargs ): + """ + :keyword receiver_name: Required. The name of the receiver to resubscribe. + :paramtype receiver_name: str + """ super(EnableRequest, self).__init__(**kwargs) self.receiver_name = kwargs['receiver_name'] @@ -550,10 +693,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -565,6 +708,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -575,20 +724,20 @@ class ItsmReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Itsm receiver. Names must be unique across all receivers + :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers within an action group. - :type name: str - :param workspace_id: Required. OMS LA instance identifier. - :type workspace_id: str - :param connection_id: Required. Unique identification of ITSM connection among multiple defined + :vartype name: str + :ivar workspace_id: Required. OMS LA instance identifier. + :vartype workspace_id: str + :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined in above workspace. - :type connection_id: str - :param ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + :vartype connection_id: str + :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as well. - :type ticket_configuration: str - :param region: Required. Region in which workspace resides. Supported + :vartype ticket_configuration: str + :ivar region: Required. Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - :type region: str + :vartype region: str """ _validation = { @@ -611,6 +760,22 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the Itsm receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword workspace_id: Required. OMS LA instance identifier. + :paramtype workspace_id: str + :keyword connection_id: Required. Unique identification of ITSM connection among multiple + defined in above workspace. + :paramtype connection_id: str + :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. + :paramtype ticket_configuration: str + :keyword region: Required. Region in which workspace resides. Supported + values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + :paramtype region: str + """ super(ItsmReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.workspace_id = kwargs['workspace_id'] @@ -626,13 +791,13 @@ class SmsReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SMS receiver. Names must be unique across all receivers + :ivar name: Required. The name of the SMS receiver. Names must be unique across all receivers within an action group. - :type name: str - :param country_code: Required. The country code of the SMS receiver. - :type country_code: str - :param phone_number: Required. The phone number of the SMS receiver. - :type phone_number: str + :vartype name: str + :ivar country_code: Required. The country code of the SMS receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the SMS receiver. + :vartype phone_number: str :ivar status: The status of the receiver. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2017_04_01.models.ReceiverStatus @@ -656,6 +821,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the SMS receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the SMS receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the SMS receiver. + :paramtype phone_number: str + """ super(SmsReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.country_code = kwargs['country_code'] @@ -668,11 +842,11 @@ class WebhookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the webhook receiver. Names must be unique across all + :ivar name: Required. The name of the webhook receiver. Names must be unique across all receivers within an action group. - :type name: str - :param service_uri: Required. The URI where webhooks should be sent. - :type service_uri: str + :vartype name: str + :ivar service_uri: Required. The URI where webhooks should be sent. + :vartype service_uri: str """ _validation = { @@ -689,6 +863,13 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the webhook receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword service_uri: Required. The URI where webhooks should be sent. + :paramtype service_uri: str + """ super(WebhookReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.service_uri = kwargs['service_uri'] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models_py3.py index e7619cc6add36..92b25077d8324 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_models_py3.py @@ -15,10 +15,10 @@ class ActionGroupList(msrest.serialization.Model): """A list of action groups. - :param value: The list of action groups. - :type value: list[~$(python-base-namespace).v2017_04_01.models.ActionGroupResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar value: The list of action groups. + :vartype value: list[~$(python-base-namespace).v2017_04_01.models.ActionGroupResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -33,6 +33,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of action groups. + :paramtype value: list[~$(python-base-namespace).v2017_04_01.models.ActionGroupResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(ActionGroupList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -41,11 +47,11 @@ def __init__( class ActionGroupPatchBody(msrest.serialization.Model): """An action group object for the body of patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. - :type enabled: bool + :vartype enabled: bool """ _attribute_map = { @@ -60,6 +66,13 @@ def __init__( enabled: Optional[bool] = True, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ super(ActionGroupPatchBody, self).__init__(**kwargs) self.tags = tags self.enabled = enabled @@ -78,10 +91,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -106,6 +119,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -127,30 +146,30 @@ class ActionGroupResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param group_short_name: The short name of the action group. This will be used in SMS messages. - :type group_short_name: str - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar group_short_name: The short name of the action group. This will be used in SMS messages. + :vartype group_short_name: str + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. - :type enabled: bool - :param email_receivers: The list of email receivers that are part of this action group. - :type email_receivers: list[~$(python-base-namespace).v2017_04_01.models.EmailReceiver] - :param sms_receivers: The list of SMS receivers that are part of this action group. - :type sms_receivers: list[~$(python-base-namespace).v2017_04_01.models.SmsReceiver] - :param webhook_receivers: The list of webhook receivers that are part of this action group. - :type webhook_receivers: list[~$(python-base-namespace).v2017_04_01.models.WebhookReceiver] - :param itsm_receivers: The list of ITSM receivers that are part of this action group. - :type itsm_receivers: list[~$(python-base-namespace).v2017_04_01.models.ItsmReceiver] - :param azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :type azure_app_push_receivers: + :vartype enabled: bool + :ivar email_receivers: The list of email receivers that are part of this action group. + :vartype email_receivers: list[~$(python-base-namespace).v2017_04_01.models.EmailReceiver] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~$(python-base-namespace).v2017_04_01.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~$(python-base-namespace).v2017_04_01.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~$(python-base-namespace).v2017_04_01.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: list[~$(python-base-namespace).v2017_04_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of this action group. - :type automation_runbook_receivers: + :vartype automation_runbook_receivers: list[~$(python-base-namespace).v2017_04_01.models.AutomationRunbookReceiver] """ @@ -193,6 +212,35 @@ def __init__( automation_runbook_receivers: Optional[List["AutomationRunbookReceiver"]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword group_short_name: The short name of the action group. This will be used in SMS + messages. + :paramtype group_short_name: str + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its receivers will receive communications. + :paramtype enabled: bool + :keyword email_receivers: The list of email receivers that are part of this action group. + :paramtype email_receivers: list[~$(python-base-namespace).v2017_04_01.models.EmailReceiver] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~$(python-base-namespace).v2017_04_01.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: + list[~$(python-base-namespace).v2017_04_01.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~$(python-base-namespace).v2017_04_01.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: + list[~$(python-base-namespace).v2017_04_01.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~$(python-base-namespace).v2017_04_01.models.AutomationRunbookReceiver] + """ super(ActionGroupResource, self).__init__(location=location, tags=tags, **kwargs) self.group_short_name = group_short_name self.enabled = enabled @@ -209,12 +257,12 @@ class ActivityLogAlertActionGroup(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param action_group_id: Required. The resourceId of the action group. This cannot be null or + :ivar action_group_id: Required. The resourceId of the action group. This cannot be null or empty. - :type action_group_id: str - :param webhook_properties: the dictionary of custom properties to include with the post + :vartype action_group_id: str + :ivar webhook_properties: the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. - :type webhook_properties: dict[str, str] + :vartype webhook_properties: dict[str, str] """ _validation = { @@ -233,6 +281,14 @@ def __init__( webhook_properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword action_group_id: Required. The resourceId of the action group. This cannot be null or + empty. + :paramtype action_group_id: str + :keyword webhook_properties: the dictionary of custom properties to include with the post + operation. These data are appended to the webhook payload. + :paramtype webhook_properties: dict[str, str] + """ super(ActivityLogAlertActionGroup, self).__init__(**kwargs) self.action_group_id = action_group_id self.webhook_properties = webhook_properties @@ -241,8 +297,8 @@ def __init__( class ActivityLogAlertActionList(msrest.serialization.Model): """A list of activity log alert actions. - :param action_groups: The list of activity log alerts. - :type action_groups: + :ivar action_groups: The list of activity log alerts. + :vartype action_groups: list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertActionGroup] """ @@ -256,6 +312,11 @@ def __init__( action_groups: Optional[List["ActivityLogAlertActionGroup"]] = None, **kwargs ): + """ + :keyword action_groups: The list of activity log alerts. + :paramtype action_groups: + list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertActionGroup] + """ super(ActivityLogAlertActionList, self).__init__(**kwargs) self.action_groups = action_groups @@ -265,8 +326,9 @@ class ActivityLogAlertAllOfCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param all_of: Required. The list of activity log alert conditions. - :type all_of: list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertLeafCondition] + :ivar all_of: Required. The list of activity log alert conditions. + :vartype all_of: + list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertLeafCondition] """ _validation = { @@ -283,6 +345,11 @@ def __init__( all_of: List["ActivityLogAlertLeafCondition"], **kwargs ): + """ + :keyword all_of: Required. The list of activity log alert conditions. + :paramtype all_of: + list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertLeafCondition] + """ super(ActivityLogAlertAllOfCondition, self).__init__(**kwargs) self.all_of = all_of @@ -292,14 +359,14 @@ class ActivityLogAlertLeafCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param field: Required. The name of the field that this condition will examine. The possible + :ivar field: Required. The name of the field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties.'. - :type field: str - :param equals: Required. The field value will be compared to this value (case-insensitive) to + :vartype field: str + :ivar equals: Required. The field value will be compared to this value (case-insensitive) to determine if the condition is met. - :type equals: str + :vartype equals: str """ _validation = { @@ -319,6 +386,16 @@ def __init__( equals: str, **kwargs ): + """ + :keyword field: Required. The name of the field that this condition will examine. The possible + values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', + 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or + anything beginning with 'properties.'. + :paramtype field: str + :keyword equals: Required. The field value will be compared to this value (case-insensitive) to + determine if the condition is met. + :paramtype equals: str + """ super(ActivityLogAlertLeafCondition, self).__init__(**kwargs) self.field = field self.equals = equals @@ -327,10 +404,10 @@ def __init__( class ActivityLogAlertList(msrest.serialization.Model): """A list of activity log alerts. - :param value: The list of activity log alerts. - :type value: list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar value: The list of activity log alerts. + :vartype value: list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -345,6 +422,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of activity log alerts. + :paramtype value: list[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(ActivityLogAlertList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -353,11 +436,11 @@ def __init__( class ActivityLogAlertPatchBody(msrest.serialization.Model): """An activity log alert object for the body of patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param enabled: Indicates whether this activity log alert is enabled. If an activity log alert + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. - :type enabled: bool + :vartype enabled: bool """ _attribute_map = { @@ -372,6 +455,13 @@ def __init__( enabled: Optional[bool] = True, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this activity log alert is enabled. If an activity log + alert is not enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ super(ActivityLogAlertPatchBody, self).__init__(**kwargs) self.tags = tags self.enabled = enabled @@ -390,23 +480,23 @@ class ActivityLogAlertResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param scopes: A list of resourceIds that will be used as prefixes. The alert will only apply - to activityLogs with resourceIds that fall under one of these prefixes. This list must include - at least one item. - :type scopes: list[str] - :param enabled: Indicates whether this activity log alert is enabled. If an activity log alert + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar scopes: A list of resourceIds that will be used as prefixes. The alert will only apply to + activityLogs with resourceIds that fall under one of these prefixes. This list must include at + least one item. + :vartype scopes: list[str] + :ivar enabled: Indicates whether this activity log alert is enabled. If an activity log alert is not enabled, then none of its actions will be activated. - :type enabled: bool - :param condition: The condition that will cause this alert to activate. - :type condition: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertAllOfCondition - :param actions: The actions that will activate when the condition is met. - :type actions: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertActionList - :param description: A description of this activity log alert. - :type description: str + :vartype enabled: bool + :ivar condition: The condition that will cause this alert to activate. + :vartype condition: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertAllOfCondition + :ivar actions: The actions that will activate when the condition is met. + :vartype actions: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertActionList + :ivar description: A description of this activity log alert. + :vartype description: str """ _validation = { @@ -441,6 +531,26 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword scopes: A list of resourceIds that will be used as prefixes. The alert will only apply + to activityLogs with resourceIds that fall under one of these prefixes. This list must include + at least one item. + :paramtype scopes: list[str] + :keyword enabled: Indicates whether this activity log alert is enabled. If an activity log + alert is not enabled, then none of its actions will be activated. + :paramtype enabled: bool + :keyword condition: The condition that will cause this alert to activate. + :paramtype condition: + ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertAllOfCondition + :keyword actions: The actions that will activate when the condition is met. + :paramtype actions: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertActionList + :keyword description: A description of this activity log alert. + :paramtype description: str + """ super(ActivityLogAlertResource, self).__init__(location=location, tags=tags, **kwargs) self.scopes = scopes self.enabled = enabled @@ -454,19 +564,19 @@ class AutomationRunbookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. - :type automation_account_id: str - :param runbook_name: Required. The name for this runbook. - :type runbook_name: str - :param webhook_resource_id: Required. The resource id for webhook linked to this runbook. - :type webhook_resource_id: str - :param is_global_runbook: Required. Indicates whether this instance is global runbook. - :type is_global_runbook: bool - :param name: Indicates name of the webhook. - :type name: str - :param service_uri: The URI where webhooks should be sent. - :type service_uri: str + :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook + and authenticate to Azure resource. + :vartype automation_account_id: str + :ivar runbook_name: Required. The name for this runbook. + :vartype runbook_name: str + :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :vartype webhook_resource_id: str + :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :vartype is_global_runbook: bool + :ivar name: Indicates name of the webhook. + :vartype name: str + :ivar service_uri: The URI where webhooks should be sent. + :vartype service_uri: str """ _validation = { @@ -496,6 +606,21 @@ def __init__( service_uri: Optional[str] = None, **kwargs ): + """ + :keyword automation_account_id: Required. The Azure automation account Id which holds this + runbook and authenticate to Azure resource. + :paramtype automation_account_id: str + :keyword runbook_name: Required. The name for this runbook. + :paramtype runbook_name: str + :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :paramtype webhook_resource_id: str + :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :paramtype is_global_runbook: bool + :keyword name: Indicates name of the webhook. + :paramtype name: str + :keyword service_uri: The URI where webhooks should be sent. + :paramtype service_uri: str + """ super(AutomationRunbookReceiver, self).__init__(**kwargs) self.automation_account_id = automation_account_id self.runbook_name = runbook_name @@ -510,11 +635,11 @@ class AzureAppPushReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Azure mobile app push receiver. Names must be unique + :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. - :type name: str - :param email_address: Required. The email address registered for the Azure mobile app. - :type email_address: str + :vartype name: str + :ivar email_address: Required. The email address registered for the Azure mobile app. + :vartype email_address: str """ _validation = { @@ -534,6 +659,13 @@ def __init__( email_address: str, **kwargs ): + """ + :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique + across all receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address registered for the Azure mobile app. + :paramtype email_address: str + """ super(AzureAppPushReceiver, self).__init__(**kwargs) self.name = name self.email_address = email_address @@ -546,11 +678,11 @@ class EmailReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param email_address: Required. The email address of this receiver. - :type email_address: str + :ivar name: Required. The name of the email receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar email_address: Required. The email address of this receiver. + :vartype email_address: str :ivar status: The receiver status of the e-mail. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2017_04_01.models.ReceiverStatus @@ -575,6 +707,13 @@ def __init__( email_address: str, **kwargs ): + """ + :keyword name: Required. The name of the email receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address of this receiver. + :paramtype email_address: str + """ super(EmailReceiver, self).__init__(**kwargs) self.name = name self.email_address = email_address @@ -586,8 +725,8 @@ class EnableRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param receiver_name: Required. The name of the receiver to resubscribe. - :type receiver_name: str + :ivar receiver_name: Required. The name of the receiver to resubscribe. + :vartype receiver_name: str """ _validation = { @@ -604,6 +743,10 @@ def __init__( receiver_name: str, **kwargs ): + """ + :keyword receiver_name: Required. The name of the receiver to resubscribe. + :paramtype receiver_name: str + """ super(EnableRequest, self).__init__(**kwargs) self.receiver_name = receiver_name @@ -611,10 +754,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -629,6 +772,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -639,20 +788,20 @@ class ItsmReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Itsm receiver. Names must be unique across all receivers + :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers within an action group. - :type name: str - :param workspace_id: Required. OMS LA instance identifier. - :type workspace_id: str - :param connection_id: Required. Unique identification of ITSM connection among multiple defined + :vartype name: str + :ivar workspace_id: Required. OMS LA instance identifier. + :vartype workspace_id: str + :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined in above workspace. - :type connection_id: str - :param ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + :vartype connection_id: str + :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as well. - :type ticket_configuration: str - :param region: Required. Region in which workspace resides. Supported + :vartype ticket_configuration: str + :ivar region: Required. Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - :type region: str + :vartype region: str """ _validation = { @@ -681,6 +830,22 @@ def __init__( region: str, **kwargs ): + """ + :keyword name: Required. The name of the Itsm receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword workspace_id: Required. OMS LA instance identifier. + :paramtype workspace_id: str + :keyword connection_id: Required. Unique identification of ITSM connection among multiple + defined in above workspace. + :paramtype connection_id: str + :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. + :paramtype ticket_configuration: str + :keyword region: Required. Region in which workspace resides. Supported + values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + :paramtype region: str + """ super(ItsmReceiver, self).__init__(**kwargs) self.name = name self.workspace_id = workspace_id @@ -696,13 +861,13 @@ class SmsReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SMS receiver. Names must be unique across all receivers + :ivar name: Required. The name of the SMS receiver. Names must be unique across all receivers within an action group. - :type name: str - :param country_code: Required. The country code of the SMS receiver. - :type country_code: str - :param phone_number: Required. The phone number of the SMS receiver. - :type phone_number: str + :vartype name: str + :ivar country_code: Required. The country code of the SMS receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the SMS receiver. + :vartype phone_number: str :ivar status: The status of the receiver. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2017_04_01.models.ReceiverStatus @@ -730,6 +895,15 @@ def __init__( phone_number: str, **kwargs ): + """ + :keyword name: Required. The name of the SMS receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the SMS receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the SMS receiver. + :paramtype phone_number: str + """ super(SmsReceiver, self).__init__(**kwargs) self.name = name self.country_code = country_code @@ -742,11 +916,11 @@ class WebhookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the webhook receiver. Names must be unique across all + :ivar name: Required. The name of the webhook receiver. Names must be unique across all receivers within an action group. - :type name: str - :param service_uri: Required. The URI where webhooks should be sent. - :type service_uri: str + :vartype name: str + :ivar service_uri: Required. The URI where webhooks should be sent. + :vartype service_uri: str """ _validation = { @@ -766,6 +940,13 @@ def __init__( service_uri: str, **kwargs ): + """ + :keyword name: Required. The name of the webhook receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword service_uri: Required. The URI where webhooks should be sent. + :paramtype service_uri: str + """ super(WebhookReceiver, self).__init__(**kwargs) self.name = name self.service_uri = service_uri diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_monitor_management_client_enums.py index 238df22ea2f0b..5e8a759db49cf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/models/_monitor_management_client_enums.py @@ -6,27 +6,12 @@ # 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 ReceiverStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReceiverStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates the status of the receiver. Receivers that are not Enabled will not receive any communications. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_action_groups_operations.py index ea02f9051b2b3..8f201aa945f02 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_action_groups_operations.py @@ -5,24 +5,290 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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_delete_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + action_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_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] + 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, + **kwargs + ) + + +def build_list_by_subscription_id_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups') + 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( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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_enable_receiver_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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] + 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class ActionGroupsOperations(object): """ActionGroupsOperations operations. @@ -45,6 +311,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -55,7 +322,7 @@ def create_or_update( # type: (...) -> "_models.ActionGroupResource" """Create a new action group or update an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -71,38 +338,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group, 'ActionGroupResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group, 'ActionGroupResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -115,8 +372,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -126,7 +386,7 @@ def get( # type: (...) -> "_models.ActionGroupResource" """Get an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -140,33 +400,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -175,8 +425,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -186,7 +439,7 @@ def delete( # type: (...) -> None """Delete an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -200,33 +453,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -234,6 +477,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -244,7 +489,7 @@ def update( # type: (...) -> "_models.ActionGroupResource" """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -260,38 +505,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - 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'), - 'actionGroupName': self._serialize.url("action_group_name", action_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -300,8 +535,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def list_by_subscription_id( self, **kwargs # type: Any @@ -311,7 +549,8 @@ def list_by_subscription_id( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ActionGroupList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupList] + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -319,34 +558,29 @@ def list_by_subscription_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-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_subscription_id.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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription_id.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_list_by_subscription_id_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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -359,17 +593,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -378,11 +614,12 @@ def list_by_resource_group( # type: (...) -> Iterable["_models.ActionGroupList"] """Get a list of all action groups in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 ActionGroupList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupList] + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -390,35 +627,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -431,17 +664,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.insights/actionGroups'} # type: ignore + @distributed_trace def enable_receiver( self, resource_group_name, # type: str @@ -453,7 +688,7 @@ def enable_receiver( """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -469,41 +704,32 @@ def enable_receiver( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.enable_receiver.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(enable_request, 'EnableRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_enable_receiver_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.enable_receiver.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(enable_request, 'EnableRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(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, 409]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) enable_receiver.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_activity_log_alerts_operations.py index f1b3eaf39f846..1818ad14dd084 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_activity_log_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_04_01/operations/_activity_log_alerts_operations.py @@ -5,24 +5,250 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + subscription_id, # type: str + resource_group_name, # type: str + activity_log_alert_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_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, + **kwargs + ) + + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + activity_log_alert_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_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_delete_request( + subscription_id, # type: str + resource_group_name, # type: str + activity_log_alert_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_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, # type: str + resource_group_name, # type: str + activity_log_alert_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_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, + **kwargs + ) + + +def build_list_by_subscription_id_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts') + 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, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, 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 + ) + +# fmt: on class ActivityLogAlertsOperations(object): """ActivityLogAlertsOperations operations. @@ -45,6 +271,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -55,7 +282,7 @@ def create_or_update( # type: (...) -> "_models.ActivityLogAlertResource" """Create a new activity log alert or update an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. :type activity_log_alert_name: str @@ -71,38 +298,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-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'), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(activity_log_alert, 'ActivityLogAlertResource') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(activity_log_alert, 'ActivityLogAlertResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -115,8 +332,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -126,7 +346,7 @@ def get( # type: (...) -> "_models.ActivityLogAlertResource" """Get an activity log alert. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. :type activity_log_alert_name: str @@ -140,33 +360,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-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'), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # 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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) @@ -175,8 +385,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -186,7 +399,7 @@ def delete( # type: (...) -> None """Delete an activity log alert. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. :type activity_log_alert_name: str @@ -200,33 +413,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-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'), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # 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_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -234,6 +437,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -245,12 +450,13 @@ def update( """Updates an existing ActivityLogAlertResource's tags. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param activity_log_alert_name: The name of the activity log alert. :type activity_log_alert_name: str :param activity_log_alert_patch: Parameters supplied to the operation. - :type activity_log_alert_patch: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertPatchBody + :type activity_log_alert_patch: + ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertPatchBody :keyword callable cls: A custom type or function that will be passed the direct response :return: ActivityLogAlertResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertResource @@ -261,38 +467,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-01" - 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'), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(activity_log_alert_patch, 'ActivityLogAlertPatchBody') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(activity_log_alert_patch, 'ActivityLogAlertPatchBody') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) @@ -301,8 +497,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace def list_by_subscription_id( self, **kwargs # type: Any @@ -311,8 +510,10 @@ def list_by_subscription_id( """Get a list of all activity log alerts 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 ActivityLogAlertList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertList] + :return: An iterator like instance of either ActivityLogAlertList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertList"] @@ -320,34 +521,29 @@ def list_by_subscription_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-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_subscription_id.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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription_id.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_list_by_subscription_id_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('ActivityLogAlertList', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -360,17 +556,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/activityLogAlerts'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -379,11 +577,13 @@ def list_by_resource_group( # type: (...) -> Iterable["_models.ActivityLogAlertList"] """Get a list of all activity log alerts in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 ActivityLogAlertList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertList] + :return: An iterator like instance of either ActivityLogAlertList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_04_01.models.ActivityLogAlertList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActivityLogAlertList"] @@ -391,35 +591,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-04-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') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('ActivityLogAlertList', pipeline_response) + deserialized = self._deserialize("ActivityLogAlertList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -432,12 +628,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_configuration.py index 7f204474d1896..ab58ec15ec06e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_metadata.json index 1ae63ddbf3366..0f3d571414fae 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "diagnostic_settings_category": "DiagnosticSettingsCategoryOperations", diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_monitor_management_client.py index bc4d0dc8dbcd5..4d8c526660265 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_monitor_management_client.py @@ -6,93 +6,96 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import DiagnosticSettingsCategoryOperations, DiagnosticSettingsOperations, MetricDefinitionsOperations, MetricsOperations, SubscriptionDiagnosticSettingsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import DiagnosticSettingsCategoryOperations -from .operations import DiagnosticSettingsOperations -from .operations import MetricDefinitionsOperations -from .operations import MetricsOperations -from .operations import SubscriptionDiagnosticSettingsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. :ivar diagnostic_settings_category: DiagnosticSettingsCategoryOperations operations - :vartype diagnostic_settings_category: $(python-base-namespace).v2017_05_01_preview.operations.DiagnosticSettingsCategoryOperations + :vartype diagnostic_settings_category: + $(python-base-namespace).v2017_05_01_preview.operations.DiagnosticSettingsCategoryOperations :ivar diagnostic_settings: DiagnosticSettingsOperations operations - :vartype diagnostic_settings: $(python-base-namespace).v2017_05_01_preview.operations.DiagnosticSettingsOperations + :vartype diagnostic_settings: + $(python-base-namespace).v2017_05_01_preview.operations.DiagnosticSettingsOperations :ivar metric_definitions: MetricDefinitionsOperations operations - :vartype metric_definitions: $(python-base-namespace).v2017_05_01_preview.operations.MetricDefinitionsOperations + :vartype metric_definitions: + $(python-base-namespace).v2017_05_01_preview.operations.MetricDefinitionsOperations :ivar metrics: MetricsOperations operations :vartype metrics: $(python-base-namespace).v2017_05_01_preview.operations.MetricsOperations :ivar subscription_diagnostic_settings: SubscriptionDiagnosticSettingsOperations operations - :vartype subscription_diagnostic_settings: $(python-base-namespace).v2017_05_01_preview.operations.SubscriptionDiagnosticSettingsOperations + :vartype subscription_diagnostic_settings: + $(python-base-namespace).v2017_05_01_preview.operations.SubscriptionDiagnosticSettingsOperations :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations(self._client, self._config, self._serialize, self._deserialize) + self.diagnostic_settings = DiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_definitions = MetricDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations( - self._client, self._config, self._serialize, self._deserialize) - self.diagnostic_settings = DiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.metric_definitions = MetricDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.metrics = MetricsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_configuration.py index 45862e08ab639..ac5e4fab2ecee 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_monitor_management_client.py index f01ad0b4a80c6..e5c199e8f47c5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_monitor_management_client.py @@ -6,89 +6,92 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import DiagnosticSettingsCategoryOperations, DiagnosticSettingsOperations, MetricDefinitionsOperations, MetricsOperations, SubscriptionDiagnosticSettingsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MonitorManagementClientConfiguration -from .operations import DiagnosticSettingsCategoryOperations -from .operations import DiagnosticSettingsOperations -from .operations import MetricDefinitionsOperations -from .operations import MetricsOperations -from .operations import SubscriptionDiagnosticSettingsOperations -from .. import models - - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar diagnostic_settings_category: DiagnosticSettingsCategoryOperations operations - :vartype diagnostic_settings_category: $(python-base-namespace).v2017_05_01_preview.aio.operations.DiagnosticSettingsCategoryOperations + :vartype diagnostic_settings_category: + $(python-base-namespace).v2017_05_01_preview.aio.operations.DiagnosticSettingsCategoryOperations :ivar diagnostic_settings: DiagnosticSettingsOperations operations - :vartype diagnostic_settings: $(python-base-namespace).v2017_05_01_preview.aio.operations.DiagnosticSettingsOperations + :vartype diagnostic_settings: + $(python-base-namespace).v2017_05_01_preview.aio.operations.DiagnosticSettingsOperations :ivar metric_definitions: MetricDefinitionsOperations operations - :vartype metric_definitions: $(python-base-namespace).v2017_05_01_preview.aio.operations.MetricDefinitionsOperations + :vartype metric_definitions: + $(python-base-namespace).v2017_05_01_preview.aio.operations.MetricDefinitionsOperations :ivar metrics: MetricsOperations operations :vartype metrics: $(python-base-namespace).v2017_05_01_preview.aio.operations.MetricsOperations :ivar subscription_diagnostic_settings: SubscriptionDiagnosticSettingsOperations operations - :vartype subscription_diagnostic_settings: $(python-base-namespace).v2017_05_01_preview.aio.operations.SubscriptionDiagnosticSettingsOperations + :vartype subscription_diagnostic_settings: + $(python-base-namespace).v2017_05_01_preview.aio.operations.SubscriptionDiagnosticSettingsOperations :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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations(self._client, self._config, self._serialize, self._deserialize) + self.diagnostic_settings = DiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_definitions = MetricDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations( - self._client, self._config, self._serialize, self._deserialize) - self.diagnostic_settings = DiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.metric_definitions = MetricDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.metrics = MetricsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py index 45f9db049d631..cafab6b4b88bc 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py @@ -5,16 +5,20 @@ # 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, Optional, TypeVar import warnings 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_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._diagnostic_settings_category_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_uri: str, @@ -62,32 +67,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_get_request( + resource_uri=resource_uri, + name=name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DiagnosticSettingsCategoryResource', pipeline_response) @@ -96,8 +91,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}'} # type: ignore + + @distributed_trace_async async def list( self, resource_uri: str, @@ -109,7 +107,8 @@ async def list( :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticSettingsCategoryResourceCollection, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsCategoryResourceCollection + :rtype: + ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsCategoryResourceCollection :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsCategoryResourceCollection"] @@ -117,31 +116,21 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - accept = "application/json" - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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_list_request( + resource_uri=resource_uri, + 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) 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DiagnosticSettingsCategoryResourceCollection', pipeline_response) @@ -150,4 +139,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_operations.py index 6e9b20cb81468..f57b4c4dd0a91 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_diagnostic_settings_operations.py @@ -5,16 +5,20 @@ # 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, Optional, TypeVar import warnings 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_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._diagnostic_settings_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_uri: str, @@ -62,32 +67,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_get_request( + resource_uri=resource_uri, + name=name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DiagnosticSettingsResource', pipeline_response) @@ -96,8 +91,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_uri: str, @@ -112,7 +110,8 @@ async def create_or_update( :param name: The name of the diagnostic setting. :type name: str :param parameters: Parameters supplied to the operation. - :type parameters: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource + :type parameters: + ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticSettingsResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource @@ -123,37 +122,27 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - 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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DiagnosticSettingsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_uri=resource_uri, + name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DiagnosticSettingsResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DiagnosticSettingsResource', pipeline_response) @@ -162,8 +151,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_uri: str, @@ -186,32 +178,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_delete_request( + resource_uri=resource_uri, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -219,6 +201,8 @@ async def delete( delete.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace_async async def list( self, resource_uri: str, @@ -230,7 +214,8 @@ async def list( :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticSettingsResourceCollection, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResourceCollection + :rtype: + ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResourceCollection :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsResourceCollection"] @@ -238,31 +223,21 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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_list_request( + resource_uri=resource_uri, + 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) 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DiagnosticSettingsResourceCollection', pipeline_response) @@ -271,4 +246,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metric_definitions_operations.py index 2f1e2fcc8abb1..ca5ce67eba088 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metric_definitions_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._metric_definitions_operations import build_list_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 list( self, resource_uri: str, @@ -51,8 +57,10 @@ def list( :param resource_uri: The identifier of the resource. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinitionCollection] + :return: An iterator like instance of either MetricDefinitionCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinitionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionCollection"] @@ -60,34 +68,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-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 - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + template_url=self.list.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_list_request( + resource_uri=resource_uri, + 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('MetricDefinitionCollection', pipeline_response) + deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -100,12 +103,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metrics_operations.py index c67d4fab6b8a9..7e03d11992493 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metrics_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_metrics_operations.py @@ -6,16 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._metrics_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_uri: str, @@ -98,47 +103,29 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - accept = "application/json" - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if timespan is not None: - query_parameters['timespan'] = self._serialize.query("timespan", timespan, 'str') - if interval is not None: - query_parameters['interval'] = self._serialize.query("interval", interval, 'duration') - if metric is not None: - query_parameters['metric'] = self._serialize.query("metric", metric, 'str') - if aggregation is not None: - query_parameters['aggregation'] = self._serialize.query("aggregation", aggregation, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if result_type is not None: - query_parameters['resultType'] = self._serialize.query("result_type", result_type, '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_list_request( + resource_uri=resource_uri, + timespan=timespan, + interval=interval, + metric=metric, + aggregation=aggregation, + top=top, + orderby=orderby, + filter=filter, + result_type=result_type, + template_url=self.list.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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Response', pipeline_response) @@ -147,4 +134,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/metrics'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py index 64ba48d799b05..4b0c9ac8f0f1c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py @@ -5,16 +5,20 @@ # 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, Optional, TypeVar import warnings 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_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._subscription_diagnostic_settings_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, name: str, @@ -51,7 +56,8 @@ async def get( :type name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionDiagnosticSettingsResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :rtype: + ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResource"] @@ -59,32 +65,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - 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), - 'name': self._serialize.url("name", 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 = build_get_request( + subscription_id=self._config.subscription_id, + name=name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SubscriptionDiagnosticSettingsResource', pipeline_response) @@ -93,8 +89,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, name: str, @@ -106,10 +105,12 @@ async def create_or_update( :param name: The name of the diagnostic setting. :type name: str :param parameters: Parameters supplied to the operation. - :type parameters: ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :type parameters: + ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionDiagnosticSettingsResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :rtype: + ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResource"] @@ -117,37 +118,27 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - 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), - 'name': self._serialize.url("name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SubscriptionDiagnosticSettingsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SubscriptionDiagnosticSettingsResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SubscriptionDiagnosticSettingsResource', pipeline_response) @@ -156,8 +147,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace_async async def delete( self, name: str, @@ -177,32 +171,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-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), - 'name': self._serialize.url("name", 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 = build_delete_request( + subscription_id=self._config.subscription_id, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -210,6 +194,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace_async async def list( self, **kwargs: Any @@ -218,7 +204,8 @@ async def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionDiagnosticSettingsResourceCollection, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResourceCollection + :rtype: + ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResourceCollection :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResourceCollection"] @@ -226,31 +213,21 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - accept = "application/json" - - # 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + subscription_id=self._config.subscription_id, + 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) 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SubscriptionDiagnosticSettingsResourceCollection', pipeline_response) @@ -259,4 +236,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models.py index 4f1b71bd9ceec..2bc2cdc739f63 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models.py @@ -39,6 +39,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProxyOnlyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -56,9 +58,10 @@ class DiagnosticSettingsCategoryResource(ProxyOnlyResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param category_type: The type of the diagnostic settings category. Possible values include: + :ivar category_type: The type of the diagnostic settings category. Possible values include: "Metrics", "Logs". - :type category_type: str or ~$(python-base-namespace).v2017_05_01_preview.models.CategoryType + :vartype category_type: str or + ~$(python-base-namespace).v2017_05_01_preview.models.CategoryType """ _validation = { @@ -78,6 +81,12 @@ def __init__( self, **kwargs ): + """ + :keyword category_type: The type of the diagnostic settings category. Possible values include: + "Metrics", "Logs". + :paramtype category_type: str or + ~$(python-base-namespace).v2017_05_01_preview.models.CategoryType + """ super(DiagnosticSettingsCategoryResource, self).__init__(**kwargs) self.category_type = kwargs.get('category_type', None) @@ -85,8 +94,8 @@ def __init__( class DiagnosticSettingsCategoryResourceCollection(msrest.serialization.Model): """Represents a collection of diagnostic setting category resources. - :param value: The collection of diagnostic settings category resources. - :type value: + :ivar value: The collection of diagnostic settings category resources. + :vartype value: list[~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsCategoryResource] """ @@ -98,6 +107,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: The collection of diagnostic settings category resources. + :paramtype value: + list[~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsCategoryResource] + """ super(DiagnosticSettingsCategoryResourceCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -113,30 +127,30 @@ class DiagnosticSettingsResource(ProxyOnlyResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param storage_account_id: The resource ID of the storage account to which you would like to + :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. - :type service_bus_rule_id: str - :param event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :type event_hub_authorization_rule_id: str - :param event_hub_name: The name of the event hub. If none is specified, the default event hub + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :vartype event_hub_authorization_rule_id: str + :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub will be selected. - :type event_hub_name: str - :param metrics: The list of metric settings. - :type metrics: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricSettings] - :param logs: The list of logs settings. - :type logs: list[~$(python-base-namespace).v2017_05_01_preview.models.LogSettings] - :param workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would + :vartype event_hub_name: str + :ivar metrics: The list of metric settings. + :vartype metrics: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricSettings] + :ivar logs: The list of logs settings. + :vartype logs: list[~$(python-base-namespace).v2017_05_01_preview.models.LogSettings] + :ivar workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str - :param log_analytics_destination_type: A string indicating whether the export to Log Analytics + :vartype workspace_id: str + :ivar log_analytics_destination_type: A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type constructed as follows: :code:``_:code:``. Possible values are: Dedicated and null (null is default.). - :type log_analytics_destination_type: str + :vartype log_analytics_destination_type: str """ _validation = { @@ -163,6 +177,32 @@ def __init__( self, **kwargs ): + """ + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here + to maintain backwards compatibility. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub + will be selected. + :paramtype event_hub_name: str + :keyword metrics: The list of metric settings. + :paramtype metrics: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricSettings] + :keyword logs: The list of logs settings. + :paramtype logs: list[~$(python-base-namespace).v2017_05_01_preview.models.LogSettings] + :keyword workspace_id: The full ARM resource ID of the Log Analytics workspace to which you + would like to send Diagnostic Logs. Example: + /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + :paramtype workspace_id: str + :keyword log_analytics_destination_type: A string indicating whether the export to Log + Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination + type constructed as follows: :code:``_:code:``. Possible values are: Dedicated and null (null is default.). + :paramtype log_analytics_destination_type: str + """ super(DiagnosticSettingsResource, self).__init__(**kwargs) self.storage_account_id = kwargs.get('storage_account_id', None) self.service_bus_rule_id = kwargs.get('service_bus_rule_id', None) @@ -177,8 +217,8 @@ def __init__( class DiagnosticSettingsResourceCollection(msrest.serialization.Model): """Represents a collection of alert rule resources. - :param value: The collection of diagnostic settings resources;. - :type value: + :ivar value: The collection of diagnostic settings resources;. + :vartype value: list[~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource] """ @@ -190,6 +230,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: The collection of diagnostic settings resources;. + :paramtype value: + list[~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource] + """ super(DiagnosticSettingsResourceCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -197,10 +242,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -212,6 +257,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -222,10 +273,10 @@ class LocalizableString(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the invariant value. - :type value: str - :param localized_value: the locale specific value. - :type localized_value: str + :ivar value: Required. the invariant value. + :vartype value: str + :ivar localized_value: the locale specific value. + :vartype localized_value: str """ _validation = { @@ -241,6 +292,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. the invariant value. + :paramtype value: str + :keyword localized_value: the locale specific value. + :paramtype localized_value: str + """ super(LocalizableString, self).__init__(**kwargs) self.value = kwargs['value'] self.localized_value = kwargs.get('localized_value', None) @@ -251,14 +308,14 @@ class LogSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param category: Name of a Diagnostic Log category for a resource type this setting is applied + :ivar category: Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. - :type category: str - :param enabled: Required. a value indicating whether this log is enabled. - :type enabled: bool - :param retention_policy: the retention policy for this log. - :type retention_policy: ~$(python-base-namespace).v2017_05_01_preview.models.RetentionPolicy + :vartype category: str + :ivar enabled: Required. a value indicating whether this log is enabled. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this log. + :vartype retention_policy: ~$(python-base-namespace).v2017_05_01_preview.models.RetentionPolicy """ _validation = { @@ -275,6 +332,17 @@ def __init__( self, **kwargs ): + """ + :keyword category: Name of a Diagnostic Log category for a resource type this setting is + applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET + diagnostic settings operation. + :paramtype category: str + :keyword enabled: Required. a value indicating whether this log is enabled. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this log. + :paramtype retention_policy: + ~$(python-base-namespace).v2017_05_01_preview.models.RetentionPolicy + """ super(LogSettings, self).__init__(**kwargs) self.category = kwargs.get('category', None) self.enabled = kwargs['enabled'] @@ -284,10 +352,10 @@ def __init__( class MetadataValue(msrest.serialization.Model): """Represents a metric metadata value. - :param name: the name of the metadata. - :type name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString - :param value: the value of the metadata. - :type value: str + :ivar name: the name of the metadata. + :vartype name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString + :ivar value: the value of the metadata. + :vartype value: str """ _attribute_map = { @@ -299,6 +367,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: the name of the metadata. + :paramtype name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString + :keyword value: the value of the metadata. + :paramtype value: str + """ super(MetadataValue, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.value = kwargs.get('value', None) @@ -309,25 +383,26 @@ class Metric(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. the metric Id. - :type id: str - :param type: Required. the resource type of the metric resource. - :type type: str - :param name: Required. the name and the display name of the metric, i.e. it is localizable + :ivar id: Required. the metric Id. + :vartype id: str + :ivar type: Required. the resource type of the metric resource. + :vartype type: str + :ivar name: Required. the name and the display name of the metric, i.e. it is localizable string. - :type name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString - :param display_description: Detailed description of this metric. - :type display_description: str - :param error_code: 'Success' or the error details on query failures for this metric. - :type error_code: str - :param error_message: Error message encountered querying this specific metric. - :type error_message: str - :param unit: Required. the unit of the metric. Possible values include: "Count", "Bytes", + :vartype name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString + :ivar display_description: Detailed description of this metric. + :vartype display_description: str + :ivar error_code: 'Success' or the error details on query failures for this metric. + :vartype error_code: str + :ivar error_message: Error message encountered querying this specific metric. + :vartype error_message: str + :ivar unit: Required. the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". - :type unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit - :param timeseries: Required. the time series returned when a data query is performed. - :type timeseries: list[~$(python-base-namespace).v2017_05_01_preview.models.TimeSeriesElement] + :vartype unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit + :ivar timeseries: Required. the time series returned when a data query is performed. + :vartype timeseries: + list[~$(python-base-namespace).v2017_05_01_preview.models.TimeSeriesElement] """ _validation = { @@ -353,6 +428,28 @@ def __init__( self, **kwargs ): + """ + :keyword id: Required. the metric Id. + :paramtype id: str + :keyword type: Required. the resource type of the metric resource. + :paramtype type: str + :keyword name: Required. the name and the display name of the metric, i.e. it is localizable + string. + :paramtype name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString + :keyword display_description: Detailed description of this metric. + :paramtype display_description: str + :keyword error_code: 'Success' or the error details on query failures for this metric. + :paramtype error_code: str + :keyword error_message: Error message encountered querying this specific metric. + :paramtype error_message: str + :keyword unit: Required. the unit of the metric. Possible values include: "Count", "Bytes", + "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", + "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + :paramtype unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit + :keyword timeseries: Required. the time series returned when a data query is performed. + :paramtype timeseries: + list[~$(python-base-namespace).v2017_05_01_preview.models.TimeSeriesElement] + """ super(Metric, self).__init__(**kwargs) self.id = kwargs['id'] self.type = kwargs['type'] @@ -367,12 +464,12 @@ def __init__( class MetricAvailability(msrest.serialization.Model): """Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. - :param time_grain: the time grain specifies the aggregation interval for the metric. Expressed + :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. - :type time_grain: ~datetime.timedelta - :param retention: the retention period for the metric at the specified timegrain. Expressed as + :vartype time_grain: ~datetime.timedelta + :ivar retention: the retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc. - :type retention: ~datetime.timedelta + :vartype retention: ~datetime.timedelta """ _attribute_map = { @@ -384,6 +481,14 @@ def __init__( self, **kwargs ): + """ + :keyword time_grain: the time grain specifies the aggregation interval for the metric. + Expressed as a duration 'PT1M', 'P1D', etc. + :paramtype time_grain: ~datetime.timedelta + :keyword retention: the retention period for the metric at the specified timegrain. Expressed + as a duration 'PT1M', 'P1D', etc. + :paramtype retention: ~datetime.timedelta + """ super(MetricAvailability, self).__init__(**kwargs) self.time_grain = kwargs.get('time_grain', None) self.retention = kwargs.get('retention', None) @@ -392,34 +497,35 @@ def __init__( class MetricDefinition(msrest.serialization.Model): """Metric definition class specifies the metadata for a metric. - :param is_dimension_required: Flag to indicate whether the dimension is required. - :type is_dimension_required: bool - :param resource_id: the resource identifier of the resource that emitted the metric. - :type resource_id: str - :param name: the name and the display name of the metric, i.e. it is a localizable string. - :type name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString - :param display_description: Detailed description of this metric. - :type display_description: str - :param category: Custom category name for this metric. - :type category: str - :param unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + :ivar is_dimension_required: Flag to indicate whether the dimension is required. + :vartype is_dimension_required: bool + :ivar resource_id: the resource identifier of the resource that emitted the metric. + :vartype resource_id: str + :ivar name: the name and the display name of the metric, i.e. it is a localizable string. + :vartype name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString + :ivar display_description: Detailed description of this metric. + :vartype display_description: str + :ivar category: Custom category name for this metric. + :vartype category: str + :ivar unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". - :type unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit - :param primary_aggregation_type: the primary aggregation type value defining how to use the + :vartype unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit + :ivar primary_aggregation_type: the primary aggregation type value defining how to use the values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", "Total". - :type primary_aggregation_type: str or + :vartype primary_aggregation_type: str or ~$(python-base-namespace).v2017_05_01_preview.models.AggregationType - :param metric_availabilities: the collection of what aggregation intervals are available to be + :ivar metric_availabilities: the collection of what aggregation intervals are available to be queried. - :type metric_availabilities: + :vartype metric_availabilities: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricAvailability] - :param id: the resource identifier of the metric definition. - :type id: str - :param dimensions: the name and the display name of the dimension, i.e. it is a localizable + :ivar id: the resource identifier of the metric definition. + :vartype id: str + :ivar dimensions: the name and the display name of the dimension, i.e. it is a localizable string. - :type dimensions: list[~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString] + :vartype dimensions: + list[~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString] """ _attribute_map = { @@ -439,6 +545,37 @@ def __init__( self, **kwargs ): + """ + :keyword is_dimension_required: Flag to indicate whether the dimension is required. + :paramtype is_dimension_required: bool + :keyword resource_id: the resource identifier of the resource that emitted the metric. + :paramtype resource_id: str + :keyword name: the name and the display name of the metric, i.e. it is a localizable string. + :paramtype name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString + :keyword display_description: Detailed description of this metric. + :paramtype display_description: str + :keyword category: Custom category name for this metric. + :paramtype category: str + :keyword unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", + "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + :paramtype unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit + :keyword primary_aggregation_type: the primary aggregation type value defining how to use the + values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", + "Total". + :paramtype primary_aggregation_type: str or + ~$(python-base-namespace).v2017_05_01_preview.models.AggregationType + :keyword metric_availabilities: the collection of what aggregation intervals are available to + be queried. + :paramtype metric_availabilities: + list[~$(python-base-namespace).v2017_05_01_preview.models.MetricAvailability] + :keyword id: the resource identifier of the metric definition. + :paramtype id: str + :keyword dimensions: the name and the display name of the dimension, i.e. it is a localizable + string. + :paramtype dimensions: + list[~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString] + """ super(MetricDefinition, self).__init__(**kwargs) self.is_dimension_required = kwargs.get('is_dimension_required', None) self.resource_id = kwargs.get('resource_id', None) @@ -457,8 +594,8 @@ class MetricDefinitionCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the values for the metric definitions. - :type value: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinition] + :ivar value: Required. the values for the metric definitions. + :vartype value: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinition] """ _validation = { @@ -473,6 +610,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. the values for the metric definitions. + :paramtype value: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinition] + """ super(MetricDefinitionCollection, self).__init__(**kwargs) self.value = kwargs['value'] @@ -482,16 +623,16 @@ class MetricSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_grain: the timegrain of the metric in ISO8601 format. - :type time_grain: ~datetime.timedelta - :param category: Name of a Diagnostic Metric category for a resource type this setting is + :ivar time_grain: the timegrain of the metric in ISO8601 format. + :vartype time_grain: ~datetime.timedelta + :ivar category: Name of a Diagnostic Metric category for a resource type this setting is applied to. To obtain the list of Diagnostic metric categories for a resource, first perform a GET diagnostic settings operation. - :type category: str - :param enabled: Required. a value indicating whether this category is enabled. - :type enabled: bool - :param retention_policy: the retention policy for this category. - :type retention_policy: ~$(python-base-namespace).v2017_05_01_preview.models.RetentionPolicy + :vartype category: str + :ivar enabled: Required. a value indicating whether this category is enabled. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this category. + :vartype retention_policy: ~$(python-base-namespace).v2017_05_01_preview.models.RetentionPolicy """ _validation = { @@ -509,6 +650,19 @@ def __init__( self, **kwargs ): + """ + :keyword time_grain: the timegrain of the metric in ISO8601 format. + :paramtype time_grain: ~datetime.timedelta + :keyword category: Name of a Diagnostic Metric category for a resource type this setting is + applied to. To obtain the list of Diagnostic metric categories for a resource, first perform a + GET diagnostic settings operation. + :paramtype category: str + :keyword enabled: Required. a value indicating whether this category is enabled. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this category. + :paramtype retention_policy: + ~$(python-base-namespace).v2017_05_01_preview.models.RetentionPolicy + """ super(MetricSettings, self).__init__(**kwargs) self.time_grain = kwargs.get('time_grain', None) self.category = kwargs.get('category', None) @@ -521,19 +675,19 @@ class MetricValue(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_stamp: Required. the timestamp for the metric value in ISO 8601 format. - :type time_stamp: ~datetime.datetime - :param average: the average value in the time range. - :type average: float - :param minimum: the least value in the time range. - :type minimum: float - :param maximum: the greatest value in the time range. - :type maximum: float - :param total: the sum of all of the values in the time range. - :type total: float - :param count: the number of samples in the time range. Can be used to determine the number of + :ivar time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :vartype time_stamp: ~datetime.datetime + :ivar average: the average value in the time range. + :vartype average: float + :ivar minimum: the least value in the time range. + :vartype minimum: float + :ivar maximum: the greatest value in the time range. + :vartype maximum: float + :ivar total: the sum of all of the values in the time range. + :vartype total: float + :ivar count: the number of samples in the time range. Can be used to determine the number of values that contributed to the average value. - :type count: long + :vartype count: long """ _validation = { @@ -553,6 +707,21 @@ def __init__( self, **kwargs ): + """ + :keyword time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :paramtype time_stamp: ~datetime.datetime + :keyword average: the average value in the time range. + :paramtype average: float + :keyword minimum: the least value in the time range. + :paramtype minimum: float + :keyword maximum: the greatest value in the time range. + :paramtype maximum: float + :keyword total: the sum of all of the values in the time range. + :paramtype total: float + :keyword count: the number of samples in the time range. Can be used to determine the number of + values that contributed to the average value. + :paramtype count: long + """ super(MetricValue, self).__init__(**kwargs) self.time_stamp = kwargs['time_stamp'] self.average = kwargs.get('average', None) @@ -567,18 +736,18 @@ class Response(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param cost: The integer value representing the relative cost of the query. - :type cost: int - :param timespan: Required. The timespan for which the data was retrieved. Its value consists of + :ivar cost: The integer value representing the relative cost of the query. + :vartype cost: int + :ivar timespan: Required. The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. - :type timespan: str - :param interval: The interval (window size) for which the metric data was returned in. This - may be adjusted in the future and returned back from what was originally requested. This is - not present if a metadata request was made. - :type interval: ~datetime.timedelta - :param value: Required. the value of the collection. - :type value: list[~$(python-base-namespace).v2017_05_01_preview.models.Metric] + :vartype timespan: str + :ivar interval: The interval (window size) for which the metric data was returned in. This may + be adjusted in the future and returned back from what was originally requested. This is not + present if a metadata request was made. + :vartype interval: ~datetime.timedelta + :ivar value: Required. the value of the collection. + :vartype value: list[~$(python-base-namespace).v2017_05_01_preview.models.Metric] """ _validation = { @@ -598,6 +767,20 @@ def __init__( self, **kwargs ): + """ + :keyword cost: The integer value representing the relative cost of the query. + :paramtype cost: int + :keyword timespan: Required. The timespan for which the data was retrieved. Its value consists + of two datetimes concatenated, separated by '/'. This may be adjusted in the future and + returned back from what was originally requested. + :paramtype timespan: str + :keyword interval: The interval (window size) for which the metric data was returned in. This + may be adjusted in the future and returned back from what was originally requested. This is + not present if a metadata request was made. + :paramtype interval: ~datetime.timedelta + :keyword value: Required. the value of the collection. + :paramtype value: list[~$(python-base-namespace).v2017_05_01_preview.models.Metric] + """ super(Response, self).__init__(**kwargs) self.cost = kwargs.get('cost', None) self.timespan = kwargs['timespan'] @@ -610,11 +793,11 @@ class RetentionPolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param enabled: Required. a value indicating whether the retention policy is enabled. - :type enabled: bool - :param days: Required. the number of days for the retention in days. A value of 0 will retain + :ivar enabled: Required. a value indicating whether the retention policy is enabled. + :vartype enabled: bool + :ivar days: Required. the number of days for the retention in days. A value of 0 will retain the events indefinitely. - :type days: int + :vartype days: int """ _validation = { @@ -631,6 +814,13 @@ def __init__( self, **kwargs ): + """ + :keyword enabled: Required. a value indicating whether the retention policy is enabled. + :paramtype enabled: bool + :keyword days: Required. the number of days for the retention in days. A value of 0 will retain + the events indefinitely. + :paramtype days: int + """ super(RetentionPolicy, self).__init__(**kwargs) self.enabled = kwargs['enabled'] self.days = kwargs['days'] @@ -647,8 +837,8 @@ class SubscriptionProxyOnlyResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Location of the resource. - :type location: str + :ivar location: Location of the resource. + :vartype location: str """ _validation = { @@ -668,6 +858,10 @@ def __init__( self, **kwargs ): + """ + :keyword location: Location of the resource. + :paramtype location: str + """ super(SubscriptionProxyOnlyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -686,25 +880,26 @@ class SubscriptionDiagnosticSettingsResource(SubscriptionProxyOnlyResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Location of the resource. - :type location: str - :param storage_account_id: The resource ID of the storage account to which you would like to + :ivar location: Location of the resource. + :vartype location: str + :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. - :type service_bus_rule_id: str - :param event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :type event_hub_authorization_rule_id: str - :param event_hub_name: The name of the event hub. If none is specified, the default event hub + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :vartype event_hub_authorization_rule_id: str + :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub will be selected. - :type event_hub_name: str - :param logs: The list of logs settings. - :type logs: list[~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionLogSettings] - :param workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would + :vartype event_hub_name: str + :ivar logs: The list of logs settings. + :vartype logs: + list[~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionLogSettings] + :ivar workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str + :vartype workspace_id: str """ _validation = { @@ -730,6 +925,28 @@ def __init__( self, **kwargs ): + """ + :keyword location: Location of the resource. + :paramtype location: str + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here + to maintain backwards compatibility. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub + will be selected. + :paramtype event_hub_name: str + :keyword logs: The list of logs settings. + :paramtype logs: + list[~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionLogSettings] + :keyword workspace_id: The full ARM resource ID of the Log Analytics workspace to which you + would like to send Diagnostic Logs. Example: + /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + :paramtype workspace_id: str + """ super(SubscriptionDiagnosticSettingsResource, self).__init__(**kwargs) self.storage_account_id = kwargs.get('storage_account_id', None) self.service_bus_rule_id = kwargs.get('service_bus_rule_id', None) @@ -742,8 +959,8 @@ def __init__( class SubscriptionDiagnosticSettingsResourceCollection(msrest.serialization.Model): """Represents a collection of subscription diagnostic settings resources. - :param value: The collection of subscription diagnostic settings resources. - :type value: + :ivar value: The collection of subscription diagnostic settings resources. + :vartype value: list[~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource] """ @@ -755,6 +972,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: The collection of subscription diagnostic settings resources. + :paramtype value: + list[~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource] + """ super(SubscriptionDiagnosticSettingsResourceCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -764,11 +986,11 @@ class SubscriptionLogSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param category: Name of a Subscription Diagnostic Log category for a resource type this - setting is applied to. - :type category: str - :param enabled: Required. a value indicating whether this log is enabled. - :type enabled: bool + :ivar category: Name of a Subscription Diagnostic Log category for a resource type this setting + is applied to. + :vartype category: str + :ivar enabled: Required. a value indicating whether this log is enabled. + :vartype enabled: bool """ _validation = { @@ -784,6 +1006,13 @@ def __init__( self, **kwargs ): + """ + :keyword category: Name of a Subscription Diagnostic Log category for a resource type this + setting is applied to. + :paramtype category: str + :keyword enabled: Required. a value indicating whether this log is enabled. + :paramtype enabled: bool + """ super(SubscriptionLogSettings, self).__init__(**kwargs) self.category = kwargs.get('category', None) self.enabled = kwargs['enabled'] @@ -792,11 +1021,12 @@ def __init__( class TimeSeriesElement(msrest.serialization.Model): """A time series result type. The discriminator value is always TimeSeries in this case. - :param metadatavalues: the metadata values returned if $filter was specified in the call. - :type metadatavalues: list[~$(python-base-namespace).v2017_05_01_preview.models.MetadataValue] - :param data: An array of data points representing the metric values. This is only returned if - a result type of data is specified. - :type data: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricValue] + :ivar metadatavalues: the metadata values returned if $filter was specified in the call. + :vartype metadatavalues: + list[~$(python-base-namespace).v2017_05_01_preview.models.MetadataValue] + :ivar data: An array of data points representing the metric values. This is only returned if a + result type of data is specified. + :vartype data: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricValue] """ _attribute_map = { @@ -808,6 +1038,14 @@ def __init__( self, **kwargs ): + """ + :keyword metadatavalues: the metadata values returned if $filter was specified in the call. + :paramtype metadatavalues: + list[~$(python-base-namespace).v2017_05_01_preview.models.MetadataValue] + :keyword data: An array of data points representing the metric values. This is only returned + if a result type of data is specified. + :paramtype data: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricValue] + """ super(TimeSeriesElement, self).__init__(**kwargs) self.metadatavalues = kwargs.get('metadatavalues', None) self.data = kwargs.get('data', None) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models_py3.py index c5e381a974b89..5e7f0b6cacbc8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_models_py3.py @@ -44,6 +44,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProxyOnlyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -61,9 +63,10 @@ class DiagnosticSettingsCategoryResource(ProxyOnlyResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param category_type: The type of the diagnostic settings category. Possible values include: + :ivar category_type: The type of the diagnostic settings category. Possible values include: "Metrics", "Logs". - :type category_type: str or ~$(python-base-namespace).v2017_05_01_preview.models.CategoryType + :vartype category_type: str or + ~$(python-base-namespace).v2017_05_01_preview.models.CategoryType """ _validation = { @@ -85,6 +88,12 @@ def __init__( category_type: Optional[Union[str, "CategoryType"]] = None, **kwargs ): + """ + :keyword category_type: The type of the diagnostic settings category. Possible values include: + "Metrics", "Logs". + :paramtype category_type: str or + ~$(python-base-namespace).v2017_05_01_preview.models.CategoryType + """ super(DiagnosticSettingsCategoryResource, self).__init__(**kwargs) self.category_type = category_type @@ -92,8 +101,8 @@ def __init__( class DiagnosticSettingsCategoryResourceCollection(msrest.serialization.Model): """Represents a collection of diagnostic setting category resources. - :param value: The collection of diagnostic settings category resources. - :type value: + :ivar value: The collection of diagnostic settings category resources. + :vartype value: list[~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsCategoryResource] """ @@ -107,6 +116,11 @@ def __init__( value: Optional[List["DiagnosticSettingsCategoryResource"]] = None, **kwargs ): + """ + :keyword value: The collection of diagnostic settings category resources. + :paramtype value: + list[~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsCategoryResource] + """ super(DiagnosticSettingsCategoryResourceCollection, self).__init__(**kwargs) self.value = value @@ -122,30 +136,30 @@ class DiagnosticSettingsResource(ProxyOnlyResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param storage_account_id: The resource ID of the storage account to which you would like to + :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. - :type service_bus_rule_id: str - :param event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :type event_hub_authorization_rule_id: str - :param event_hub_name: The name of the event hub. If none is specified, the default event hub + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :vartype event_hub_authorization_rule_id: str + :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub will be selected. - :type event_hub_name: str - :param metrics: The list of metric settings. - :type metrics: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricSettings] - :param logs: The list of logs settings. - :type logs: list[~$(python-base-namespace).v2017_05_01_preview.models.LogSettings] - :param workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would + :vartype event_hub_name: str + :ivar metrics: The list of metric settings. + :vartype metrics: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricSettings] + :ivar logs: The list of logs settings. + :vartype logs: list[~$(python-base-namespace).v2017_05_01_preview.models.LogSettings] + :ivar workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str - :param log_analytics_destination_type: A string indicating whether the export to Log Analytics + :vartype workspace_id: str + :ivar log_analytics_destination_type: A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type constructed as follows: :code:``_:code:``. Possible values are: Dedicated and null (null is default.). - :type log_analytics_destination_type: str + :vartype log_analytics_destination_type: str """ _validation = { @@ -181,6 +195,32 @@ def __init__( log_analytics_destination_type: Optional[str] = None, **kwargs ): + """ + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here + to maintain backwards compatibility. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub + will be selected. + :paramtype event_hub_name: str + :keyword metrics: The list of metric settings. + :paramtype metrics: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricSettings] + :keyword logs: The list of logs settings. + :paramtype logs: list[~$(python-base-namespace).v2017_05_01_preview.models.LogSettings] + :keyword workspace_id: The full ARM resource ID of the Log Analytics workspace to which you + would like to send Diagnostic Logs. Example: + /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + :paramtype workspace_id: str + :keyword log_analytics_destination_type: A string indicating whether the export to Log + Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination + type constructed as follows: :code:``_:code:``. Possible values are: Dedicated and null (null is default.). + :paramtype log_analytics_destination_type: str + """ super(DiagnosticSettingsResource, self).__init__(**kwargs) self.storage_account_id = storage_account_id self.service_bus_rule_id = service_bus_rule_id @@ -195,8 +235,8 @@ def __init__( class DiagnosticSettingsResourceCollection(msrest.serialization.Model): """Represents a collection of alert rule resources. - :param value: The collection of diagnostic settings resources;. - :type value: + :ivar value: The collection of diagnostic settings resources;. + :vartype value: list[~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource] """ @@ -210,6 +250,11 @@ def __init__( value: Optional[List["DiagnosticSettingsResource"]] = None, **kwargs ): + """ + :keyword value: The collection of diagnostic settings resources;. + :paramtype value: + list[~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource] + """ super(DiagnosticSettingsResourceCollection, self).__init__(**kwargs) self.value = value @@ -217,10 +262,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -235,6 +280,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -245,10 +296,10 @@ class LocalizableString(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the invariant value. - :type value: str - :param localized_value: the locale specific value. - :type localized_value: str + :ivar value: Required. the invariant value. + :vartype value: str + :ivar localized_value: the locale specific value. + :vartype localized_value: str """ _validation = { @@ -267,6 +318,12 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. the invariant value. + :paramtype value: str + :keyword localized_value: the locale specific value. + :paramtype localized_value: str + """ super(LocalizableString, self).__init__(**kwargs) self.value = value self.localized_value = localized_value @@ -277,14 +334,14 @@ class LogSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param category: Name of a Diagnostic Log category for a resource type this setting is applied + :ivar category: Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. - :type category: str - :param enabled: Required. a value indicating whether this log is enabled. - :type enabled: bool - :param retention_policy: the retention policy for this log. - :type retention_policy: ~$(python-base-namespace).v2017_05_01_preview.models.RetentionPolicy + :vartype category: str + :ivar enabled: Required. a value indicating whether this log is enabled. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this log. + :vartype retention_policy: ~$(python-base-namespace).v2017_05_01_preview.models.RetentionPolicy """ _validation = { @@ -305,6 +362,17 @@ def __init__( retention_policy: Optional["RetentionPolicy"] = None, **kwargs ): + """ + :keyword category: Name of a Diagnostic Log category for a resource type this setting is + applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET + diagnostic settings operation. + :paramtype category: str + :keyword enabled: Required. a value indicating whether this log is enabled. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this log. + :paramtype retention_policy: + ~$(python-base-namespace).v2017_05_01_preview.models.RetentionPolicy + """ super(LogSettings, self).__init__(**kwargs) self.category = category self.enabled = enabled @@ -314,10 +382,10 @@ def __init__( class MetadataValue(msrest.serialization.Model): """Represents a metric metadata value. - :param name: the name of the metadata. - :type name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString - :param value: the value of the metadata. - :type value: str + :ivar name: the name of the metadata. + :vartype name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString + :ivar value: the value of the metadata. + :vartype value: str """ _attribute_map = { @@ -332,6 +400,12 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword name: the name of the metadata. + :paramtype name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString + :keyword value: the value of the metadata. + :paramtype value: str + """ super(MetadataValue, self).__init__(**kwargs) self.name = name self.value = value @@ -342,25 +416,26 @@ class Metric(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. the metric Id. - :type id: str - :param type: Required. the resource type of the metric resource. - :type type: str - :param name: Required. the name and the display name of the metric, i.e. it is localizable + :ivar id: Required. the metric Id. + :vartype id: str + :ivar type: Required. the resource type of the metric resource. + :vartype type: str + :ivar name: Required. the name and the display name of the metric, i.e. it is localizable string. - :type name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString - :param display_description: Detailed description of this metric. - :type display_description: str - :param error_code: 'Success' or the error details on query failures for this metric. - :type error_code: str - :param error_message: Error message encountered querying this specific metric. - :type error_message: str - :param unit: Required. the unit of the metric. Possible values include: "Count", "Bytes", + :vartype name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString + :ivar display_description: Detailed description of this metric. + :vartype display_description: str + :ivar error_code: 'Success' or the error details on query failures for this metric. + :vartype error_code: str + :ivar error_message: Error message encountered querying this specific metric. + :vartype error_message: str + :ivar unit: Required. the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". - :type unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit - :param timeseries: Required. the time series returned when a data query is performed. - :type timeseries: list[~$(python-base-namespace).v2017_05_01_preview.models.TimeSeriesElement] + :vartype unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit + :ivar timeseries: Required. the time series returned when a data query is performed. + :vartype timeseries: + list[~$(python-base-namespace).v2017_05_01_preview.models.TimeSeriesElement] """ _validation = { @@ -395,6 +470,28 @@ def __init__( error_message: Optional[str] = None, **kwargs ): + """ + :keyword id: Required. the metric Id. + :paramtype id: str + :keyword type: Required. the resource type of the metric resource. + :paramtype type: str + :keyword name: Required. the name and the display name of the metric, i.e. it is localizable + string. + :paramtype name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString + :keyword display_description: Detailed description of this metric. + :paramtype display_description: str + :keyword error_code: 'Success' or the error details on query failures for this metric. + :paramtype error_code: str + :keyword error_message: Error message encountered querying this specific metric. + :paramtype error_message: str + :keyword unit: Required. the unit of the metric. Possible values include: "Count", "Bytes", + "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", + "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + :paramtype unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit + :keyword timeseries: Required. the time series returned when a data query is performed. + :paramtype timeseries: + list[~$(python-base-namespace).v2017_05_01_preview.models.TimeSeriesElement] + """ super(Metric, self).__init__(**kwargs) self.id = id self.type = type @@ -409,12 +506,12 @@ def __init__( class MetricAvailability(msrest.serialization.Model): """Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. - :param time_grain: the time grain specifies the aggregation interval for the metric. Expressed + :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. - :type time_grain: ~datetime.timedelta - :param retention: the retention period for the metric at the specified timegrain. Expressed as + :vartype time_grain: ~datetime.timedelta + :ivar retention: the retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc. - :type retention: ~datetime.timedelta + :vartype retention: ~datetime.timedelta """ _attribute_map = { @@ -429,6 +526,14 @@ def __init__( retention: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword time_grain: the time grain specifies the aggregation interval for the metric. + Expressed as a duration 'PT1M', 'P1D', etc. + :paramtype time_grain: ~datetime.timedelta + :keyword retention: the retention period for the metric at the specified timegrain. Expressed + as a duration 'PT1M', 'P1D', etc. + :paramtype retention: ~datetime.timedelta + """ super(MetricAvailability, self).__init__(**kwargs) self.time_grain = time_grain self.retention = retention @@ -437,34 +542,35 @@ def __init__( class MetricDefinition(msrest.serialization.Model): """Metric definition class specifies the metadata for a metric. - :param is_dimension_required: Flag to indicate whether the dimension is required. - :type is_dimension_required: bool - :param resource_id: the resource identifier of the resource that emitted the metric. - :type resource_id: str - :param name: the name and the display name of the metric, i.e. it is a localizable string. - :type name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString - :param display_description: Detailed description of this metric. - :type display_description: str - :param category: Custom category name for this metric. - :type category: str - :param unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + :ivar is_dimension_required: Flag to indicate whether the dimension is required. + :vartype is_dimension_required: bool + :ivar resource_id: the resource identifier of the resource that emitted the metric. + :vartype resource_id: str + :ivar name: the name and the display name of the metric, i.e. it is a localizable string. + :vartype name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString + :ivar display_description: Detailed description of this metric. + :vartype display_description: str + :ivar category: Custom category name for this metric. + :vartype category: str + :ivar unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". - :type unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit - :param primary_aggregation_type: the primary aggregation type value defining how to use the + :vartype unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit + :ivar primary_aggregation_type: the primary aggregation type value defining how to use the values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", "Total". - :type primary_aggregation_type: str or + :vartype primary_aggregation_type: str or ~$(python-base-namespace).v2017_05_01_preview.models.AggregationType - :param metric_availabilities: the collection of what aggregation intervals are available to be + :ivar metric_availabilities: the collection of what aggregation intervals are available to be queried. - :type metric_availabilities: + :vartype metric_availabilities: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricAvailability] - :param id: the resource identifier of the metric definition. - :type id: str - :param dimensions: the name and the display name of the dimension, i.e. it is a localizable + :ivar id: the resource identifier of the metric definition. + :vartype id: str + :ivar dimensions: the name and the display name of the dimension, i.e. it is a localizable string. - :type dimensions: list[~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString] + :vartype dimensions: + list[~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString] """ _attribute_map = { @@ -495,6 +601,37 @@ def __init__( dimensions: Optional[List["LocalizableString"]] = None, **kwargs ): + """ + :keyword is_dimension_required: Flag to indicate whether the dimension is required. + :paramtype is_dimension_required: bool + :keyword resource_id: the resource identifier of the resource that emitted the metric. + :paramtype resource_id: str + :keyword name: the name and the display name of the metric, i.e. it is a localizable string. + :paramtype name: ~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString + :keyword display_description: Detailed description of this metric. + :paramtype display_description: str + :keyword category: Custom category name for this metric. + :paramtype category: str + :keyword unit: the unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", + "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + :paramtype unit: str or ~$(python-base-namespace).v2017_05_01_preview.models.Unit + :keyword primary_aggregation_type: the primary aggregation type value defining how to use the + values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", + "Total". + :paramtype primary_aggregation_type: str or + ~$(python-base-namespace).v2017_05_01_preview.models.AggregationType + :keyword metric_availabilities: the collection of what aggregation intervals are available to + be queried. + :paramtype metric_availabilities: + list[~$(python-base-namespace).v2017_05_01_preview.models.MetricAvailability] + :keyword id: the resource identifier of the metric definition. + :paramtype id: str + :keyword dimensions: the name and the display name of the dimension, i.e. it is a localizable + string. + :paramtype dimensions: + list[~$(python-base-namespace).v2017_05_01_preview.models.LocalizableString] + """ super(MetricDefinition, self).__init__(**kwargs) self.is_dimension_required = is_dimension_required self.resource_id = resource_id @@ -513,8 +650,8 @@ class MetricDefinitionCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the values for the metric definitions. - :type value: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinition] + :ivar value: Required. the values for the metric definitions. + :vartype value: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinition] """ _validation = { @@ -531,6 +668,10 @@ def __init__( value: List["MetricDefinition"], **kwargs ): + """ + :keyword value: Required. the values for the metric definitions. + :paramtype value: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinition] + """ super(MetricDefinitionCollection, self).__init__(**kwargs) self.value = value @@ -540,16 +681,16 @@ class MetricSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_grain: the timegrain of the metric in ISO8601 format. - :type time_grain: ~datetime.timedelta - :param category: Name of a Diagnostic Metric category for a resource type this setting is + :ivar time_grain: the timegrain of the metric in ISO8601 format. + :vartype time_grain: ~datetime.timedelta + :ivar category: Name of a Diagnostic Metric category for a resource type this setting is applied to. To obtain the list of Diagnostic metric categories for a resource, first perform a GET diagnostic settings operation. - :type category: str - :param enabled: Required. a value indicating whether this category is enabled. - :type enabled: bool - :param retention_policy: the retention policy for this category. - :type retention_policy: ~$(python-base-namespace).v2017_05_01_preview.models.RetentionPolicy + :vartype category: str + :ivar enabled: Required. a value indicating whether this category is enabled. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this category. + :vartype retention_policy: ~$(python-base-namespace).v2017_05_01_preview.models.RetentionPolicy """ _validation = { @@ -572,6 +713,19 @@ def __init__( retention_policy: Optional["RetentionPolicy"] = None, **kwargs ): + """ + :keyword time_grain: the timegrain of the metric in ISO8601 format. + :paramtype time_grain: ~datetime.timedelta + :keyword category: Name of a Diagnostic Metric category for a resource type this setting is + applied to. To obtain the list of Diagnostic metric categories for a resource, first perform a + GET diagnostic settings operation. + :paramtype category: str + :keyword enabled: Required. a value indicating whether this category is enabled. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this category. + :paramtype retention_policy: + ~$(python-base-namespace).v2017_05_01_preview.models.RetentionPolicy + """ super(MetricSettings, self).__init__(**kwargs) self.time_grain = time_grain self.category = category @@ -584,19 +738,19 @@ class MetricValue(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_stamp: Required. the timestamp for the metric value in ISO 8601 format. - :type time_stamp: ~datetime.datetime - :param average: the average value in the time range. - :type average: float - :param minimum: the least value in the time range. - :type minimum: float - :param maximum: the greatest value in the time range. - :type maximum: float - :param total: the sum of all of the values in the time range. - :type total: float - :param count: the number of samples in the time range. Can be used to determine the number of + :ivar time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :vartype time_stamp: ~datetime.datetime + :ivar average: the average value in the time range. + :vartype average: float + :ivar minimum: the least value in the time range. + :vartype minimum: float + :ivar maximum: the greatest value in the time range. + :vartype maximum: float + :ivar total: the sum of all of the values in the time range. + :vartype total: float + :ivar count: the number of samples in the time range. Can be used to determine the number of values that contributed to the average value. - :type count: long + :vartype count: long """ _validation = { @@ -623,6 +777,21 @@ def __init__( count: Optional[int] = None, **kwargs ): + """ + :keyword time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :paramtype time_stamp: ~datetime.datetime + :keyword average: the average value in the time range. + :paramtype average: float + :keyword minimum: the least value in the time range. + :paramtype minimum: float + :keyword maximum: the greatest value in the time range. + :paramtype maximum: float + :keyword total: the sum of all of the values in the time range. + :paramtype total: float + :keyword count: the number of samples in the time range. Can be used to determine the number of + values that contributed to the average value. + :paramtype count: long + """ super(MetricValue, self).__init__(**kwargs) self.time_stamp = time_stamp self.average = average @@ -637,18 +806,18 @@ class Response(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param cost: The integer value representing the relative cost of the query. - :type cost: int - :param timespan: Required. The timespan for which the data was retrieved. Its value consists of + :ivar cost: The integer value representing the relative cost of the query. + :vartype cost: int + :ivar timespan: Required. The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. - :type timespan: str - :param interval: The interval (window size) for which the metric data was returned in. This - may be adjusted in the future and returned back from what was originally requested. This is - not present if a metadata request was made. - :type interval: ~datetime.timedelta - :param value: Required. the value of the collection. - :type value: list[~$(python-base-namespace).v2017_05_01_preview.models.Metric] + :vartype timespan: str + :ivar interval: The interval (window size) for which the metric data was returned in. This may + be adjusted in the future and returned back from what was originally requested. This is not + present if a metadata request was made. + :vartype interval: ~datetime.timedelta + :ivar value: Required. the value of the collection. + :vartype value: list[~$(python-base-namespace).v2017_05_01_preview.models.Metric] """ _validation = { @@ -673,6 +842,20 @@ def __init__( interval: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword cost: The integer value representing the relative cost of the query. + :paramtype cost: int + :keyword timespan: Required. The timespan for which the data was retrieved. Its value consists + of two datetimes concatenated, separated by '/'. This may be adjusted in the future and + returned back from what was originally requested. + :paramtype timespan: str + :keyword interval: The interval (window size) for which the metric data was returned in. This + may be adjusted in the future and returned back from what was originally requested. This is + not present if a metadata request was made. + :paramtype interval: ~datetime.timedelta + :keyword value: Required. the value of the collection. + :paramtype value: list[~$(python-base-namespace).v2017_05_01_preview.models.Metric] + """ super(Response, self).__init__(**kwargs) self.cost = cost self.timespan = timespan @@ -685,11 +868,11 @@ class RetentionPolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param enabled: Required. a value indicating whether the retention policy is enabled. - :type enabled: bool - :param days: Required. the number of days for the retention in days. A value of 0 will retain + :ivar enabled: Required. a value indicating whether the retention policy is enabled. + :vartype enabled: bool + :ivar days: Required. the number of days for the retention in days. A value of 0 will retain the events indefinitely. - :type days: int + :vartype days: int """ _validation = { @@ -709,6 +892,13 @@ def __init__( days: int, **kwargs ): + """ + :keyword enabled: Required. a value indicating whether the retention policy is enabled. + :paramtype enabled: bool + :keyword days: Required. the number of days for the retention in days. A value of 0 will retain + the events indefinitely. + :paramtype days: int + """ super(RetentionPolicy, self).__init__(**kwargs) self.enabled = enabled self.days = days @@ -725,8 +915,8 @@ class SubscriptionProxyOnlyResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Location of the resource. - :type location: str + :ivar location: Location of the resource. + :vartype location: str """ _validation = { @@ -748,6 +938,10 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: Location of the resource. + :paramtype location: str + """ super(SubscriptionProxyOnlyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -766,25 +960,26 @@ class SubscriptionDiagnosticSettingsResource(SubscriptionProxyOnlyResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Location of the resource. - :type location: str - :param storage_account_id: The resource ID of the storage account to which you would like to + :ivar location: Location of the resource. + :vartype location: str + :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. - :type service_bus_rule_id: str - :param event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :type event_hub_authorization_rule_id: str - :param event_hub_name: The name of the event hub. If none is specified, the default event hub + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :vartype event_hub_authorization_rule_id: str + :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub will be selected. - :type event_hub_name: str - :param logs: The list of logs settings. - :type logs: list[~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionLogSettings] - :param workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would + :vartype event_hub_name: str + :ivar logs: The list of logs settings. + :vartype logs: + list[~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionLogSettings] + :ivar workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str + :vartype workspace_id: str """ _validation = { @@ -818,6 +1013,28 @@ def __init__( workspace_id: Optional[str] = None, **kwargs ): + """ + :keyword location: Location of the resource. + :paramtype location: str + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here + to maintain backwards compatibility. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub + will be selected. + :paramtype event_hub_name: str + :keyword logs: The list of logs settings. + :paramtype logs: + list[~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionLogSettings] + :keyword workspace_id: The full ARM resource ID of the Log Analytics workspace to which you + would like to send Diagnostic Logs. Example: + /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + :paramtype workspace_id: str + """ super(SubscriptionDiagnosticSettingsResource, self).__init__(location=location, **kwargs) self.storage_account_id = storage_account_id self.service_bus_rule_id = service_bus_rule_id @@ -830,8 +1047,8 @@ def __init__( class SubscriptionDiagnosticSettingsResourceCollection(msrest.serialization.Model): """Represents a collection of subscription diagnostic settings resources. - :param value: The collection of subscription diagnostic settings resources. - :type value: + :ivar value: The collection of subscription diagnostic settings resources. + :vartype value: list[~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource] """ @@ -845,6 +1062,11 @@ def __init__( value: Optional[List["SubscriptionDiagnosticSettingsResource"]] = None, **kwargs ): + """ + :keyword value: The collection of subscription diagnostic settings resources. + :paramtype value: + list[~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource] + """ super(SubscriptionDiagnosticSettingsResourceCollection, self).__init__(**kwargs) self.value = value @@ -854,11 +1076,11 @@ class SubscriptionLogSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param category: Name of a Subscription Diagnostic Log category for a resource type this - setting is applied to. - :type category: str - :param enabled: Required. a value indicating whether this log is enabled. - :type enabled: bool + :ivar category: Name of a Subscription Diagnostic Log category for a resource type this setting + is applied to. + :vartype category: str + :ivar enabled: Required. a value indicating whether this log is enabled. + :vartype enabled: bool """ _validation = { @@ -877,6 +1099,13 @@ def __init__( category: Optional[str] = None, **kwargs ): + """ + :keyword category: Name of a Subscription Diagnostic Log category for a resource type this + setting is applied to. + :paramtype category: str + :keyword enabled: Required. a value indicating whether this log is enabled. + :paramtype enabled: bool + """ super(SubscriptionLogSettings, self).__init__(**kwargs) self.category = category self.enabled = enabled @@ -885,11 +1114,12 @@ def __init__( class TimeSeriesElement(msrest.serialization.Model): """A time series result type. The discriminator value is always TimeSeries in this case. - :param metadatavalues: the metadata values returned if $filter was specified in the call. - :type metadatavalues: list[~$(python-base-namespace).v2017_05_01_preview.models.MetadataValue] - :param data: An array of data points representing the metric values. This is only returned if - a result type of data is specified. - :type data: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricValue] + :ivar metadatavalues: the metadata values returned if $filter was specified in the call. + :vartype metadatavalues: + list[~$(python-base-namespace).v2017_05_01_preview.models.MetadataValue] + :ivar data: An array of data points representing the metric values. This is only returned if a + result type of data is specified. + :vartype data: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricValue] """ _attribute_map = { @@ -904,6 +1134,14 @@ def __init__( data: Optional[List["MetricValue"]] = None, **kwargs ): + """ + :keyword metadatavalues: the metadata values returned if $filter was specified in the call. + :paramtype metadatavalues: + list[~$(python-base-namespace).v2017_05_01_preview.models.MetadataValue] + :keyword data: An array of data points representing the metric values. This is only returned + if a result type of data is specified. + :paramtype data: list[~$(python-base-namespace).v2017_05_01_preview.models.MetricValue] + """ super(TimeSeriesElement, self).__init__(**kwargs) self.metadatavalues = metadatavalues self.data = data diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_monitor_management_client_enums.py index a9c23992cba4f..4e17f31bcd8ce 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/models/_monitor_management_client_enums.py @@ -6,27 +6,12 @@ # 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 AggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the primary aggregation type value defining how to use the values for display. """ @@ -37,19 +22,19 @@ class AggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MAXIMUM = "Maximum" TOTAL = "Total" -class CategoryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CategoryType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the diagnostic settings category. """ METRICS = "Metrics" LOGS = "Logs" -class ResultType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResultType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DATA = "Data" METADATA = "Metadata" -class Unit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Unit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The unit of the metric. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_category_operations.py index 34a67c997d289..da90bf1e0fa9f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_category_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_category_operations.py @@ -5,23 +5,97 @@ # 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 TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + resource_uri, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "name": _SERIALIZER.url("name", 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_list_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + 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 + ) + +# fmt: on class DiagnosticSettingsCategoryOperations(object): """DiagnosticSettingsCategoryOperations operations. @@ -44,6 +118,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_uri, # type: str @@ -67,32 +142,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_get_request( + resource_uri=resource_uri, + name=name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DiagnosticSettingsCategoryResource', pipeline_response) @@ -101,8 +166,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}'} # type: ignore + + @distributed_trace def list( self, resource_uri, # type: str @@ -115,7 +183,8 @@ def list( :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticSettingsCategoryResourceCollection, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsCategoryResourceCollection + :rtype: + ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsCategoryResourceCollection :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsCategoryResourceCollection"] @@ -123,31 +192,21 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - accept = "application/json" - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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_list_request( + resource_uri=resource_uri, + 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) 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DiagnosticSettingsCategoryResourceCollection', pipeline_response) @@ -156,4 +215,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_operations.py index 1a0812a78dbd9..5a9e6070d56ee 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_diagnostic_settings_operations.py @@ -5,23 +5,169 @@ # 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 TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + resource_uri, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "name": _SERIALIZER.url("name", 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( + resource_uri, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "name": _SERIALIZER.url("name", 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, + **kwargs + ) + + +def build_delete_request( + resource_uri, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "name": _SERIALIZER.url("name", 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_list_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + 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 + ) + +# fmt: on class DiagnosticSettingsOperations(object): """DiagnosticSettingsOperations operations. @@ -44,6 +190,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_uri, # type: str @@ -67,32 +214,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_get_request( + resource_uri=resource_uri, + name=name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DiagnosticSettingsResource', pipeline_response) @@ -101,8 +238,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_uri, # type: str @@ -118,7 +258,8 @@ def create_or_update( :param name: The name of the diagnostic setting. :type name: str :param parameters: Parameters supplied to the operation. - :type parameters: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource + :type parameters: + ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticSettingsResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResource @@ -129,37 +270,27 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - 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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'DiagnosticSettingsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_uri=resource_uri, + name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DiagnosticSettingsResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DiagnosticSettingsResource', pipeline_response) @@ -168,8 +299,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def delete( self, resource_uri, # type: str @@ -193,32 +327,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_delete_request( + resource_uri=resource_uri, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -226,6 +350,8 @@ def delete( delete.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def list( self, resource_uri, # type: str @@ -238,7 +364,8 @@ def list( :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticSettingsResourceCollection, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResourceCollection + :rtype: + ~$(python-base-namespace).v2017_05_01_preview.models.DiagnosticSettingsResourceCollection :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsResourceCollection"] @@ -246,31 +373,21 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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_list_request( + resource_uri=resource_uri, + 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) 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DiagnosticSettingsResourceCollection', pipeline_response) @@ -279,4 +396,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metric_definitions_operations.py index 8ea5c705647b0..0d20b20d826aa 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metric_definitions_operations.py @@ -5,24 +5,64 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/metricDefinitions') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + 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 + ) + +# fmt: on class MetricDefinitionsOperations(object): """MetricDefinitionsOperations operations. @@ -45,6 +85,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_uri, # type: str @@ -56,8 +97,10 @@ def list( :param resource_uri: The identifier of the resource. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinitionCollection] + :return: An iterator like instance of either MetricDefinitionCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_05_01_preview.models.MetricDefinitionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionCollection"] @@ -65,34 +108,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-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 - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + template_url=self.list.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_list_request( + resource_uri=resource_uri, + 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('MetricDefinitionCollection', pipeline_response) + deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,12 +143,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metrics_operations.py index 797f7c758f493..c21552c314d84 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metrics_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_metrics_operations.py @@ -6,23 +6,88 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + timespan = kwargs.pop('timespan', None) # type: Optional[str] + interval = kwargs.pop('interval', None) # type: Optional[datetime.timedelta] + metric = kwargs.pop('metric', None) # type: Optional[str] + aggregation = kwargs.pop('aggregation', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + orderby = kwargs.pop('orderby', None) # type: Optional[str] + filter = kwargs.pop('filter', None) # type: Optional[str] + result_type = kwargs.pop('result_type', None) # type: Optional[Union[str, "_models.ResultType"]] + + api_version = "2017-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/metrics') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if timespan is not None: + query_parameters['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') + if interval is not None: + query_parameters['interval'] = _SERIALIZER.query("interval", interval, 'duration') + if metric is not None: + query_parameters['metric'] = _SERIALIZER.query("metric", metric, 'str') + if aggregation is not None: + query_parameters['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') + if top is not None: + query_parameters['$top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['$orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if result_type is not None: + query_parameters['resultType'] = _SERIALIZER.query("result_type", result_type, '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 + ) + +# fmt: on class MetricsOperations(object): """MetricsOperations operations. @@ -45,6 +110,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_uri, # type: str @@ -103,47 +169,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - accept = "application/json" - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if timespan is not None: - query_parameters['timespan'] = self._serialize.query("timespan", timespan, 'str') - if interval is not None: - query_parameters['interval'] = self._serialize.query("interval", interval, 'duration') - if metric is not None: - query_parameters['metric'] = self._serialize.query("metric", metric, 'str') - if aggregation is not None: - query_parameters['aggregation'] = self._serialize.query("aggregation", aggregation, 'str') - if top is not None: - query_parameters['$top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['$orderby'] = self._serialize.query("orderby", orderby, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if result_type is not None: - query_parameters['resultType'] = self._serialize.query("result_type", result_type, '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_list_request( + resource_uri=resource_uri, + timespan=timespan, + interval=interval, + metric=metric, + aggregation=aggregation, + top=top, + orderby=orderby, + filter=filter, + result_type=result_type, + template_url=self.list.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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Response', pipeline_response) @@ -152,4 +200,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/metrics'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_subscription_diagnostic_settings_operations.py index 00fd46a8c8773..5d14c46be29a7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_subscription_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_05_01_preview/operations/_subscription_diagnostic_settings_operations.py @@ -5,23 +5,169 @@ # 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 TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + subscription_id, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "name": _SERIALIZER.url("name", 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, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "name": _SERIALIZER.url("name", 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, + **kwargs + ) + + +def build_delete_request( + subscription_id, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "name": _SERIALIZER.url("name", 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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2017-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings') + 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 + ) + +# fmt: on class SubscriptionDiagnosticSettingsOperations(object): """SubscriptionDiagnosticSettingsOperations operations. @@ -44,6 +190,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, name, # type: str @@ -56,7 +203,8 @@ def get( :type name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionDiagnosticSettingsResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :rtype: + ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResource"] @@ -64,32 +212,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - 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), - 'name': self._serialize.url("name", 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 = build_get_request( + subscription_id=self._config.subscription_id, + name=name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SubscriptionDiagnosticSettingsResource', pipeline_response) @@ -98,8 +236,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def create_or_update( self, name, # type: str @@ -112,10 +253,12 @@ def create_or_update( :param name: The name of the diagnostic setting. :type name: str :param parameters: Parameters supplied to the operation. - :type parameters: ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :type parameters: + ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionDiagnosticSettingsResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :rtype: + ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResource"] @@ -123,37 +266,27 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - 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), - 'name': self._serialize.url("name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'SubscriptionDiagnosticSettingsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SubscriptionDiagnosticSettingsResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SubscriptionDiagnosticSettingsResource', pipeline_response) @@ -162,8 +295,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def delete( self, name, # type: str @@ -184,32 +320,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-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), - 'name': self._serialize.url("name", 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 = build_delete_request( + subscription_id=self._config.subscription_id, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -217,6 +343,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -226,7 +354,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionDiagnosticSettingsResourceCollection, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResourceCollection + :rtype: + ~$(python-base-namespace).v2017_05_01_preview.models.SubscriptionDiagnosticSettingsResourceCollection :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResourceCollection"] @@ -234,31 +363,21 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-05-01-preview" - accept = "application/json" - - # 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + subscription_id=self._config.subscription_id, + 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) 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SubscriptionDiagnosticSettingsResourceCollection', pipeline_response) @@ -267,4 +386,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/diagnosticSettings'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_configuration.py index 6dd30405ac622..5048e06a76aac 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -37,9 +37,9 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2017-11-01-preview" @@ -62,4 +62,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_metadata.json index be87d4f16fcc7..dc6519555c3ac 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,11 +79,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "metric_baseline": "MetricBaselineOperations" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_monitor_management_client.py index 6b0003ef7c341..0369a27b9362f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_monitor_management_client.py @@ -6,67 +6,78 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import MetricBaselineOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import MetricBaselineOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. :ivar metric_baseline: MetricBaselineOperations operations - :vartype metric_baseline: $(python-base-namespace).v2017_11_01_preview.operations.MetricBaselineOperations + :vartype metric_baseline: + $(python-base-namespace).v2017_11_01_preview.operations.MetricBaselineOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :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" - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, **kwargs) + self._config = MonitorManagementClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.metric_baseline = MetricBaselineOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_baseline = MetricBaselineOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_configuration.py index f0599c4e5ec28..b94ccd520e188 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/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 @@ -34,9 +34,9 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(MonitorManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2017-11-01-preview" @@ -58,4 +58,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_monitor_management_client.py index 66e7e2379476e..294998b3c92d0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_monitor_management_client.py @@ -6,63 +6,74 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import MonitorManagementClientConfiguration from .operations import MetricBaselineOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar metric_baseline: MetricBaselineOperations operations - :vartype metric_baseline: $(python-base-namespace).v2017_11_01_preview.aio.operations.MetricBaselineOperations + :vartype metric_baseline: + $(python-base-namespace).v2017_11_01_preview.aio.operations.MetricBaselineOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :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", - 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 = MonitorManagementClientConfiguration(credential, **kwargs) + self._config = MonitorManagementClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.metric_baseline = MetricBaselineOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_baseline = MetricBaselineOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/operations/_metric_baseline_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/operations/_metric_baseline_operations.py index dbf2ab029f66a..c8caf0224f939 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/operations/_metric_baseline_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/aio/operations/_metric_baseline_operations.py @@ -6,16 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._metric_baseline_operations import build_calculate_baseline_request, build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_uri: str, @@ -83,42 +88,27 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'metricName': self._serialize.url("metric_name", metric_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if timespan is not None: - query_parameters['timespan'] = self._serialize.query("timespan", timespan, 'str') - if interval is not None: - query_parameters['interval'] = self._serialize.query("interval", interval, 'duration') - if aggregation is not None: - query_parameters['aggregation'] = self._serialize.query("aggregation", aggregation, 'str') - if sensitivities is not None: - query_parameters['sensitivities'] = self._serialize.query("sensitivities", sensitivities, 'str') - if result_type is not None: - query_parameters['resultType'] = self._serialize.query("result_type", result_type, '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_request( + resource_uri=resource_uri, + metric_name=metric_name, + timespan=timespan, + interval=interval, + aggregation=aggregation, + sensitivities=sensitivities, + result_type=result_type, + template_url=self.get.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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BaselineResponse', pipeline_response) @@ -127,8 +117,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/baseline/{metricName}'} # type: ignore + + @distributed_trace_async async def calculate_baseline( self, resource_uri: str, @@ -144,7 +137,8 @@ async def calculate_baseline( :type resource_uri: str :param time_series_information: Information that need to be specified to calculate a baseline on a time series. - :type time_series_information: ~$(python-base-namespace).v2017_11_01_preview.models.TimeSeriesInformation + :type time_series_information: + ~$(python-base-namespace).v2017_11_01_preview.models.TimeSeriesInformation :keyword callable cls: A custom type or function that will be passed the direct response :return: CalculateBaselineResponse, or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_11_01_preview.models.CalculateBaselineResponse @@ -155,36 +149,26 @@ async def calculate_baseline( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_baseline.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(time_series_information, 'TimeSeriesInformation') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_calculate_baseline_request( + resource_uri=resource_uri, + content_type=content_type, + json=_json, + template_url=self.calculate_baseline.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(time_series_information, 'TimeSeriesInformation') - body_content_kwargs['content'] = body_content - request = self._client.post(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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CalculateBaselineResponse', pipeline_response) @@ -193,4 +177,6 @@ async def calculate_baseline( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_baseline.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/calculatebaseline'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_models.py index 7cdac8f92b2a6..52b04b27fa5d1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_models.py @@ -15,15 +15,15 @@ class Baseline(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sensitivity: Required. the sensitivity of the baseline. Possible values include: "Low", + :ivar sensitivity: Required. the sensitivity of the baseline. Possible values include: "Low", "Medium", "High". - :type sensitivity: str or ~$(python-base-namespace).v2017_11_01_preview.models.Sensitivity - :param low_thresholds: Required. The low thresholds of the baseline. - :type low_thresholds: list[float] - :param high_thresholds: Required. The high thresholds of the baseline. - :type high_thresholds: list[float] - :param timestamps: the array of timestamps of the baselines. - :type timestamps: list[~datetime.datetime] + :vartype sensitivity: str or ~$(python-base-namespace).v2017_11_01_preview.models.Sensitivity + :ivar low_thresholds: Required. The low thresholds of the baseline. + :vartype low_thresholds: list[float] + :ivar high_thresholds: Required. The high thresholds of the baseline. + :vartype high_thresholds: list[float] + :ivar timestamps: the array of timestamps of the baselines. + :vartype timestamps: list[~datetime.datetime] """ _validation = { @@ -43,6 +43,17 @@ def __init__( self, **kwargs ): + """ + :keyword sensitivity: Required. the sensitivity of the baseline. Possible values include: + "Low", "Medium", "High". + :paramtype sensitivity: str or ~$(python-base-namespace).v2017_11_01_preview.models.Sensitivity + :keyword low_thresholds: Required. The low thresholds of the baseline. + :paramtype low_thresholds: list[float] + :keyword high_thresholds: Required. The high thresholds of the baseline. + :paramtype high_thresholds: list[float] + :keyword timestamps: the array of timestamps of the baselines. + :paramtype timestamps: list[~datetime.datetime] + """ super(Baseline, self).__init__(**kwargs) self.sensitivity = kwargs['sensitivity'] self.low_thresholds = kwargs['low_thresholds'] @@ -53,10 +64,10 @@ def __init__( class BaselineMetadataValue(msrest.serialization.Model): """Represents a baseline metadata value. - :param name: the name of the metadata. - :type name: ~$(python-base-namespace).v2017_11_01_preview.models.LocalizableString - :param value: the value of the metadata. - :type value: str + :ivar name: the name of the metadata. + :vartype name: ~$(python-base-namespace).v2017_11_01_preview.models.LocalizableString + :ivar value: the value of the metadata. + :vartype value: str """ _attribute_map = { @@ -68,6 +79,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: the name of the metadata. + :paramtype name: ~$(python-base-namespace).v2017_11_01_preview.models.LocalizableString + :keyword value: the value of the metadata. + :paramtype value: str + """ super(BaselineMetadataValue, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.value = kwargs.get('value', None) @@ -84,22 +101,22 @@ class BaselineResponse(msrest.serialization.Model): :vartype type: str :ivar name: the name and the display name of the metric, i.e. it is localizable string. :vartype name: ~$(python-base-namespace).v2017_11_01_preview.models.LocalizableString - :param timespan: The timespan for which the data was retrieved. Its value consists of two + :ivar timespan: The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. - :type timespan: str - :param interval: The interval (window size) for which the metric data was returned in. This - may be adjusted in the future and returned back from what was originally requested. This is - not present if a metadata request was made. - :type interval: ~datetime.timedelta - :param aggregation: The aggregation type of the metric. - :type aggregation: str - :param timestamps: the array of timestamps of the baselines. - :type timestamps: list[~datetime.datetime] - :param baseline: the baseline values for each sensitivity. - :type baseline: list[~$(python-base-namespace).v2017_11_01_preview.models.Baseline] - :param metadata: the baseline metadata values. - :type metadata: + :vartype timespan: str + :ivar interval: The interval (window size) for which the metric data was returned in. This may + be adjusted in the future and returned back from what was originally requested. This is not + present if a metadata request was made. + :vartype interval: ~datetime.timedelta + :ivar aggregation: The aggregation type of the metric. + :vartype aggregation: str + :ivar timestamps: the array of timestamps of the baselines. + :vartype timestamps: list[~datetime.datetime] + :ivar baseline: the baseline values for each sensitivity. + :vartype baseline: list[~$(python-base-namespace).v2017_11_01_preview.models.Baseline] + :ivar metadata: the baseline metadata values. + :vartype metadata: list[~$(python-base-namespace).v2017_11_01_preview.models.BaselineMetadataValue] """ @@ -125,6 +142,25 @@ def __init__( self, **kwargs ): + """ + :keyword timespan: The timespan for which the data was retrieved. Its value consists of two + datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back + from what was originally requested. + :paramtype timespan: str + :keyword interval: The interval (window size) for which the metric data was returned in. This + may be adjusted in the future and returned back from what was originally requested. This is + not present if a metadata request was made. + :paramtype interval: ~datetime.timedelta + :keyword aggregation: The aggregation type of the metric. + :paramtype aggregation: str + :keyword timestamps: the array of timestamps of the baselines. + :paramtype timestamps: list[~datetime.datetime] + :keyword baseline: the baseline values for each sensitivity. + :paramtype baseline: list[~$(python-base-namespace).v2017_11_01_preview.models.Baseline] + :keyword metadata: the baseline metadata values. + :paramtype metadata: + list[~$(python-base-namespace).v2017_11_01_preview.models.BaselineMetadataValue] + """ super(BaselineResponse, self).__init__(**kwargs) self.id = None self.type = None @@ -142,12 +178,12 @@ class CalculateBaselineResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. the resource type of the baseline resource. - :type type: str - :param timestamps: the array of timestamps of the baselines. - :type timestamps: list[~datetime.datetime] - :param baseline: Required. the baseline values for each sensitivity. - :type baseline: list[~$(python-base-namespace).v2017_11_01_preview.models.Baseline] + :ivar type: Required. the resource type of the baseline resource. + :vartype type: str + :ivar timestamps: the array of timestamps of the baselines. + :vartype timestamps: list[~datetime.datetime] + :ivar baseline: Required. the baseline values for each sensitivity. + :vartype baseline: list[~$(python-base-namespace).v2017_11_01_preview.models.Baseline] """ _validation = { @@ -165,6 +201,14 @@ def __init__( self, **kwargs ): + """ + :keyword type: Required. the resource type of the baseline resource. + :paramtype type: str + :keyword timestamps: the array of timestamps of the baselines. + :paramtype timestamps: list[~datetime.datetime] + :keyword baseline: Required. the baseline values for each sensitivity. + :paramtype baseline: list[~$(python-base-namespace).v2017_11_01_preview.models.Baseline] + """ super(CalculateBaselineResponse, self).__init__(**kwargs) self.type = kwargs['type'] self.timestamps = kwargs.get('timestamps', None) @@ -174,10 +218,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -189,6 +233,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -199,10 +249,10 @@ class LocalizableString(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the invariant value. - :type value: str - :param localized_value: the locale specific value. - :type localized_value: str + :ivar value: Required. the invariant value. + :vartype value: str + :ivar localized_value: the locale specific value. + :vartype localized_value: str """ _validation = { @@ -218,6 +268,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. the invariant value. + :paramtype value: str + :keyword localized_value: the locale specific value. + :paramtype localized_value: str + """ super(LocalizableString, self).__init__(**kwargs) self.value = kwargs['value'] self.localized_value = kwargs.get('localized_value', None) @@ -228,12 +284,12 @@ class TimeSeriesInformation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sensitivities: Required. the list of sensitivities for calculating the baseline. - :type sensitivities: list[str] - :param values: Required. The metric values to calculate the baseline. - :type values: list[float] - :param timestamps: the array of timestamps of the baselines. - :type timestamps: list[~datetime.datetime] + :ivar sensitivities: Required. the list of sensitivities for calculating the baseline. + :vartype sensitivities: list[str] + :ivar values: Required. The metric values to calculate the baseline. + :vartype values: list[float] + :ivar timestamps: the array of timestamps of the baselines. + :vartype timestamps: list[~datetime.datetime] """ _validation = { @@ -251,6 +307,14 @@ def __init__( self, **kwargs ): + """ + :keyword sensitivities: Required. the list of sensitivities for calculating the baseline. + :paramtype sensitivities: list[str] + :keyword values: Required. The metric values to calculate the baseline. + :paramtype values: list[float] + :keyword timestamps: the array of timestamps of the baselines. + :paramtype timestamps: list[~datetime.datetime] + """ super(TimeSeriesInformation, self).__init__(**kwargs) self.sensitivities = kwargs['sensitivities'] self.values = kwargs['values'] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_models_py3.py index 343075e3c0dca..ddf9d5c536cf4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_models_py3.py @@ -20,15 +20,15 @@ class Baseline(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sensitivity: Required. the sensitivity of the baseline. Possible values include: "Low", + :ivar sensitivity: Required. the sensitivity of the baseline. Possible values include: "Low", "Medium", "High". - :type sensitivity: str or ~$(python-base-namespace).v2017_11_01_preview.models.Sensitivity - :param low_thresholds: Required. The low thresholds of the baseline. - :type low_thresholds: list[float] - :param high_thresholds: Required. The high thresholds of the baseline. - :type high_thresholds: list[float] - :param timestamps: the array of timestamps of the baselines. - :type timestamps: list[~datetime.datetime] + :vartype sensitivity: str or ~$(python-base-namespace).v2017_11_01_preview.models.Sensitivity + :ivar low_thresholds: Required. The low thresholds of the baseline. + :vartype low_thresholds: list[float] + :ivar high_thresholds: Required. The high thresholds of the baseline. + :vartype high_thresholds: list[float] + :ivar timestamps: the array of timestamps of the baselines. + :vartype timestamps: list[~datetime.datetime] """ _validation = { @@ -53,6 +53,17 @@ def __init__( timestamps: Optional[List[datetime.datetime]] = None, **kwargs ): + """ + :keyword sensitivity: Required. the sensitivity of the baseline. Possible values include: + "Low", "Medium", "High". + :paramtype sensitivity: str or ~$(python-base-namespace).v2017_11_01_preview.models.Sensitivity + :keyword low_thresholds: Required. The low thresholds of the baseline. + :paramtype low_thresholds: list[float] + :keyword high_thresholds: Required. The high thresholds of the baseline. + :paramtype high_thresholds: list[float] + :keyword timestamps: the array of timestamps of the baselines. + :paramtype timestamps: list[~datetime.datetime] + """ super(Baseline, self).__init__(**kwargs) self.sensitivity = sensitivity self.low_thresholds = low_thresholds @@ -63,10 +74,10 @@ def __init__( class BaselineMetadataValue(msrest.serialization.Model): """Represents a baseline metadata value. - :param name: the name of the metadata. - :type name: ~$(python-base-namespace).v2017_11_01_preview.models.LocalizableString - :param value: the value of the metadata. - :type value: str + :ivar name: the name of the metadata. + :vartype name: ~$(python-base-namespace).v2017_11_01_preview.models.LocalizableString + :ivar value: the value of the metadata. + :vartype value: str """ _attribute_map = { @@ -81,6 +92,12 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword name: the name of the metadata. + :paramtype name: ~$(python-base-namespace).v2017_11_01_preview.models.LocalizableString + :keyword value: the value of the metadata. + :paramtype value: str + """ super(BaselineMetadataValue, self).__init__(**kwargs) self.name = name self.value = value @@ -97,22 +114,22 @@ class BaselineResponse(msrest.serialization.Model): :vartype type: str :ivar name: the name and the display name of the metric, i.e. it is localizable string. :vartype name: ~$(python-base-namespace).v2017_11_01_preview.models.LocalizableString - :param timespan: The timespan for which the data was retrieved. Its value consists of two + :ivar timespan: The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. - :type timespan: str - :param interval: The interval (window size) for which the metric data was returned in. This - may be adjusted in the future and returned back from what was originally requested. This is - not present if a metadata request was made. - :type interval: ~datetime.timedelta - :param aggregation: The aggregation type of the metric. - :type aggregation: str - :param timestamps: the array of timestamps of the baselines. - :type timestamps: list[~datetime.datetime] - :param baseline: the baseline values for each sensitivity. - :type baseline: list[~$(python-base-namespace).v2017_11_01_preview.models.Baseline] - :param metadata: the baseline metadata values. - :type metadata: + :vartype timespan: str + :ivar interval: The interval (window size) for which the metric data was returned in. This may + be adjusted in the future and returned back from what was originally requested. This is not + present if a metadata request was made. + :vartype interval: ~datetime.timedelta + :ivar aggregation: The aggregation type of the metric. + :vartype aggregation: str + :ivar timestamps: the array of timestamps of the baselines. + :vartype timestamps: list[~datetime.datetime] + :ivar baseline: the baseline values for each sensitivity. + :vartype baseline: list[~$(python-base-namespace).v2017_11_01_preview.models.Baseline] + :ivar metadata: the baseline metadata values. + :vartype metadata: list[~$(python-base-namespace).v2017_11_01_preview.models.BaselineMetadataValue] """ @@ -145,6 +162,25 @@ def __init__( metadata: Optional[List["BaselineMetadataValue"]] = None, **kwargs ): + """ + :keyword timespan: The timespan for which the data was retrieved. Its value consists of two + datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back + from what was originally requested. + :paramtype timespan: str + :keyword interval: The interval (window size) for which the metric data was returned in. This + may be adjusted in the future and returned back from what was originally requested. This is + not present if a metadata request was made. + :paramtype interval: ~datetime.timedelta + :keyword aggregation: The aggregation type of the metric. + :paramtype aggregation: str + :keyword timestamps: the array of timestamps of the baselines. + :paramtype timestamps: list[~datetime.datetime] + :keyword baseline: the baseline values for each sensitivity. + :paramtype baseline: list[~$(python-base-namespace).v2017_11_01_preview.models.Baseline] + :keyword metadata: the baseline metadata values. + :paramtype metadata: + list[~$(python-base-namespace).v2017_11_01_preview.models.BaselineMetadataValue] + """ super(BaselineResponse, self).__init__(**kwargs) self.id = None self.type = None @@ -162,12 +198,12 @@ class CalculateBaselineResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. the resource type of the baseline resource. - :type type: str - :param timestamps: the array of timestamps of the baselines. - :type timestamps: list[~datetime.datetime] - :param baseline: Required. the baseline values for each sensitivity. - :type baseline: list[~$(python-base-namespace).v2017_11_01_preview.models.Baseline] + :ivar type: Required. the resource type of the baseline resource. + :vartype type: str + :ivar timestamps: the array of timestamps of the baselines. + :vartype timestamps: list[~datetime.datetime] + :ivar baseline: Required. the baseline values for each sensitivity. + :vartype baseline: list[~$(python-base-namespace).v2017_11_01_preview.models.Baseline] """ _validation = { @@ -189,6 +225,14 @@ def __init__( timestamps: Optional[List[datetime.datetime]] = None, **kwargs ): + """ + :keyword type: Required. the resource type of the baseline resource. + :paramtype type: str + :keyword timestamps: the array of timestamps of the baselines. + :paramtype timestamps: list[~datetime.datetime] + :keyword baseline: Required. the baseline values for each sensitivity. + :paramtype baseline: list[~$(python-base-namespace).v2017_11_01_preview.models.Baseline] + """ super(CalculateBaselineResponse, self).__init__(**kwargs) self.type = type self.timestamps = timestamps @@ -198,10 +242,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -216,6 +260,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -226,10 +276,10 @@ class LocalizableString(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the invariant value. - :type value: str - :param localized_value: the locale specific value. - :type localized_value: str + :ivar value: Required. the invariant value. + :vartype value: str + :ivar localized_value: the locale specific value. + :vartype localized_value: str """ _validation = { @@ -248,6 +298,12 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. the invariant value. + :paramtype value: str + :keyword localized_value: the locale specific value. + :paramtype localized_value: str + """ super(LocalizableString, self).__init__(**kwargs) self.value = value self.localized_value = localized_value @@ -258,12 +314,12 @@ class TimeSeriesInformation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sensitivities: Required. the list of sensitivities for calculating the baseline. - :type sensitivities: list[str] - :param values: Required. The metric values to calculate the baseline. - :type values: list[float] - :param timestamps: the array of timestamps of the baselines. - :type timestamps: list[~datetime.datetime] + :ivar sensitivities: Required. the list of sensitivities for calculating the baseline. + :vartype sensitivities: list[str] + :ivar values: Required. The metric values to calculate the baseline. + :vartype values: list[float] + :ivar timestamps: the array of timestamps of the baselines. + :vartype timestamps: list[~datetime.datetime] """ _validation = { @@ -285,6 +341,14 @@ def __init__( timestamps: Optional[List[datetime.datetime]] = None, **kwargs ): + """ + :keyword sensitivities: Required. the list of sensitivities for calculating the baseline. + :paramtype sensitivities: list[str] + :keyword values: Required. The metric values to calculate the baseline. + :paramtype values: list[float] + :keyword timestamps: the array of timestamps of the baselines. + :paramtype timestamps: list[~datetime.datetime] + """ super(TimeSeriesInformation, self).__init__(**kwargs) self.sensitivities = sensitivities self.values = values diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_monitor_management_client_enums.py index 6b954160c37c1..84dc084ea9ed8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/models/_monitor_management_client_enums.py @@ -6,32 +6,17 @@ # 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 ResultType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResultType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DATA = "Data" METADATA = "Metadata" -class Sensitivity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Sensitivity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the sensitivity of the baseline. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/operations/_metric_baseline_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/operations/_metric_baseline_operations.py index d3198ee568826..c998b35d43776 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/operations/_metric_baseline_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_11_01_preview/operations/_metric_baseline_operations.py @@ -6,23 +6,117 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + resource_uri, # type: str + metric_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + timespan = kwargs.pop('timespan', None) # type: Optional[str] + interval = kwargs.pop('interval', None) # type: Optional[datetime.timedelta] + aggregation = kwargs.pop('aggregation', None) # type: Optional[str] + sensitivities = kwargs.pop('sensitivities', None) # type: Optional[str] + result_type = kwargs.pop('result_type', None) # type: Optional[Union[str, "_models.ResultType"]] + + api_version = "2017-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/baseline/{metricName}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "metricName": _SERIALIZER.url("metric_name", metric_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if timespan is not None: + query_parameters['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') + if interval is not None: + query_parameters['interval'] = _SERIALIZER.query("interval", interval, 'duration') + if aggregation is not None: + query_parameters['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') + if sensitivities is not None: + query_parameters['sensitivities'] = _SERIALIZER.query("sensitivities", sensitivities, 'str') + if result_type is not None: + query_parameters['resultType'] = _SERIALIZER.query("result_type", result_type, '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_calculate_baseline_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/calculatebaseline') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class MetricBaselineOperations(object): """MetricBaselineOperations operations. @@ -45,6 +139,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_uri, # type: str @@ -88,42 +183,27 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'metricName': self._serialize.url("metric_name", metric_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if timespan is not None: - query_parameters['timespan'] = self._serialize.query("timespan", timespan, 'str') - if interval is not None: - query_parameters['interval'] = self._serialize.query("interval", interval, 'duration') - if aggregation is not None: - query_parameters['aggregation'] = self._serialize.query("aggregation", aggregation, 'str') - if sensitivities is not None: - query_parameters['sensitivities'] = self._serialize.query("sensitivities", sensitivities, 'str') - if result_type is not None: - query_parameters['resultType'] = self._serialize.query("result_type", result_type, '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_request( + resource_uri=resource_uri, + metric_name=metric_name, + timespan=timespan, + interval=interval, + aggregation=aggregation, + sensitivities=sensitivities, + result_type=result_type, + template_url=self.get.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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BaselineResponse', pipeline_response) @@ -132,8 +212,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/baseline/{metricName}'} # type: ignore + + @distributed_trace def calculate_baseline( self, resource_uri, # type: str @@ -150,7 +233,8 @@ def calculate_baseline( :type resource_uri: str :param time_series_information: Information that need to be specified to calculate a baseline on a time series. - :type time_series_information: ~$(python-base-namespace).v2017_11_01_preview.models.TimeSeriesInformation + :type time_series_information: + ~$(python-base-namespace).v2017_11_01_preview.models.TimeSeriesInformation :keyword callable cls: A custom type or function that will be passed the direct response :return: CalculateBaselineResponse, or the result of cls(response) :rtype: ~$(python-base-namespace).v2017_11_01_preview.models.CalculateBaselineResponse @@ -161,36 +245,26 @@ def calculate_baseline( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_baseline.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(time_series_information, 'TimeSeriesInformation') + + request = build_calculate_baseline_request( + resource_uri=resource_uri, + content_type=content_type, + json=_json, + template_url=self.calculate_baseline.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(time_series_information, 'TimeSeriesInformation') - body_content_kwargs['content'] = body_content - request = self._client.post(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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CalculateBaselineResponse', pipeline_response) @@ -199,4 +273,6 @@ def calculate_baseline( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_baseline.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/calculatebaseline'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_configuration.py index a1191ae931c45..9d0a15302b39f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -37,9 +37,9 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2017-12-01-preview" @@ -62,4 +62,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_metadata.json index d10acf8b52db7..18bc077c7cd89 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,11 +79,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "metric_namespaces": "MetricNamespacesOperations" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_monitor_management_client.py index fde0624d94752..0b26d435ee6d0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_monitor_management_client.py @@ -6,67 +6,78 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import MetricNamespacesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import MetricNamespacesOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. :ivar metric_namespaces: MetricNamespacesOperations operations - :vartype metric_namespaces: $(python-base-namespace).v2017_12_01_preview.operations.MetricNamespacesOperations + :vartype metric_namespaces: + $(python-base-namespace).v2017_12_01_preview.operations.MetricNamespacesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :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" - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, **kwargs) + self._config = MonitorManagementClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.metric_namespaces = MetricNamespacesOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_namespaces = MetricNamespacesOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_configuration.py index 8278395d0e83b..cf4b6135bb510 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/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 @@ -34,9 +34,9 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(MonitorManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2017-12-01-preview" @@ -58,4 +58,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_monitor_management_client.py index 174248807f3e9..da77ac77c9fa5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_monitor_management_client.py @@ -6,63 +6,74 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import MonitorManagementClientConfiguration from .operations import MetricNamespacesOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar metric_namespaces: MetricNamespacesOperations operations - :vartype metric_namespaces: $(python-base-namespace).v2017_12_01_preview.aio.operations.MetricNamespacesOperations + :vartype metric_namespaces: + $(python-base-namespace).v2017_12_01_preview.aio.operations.MetricNamespacesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :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", - 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 = MonitorManagementClientConfiguration(credential, **kwargs) + self._config = MonitorManagementClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.metric_namespaces = MetricNamespacesOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_namespaces = MetricNamespacesOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_metric_namespaces_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_metric_namespaces_operations.py index 0db0d9d75a4e6..f58ee93aa86d6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_metric_namespaces_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/aio/operations/_metric_namespaces_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._metric_namespaces_operations import build_list_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 list( self, resource_uri: str, @@ -55,8 +61,10 @@ def list( namespaces. :type start_time: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricNamespaceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespaceCollection] + :return: An iterator like instance of either MetricNamespaceCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespaceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricNamespaceCollection"] @@ -64,36 +72,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-12-01-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 - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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 start_time is not None: - query_parameters['startTime'] = self._serialize.query("start_time", start_time, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + start_time=start_time, + template_url=self.list.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_list_request( + resource_uri=resource_uri, + start_time=start_time, + 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('MetricNamespaceCollection', pipeline_response) + deserialized = self._deserialize("MetricNamespaceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,12 +109,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models.py index 4e9ee9c2fe299..81ff929b705aa 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models.py @@ -13,10 +13,10 @@ class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -28,6 +28,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -36,17 +42,17 @@ def __init__( class MetricNamespace(msrest.serialization.Model): """Metric namespace class specifies the metadata for a metric namespace. - :param id: The ID of the metric namespace. - :type id: str - :param type: The type of the namespace. - :type type: str - :param name: The escaped name of the namespace. - :type name: str - :param classification: Kind of namespace. Possible values include: "Platform", "Custom", "Qos". - :type classification: str or + :ivar id: The ID of the metric namespace. + :vartype id: str + :ivar type: The type of the namespace. + :vartype type: str + :ivar name: The escaped name of the namespace. + :vartype name: str + :ivar classification: Kind of namespace. Possible values include: "Platform", "Custom", "Qos". + :vartype classification: str or ~$(python-base-namespace).v2017_12_01_preview.models.NamespaceClassification - :param properties: Properties which include the fully qualified namespace name. - :type properties: ~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespaceName + :ivar properties: Properties which include the fully qualified namespace name. + :vartype properties: ~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespaceName """ _attribute_map = { @@ -61,6 +67,20 @@ def __init__( self, **kwargs ): + """ + :keyword id: The ID of the metric namespace. + :paramtype id: str + :keyword type: The type of the namespace. + :paramtype type: str + :keyword name: The escaped name of the namespace. + :paramtype name: str + :keyword classification: Kind of namespace. Possible values include: "Platform", "Custom", + "Qos". + :paramtype classification: str or + ~$(python-base-namespace).v2017_12_01_preview.models.NamespaceClassification + :keyword properties: Properties which include the fully qualified namespace name. + :paramtype properties: ~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespaceName + """ super(MetricNamespace, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.type = kwargs.get('type', None) @@ -74,8 +94,8 @@ class MetricNamespaceCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. The values for the metric namespaces. - :type value: list[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespace] + :ivar value: Required. The values for the metric namespaces. + :vartype value: list[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespace] """ _validation = { @@ -90,6 +110,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. The values for the metric namespaces. + :paramtype value: list[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespace] + """ super(MetricNamespaceCollection, self).__init__(**kwargs) self.value = kwargs['value'] @@ -97,8 +121,8 @@ def __init__( class MetricNamespaceName(msrest.serialization.Model): """The fully qualified metric namespace name. - :param metric_namespace_name: The metric namespace name. - :type metric_namespace_name: str + :ivar metric_namespace_name: The metric namespace name. + :vartype metric_namespace_name: str """ _attribute_map = { @@ -109,5 +133,9 @@ def __init__( self, **kwargs ): + """ + :keyword metric_namespace_name: The metric namespace name. + :paramtype metric_namespace_name: str + """ super(MetricNamespaceName, self).__init__(**kwargs) self.metric_namespace_name = kwargs.get('metric_namespace_name', None) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models_py3.py index e31361dc0b99e..92439e54e50b2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_models_py3.py @@ -17,10 +17,10 @@ class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -35,6 +35,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -43,17 +49,17 @@ def __init__( class MetricNamespace(msrest.serialization.Model): """Metric namespace class specifies the metadata for a metric namespace. - :param id: The ID of the metric namespace. - :type id: str - :param type: The type of the namespace. - :type type: str - :param name: The escaped name of the namespace. - :type name: str - :param classification: Kind of namespace. Possible values include: "Platform", "Custom", "Qos". - :type classification: str or + :ivar id: The ID of the metric namespace. + :vartype id: str + :ivar type: The type of the namespace. + :vartype type: str + :ivar name: The escaped name of the namespace. + :vartype name: str + :ivar classification: Kind of namespace. Possible values include: "Platform", "Custom", "Qos". + :vartype classification: str or ~$(python-base-namespace).v2017_12_01_preview.models.NamespaceClassification - :param properties: Properties which include the fully qualified namespace name. - :type properties: ~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespaceName + :ivar properties: Properties which include the fully qualified namespace name. + :vartype properties: ~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespaceName """ _attribute_map = { @@ -74,6 +80,20 @@ def __init__( properties: Optional["MetricNamespaceName"] = None, **kwargs ): + """ + :keyword id: The ID of the metric namespace. + :paramtype id: str + :keyword type: The type of the namespace. + :paramtype type: str + :keyword name: The escaped name of the namespace. + :paramtype name: str + :keyword classification: Kind of namespace. Possible values include: "Platform", "Custom", + "Qos". + :paramtype classification: str or + ~$(python-base-namespace).v2017_12_01_preview.models.NamespaceClassification + :keyword properties: Properties which include the fully qualified namespace name. + :paramtype properties: ~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespaceName + """ super(MetricNamespace, self).__init__(**kwargs) self.id = id self.type = type @@ -87,8 +107,8 @@ class MetricNamespaceCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. The values for the metric namespaces. - :type value: list[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespace] + :ivar value: Required. The values for the metric namespaces. + :vartype value: list[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespace] """ _validation = { @@ -105,6 +125,10 @@ def __init__( value: List["MetricNamespace"], **kwargs ): + """ + :keyword value: Required. The values for the metric namespaces. + :paramtype value: list[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespace] + """ super(MetricNamespaceCollection, self).__init__(**kwargs) self.value = value @@ -112,8 +136,8 @@ def __init__( class MetricNamespaceName(msrest.serialization.Model): """The fully qualified metric namespace name. - :param metric_namespace_name: The metric namespace name. - :type metric_namespace_name: str + :ivar metric_namespace_name: The metric namespace name. + :vartype metric_namespace_name: str """ _attribute_map = { @@ -126,5 +150,9 @@ def __init__( metric_namespace_name: Optional[str] = None, **kwargs ): + """ + :keyword metric_namespace_name: The metric namespace name. + :paramtype metric_namespace_name: str + """ super(MetricNamespaceName, self).__init__(**kwargs) self.metric_namespace_name = metric_namespace_name diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_monitor_management_client_enums.py index 8df48e53f31df..903fea1fdccaa 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/models/_monitor_management_client_enums.py @@ -6,27 +6,12 @@ # 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 NamespaceClassification(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NamespaceClassification(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Kind of namespace """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_metric_namespaces_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_metric_namespaces_operations.py index 97505136a4766..027f943fc30a4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_metric_namespaces_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2017_12_01_preview/operations/_metric_namespaces_operations.py @@ -5,24 +5,68 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + start_time = kwargs.pop('start_time', None) # type: Optional[str] + + api_version = "2017-12-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/metricNamespaces') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + 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') + if start_time is not None: + query_parameters['startTime'] = _SERIALIZER.query("start_time", start_time, '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 + ) + +# fmt: on class MetricNamespacesOperations(object): """MetricNamespacesOperations operations. @@ -45,6 +89,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_uri, # type: str @@ -60,8 +105,10 @@ def list( namespaces. :type start_time: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricNamespaceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespaceCollection] + :return: An iterator like instance of either MetricNamespaceCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2017_12_01_preview.models.MetricNamespaceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricNamespaceCollection"] @@ -69,36 +116,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-12-01-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 - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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 start_time is not None: - query_parameters['startTime'] = self._serialize.query("start_time", start_time, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + start_time=start_time, + template_url=self.list.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_list_request( + resource_uri=resource_uri, + start_time=start_time, + 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('MetricNamespaceCollection', pipeline_response) + deserialized = self._deserialize("MetricNamespaceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -111,12 +153,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_configuration.py index 2a02767f7a672..6bc81525b2464 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -37,9 +37,9 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2018-01-01" @@ -62,4 +62,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_metadata.json index 213c25c681a7b..99fa18757f37c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,11 +79,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "metric_definitions": "MetricDefinitionsOperations", diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_monitor_management_client.py index 5059198cc5e5d..e941d9958f566 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_monitor_management_client.py @@ -6,72 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import MetricDefinitionsOperations, MetricsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import MetricDefinitionsOperations -from .operations import MetricsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. :ivar metric_definitions: MetricDefinitionsOperations operations - :vartype metric_definitions: $(python-base-namespace).v2018_01_01.operations.MetricDefinitionsOperations + :vartype metric_definitions: + $(python-base-namespace).v2018_01_01.operations.MetricDefinitionsOperations :ivar metrics: MetricsOperations operations :vartype metrics: $(python-base-namespace).v2018_01_01.operations.MetricsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :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" - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, **kwargs) + self._config = MonitorManagementClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.metric_definitions = MetricDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_definitions = MetricDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.metrics = MetricsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_configuration.py index 693bca4bcf259..cffdc2d34b319 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/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 @@ -34,9 +34,9 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(MonitorManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2018-01-01" @@ -58,4 +58,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_monitor_management_client.py index b1fe92be01a38..11c57b3a714aa 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_monitor_management_client.py @@ -6,68 +6,77 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import MetricDefinitionsOperations, MetricsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MonitorManagementClientConfiguration -from .operations import MetricDefinitionsOperations -from .operations import MetricsOperations -from .. import models - - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar metric_definitions: MetricDefinitionsOperations operations - :vartype metric_definitions: $(python-base-namespace).v2018_01_01.aio.operations.MetricDefinitionsOperations + :vartype metric_definitions: + $(python-base-namespace).v2018_01_01.aio.operations.MetricDefinitionsOperations :ivar metrics: MetricsOperations operations :vartype metrics: $(python-base-namespace).v2018_01_01.aio.operations.MetricsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :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", - 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 = MonitorManagementClientConfiguration(credential, **kwargs) + self._config = MonitorManagementClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.metric_definitions = MetricDefinitionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metrics = MetricsOperations(self._client, self._config, self._serialize, self._deserialize) - self.metric_definitions = MetricDefinitionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.metrics = MetricsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metric_definitions_operations.py index 0345cdbc7dcbf..fda3b5ccdbe23 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metric_definitions_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._metric_definitions_operations import build_list_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 list( self, resource_uri: str, @@ -54,8 +60,10 @@ def list( :param metricnamespace: Metric namespace to query metric definitions for. :type metricnamespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_01_01.models.MetricDefinitionCollection] + :return: An iterator like instance of either MetricDefinitionCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_01_01.models.MetricDefinitionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionCollection"] @@ -63,36 +71,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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 metricnamespace is not None: - query_parameters['metricnamespace'] = self._serialize.query("metricnamespace", metricnamespace, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + metricnamespace=metricnamespace, + template_url=self.list.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_list_request( + resource_uri=resource_uri, + metricnamespace=metricnamespace, + 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('MetricDefinitionCollection', pipeline_response) + deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,12 +108,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metrics_operations.py index dca74acb8dcf7..bc650c2c02f17 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metrics_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/aio/operations/_metrics_operations.py @@ -6,16 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._metrics_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_uri: str, @@ -106,49 +111,30 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01" - accept = "application/json" - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if timespan is not None: - query_parameters['timespan'] = self._serialize.query("timespan", timespan, 'str') - if interval is not None: - query_parameters['interval'] = self._serialize.query("interval", interval, 'duration') - if metricnames is not None: - query_parameters['metricnames'] = self._serialize.query("metricnames", metricnames, 'str') - if aggregation is not None: - query_parameters['aggregation'] = self._serialize.query("aggregation", aggregation, 'str') - if top is not None: - query_parameters['top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['orderby'] = self._serialize.query("orderby", orderby, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if result_type is not None: - query_parameters['resultType'] = self._serialize.query("result_type", result_type, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if metricnamespace is not None: - query_parameters['metricnamespace'] = self._serialize.query("metricnamespace", metricnamespace, '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_list_request( + resource_uri=resource_uri, + timespan=timespan, + interval=interval, + metricnames=metricnames, + aggregation=aggregation, + top=top, + orderby=orderby, + filter=filter, + result_type=result_type, + metricnamespace=metricnamespace, + template_url=self.list.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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Response', pipeline_response) @@ -157,4 +143,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/metrics'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models.py index f474ab6343f0b..eb51409e811f2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models.py @@ -13,10 +13,10 @@ class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -28,6 +28,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -38,10 +44,10 @@ class LocalizableString(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the invariant value. - :type value: str - :param localized_value: the locale specific value. - :type localized_value: str + :ivar value: Required. the invariant value. + :vartype value: str + :ivar localized_value: the locale specific value. + :vartype localized_value: str """ _validation = { @@ -57,6 +63,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. the invariant value. + :paramtype value: str + :keyword localized_value: the locale specific value. + :paramtype localized_value: str + """ super(LocalizableString, self).__init__(**kwargs) self.value = kwargs['value'] self.localized_value = kwargs.get('localized_value', None) @@ -65,10 +77,10 @@ def __init__( class MetadataValue(msrest.serialization.Model): """Represents a metric metadata value. - :param name: the name of the metadata. - :type name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString - :param value: the value of the metadata. - :type value: str + :ivar name: the name of the metadata. + :vartype name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString + :ivar value: the value of the metadata. + :vartype value: str """ _attribute_map = { @@ -80,6 +92,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: the name of the metadata. + :paramtype name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString + :keyword value: the value of the metadata. + :paramtype value: str + """ super(MetadataValue, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.value = kwargs.get('value', None) @@ -90,25 +108,25 @@ class Metric(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. the metric Id. - :type id: str - :param type: Required. the resource type of the metric resource. - :type type: str - :param name: Required. the name and the display name of the metric, i.e. it is localizable + :ivar id: Required. the metric Id. + :vartype id: str + :ivar type: Required. the resource type of the metric resource. + :vartype type: str + :ivar name: Required. the name and the display name of the metric, i.e. it is localizable string. - :type name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString - :param display_description: Detailed description of this metric. - :type display_description: str - :param error_code: 'Success' or the error details on query failures for this metric. - :type error_code: str - :param error_message: Error message encountered querying this specific metric. - :type error_message: str - :param unit: Required. The unit of the metric. Possible values include: "Count", "Bytes", + :vartype name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString + :ivar display_description: Detailed description of this metric. + :vartype display_description: str + :ivar error_code: 'Success' or the error details on query failures for this metric. + :vartype error_code: str + :ivar error_message: Error message encountered querying this specific metric. + :vartype error_message: str + :ivar unit: Required. The unit of the metric. Possible values include: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". - :type unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit - :param timeseries: Required. the time series returned when a data query is performed. - :type timeseries: list[~$(python-base-namespace).v2018_01_01.models.TimeSeriesElement] + :vartype unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit + :ivar timeseries: Required. the time series returned when a data query is performed. + :vartype timeseries: list[~$(python-base-namespace).v2018_01_01.models.TimeSeriesElement] """ _validation = { @@ -134,6 +152,27 @@ def __init__( self, **kwargs ): + """ + :keyword id: Required. the metric Id. + :paramtype id: str + :keyword type: Required. the resource type of the metric resource. + :paramtype type: str + :keyword name: Required. the name and the display name of the metric, i.e. it is localizable + string. + :paramtype name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString + :keyword display_description: Detailed description of this metric. + :paramtype display_description: str + :keyword error_code: 'Success' or the error details on query failures for this metric. + :paramtype error_code: str + :keyword error_message: Error message encountered querying this specific metric. + :paramtype error_message: str + :keyword unit: Required. The unit of the metric. Possible values include: "Count", "Bytes", + "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", + "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + :paramtype unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit + :keyword timeseries: Required. the time series returned when a data query is performed. + :paramtype timeseries: list[~$(python-base-namespace).v2018_01_01.models.TimeSeriesElement] + """ super(Metric, self).__init__(**kwargs) self.id = kwargs['id'] self.type = kwargs['type'] @@ -148,12 +187,12 @@ def __init__( class MetricAvailability(msrest.serialization.Model): """Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. - :param time_grain: the time grain specifies the aggregation interval for the metric. Expressed + :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. - :type time_grain: ~datetime.timedelta - :param retention: the retention period for the metric at the specified timegrain. Expressed as + :vartype time_grain: ~datetime.timedelta + :ivar retention: the retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc. - :type retention: ~datetime.timedelta + :vartype retention: ~datetime.timedelta """ _attribute_map = { @@ -165,6 +204,14 @@ def __init__( self, **kwargs ): + """ + :keyword time_grain: the time grain specifies the aggregation interval for the metric. + Expressed as a duration 'PT1M', 'P1D', etc. + :paramtype time_grain: ~datetime.timedelta + :keyword retention: the retention period for the metric at the specified timegrain. Expressed + as a duration 'PT1M', 'P1D', etc. + :paramtype retention: ~datetime.timedelta + """ super(MetricAvailability, self).__init__(**kwargs) self.time_grain = kwargs.get('time_grain', None) self.retention = kwargs.get('retention', None) @@ -173,42 +220,42 @@ def __init__( class MetricDefinition(msrest.serialization.Model): """Metric definition class specifies the metadata for a metric. - :param is_dimension_required: Flag to indicate whether the dimension is required. - :type is_dimension_required: bool - :param resource_id: the resource identifier of the resource that emitted the metric. - :type resource_id: str - :param namespace: the namespace the metric belongs to. - :type namespace: str - :param name: the name and the display name of the metric, i.e. it is a localizable string. - :type name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString - :param display_description: Detailed description of this metric. - :type display_description: str - :param category: Custom category name for this metric. - :type category: str - :param metric_class: The class of the metric. Possible values include: "Availability", + :ivar is_dimension_required: Flag to indicate whether the dimension is required. + :vartype is_dimension_required: bool + :ivar resource_id: the resource identifier of the resource that emitted the metric. + :vartype resource_id: str + :ivar namespace: the namespace the metric belongs to. + :vartype namespace: str + :ivar name: the name and the display name of the metric, i.e. it is a localizable string. + :vartype name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString + :ivar display_description: Detailed description of this metric. + :vartype display_description: str + :ivar category: Custom category name for this metric. + :vartype category: str + :ivar metric_class: The class of the metric. Possible values include: "Availability", "Transactions", "Errors", "Latency", "Saturation". - :type metric_class: str or ~$(python-base-namespace).v2018_01_01.models.MetricClass - :param unit: The unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + :vartype metric_class: str or ~$(python-base-namespace).v2018_01_01.models.MetricClass + :ivar unit: The unit of the metric. Possible values include: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". - :type unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit - :param primary_aggregation_type: the primary aggregation type value defining how to use the + :vartype unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit + :ivar primary_aggregation_type: the primary aggregation type value defining how to use the values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", "Total". - :type primary_aggregation_type: str or + :vartype primary_aggregation_type: str or ~$(python-base-namespace).v2018_01_01.models.AggregationType - :param supported_aggregation_types: the collection of what aggregation types are supported. - :type supported_aggregation_types: list[str or + :ivar supported_aggregation_types: the collection of what aggregation types are supported. + :vartype supported_aggregation_types: list[str or ~$(python-base-namespace).v2018_01_01.models.AggregationType] - :param metric_availabilities: the collection of what aggregation intervals are available to be + :ivar metric_availabilities: the collection of what aggregation intervals are available to be queried. - :type metric_availabilities: + :vartype metric_availabilities: list[~$(python-base-namespace).v2018_01_01.models.MetricAvailability] - :param id: the resource identifier of the metric definition. - :type id: str - :param dimensions: the name and the display name of the dimension, i.e. it is a localizable + :ivar id: the resource identifier of the metric definition. + :vartype id: str + :ivar dimensions: the name and the display name of the dimension, i.e. it is a localizable string. - :type dimensions: list[~$(python-base-namespace).v2018_01_01.models.LocalizableString] + :vartype dimensions: list[~$(python-base-namespace).v2018_01_01.models.LocalizableString] """ _attribute_map = { @@ -231,6 +278,44 @@ def __init__( self, **kwargs ): + """ + :keyword is_dimension_required: Flag to indicate whether the dimension is required. + :paramtype is_dimension_required: bool + :keyword resource_id: the resource identifier of the resource that emitted the metric. + :paramtype resource_id: str + :keyword namespace: the namespace the metric belongs to. + :paramtype namespace: str + :keyword name: the name and the display name of the metric, i.e. it is a localizable string. + :paramtype name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString + :keyword display_description: Detailed description of this metric. + :paramtype display_description: str + :keyword category: Custom category name for this metric. + :paramtype category: str + :keyword metric_class: The class of the metric. Possible values include: "Availability", + "Transactions", "Errors", "Latency", "Saturation". + :paramtype metric_class: str or ~$(python-base-namespace).v2018_01_01.models.MetricClass + :keyword unit: The unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", + "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + :paramtype unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit + :keyword primary_aggregation_type: the primary aggregation type value defining how to use the + values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", + "Total". + :paramtype primary_aggregation_type: str or + ~$(python-base-namespace).v2018_01_01.models.AggregationType + :keyword supported_aggregation_types: the collection of what aggregation types are supported. + :paramtype supported_aggregation_types: list[str or + ~$(python-base-namespace).v2018_01_01.models.AggregationType] + :keyword metric_availabilities: the collection of what aggregation intervals are available to + be queried. + :paramtype metric_availabilities: + list[~$(python-base-namespace).v2018_01_01.models.MetricAvailability] + :keyword id: the resource identifier of the metric definition. + :paramtype id: str + :keyword dimensions: the name and the display name of the dimension, i.e. it is a localizable + string. + :paramtype dimensions: list[~$(python-base-namespace).v2018_01_01.models.LocalizableString] + """ super(MetricDefinition, self).__init__(**kwargs) self.is_dimension_required = kwargs.get('is_dimension_required', None) self.resource_id = kwargs.get('resource_id', None) @@ -252,8 +337,8 @@ class MetricDefinitionCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the values for the metric definitions. - :type value: list[~$(python-base-namespace).v2018_01_01.models.MetricDefinition] + :ivar value: Required. the values for the metric definitions. + :vartype value: list[~$(python-base-namespace).v2018_01_01.models.MetricDefinition] """ _validation = { @@ -268,6 +353,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. the values for the metric definitions. + :paramtype value: list[~$(python-base-namespace).v2018_01_01.models.MetricDefinition] + """ super(MetricDefinitionCollection, self).__init__(**kwargs) self.value = kwargs['value'] @@ -277,19 +366,19 @@ class MetricValue(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_stamp: Required. the timestamp for the metric value in ISO 8601 format. - :type time_stamp: ~datetime.datetime - :param average: the average value in the time range. - :type average: float - :param minimum: the least value in the time range. - :type minimum: float - :param maximum: the greatest value in the time range. - :type maximum: float - :param total: the sum of all of the values in the time range. - :type total: float - :param count: the number of samples in the time range. Can be used to determine the number of + :ivar time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :vartype time_stamp: ~datetime.datetime + :ivar average: the average value in the time range. + :vartype average: float + :ivar minimum: the least value in the time range. + :vartype minimum: float + :ivar maximum: the greatest value in the time range. + :vartype maximum: float + :ivar total: the sum of all of the values in the time range. + :vartype total: float + :ivar count: the number of samples in the time range. Can be used to determine the number of values that contributed to the average value. - :type count: float + :vartype count: float """ _validation = { @@ -309,6 +398,21 @@ def __init__( self, **kwargs ): + """ + :keyword time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :paramtype time_stamp: ~datetime.datetime + :keyword average: the average value in the time range. + :paramtype average: float + :keyword minimum: the least value in the time range. + :paramtype minimum: float + :keyword maximum: the greatest value in the time range. + :paramtype maximum: float + :keyword total: the sum of all of the values in the time range. + :paramtype total: float + :keyword count: the number of samples in the time range. Can be used to determine the number of + values that contributed to the average value. + :paramtype count: float + """ super(MetricValue, self).__init__(**kwargs) self.time_stamp = kwargs['time_stamp'] self.average = kwargs.get('average', None) @@ -323,22 +427,22 @@ class Response(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param cost: The integer value representing the relative cost of the query. - :type cost: int - :param timespan: Required. The timespan for which the data was retrieved. Its value consists of + :ivar cost: The integer value representing the relative cost of the query. + :vartype cost: int + :ivar timespan: Required. The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. - :type timespan: str - :param interval: The interval (window size) for which the metric data was returned in. This - may be adjusted in the future and returned back from what was originally requested. This is - not present if a metadata request was made. - :type interval: ~datetime.timedelta - :param namespace: The namespace of the metrics being queried. - :type namespace: str - :param resourceregion: The region of the resource being queried for metrics. - :type resourceregion: str - :param value: Required. the value of the collection. - :type value: list[~$(python-base-namespace).v2018_01_01.models.Metric] + :vartype timespan: str + :ivar interval: The interval (window size) for which the metric data was returned in. This may + be adjusted in the future and returned back from what was originally requested. This is not + present if a metadata request was made. + :vartype interval: ~datetime.timedelta + :ivar namespace: The namespace of the metrics being queried. + :vartype namespace: str + :ivar resourceregion: The region of the resource being queried for metrics. + :vartype resourceregion: str + :ivar value: Required. the value of the collection. + :vartype value: list[~$(python-base-namespace).v2018_01_01.models.Metric] """ _validation = { @@ -360,6 +464,24 @@ def __init__( self, **kwargs ): + """ + :keyword cost: The integer value representing the relative cost of the query. + :paramtype cost: int + :keyword timespan: Required. The timespan for which the data was retrieved. Its value consists + of two datetimes concatenated, separated by '/'. This may be adjusted in the future and + returned back from what was originally requested. + :paramtype timespan: str + :keyword interval: The interval (window size) for which the metric data was returned in. This + may be adjusted in the future and returned back from what was originally requested. This is + not present if a metadata request was made. + :paramtype interval: ~datetime.timedelta + :keyword namespace: The namespace of the metrics being queried. + :paramtype namespace: str + :keyword resourceregion: The region of the resource being queried for metrics. + :paramtype resourceregion: str + :keyword value: Required. the value of the collection. + :paramtype value: list[~$(python-base-namespace).v2018_01_01.models.Metric] + """ super(Response, self).__init__(**kwargs) self.cost = kwargs.get('cost', None) self.timespan = kwargs['timespan'] @@ -372,11 +494,11 @@ def __init__( class TimeSeriesElement(msrest.serialization.Model): """A time series result type. The discriminator value is always TimeSeries in this case. - :param metadatavalues: the metadata values returned if $filter was specified in the call. - :type metadatavalues: list[~$(python-base-namespace).v2018_01_01.models.MetadataValue] - :param data: An array of data points representing the metric values. This is only returned if - a result type of data is specified. - :type data: list[~$(python-base-namespace).v2018_01_01.models.MetricValue] + :ivar metadatavalues: the metadata values returned if $filter was specified in the call. + :vartype metadatavalues: list[~$(python-base-namespace).v2018_01_01.models.MetadataValue] + :ivar data: An array of data points representing the metric values. This is only returned if a + result type of data is specified. + :vartype data: list[~$(python-base-namespace).v2018_01_01.models.MetricValue] """ _attribute_map = { @@ -388,6 +510,13 @@ def __init__( self, **kwargs ): + """ + :keyword metadatavalues: the metadata values returned if $filter was specified in the call. + :paramtype metadatavalues: list[~$(python-base-namespace).v2018_01_01.models.MetadataValue] + :keyword data: An array of data points representing the metric values. This is only returned + if a result type of data is specified. + :paramtype data: list[~$(python-base-namespace).v2018_01_01.models.MetricValue] + """ super(TimeSeriesElement, self).__init__(**kwargs) self.metadatavalues = kwargs.get('metadatavalues', None) self.data = kwargs.get('data', None) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models_py3.py index d82c93e35b597..f7a0b02333a94 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_models_py3.py @@ -18,10 +18,10 @@ class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -36,6 +36,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -46,10 +52,10 @@ class LocalizableString(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the invariant value. - :type value: str - :param localized_value: the locale specific value. - :type localized_value: str + :ivar value: Required. the invariant value. + :vartype value: str + :ivar localized_value: the locale specific value. + :vartype localized_value: str """ _validation = { @@ -68,6 +74,12 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. the invariant value. + :paramtype value: str + :keyword localized_value: the locale specific value. + :paramtype localized_value: str + """ super(LocalizableString, self).__init__(**kwargs) self.value = value self.localized_value = localized_value @@ -76,10 +88,10 @@ def __init__( class MetadataValue(msrest.serialization.Model): """Represents a metric metadata value. - :param name: the name of the metadata. - :type name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString - :param value: the value of the metadata. - :type value: str + :ivar name: the name of the metadata. + :vartype name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString + :ivar value: the value of the metadata. + :vartype value: str """ _attribute_map = { @@ -94,6 +106,12 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword name: the name of the metadata. + :paramtype name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString + :keyword value: the value of the metadata. + :paramtype value: str + """ super(MetadataValue, self).__init__(**kwargs) self.name = name self.value = value @@ -104,25 +122,25 @@ class Metric(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. the metric Id. - :type id: str - :param type: Required. the resource type of the metric resource. - :type type: str - :param name: Required. the name and the display name of the metric, i.e. it is localizable + :ivar id: Required. the metric Id. + :vartype id: str + :ivar type: Required. the resource type of the metric resource. + :vartype type: str + :ivar name: Required. the name and the display name of the metric, i.e. it is localizable string. - :type name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString - :param display_description: Detailed description of this metric. - :type display_description: str - :param error_code: 'Success' or the error details on query failures for this metric. - :type error_code: str - :param error_message: Error message encountered querying this specific metric. - :type error_message: str - :param unit: Required. The unit of the metric. Possible values include: "Count", "Bytes", + :vartype name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString + :ivar display_description: Detailed description of this metric. + :vartype display_description: str + :ivar error_code: 'Success' or the error details on query failures for this metric. + :vartype error_code: str + :ivar error_message: Error message encountered querying this specific metric. + :vartype error_message: str + :ivar unit: Required. The unit of the metric. Possible values include: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". - :type unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit - :param timeseries: Required. the time series returned when a data query is performed. - :type timeseries: list[~$(python-base-namespace).v2018_01_01.models.TimeSeriesElement] + :vartype unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit + :ivar timeseries: Required. the time series returned when a data query is performed. + :vartype timeseries: list[~$(python-base-namespace).v2018_01_01.models.TimeSeriesElement] """ _validation = { @@ -157,6 +175,27 @@ def __init__( error_message: Optional[str] = None, **kwargs ): + """ + :keyword id: Required. the metric Id. + :paramtype id: str + :keyword type: Required. the resource type of the metric resource. + :paramtype type: str + :keyword name: Required. the name and the display name of the metric, i.e. it is localizable + string. + :paramtype name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString + :keyword display_description: Detailed description of this metric. + :paramtype display_description: str + :keyword error_code: 'Success' or the error details on query failures for this metric. + :paramtype error_code: str + :keyword error_message: Error message encountered querying this specific metric. + :paramtype error_message: str + :keyword unit: Required. The unit of the metric. Possible values include: "Count", "Bytes", + "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", + "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + :paramtype unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit + :keyword timeseries: Required. the time series returned when a data query is performed. + :paramtype timeseries: list[~$(python-base-namespace).v2018_01_01.models.TimeSeriesElement] + """ super(Metric, self).__init__(**kwargs) self.id = id self.type = type @@ -171,12 +210,12 @@ def __init__( class MetricAvailability(msrest.serialization.Model): """Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that time grain. - :param time_grain: the time grain specifies the aggregation interval for the metric. Expressed + :ivar time_grain: the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc. - :type time_grain: ~datetime.timedelta - :param retention: the retention period for the metric at the specified timegrain. Expressed as + :vartype time_grain: ~datetime.timedelta + :ivar retention: the retention period for the metric at the specified timegrain. Expressed as a duration 'PT1M', 'P1D', etc. - :type retention: ~datetime.timedelta + :vartype retention: ~datetime.timedelta """ _attribute_map = { @@ -191,6 +230,14 @@ def __init__( retention: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword time_grain: the time grain specifies the aggregation interval for the metric. + Expressed as a duration 'PT1M', 'P1D', etc. + :paramtype time_grain: ~datetime.timedelta + :keyword retention: the retention period for the metric at the specified timegrain. Expressed + as a duration 'PT1M', 'P1D', etc. + :paramtype retention: ~datetime.timedelta + """ super(MetricAvailability, self).__init__(**kwargs) self.time_grain = time_grain self.retention = retention @@ -199,42 +246,42 @@ def __init__( class MetricDefinition(msrest.serialization.Model): """Metric definition class specifies the metadata for a metric. - :param is_dimension_required: Flag to indicate whether the dimension is required. - :type is_dimension_required: bool - :param resource_id: the resource identifier of the resource that emitted the metric. - :type resource_id: str - :param namespace: the namespace the metric belongs to. - :type namespace: str - :param name: the name and the display name of the metric, i.e. it is a localizable string. - :type name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString - :param display_description: Detailed description of this metric. - :type display_description: str - :param category: Custom category name for this metric. - :type category: str - :param metric_class: The class of the metric. Possible values include: "Availability", + :ivar is_dimension_required: Flag to indicate whether the dimension is required. + :vartype is_dimension_required: bool + :ivar resource_id: the resource identifier of the resource that emitted the metric. + :vartype resource_id: str + :ivar namespace: the namespace the metric belongs to. + :vartype namespace: str + :ivar name: the name and the display name of the metric, i.e. it is a localizable string. + :vartype name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString + :ivar display_description: Detailed description of this metric. + :vartype display_description: str + :ivar category: Custom category name for this metric. + :vartype category: str + :ivar metric_class: The class of the metric. Possible values include: "Availability", "Transactions", "Errors", "Latency", "Saturation". - :type metric_class: str or ~$(python-base-namespace).v2018_01_01.models.MetricClass - :param unit: The unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + :vartype metric_class: str or ~$(python-base-namespace).v2018_01_01.models.MetricClass + :ivar unit: The unit of the metric. Possible values include: "Count", "Bytes", "Seconds", "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", "Cores", "MilliCores", "NanoCores", "BitsPerSecond". - :type unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit - :param primary_aggregation_type: the primary aggregation type value defining how to use the + :vartype unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit + :ivar primary_aggregation_type: the primary aggregation type value defining how to use the values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", "Total". - :type primary_aggregation_type: str or + :vartype primary_aggregation_type: str or ~$(python-base-namespace).v2018_01_01.models.AggregationType - :param supported_aggregation_types: the collection of what aggregation types are supported. - :type supported_aggregation_types: list[str or + :ivar supported_aggregation_types: the collection of what aggregation types are supported. + :vartype supported_aggregation_types: list[str or ~$(python-base-namespace).v2018_01_01.models.AggregationType] - :param metric_availabilities: the collection of what aggregation intervals are available to be + :ivar metric_availabilities: the collection of what aggregation intervals are available to be queried. - :type metric_availabilities: + :vartype metric_availabilities: list[~$(python-base-namespace).v2018_01_01.models.MetricAvailability] - :param id: the resource identifier of the metric definition. - :type id: str - :param dimensions: the name and the display name of the dimension, i.e. it is a localizable + :ivar id: the resource identifier of the metric definition. + :vartype id: str + :ivar dimensions: the name and the display name of the dimension, i.e. it is a localizable string. - :type dimensions: list[~$(python-base-namespace).v2018_01_01.models.LocalizableString] + :vartype dimensions: list[~$(python-base-namespace).v2018_01_01.models.LocalizableString] """ _attribute_map = { @@ -271,6 +318,44 @@ def __init__( dimensions: Optional[List["LocalizableString"]] = None, **kwargs ): + """ + :keyword is_dimension_required: Flag to indicate whether the dimension is required. + :paramtype is_dimension_required: bool + :keyword resource_id: the resource identifier of the resource that emitted the metric. + :paramtype resource_id: str + :keyword namespace: the namespace the metric belongs to. + :paramtype namespace: str + :keyword name: the name and the display name of the metric, i.e. it is a localizable string. + :paramtype name: ~$(python-base-namespace).v2018_01_01.models.LocalizableString + :keyword display_description: Detailed description of this metric. + :paramtype display_description: str + :keyword category: Custom category name for this metric. + :paramtype category: str + :keyword metric_class: The class of the metric. Possible values include: "Availability", + "Transactions", "Errors", "Latency", "Saturation". + :paramtype metric_class: str or ~$(python-base-namespace).v2018_01_01.models.MetricClass + :keyword unit: The unit of the metric. Possible values include: "Count", "Bytes", "Seconds", + "CountPerSecond", "BytesPerSecond", "Percent", "MilliSeconds", "ByteSeconds", "Unspecified", + "Cores", "MilliCores", "NanoCores", "BitsPerSecond". + :paramtype unit: str or ~$(python-base-namespace).v2018_01_01.models.MetricUnit + :keyword primary_aggregation_type: the primary aggregation type value defining how to use the + values for display. Possible values include: "None", "Average", "Count", "Minimum", "Maximum", + "Total". + :paramtype primary_aggregation_type: str or + ~$(python-base-namespace).v2018_01_01.models.AggregationType + :keyword supported_aggregation_types: the collection of what aggregation types are supported. + :paramtype supported_aggregation_types: list[str or + ~$(python-base-namespace).v2018_01_01.models.AggregationType] + :keyword metric_availabilities: the collection of what aggregation intervals are available to + be queried. + :paramtype metric_availabilities: + list[~$(python-base-namespace).v2018_01_01.models.MetricAvailability] + :keyword id: the resource identifier of the metric definition. + :paramtype id: str + :keyword dimensions: the name and the display name of the dimension, i.e. it is a localizable + string. + :paramtype dimensions: list[~$(python-base-namespace).v2018_01_01.models.LocalizableString] + """ super(MetricDefinition, self).__init__(**kwargs) self.is_dimension_required = is_dimension_required self.resource_id = resource_id @@ -292,8 +377,8 @@ class MetricDefinitionCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the values for the metric definitions. - :type value: list[~$(python-base-namespace).v2018_01_01.models.MetricDefinition] + :ivar value: Required. the values for the metric definitions. + :vartype value: list[~$(python-base-namespace).v2018_01_01.models.MetricDefinition] """ _validation = { @@ -310,6 +395,10 @@ def __init__( value: List["MetricDefinition"], **kwargs ): + """ + :keyword value: Required. the values for the metric definitions. + :paramtype value: list[~$(python-base-namespace).v2018_01_01.models.MetricDefinition] + """ super(MetricDefinitionCollection, self).__init__(**kwargs) self.value = value @@ -319,19 +408,19 @@ class MetricValue(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_stamp: Required. the timestamp for the metric value in ISO 8601 format. - :type time_stamp: ~datetime.datetime - :param average: the average value in the time range. - :type average: float - :param minimum: the least value in the time range. - :type minimum: float - :param maximum: the greatest value in the time range. - :type maximum: float - :param total: the sum of all of the values in the time range. - :type total: float - :param count: the number of samples in the time range. Can be used to determine the number of + :ivar time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :vartype time_stamp: ~datetime.datetime + :ivar average: the average value in the time range. + :vartype average: float + :ivar minimum: the least value in the time range. + :vartype minimum: float + :ivar maximum: the greatest value in the time range. + :vartype maximum: float + :ivar total: the sum of all of the values in the time range. + :vartype total: float + :ivar count: the number of samples in the time range. Can be used to determine the number of values that contributed to the average value. - :type count: float + :vartype count: float """ _validation = { @@ -358,6 +447,21 @@ def __init__( count: Optional[float] = None, **kwargs ): + """ + :keyword time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :paramtype time_stamp: ~datetime.datetime + :keyword average: the average value in the time range. + :paramtype average: float + :keyword minimum: the least value in the time range. + :paramtype minimum: float + :keyword maximum: the greatest value in the time range. + :paramtype maximum: float + :keyword total: the sum of all of the values in the time range. + :paramtype total: float + :keyword count: the number of samples in the time range. Can be used to determine the number of + values that contributed to the average value. + :paramtype count: float + """ super(MetricValue, self).__init__(**kwargs) self.time_stamp = time_stamp self.average = average @@ -372,22 +476,22 @@ class Response(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param cost: The integer value representing the relative cost of the query. - :type cost: int - :param timespan: Required. The timespan for which the data was retrieved. Its value consists of + :ivar cost: The integer value representing the relative cost of the query. + :vartype cost: int + :ivar timespan: Required. The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. - :type timespan: str - :param interval: The interval (window size) for which the metric data was returned in. This - may be adjusted in the future and returned back from what was originally requested. This is - not present if a metadata request was made. - :type interval: ~datetime.timedelta - :param namespace: The namespace of the metrics being queried. - :type namespace: str - :param resourceregion: The region of the resource being queried for metrics. - :type resourceregion: str - :param value: Required. the value of the collection. - :type value: list[~$(python-base-namespace).v2018_01_01.models.Metric] + :vartype timespan: str + :ivar interval: The interval (window size) for which the metric data was returned in. This may + be adjusted in the future and returned back from what was originally requested. This is not + present if a metadata request was made. + :vartype interval: ~datetime.timedelta + :ivar namespace: The namespace of the metrics being queried. + :vartype namespace: str + :ivar resourceregion: The region of the resource being queried for metrics. + :vartype resourceregion: str + :ivar value: Required. the value of the collection. + :vartype value: list[~$(python-base-namespace).v2018_01_01.models.Metric] """ _validation = { @@ -416,6 +520,24 @@ def __init__( resourceregion: Optional[str] = None, **kwargs ): + """ + :keyword cost: The integer value representing the relative cost of the query. + :paramtype cost: int + :keyword timespan: Required. The timespan for which the data was retrieved. Its value consists + of two datetimes concatenated, separated by '/'. This may be adjusted in the future and + returned back from what was originally requested. + :paramtype timespan: str + :keyword interval: The interval (window size) for which the metric data was returned in. This + may be adjusted in the future and returned back from what was originally requested. This is + not present if a metadata request was made. + :paramtype interval: ~datetime.timedelta + :keyword namespace: The namespace of the metrics being queried. + :paramtype namespace: str + :keyword resourceregion: The region of the resource being queried for metrics. + :paramtype resourceregion: str + :keyword value: Required. the value of the collection. + :paramtype value: list[~$(python-base-namespace).v2018_01_01.models.Metric] + """ super(Response, self).__init__(**kwargs) self.cost = cost self.timespan = timespan @@ -428,11 +550,11 @@ def __init__( class TimeSeriesElement(msrest.serialization.Model): """A time series result type. The discriminator value is always TimeSeries in this case. - :param metadatavalues: the metadata values returned if $filter was specified in the call. - :type metadatavalues: list[~$(python-base-namespace).v2018_01_01.models.MetadataValue] - :param data: An array of data points representing the metric values. This is only returned if - a result type of data is specified. - :type data: list[~$(python-base-namespace).v2018_01_01.models.MetricValue] + :ivar metadatavalues: the metadata values returned if $filter was specified in the call. + :vartype metadatavalues: list[~$(python-base-namespace).v2018_01_01.models.MetadataValue] + :ivar data: An array of data points representing the metric values. This is only returned if a + result type of data is specified. + :vartype data: list[~$(python-base-namespace).v2018_01_01.models.MetricValue] """ _attribute_map = { @@ -447,6 +569,13 @@ def __init__( data: Optional[List["MetricValue"]] = None, **kwargs ): + """ + :keyword metadatavalues: the metadata values returned if $filter was specified in the call. + :paramtype metadatavalues: list[~$(python-base-namespace).v2018_01_01.models.MetadataValue] + :keyword data: An array of data points representing the metric values. This is only returned + if a result type of data is specified. + :paramtype data: list[~$(python-base-namespace).v2018_01_01.models.MetricValue] + """ super(TimeSeriesElement, self).__init__(**kwargs) self.metadatavalues = metadatavalues self.data = data diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_monitor_management_client_enums.py index 6f8d86605f131..fd09dbefdcc68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/models/_monitor_management_client_enums.py @@ -6,27 +6,12 @@ # 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 AggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the aggregation type of the metric. """ @@ -37,7 +22,7 @@ class AggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MAXIMUM = "Maximum" TOTAL = "Total" -class MetricClass(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MetricClass(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The class of the metric. """ @@ -47,7 +32,7 @@ class MetricClass(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): LATENCY = "Latency" SATURATION = "Saturation" -class MetricUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MetricUnit(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The unit of the metric. """ @@ -65,7 +50,7 @@ class MetricUnit(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): NANO_CORES = "NanoCores" BITS_PER_SECOND = "BitsPerSecond" -class ResultType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResultType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DATA = "Data" METADATA = "Metadata" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metric_definitions_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metric_definitions_operations.py index c3c1565f29c72..e3c5aa4af9dbf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metric_definitions_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metric_definitions_operations.py @@ -5,24 +5,68 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + metricnamespace = kwargs.pop('metricnamespace', None) # type: Optional[str] + + api_version = "2018-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/metricDefinitions') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + 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') + if metricnamespace is not None: + query_parameters['metricnamespace'] = _SERIALIZER.query("metricnamespace", metricnamespace, '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 + ) + +# fmt: on class MetricDefinitionsOperations(object): """MetricDefinitionsOperations operations. @@ -45,6 +89,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_uri, # type: str @@ -59,8 +104,10 @@ def list( :param metricnamespace: Metric namespace to query metric definitions for. :type metricnamespace: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricDefinitionCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_01_01.models.MetricDefinitionCollection] + :return: An iterator like instance of either MetricDefinitionCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_01_01.models.MetricDefinitionCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricDefinitionCollection"] @@ -68,36 +115,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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 metricnamespace is not None: - query_parameters['metricnamespace'] = self._serialize.query("metricnamespace", metricnamespace, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + metricnamespace=metricnamespace, + template_url=self.list.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_list_request( + resource_uri=resource_uri, + metricnamespace=metricnamespace, + 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('MetricDefinitionCollection', pipeline_response) + deserialized = self._deserialize("MetricDefinitionCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,12 +152,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metrics_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metrics_operations.py index 5f9c37f406805..a233526564ddb 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metrics_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_01_01/operations/_metrics_operations.py @@ -6,23 +6,91 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + timespan = kwargs.pop('timespan', None) # type: Optional[str] + interval = kwargs.pop('interval', None) # type: Optional[datetime.timedelta] + metricnames = kwargs.pop('metricnames', None) # type: Optional[str] + aggregation = kwargs.pop('aggregation', None) # type: Optional[str] + top = kwargs.pop('top', None) # type: Optional[int] + orderby = kwargs.pop('orderby', None) # type: Optional[str] + filter = kwargs.pop('filter', None) # type: Optional[str] + result_type = kwargs.pop('result_type', None) # type: Optional[Union[str, "_models.ResultType"]] + metricnamespace = kwargs.pop('metricnamespace', None) # type: Optional[str] + + api_version = "2018-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/metrics') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if timespan is not None: + query_parameters['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') + if interval is not None: + query_parameters['interval'] = _SERIALIZER.query("interval", interval, 'duration') + if metricnames is not None: + query_parameters['metricnames'] = _SERIALIZER.query("metricnames", metricnames, 'str') + if aggregation is not None: + query_parameters['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') + if top is not None: + query_parameters['top'] = _SERIALIZER.query("top", top, 'int') + if orderby is not None: + query_parameters['orderby'] = _SERIALIZER.query("orderby", orderby, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if result_type is not None: + query_parameters['resultType'] = _SERIALIZER.query("result_type", result_type, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if metricnamespace is not None: + query_parameters['metricnamespace'] = _SERIALIZER.query("metricnamespace", metricnamespace, '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 + ) + +# fmt: on class MetricsOperations(object): """MetricsOperations operations. @@ -45,6 +113,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_uri, # type: str @@ -111,49 +180,30 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-01" - accept = "application/json" - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if timespan is not None: - query_parameters['timespan'] = self._serialize.query("timespan", timespan, 'str') - if interval is not None: - query_parameters['interval'] = self._serialize.query("interval", interval, 'duration') - if metricnames is not None: - query_parameters['metricnames'] = self._serialize.query("metricnames", metricnames, 'str') - if aggregation is not None: - query_parameters['aggregation'] = self._serialize.query("aggregation", aggregation, 'str') - if top is not None: - query_parameters['top'] = self._serialize.query("top", top, 'int') - if orderby is not None: - query_parameters['orderby'] = self._serialize.query("orderby", orderby, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if result_type is not None: - query_parameters['resultType'] = self._serialize.query("result_type", result_type, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if metricnamespace is not None: - query_parameters['metricnamespace'] = self._serialize.query("metricnamespace", metricnamespace, '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_list_request( + resource_uri=resource_uri, + timespan=timespan, + interval=interval, + metricnames=metricnames, + aggregation=aggregation, + top=top, + orderby=orderby, + filter=filter, + result_type=result_type, + metricnamespace=metricnamespace, + template_url=self.list.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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('Response', pipeline_response) @@ -162,4 +212,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/metrics'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_configuration.py index 779b6a13b7c4a..aadc1d4296091 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_metadata.json index 72ef172f93062..29e4460a8b759 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "action_groups": "ActionGroupsOperations", diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_monitor_management_client.py index bdf4e77f7ef00..4e5fa60ad40f9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_monitor_management_client.py @@ -6,24 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ActionGroupsOperations, MetricAlertsOperations, MetricAlertsStatusOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations -from .operations import MetricAlertsOperations -from .operations import MetricAlertsStatusOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. @@ -33,56 +31,62 @@ class MonitorManagementClient(object): :ivar metric_alerts: MetricAlertsOperations operations :vartype metric_alerts: $(python-base-namespace).v2018_03_01.operations.MetricAlertsOperations :ivar metric_alerts_status: MetricAlertsStatusOperations operations - :vartype metric_alerts_status: $(python-base-namespace).v2018_03_01.operations.MetricAlertsStatusOperations + :vartype metric_alerts_status: + $(python-base-namespace).v2018_03_01.operations.MetricAlertsStatusOperations :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_alerts = MetricAlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_alerts_status = MetricAlertsStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.metric_alerts = MetricAlertsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.metric_alerts_status = MetricAlertsStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_configuration.py index aa202fc38ef3a..f68f113b2fde5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_monitor_management_client.py index c4d3e8ba5c329..42cd3189dd06c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_monitor_management_client.py @@ -6,79 +6,85 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ActionGroupsOperations, MetricAlertsOperations, MetricAlertsStatusOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations -from .operations import MetricAlertsOperations -from .operations import MetricAlertsStatusOperations -from .. import models - - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: $(python-base-namespace).v2018_03_01.aio.operations.ActionGroupsOperations + :vartype action_groups: + $(python-base-namespace).v2018_03_01.aio.operations.ActionGroupsOperations :ivar metric_alerts: MetricAlertsOperations operations - :vartype metric_alerts: $(python-base-namespace).v2018_03_01.aio.operations.MetricAlertsOperations + :vartype metric_alerts: + $(python-base-namespace).v2018_03_01.aio.operations.MetricAlertsOperations :ivar metric_alerts_status: MetricAlertsStatusOperations operations - :vartype metric_alerts_status: $(python-base-namespace).v2018_03_01.aio.operations.MetricAlertsStatusOperations + :vartype metric_alerts_status: + $(python-base-namespace).v2018_03_01.aio.operations.MetricAlertsStatusOperations :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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_alerts = MetricAlertsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_alerts_status = MetricAlertsStatusOperations(self._client, self._config, self._serialize, self._deserialize) - self.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.metric_alerts = MetricAlertsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.metric_alerts_status = MetricAlertsStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_action_groups_operations.py index 9f3045ddf232d..87b98768d8b0f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_action_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._action_groups_operations import build_create_or_update_request, build_delete_request, build_enable_receiver_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_update_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_async async def create_or_update( self, resource_group_name: str, @@ -50,7 +56,7 @@ async def create_or_update( ) -> "_models.ActionGroupResource": """Create a new action group or update an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -66,38 +72,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group, 'ActionGroupResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group, 'ActionGroupResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -110,8 +106,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -120,7 +119,7 @@ async def get( ) -> "_models.ActionGroupResource": """Get an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -134,33 +133,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -169,8 +158,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -179,7 +171,7 @@ async def delete( ) -> None: """Delete an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -193,33 +185,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -227,6 +209,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -236,7 +220,7 @@ async def update( ) -> "_models.ActionGroupResource": """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -252,38 +236,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - 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'), - 'actionGroupName': self._serialize.url("action_group_name", action_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -292,8 +266,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def list_by_subscription_id( self, **kwargs: Any @@ -302,7 +279,8 @@ def list_by_subscription_id( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ActionGroupList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -310,34 +288,29 @@ def list_by_subscription_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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_subscription_id.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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription_id.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_list_by_subscription_id_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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -350,17 +323,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -368,11 +343,12 @@ def list_by_resource_group( ) -> AsyncIterable["_models.ActionGroupList"]: """Get a list of all action groups in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 ActionGroupList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -380,35 +356,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -421,17 +393,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.insights/actionGroups'} # type: ignore + @distributed_trace_async async def enable_receiver( self, resource_group_name: str, @@ -442,7 +416,7 @@ async def enable_receiver( """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -458,41 +432,32 @@ async def enable_receiver( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.enable_receiver.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(enable_request, 'EnableRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_enable_receiver_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.enable_receiver.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(enable_request, 'EnableRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(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, 409]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) enable_receiver.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_operations.py index 96cb5971700c7..6b4ff7fc1c348 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_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 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._metric_alerts_operations import build_create_or_update_request, build_delete_request, build_get_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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -48,8 +54,10 @@ def list_by_subscription( """Retrieve alert rule definitions 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 MetricAlertResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResourceCollection] + :return: An iterator like instance of either MetricAlertResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricAlertResourceCollection"] @@ -57,34 +65,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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_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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('MetricAlertResourceCollection', pipeline_response) + deserialized = self._deserialize("MetricAlertResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,17 +100,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Insights/metricAlerts'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -115,11 +120,13 @@ def list_by_resource_group( ) -> AsyncIterable["_models.MetricAlertResourceCollection"]: """Retrieve alert rule definitions in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 MetricAlertResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResourceCollection] + :return: An iterator like instance of either MetricAlertResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricAlertResourceCollection"] @@ -127,35 +134,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('MetricAlertResourceCollection', pipeline_response) + deserialized = self._deserialize("MetricAlertResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -168,17 +171,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Insights/metricAlerts'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -187,7 +192,7 @@ async def get( ) -> "_models.MetricAlertResource": """Retrieve an alert rule definition. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -201,33 +206,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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'), - 'ruleName': self._serialize.url("rule_name", 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 = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=rule_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MetricAlertResource', pipeline_response) @@ -236,8 +231,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -247,7 +245,7 @@ async def create_or_update( ) -> "_models.MetricAlertResource": """Create or update an metric alert definition. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -263,38 +261,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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'), - 'ruleName': self._serialize.url("rule_name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'MetricAlertResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'MetricAlertResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MetricAlertResource', pipeline_response) @@ -303,8 +291,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -314,7 +305,7 @@ async def update( ) -> "_models.MetricAlertResource": """Update an metric alert definition. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -330,38 +321,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - 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'), - 'ruleName': self._serialize.url("rule_name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'MetricAlertResourcePatch') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'MetricAlertResourcePatch') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MetricAlertResource', pipeline_response) @@ -370,8 +351,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -380,7 +364,7 @@ async def delete( ) -> None: """Delete an alert rule definition. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -394,36 +378,27 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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'), - 'ruleName': self._serialize.url("rule_name", 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 = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=rule_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_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.Insights/metricAlerts/{ruleName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_status_operations.py index 0c216dfd66531..8be671ebb3852 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_status_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/aio/operations/_metric_alerts_status_operations.py @@ -5,16 +5,20 @@ # 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, Optional, TypeVar import warnings 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_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._metric_alerts_status_operations import build_list_by_name_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, @@ -48,7 +53,7 @@ async def list( ) -> "_models.MetricAlertStatusCollection": """Retrieve an alert rule status. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -62,33 +67,23 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # 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), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", 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 = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=rule_name, + 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) 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MetricAlertStatusCollection', pipeline_response) @@ -97,8 +92,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status'} # type: ignore + + @distributed_trace_async async def list_by_name( self, resource_group_name: str, @@ -108,7 +106,7 @@ async def list_by_name( ) -> "_models.MetricAlertStatusCollection": """Retrieve an alert rule status. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -124,34 +122,24 @@ async def list_by_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.list_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'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - 'statusName': self._serialize.url("status_name", status_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 = build_list_by_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=rule_name, + status_name=status_name, + template_url=self.list_by_name.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MetricAlertStatusCollection', pipeline_response) @@ -160,4 +148,6 @@ async def list_by_name( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models.py index bd481af12a402..718d640057366 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models.py @@ -13,10 +13,10 @@ class ActionGroupList(msrest.serialization.Model): """A list of action groups. - :param value: The list of action groups. - :type value: list[~$(python-base-namespace).v2018_03_01.models.ActionGroupResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar value: The list of action groups. + :vartype value: list[~$(python-base-namespace).v2018_03_01.models.ActionGroupResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -28,6 +28,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of action groups. + :paramtype value: list[~$(python-base-namespace).v2018_03_01.models.ActionGroupResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(ActionGroupList, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -36,11 +42,11 @@ def __init__( class ActionGroupPatchBody(msrest.serialization.Model): """An action group object for the body of patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. - :type enabled: bool + :vartype enabled: bool """ _attribute_map = { @@ -52,6 +58,13 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ super(ActionGroupPatchBody, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.enabled = kwargs.get('enabled', True) @@ -70,10 +83,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -95,6 +108,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -116,38 +135,39 @@ class ActionGroupResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param group_short_name: The short name of the action group. This will be used in SMS messages. - :type group_short_name: str - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar group_short_name: The short name of the action group. This will be used in SMS messages. + :vartype group_short_name: str + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. - :type enabled: bool - :param email_receivers: The list of email receivers that are part of this action group. - :type email_receivers: list[~$(python-base-namespace).v2018_03_01.models.EmailReceiver] - :param sms_receivers: The list of SMS receivers that are part of this action group. - :type sms_receivers: list[~$(python-base-namespace).v2018_03_01.models.SmsReceiver] - :param webhook_receivers: The list of webhook receivers that are part of this action group. - :type webhook_receivers: list[~$(python-base-namespace).v2018_03_01.models.WebhookReceiver] - :param itsm_receivers: The list of ITSM receivers that are part of this action group. - :type itsm_receivers: list[~$(python-base-namespace).v2018_03_01.models.ItsmReceiver] - :param azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :type azure_app_push_receivers: + :vartype enabled: bool + :ivar email_receivers: The list of email receivers that are part of this action group. + :vartype email_receivers: list[~$(python-base-namespace).v2018_03_01.models.EmailReceiver] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~$(python-base-namespace).v2018_03_01.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~$(python-base-namespace).v2018_03_01.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~$(python-base-namespace).v2018_03_01.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: list[~$(python-base-namespace).v2018_03_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of this action group. - :type automation_runbook_receivers: + :vartype automation_runbook_receivers: list[~$(python-base-namespace).v2018_03_01.models.AutomationRunbookReceiver] - :param voice_receivers: The list of voice receivers that are part of this action group. - :type voice_receivers: list[~$(python-base-namespace).v2018_03_01.models.VoiceReceiver] - :param logic_app_receivers: The list of logic app receivers that are part of this action group. - :type logic_app_receivers: list[~$(python-base-namespace).v2018_03_01.models.LogicAppReceiver] - :param azure_function_receivers: The list of azure function receivers that are part of this + :ivar voice_receivers: The list of voice receivers that are part of this action group. + :vartype voice_receivers: list[~$(python-base-namespace).v2018_03_01.models.VoiceReceiver] + :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. + :vartype logic_app_receivers: + list[~$(python-base-namespace).v2018_03_01.models.LogicAppReceiver] + :ivar azure_function_receivers: The list of azure function receivers that are part of this action group. - :type azure_function_receivers: + :vartype azure_function_receivers: list[~$(python-base-namespace).v2018_03_01.models.AzureFunctionReceiver] """ @@ -182,6 +202,45 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword group_short_name: The short name of the action group. This will be used in SMS + messages. + :paramtype group_short_name: str + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its receivers will receive communications. + :paramtype enabled: bool + :keyword email_receivers: The list of email receivers that are part of this action group. + :paramtype email_receivers: list[~$(python-base-namespace).v2018_03_01.models.EmailReceiver] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~$(python-base-namespace).v2018_03_01.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: + list[~$(python-base-namespace).v2018_03_01.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~$(python-base-namespace).v2018_03_01.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: + list[~$(python-base-namespace).v2018_03_01.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~$(python-base-namespace).v2018_03_01.models.AutomationRunbookReceiver] + :keyword voice_receivers: The list of voice receivers that are part of this action group. + :paramtype voice_receivers: list[~$(python-base-namespace).v2018_03_01.models.VoiceReceiver] + :keyword logic_app_receivers: The list of logic app receivers that are part of this action + group. + :paramtype logic_app_receivers: + list[~$(python-base-namespace).v2018_03_01.models.LogicAppReceiver] + :keyword azure_function_receivers: The list of azure function receivers that are part of this + action group. + :paramtype azure_function_receivers: + list[~$(python-base-namespace).v2018_03_01.models.AzureFunctionReceiver] + """ super(ActionGroupResource, self).__init__(**kwargs) self.group_short_name = kwargs.get('group_short_name', None) self.enabled = kwargs.get('enabled', True) @@ -201,19 +260,19 @@ class AutomationRunbookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. - :type automation_account_id: str - :param runbook_name: Required. The name for this runbook. - :type runbook_name: str - :param webhook_resource_id: Required. The resource id for webhook linked to this runbook. - :type webhook_resource_id: str - :param is_global_runbook: Required. Indicates whether this instance is global runbook. - :type is_global_runbook: bool - :param name: Indicates name of the webhook. - :type name: str - :param service_uri: The URI where webhooks should be sent. - :type service_uri: str + :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook + and authenticate to Azure resource. + :vartype automation_account_id: str + :ivar runbook_name: Required. The name for this runbook. + :vartype runbook_name: str + :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :vartype webhook_resource_id: str + :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :vartype is_global_runbook: bool + :ivar name: Indicates name of the webhook. + :vartype name: str + :ivar service_uri: The URI where webhooks should be sent. + :vartype service_uri: str """ _validation = { @@ -236,6 +295,21 @@ def __init__( self, **kwargs ): + """ + :keyword automation_account_id: Required. The Azure automation account Id which holds this + runbook and authenticate to Azure resource. + :paramtype automation_account_id: str + :keyword runbook_name: Required. The name for this runbook. + :paramtype runbook_name: str + :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :paramtype webhook_resource_id: str + :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :paramtype is_global_runbook: bool + :keyword name: Indicates name of the webhook. + :paramtype name: str + :keyword service_uri: The URI where webhooks should be sent. + :paramtype service_uri: str + """ super(AutomationRunbookReceiver, self).__init__(**kwargs) self.automation_account_id = kwargs['automation_account_id'] self.runbook_name = kwargs['runbook_name'] @@ -250,11 +324,11 @@ class AzureAppPushReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Azure mobile app push receiver. Names must be unique + :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. - :type name: str - :param email_address: Required. The email address registered for the Azure mobile app. - :type email_address: str + :vartype name: str + :ivar email_address: Required. The email address registered for the Azure mobile app. + :vartype email_address: str """ _validation = { @@ -271,6 +345,13 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique + across all receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address registered for the Azure mobile app. + :paramtype email_address: str + """ super(AzureAppPushReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.email_address = kwargs['email_address'] @@ -281,15 +362,15 @@ class AzureFunctionReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the azure function receiver. Names must be unique across all + :ivar name: Required. The name of the azure function receiver. Names must be unique across all receivers within an action group. - :type name: str - :param function_app_resource_id: Required. The azure resource id of the function app. - :type function_app_resource_id: str - :param function_name: Required. The function name in the function app. - :type function_name: str - :param http_trigger_url: Required. The http trigger url where http request sent to. - :type http_trigger_url: str + :vartype name: str + :ivar function_app_resource_id: Required. The azure resource id of the function app. + :vartype function_app_resource_id: str + :ivar function_name: Required. The function name in the function app. + :vartype function_name: str + :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :vartype http_trigger_url: str """ _validation = { @@ -310,6 +391,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the azure function receiver. Names must be unique across + all receivers within an action group. + :paramtype name: str + :keyword function_app_resource_id: Required. The azure resource id of the function app. + :paramtype function_app_resource_id: str + :keyword function_name: Required. The function name in the function app. + :paramtype function_name: str + :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :paramtype http_trigger_url: str + """ super(AzureFunctionReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.function_app_resource_id = kwargs['function_app_resource_id'] @@ -325,26 +417,27 @@ class MultiMetricCriteria(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param criterion_type: Required. Specifies the type of threshold criteria.Constant filled by - server. Possible values include: "StaticThresholdCriterion", "DynamicThresholdCriterion". - :type criterion_type: str or ~$(python-base-namespace).v2018_03_01.models.CriterionType - :param name: Required. Name of the criteria. - :type name: str - :param metric_name: Required. Name of the metric. - :type metric_name: str - :param metric_namespace: Namespace of the metric. - :type metric_namespace: str - :param time_aggregation: Required. the criteria time aggregation types. Possible values - include: "Average", "Count", "Minimum", "Maximum", "Total". - :type time_aggregation: str or ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum - :param dimensions: List of dimension conditions. - :type dimensions: list[~$(python-base-namespace).v2018_03_01.models.MetricDimension] - :param skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet + :vartype additional_properties: dict[str, any] + :ivar criterion_type: Required. Specifies the type of threshold criteria.Constant filled by + server. Possible values include: "StaticThresholdCriterion", "DynamicThresholdCriterion". + :vartype criterion_type: str or ~$(python-base-namespace).v2018_03_01.models.CriterionType + :ivar name: Required. Name of the criteria. + :vartype name: str + :ivar metric_name: Required. Name of the metric. + :vartype metric_name: str + :ivar metric_namespace: Namespace of the metric. + :vartype metric_namespace: str + :ivar time_aggregation: Required. the criteria time aggregation types. Possible values include: + "Average", "Count", "Minimum", "Maximum", "Total". + :vartype time_aggregation: str or + ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum + :ivar dimensions: List of dimension conditions. + :vartype dimensions: list[~$(python-base-namespace).v2018_03_01.models.MetricDimension] + :ivar skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. - :type skip_metric_validation: bool + :vartype skip_metric_validation: bool """ _validation = { @@ -373,6 +466,26 @@ def __init__( self, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword name: Required. Name of the criteria. + :paramtype name: str + :keyword metric_name: Required. Name of the metric. + :paramtype metric_name: str + :keyword metric_namespace: Namespace of the metric. + :paramtype metric_namespace: str + :keyword time_aggregation: Required. the criteria time aggregation types. Possible values + include: "Average", "Count", "Minimum", "Maximum", "Total". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum + :keyword dimensions: List of dimension conditions. + :paramtype dimensions: list[~$(python-base-namespace).v2018_03_01.models.MetricDimension] + :keyword skip_metric_validation: Allows creating an alert rule on a custom metric that isn't + yet emitted, by causing the metric validation to be skipped. + :paramtype skip_metric_validation: bool + """ super(MultiMetricCriteria, self).__init__(**kwargs) self.additional_properties = kwargs.get('additional_properties', None) self.criterion_type = 'MultiMetricCriteria' # type: str @@ -389,41 +502,42 @@ class DynamicMetricCriteria(MultiMetricCriteria): All required parameters must be populated in order to send to Azure. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param criterion_type: Required. Specifies the type of threshold criteria.Constant filled by - server. Possible values include: "StaticThresholdCriterion", "DynamicThresholdCriterion". - :type criterion_type: str or ~$(python-base-namespace).v2018_03_01.models.CriterionType - :param name: Required. Name of the criteria. - :type name: str - :param metric_name: Required. Name of the metric. - :type metric_name: str - :param metric_namespace: Namespace of the metric. - :type metric_namespace: str - :param time_aggregation: Required. the criteria time aggregation types. Possible values - include: "Average", "Count", "Minimum", "Maximum", "Total". - :type time_aggregation: str or ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum - :param dimensions: List of dimension conditions. - :type dimensions: list[~$(python-base-namespace).v2018_03_01.models.MetricDimension] - :param skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet + :vartype additional_properties: dict[str, any] + :ivar criterion_type: Required. Specifies the type of threshold criteria.Constant filled by + server. Possible values include: "StaticThresholdCriterion", "DynamicThresholdCriterion". + :vartype criterion_type: str or ~$(python-base-namespace).v2018_03_01.models.CriterionType + :ivar name: Required. Name of the criteria. + :vartype name: str + :ivar metric_name: Required. Name of the metric. + :vartype metric_name: str + :ivar metric_namespace: Namespace of the metric. + :vartype metric_namespace: str + :ivar time_aggregation: Required. the criteria time aggregation types. Possible values include: + "Average", "Count", "Minimum", "Maximum", "Total". + :vartype time_aggregation: str or + ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum + :ivar dimensions: List of dimension conditions. + :vartype dimensions: list[~$(python-base-namespace).v2018_03_01.models.MetricDimension] + :ivar skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. - :type skip_metric_validation: bool - :param operator: Required. The operator used to compare the metric value against the threshold. + :vartype skip_metric_validation: bool + :ivar operator: Required. The operator used to compare the metric value against the threshold. Possible values include: "GreaterThan", "LessThan", "GreaterOrLessThan". - :type operator: str or ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdOperator - :param alert_sensitivity: Required. The extent of deviation required to trigger an alert. This + :vartype operator: str or ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdOperator + :ivar alert_sensitivity: Required. The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. Possible values include: "Low", "Medium", "High". - :type alert_sensitivity: str or + :vartype alert_sensitivity: str or ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdSensitivity - :param failing_periods: Required. The minimum number of violations required within the selected + :ivar failing_periods: Required. The minimum number of violations required within the selected lookback time window required to raise an alert. - :type failing_periods: + :vartype failing_periods: ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdFailingPeriods - :param ignore_data_before: Use this option to set the date from which to start learning the + :ivar ignore_data_before: Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format). - :type ignore_data_before: ~datetime.datetime + :vartype ignore_data_before: ~datetime.datetime """ _validation = { @@ -455,6 +569,42 @@ def __init__( self, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword name: Required. Name of the criteria. + :paramtype name: str + :keyword metric_name: Required. Name of the metric. + :paramtype metric_name: str + :keyword metric_namespace: Namespace of the metric. + :paramtype metric_namespace: str + :keyword time_aggregation: Required. the criteria time aggregation types. Possible values + include: "Average", "Count", "Minimum", "Maximum", "Total". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum + :keyword dimensions: List of dimension conditions. + :paramtype dimensions: list[~$(python-base-namespace).v2018_03_01.models.MetricDimension] + :keyword skip_metric_validation: Allows creating an alert rule on a custom metric that isn't + yet emitted, by causing the metric validation to be skipped. + :paramtype skip_metric_validation: bool + :keyword operator: Required. The operator used to compare the metric value against the + threshold. Possible values include: "GreaterThan", "LessThan", "GreaterOrLessThan". + :paramtype operator: str or + ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdOperator + :keyword alert_sensitivity: Required. The extent of deviation required to trigger an alert. + This will affect how tight the threshold is to the metric series pattern. Possible values + include: "Low", "Medium", "High". + :paramtype alert_sensitivity: str or + ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdSensitivity + :keyword failing_periods: Required. The minimum number of violations required within the + selected lookback time window required to raise an alert. + :paramtype failing_periods: + ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdFailingPeriods + :keyword ignore_data_before: Use this option to set the date from which to start learning the + metric historical data and calculate the dynamic thresholds (in ISO8601 format). + :paramtype ignore_data_before: ~datetime.datetime + """ super(DynamicMetricCriteria, self).__init__(**kwargs) self.criterion_type = 'DynamicThresholdCriterion' # type: str self.operator = kwargs['operator'] @@ -468,13 +618,13 @@ class DynamicThresholdFailingPeriods(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param number_of_evaluation_periods: Required. The number of aggregated lookback points. The + :ivar number_of_evaluation_periods: Required. The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. - :type number_of_evaluation_periods: float - :param min_failing_periods_to_alert: Required. The number of violations to trigger an alert. + :vartype number_of_evaluation_periods: float + :ivar min_failing_periods_to_alert: Required. The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. - :type min_failing_periods_to_alert: float + :vartype min_failing_periods_to_alert: float """ _validation = { @@ -491,6 +641,15 @@ def __init__( self, **kwargs ): + """ + :keyword number_of_evaluation_periods: Required. The number of aggregated lookback points. The + lookback time window is calculated based on the aggregation granularity (windowSize) and the + selected number of aggregated points. + :paramtype number_of_evaluation_periods: float + :keyword min_failing_periods_to_alert: Required. The number of violations to trigger an alert. + Should be smaller or equal to numberOfEvaluationPeriods. + :paramtype min_failing_periods_to_alert: float + """ super(DynamicThresholdFailingPeriods, self).__init__(**kwargs) self.number_of_evaluation_periods = kwargs['number_of_evaluation_periods'] self.min_failing_periods_to_alert = kwargs['min_failing_periods_to_alert'] @@ -503,11 +662,11 @@ class EmailReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param email_address: Required. The email address of this receiver. - :type email_address: str + :ivar name: Required. The name of the email receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar email_address: Required. The email address of this receiver. + :vartype email_address: str :ivar status: The receiver status of the e-mail. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2018_03_01.models.ReceiverStatus @@ -529,6 +688,13 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the email receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address of this receiver. + :paramtype email_address: str + """ super(EmailReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.email_address = kwargs['email_address'] @@ -540,8 +706,8 @@ class EnableRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param receiver_name: Required. The name of the receiver to resubscribe. - :type receiver_name: str + :ivar receiver_name: Required. The name of the receiver to resubscribe. + :vartype receiver_name: str """ _validation = { @@ -556,6 +722,10 @@ def __init__( self, **kwargs ): + """ + :keyword receiver_name: Required. The name of the receiver to resubscribe. + :paramtype receiver_name: str + """ super(EnableRequest, self).__init__(**kwargs) self.receiver_name = kwargs['receiver_name'] @@ -563,10 +733,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -578,6 +748,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -588,20 +764,20 @@ class ItsmReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Itsm receiver. Names must be unique across all receivers + :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers within an action group. - :type name: str - :param workspace_id: Required. OMS LA instance identifier. - :type workspace_id: str - :param connection_id: Required. Unique identification of ITSM connection among multiple defined + :vartype name: str + :ivar workspace_id: Required. OMS LA instance identifier. + :vartype workspace_id: str + :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined in above workspace. - :type connection_id: str - :param ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + :vartype connection_id: str + :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as well. - :type ticket_configuration: str - :param region: Required. Region in which workspace resides. Supported + :vartype ticket_configuration: str + :ivar region: Required. Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - :type region: str + :vartype region: str """ _validation = { @@ -624,6 +800,22 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the Itsm receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword workspace_id: Required. OMS LA instance identifier. + :paramtype workspace_id: str + :keyword connection_id: Required. Unique identification of ITSM connection among multiple + defined in above workspace. + :paramtype connection_id: str + :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. + :paramtype ticket_configuration: str + :keyword region: Required. Region in which workspace resides. Supported + values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + :paramtype region: str + """ super(ItsmReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.workspace_id = kwargs['workspace_id'] @@ -637,13 +829,13 @@ class LogicAppReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the logic app receiver. Names must be unique across all + :ivar name: Required. The name of the logic app receiver. Names must be unique across all receivers within an action group. - :type name: str - :param resource_id: Required. The azure resource id of the logic app receiver. - :type resource_id: str - :param callback_url: Required. The callback url where http request sent to. - :type callback_url: str + :vartype name: str + :ivar resource_id: Required. The azure resource id of the logic app receiver. + :vartype resource_id: str + :ivar callback_url: Required. The callback url where http request sent to. + :vartype callback_url: str """ _validation = { @@ -662,6 +854,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the logic app receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword resource_id: Required. The azure resource id of the logic app receiver. + :paramtype resource_id: str + :keyword callback_url: Required. The callback url where http request sent to. + :paramtype callback_url: str + """ super(LogicAppReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.resource_id = kwargs['resource_id'] @@ -671,11 +872,11 @@ def __init__( class MetricAlertAction(msrest.serialization.Model): """An alert action. - :param action_group_id: the id of the action group to use. - :type action_group_id: str - :param web_hook_properties: This field allows specifying custom properties, which would be + :ivar action_group_id: the id of the action group to use. + :vartype action_group_id: str + :ivar web_hook_properties: This field allows specifying custom properties, which would be appended to the alert payload sent as input to the webhook. - :type web_hook_properties: dict[str, str] + :vartype web_hook_properties: dict[str, str] """ _attribute_map = { @@ -687,6 +888,13 @@ def __init__( self, **kwargs ): + """ + :keyword action_group_id: the id of the action group to use. + :paramtype action_group_id: str + :keyword web_hook_properties: This field allows specifying custom properties, which would be + appended to the alert payload sent as input to the webhook. + :paramtype web_hook_properties: dict[str, str] + """ super(MetricAlertAction, self).__init__(**kwargs) self.action_group_id = kwargs.get('action_group_id', None) self.web_hook_properties = kwargs.get('web_hook_properties', None) @@ -700,15 +908,14 @@ class MetricAlertCriteria(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param odata_type: Required. specifies the type of the alert criteria.Constant filled by - server. Possible values include: - "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + :vartype additional_properties: dict[str, any] + :ivar odata_type: Required. specifies the type of the alert criteria.Constant filled by server. + Possible values include: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". - :type odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype + :vartype odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype """ _validation = { @@ -728,6 +935,11 @@ def __init__( self, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + """ super(MetricAlertCriteria, self).__init__(**kwargs) self.additional_properties = kwargs.get('additional_properties', None) self.odata_type = 'MetricAlertCriteria' # type: str @@ -738,17 +950,16 @@ class MetricAlertMultipleResourceMultipleMetricCriteria(MetricAlertCriteria): All required parameters must be populated in order to send to Azure. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param odata_type: Required. specifies the type of the alert criteria.Constant filled by - server. Possible values include: - "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + :vartype additional_properties: dict[str, any] + :ivar odata_type: Required. specifies the type of the alert criteria.Constant filled by server. + Possible values include: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". - :type odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype - :param all_of: the list of multiple metric criteria for this 'all of' operation. - :type all_of: list[~$(python-base-namespace).v2018_03_01.models.MultiMetricCriteria] + :vartype odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype + :ivar all_of: the list of multiple metric criteria for this 'all of' operation. + :vartype all_of: list[~$(python-base-namespace).v2018_03_01.models.MultiMetricCriteria] """ _validation = { @@ -765,6 +976,13 @@ def __init__( self, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword all_of: the list of multiple metric criteria for this 'all of' operation. + :paramtype all_of: list[~$(python-base-namespace).v2018_03_01.models.MultiMetricCriteria] + """ super(MetricAlertMultipleResourceMultipleMetricCriteria, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria' # type: str self.all_of = kwargs.get('all_of', None) @@ -783,41 +1001,41 @@ class MetricAlertResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param description: the description of the metric alert that will be included in the alert + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar description: the description of the metric alert that will be included in the alert email. - :type description: str - :param severity: Required. Alert severity {0, 1, 2, 3, 4}. - :type severity: int - :param enabled: Required. the flag that indicates whether the metric alert is enabled. - :type enabled: bool - :param scopes: Required. the list of resource id's that this metric alert is scoped to. - :type scopes: list[str] - :param evaluation_frequency: Required. how often the metric alert is evaluated represented in + :vartype description: str + :ivar severity: Required. Alert severity {0, 1, 2, 3, 4}. + :vartype severity: int + :ivar enabled: Required. the flag that indicates whether the metric alert is enabled. + :vartype enabled: bool + :ivar scopes: Required. the list of resource id's that this metric alert is scoped to. + :vartype scopes: list[str] + :ivar evaluation_frequency: Required. how often the metric alert is evaluated represented in ISO 8601 duration format. - :type evaluation_frequency: ~datetime.timedelta - :param window_size: Required. the period of time (in ISO 8601 duration format) that is used to + :vartype evaluation_frequency: ~datetime.timedelta + :ivar window_size: Required. the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. - :type window_size: ~datetime.timedelta - :param target_resource_type: the resource type of the target resource(s) on which the alert is + :vartype window_size: ~datetime.timedelta + :ivar target_resource_type: the resource type of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource. - :type target_resource_type: str - :param target_resource_region: the region of the target resource(s) on which the alert is + :vartype target_resource_type: str + :ivar target_resource_region: the region of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource. - :type target_resource_region: str - :param criteria: Required. defines the specific alert criteria information. - :type criteria: ~$(python-base-namespace).v2018_03_01.models.MetricAlertCriteria - :param auto_mitigate: the flag that indicates whether the alert should be auto resolved or not. + :vartype target_resource_region: str + :ivar criteria: Required. defines the specific alert criteria information. + :vartype criteria: ~$(python-base-namespace).v2018_03_01.models.MetricAlertCriteria + :ivar auto_mitigate: the flag that indicates whether the alert should be auto resolved or not. The default is true. - :type auto_mitigate: bool - :param actions: the array of actions that are performed when the alert rule becomes active, and + :vartype auto_mitigate: bool + :ivar actions: the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. - :type actions: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertAction] + :vartype actions: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertAction] :ivar last_updated_time: Last time the rule was updated in ISO8601 format. :vartype last_updated_time: ~datetime.datetime :ivar is_migrated: the value indicating whether this alert rule is migrated. @@ -864,6 +1082,43 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword description: the description of the metric alert that will be included in the alert + email. + :paramtype description: str + :keyword severity: Required. Alert severity {0, 1, 2, 3, 4}. + :paramtype severity: int + :keyword enabled: Required. the flag that indicates whether the metric alert is enabled. + :paramtype enabled: bool + :keyword scopes: Required. the list of resource id's that this metric alert is scoped to. + :paramtype scopes: list[str] + :keyword evaluation_frequency: Required. how often the metric alert is evaluated represented in + ISO 8601 duration format. + :paramtype evaluation_frequency: ~datetime.timedelta + :keyword window_size: Required. the period of time (in ISO 8601 duration format) that is used + to monitor alert activity based on the threshold. + :paramtype window_size: ~datetime.timedelta + :keyword target_resource_type: the resource type of the target resource(s) on which the alert + is created/updated. Mandatory if the scope contains a subscription, resource group, or more + than one resource. + :paramtype target_resource_type: str + :keyword target_resource_region: the region of the target resource(s) on which the alert is + created/updated. Mandatory if the scope contains a subscription, resource group, or more than + one resource. + :paramtype target_resource_region: str + :keyword criteria: Required. defines the specific alert criteria information. + :paramtype criteria: ~$(python-base-namespace).v2018_03_01.models.MetricAlertCriteria + :keyword auto_mitigate: the flag that indicates whether the alert should be auto resolved or + not. The default is true. + :paramtype auto_mitigate: bool + :keyword actions: the array of actions that are performed when the alert rule becomes active, + and when an alert condition is resolved. + :paramtype actions: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertAction] + """ super(MetricAlertResource, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.severity = kwargs['severity'] @@ -883,8 +1138,8 @@ def __init__( class MetricAlertResourceCollection(msrest.serialization.Model): """Represents a collection of alert rule resources. - :param value: the values for the alert rule resources. - :type value: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertResource] + :ivar value: the values for the alert rule resources. + :vartype value: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertResource] """ _attribute_map = { @@ -895,6 +1150,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: the values for the alert rule resources. + :paramtype value: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertResource] + """ super(MetricAlertResourceCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -904,37 +1163,37 @@ class MetricAlertResourcePatch(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param description: the description of the metric alert that will be included in the alert + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar description: the description of the metric alert that will be included in the alert email. - :type description: str - :param severity: Alert severity {0, 1, 2, 3, 4}. - :type severity: int - :param enabled: the flag that indicates whether the metric alert is enabled. - :type enabled: bool - :param scopes: the list of resource id's that this metric alert is scoped to. - :type scopes: list[str] - :param evaluation_frequency: how often the metric alert is evaluated represented in ISO 8601 + :vartype description: str + :ivar severity: Alert severity {0, 1, 2, 3, 4}. + :vartype severity: int + :ivar enabled: the flag that indicates whether the metric alert is enabled. + :vartype enabled: bool + :ivar scopes: the list of resource id's that this metric alert is scoped to. + :vartype scopes: list[str] + :ivar evaluation_frequency: how often the metric alert is evaluated represented in ISO 8601 duration format. - :type evaluation_frequency: ~datetime.timedelta - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype evaluation_frequency: ~datetime.timedelta + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. - :type window_size: ~datetime.timedelta - :param target_resource_type: the resource type of the target resource(s) on which the alert is + :vartype window_size: ~datetime.timedelta + :ivar target_resource_type: the resource type of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. - :type target_resource_type: str - :param target_resource_region: the region of the target resource(s) on which the alert is + :vartype target_resource_type: str + :ivar target_resource_region: the region of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. - :type target_resource_region: str - :param criteria: defines the specific alert criteria information. - :type criteria: ~$(python-base-namespace).v2018_03_01.models.MetricAlertCriteria - :param auto_mitigate: the flag that indicates whether the alert should be auto resolved or not. + :vartype target_resource_region: str + :ivar criteria: defines the specific alert criteria information. + :vartype criteria: ~$(python-base-namespace).v2018_03_01.models.MetricAlertCriteria + :ivar auto_mitigate: the flag that indicates whether the alert should be auto resolved or not. The default is true. - :type auto_mitigate: bool - :param actions: the array of actions that are performed when the alert rule becomes active, and + :vartype auto_mitigate: bool + :ivar actions: the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. - :type actions: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertAction] + :vartype actions: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertAction] :ivar last_updated_time: Last time the rule was updated in ISO8601 format. :vartype last_updated_time: ~datetime.datetime :ivar is_migrated: the value indicating whether this alert rule is migrated. @@ -967,6 +1226,39 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword description: the description of the metric alert that will be included in the alert + email. + :paramtype description: str + :keyword severity: Alert severity {0, 1, 2, 3, 4}. + :paramtype severity: int + :keyword enabled: the flag that indicates whether the metric alert is enabled. + :paramtype enabled: bool + :keyword scopes: the list of resource id's that this metric alert is scoped to. + :paramtype scopes: list[str] + :keyword evaluation_frequency: how often the metric alert is evaluated represented in ISO 8601 + duration format. + :paramtype evaluation_frequency: ~datetime.timedelta + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. + :paramtype window_size: ~datetime.timedelta + :keyword target_resource_type: the resource type of the target resource(s) on which the alert + is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + :paramtype target_resource_type: str + :keyword target_resource_region: the region of the target resource(s) on which the alert is + created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + :paramtype target_resource_region: str + :keyword criteria: defines the specific alert criteria information. + :paramtype criteria: ~$(python-base-namespace).v2018_03_01.models.MetricAlertCriteria + :keyword auto_mitigate: the flag that indicates whether the alert should be auto resolved or + not. The default is true. + :paramtype auto_mitigate: bool + :keyword actions: the array of actions that are performed when the alert rule becomes active, + and when an alert condition is resolved. + :paramtype actions: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertAction] + """ super(MetricAlertResourcePatch, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.description = kwargs.get('description', None) @@ -989,17 +1281,16 @@ class MetricAlertSingleResourceMultipleMetricCriteria(MetricAlertCriteria): All required parameters must be populated in order to send to Azure. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param odata_type: Required. specifies the type of the alert criteria.Constant filled by - server. Possible values include: - "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + :vartype additional_properties: dict[str, any] + :ivar odata_type: Required. specifies the type of the alert criteria.Constant filled by server. + Possible values include: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". - :type odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype - :param all_of: The list of metric criteria for this 'all of' operation. - :type all_of: list[~$(python-base-namespace).v2018_03_01.models.MetricCriteria] + :vartype odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype + :ivar all_of: The list of metric criteria for this 'all of' operation. + :vartype all_of: list[~$(python-base-namespace).v2018_03_01.models.MetricCriteria] """ _validation = { @@ -1016,6 +1307,13 @@ def __init__( self, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword all_of: The list of metric criteria for this 'all of' operation. + :paramtype all_of: list[~$(python-base-namespace).v2018_03_01.models.MetricCriteria] + """ super(MetricAlertSingleResourceMultipleMetricCriteria, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria' # type: str self.all_of = kwargs.get('all_of', None) @@ -1024,14 +1322,14 @@ def __init__( class MetricAlertStatus(msrest.serialization.Model): """An alert status. - :param name: The status name. - :type name: str - :param id: The alert rule arm id. - :type id: str - :param type: The extended resource type name. - :type type: str - :param properties: The alert status properties of the metric alert status. - :type properties: ~$(python-base-namespace).v2018_03_01.models.MetricAlertStatusProperties + :ivar name: The status name. + :vartype name: str + :ivar id: The alert rule arm id. + :vartype id: str + :ivar type: The extended resource type name. + :vartype type: str + :ivar properties: The alert status properties of the metric alert status. + :vartype properties: ~$(python-base-namespace).v2018_03_01.models.MetricAlertStatusProperties """ _attribute_map = { @@ -1045,6 +1343,16 @@ def __init__( self, **kwargs ): + """ + :keyword name: The status name. + :paramtype name: str + :keyword id: The alert rule arm id. + :paramtype id: str + :keyword type: The extended resource type name. + :paramtype type: str + :keyword properties: The alert status properties of the metric alert status. + :paramtype properties: ~$(python-base-namespace).v2018_03_01.models.MetricAlertStatusProperties + """ super(MetricAlertStatus, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.id = kwargs.get('id', None) @@ -1055,8 +1363,8 @@ def __init__( class MetricAlertStatusCollection(msrest.serialization.Model): """Represents a collection of alert rule resources. - :param value: the values for the alert rule resources. - :type value: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertStatus] + :ivar value: the values for the alert rule resources. + :vartype value: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertStatus] """ _attribute_map = { @@ -1067,6 +1375,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: the values for the alert rule resources. + :paramtype value: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertStatus] + """ super(MetricAlertStatusCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -1074,12 +1386,12 @@ def __init__( class MetricAlertStatusProperties(msrest.serialization.Model): """An alert status properties. - :param dimensions: An object describing the type of the dimensions. - :type dimensions: dict[str, str] - :param status: status value. - :type status: str - :param timestamp: UTC time when the status was checked. - :type timestamp: ~datetime.datetime + :ivar dimensions: An object describing the type of the dimensions. + :vartype dimensions: dict[str, str] + :ivar status: status value. + :vartype status: str + :ivar timestamp: UTC time when the status was checked. + :vartype timestamp: ~datetime.datetime """ _attribute_map = { @@ -1092,6 +1404,14 @@ def __init__( self, **kwargs ): + """ + :keyword dimensions: An object describing the type of the dimensions. + :paramtype dimensions: dict[str, str] + :keyword status: status value. + :paramtype status: str + :keyword timestamp: UTC time when the status was checked. + :paramtype timestamp: ~datetime.datetime + """ super(MetricAlertStatusProperties, self).__init__(**kwargs) self.dimensions = kwargs.get('dimensions', None) self.status = kwargs.get('status', None) @@ -1103,31 +1423,32 @@ class MetricCriteria(MultiMetricCriteria): All required parameters must be populated in order to send to Azure. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param criterion_type: Required. Specifies the type of threshold criteria.Constant filled by - server. Possible values include: "StaticThresholdCriterion", "DynamicThresholdCriterion". - :type criterion_type: str or ~$(python-base-namespace).v2018_03_01.models.CriterionType - :param name: Required. Name of the criteria. - :type name: str - :param metric_name: Required. Name of the metric. - :type metric_name: str - :param metric_namespace: Namespace of the metric. - :type metric_namespace: str - :param time_aggregation: Required. the criteria time aggregation types. Possible values - include: "Average", "Count", "Minimum", "Maximum", "Total". - :type time_aggregation: str or ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum - :param dimensions: List of dimension conditions. - :type dimensions: list[~$(python-base-namespace).v2018_03_01.models.MetricDimension] - :param skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet + :vartype additional_properties: dict[str, any] + :ivar criterion_type: Required. Specifies the type of threshold criteria.Constant filled by + server. Possible values include: "StaticThresholdCriterion", "DynamicThresholdCriterion". + :vartype criterion_type: str or ~$(python-base-namespace).v2018_03_01.models.CriterionType + :ivar name: Required. Name of the criteria. + :vartype name: str + :ivar metric_name: Required. Name of the metric. + :vartype metric_name: str + :ivar metric_namespace: Namespace of the metric. + :vartype metric_namespace: str + :ivar time_aggregation: Required. the criteria time aggregation types. Possible values include: + "Average", "Count", "Minimum", "Maximum", "Total". + :vartype time_aggregation: str or + ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum + :ivar dimensions: List of dimension conditions. + :vartype dimensions: list[~$(python-base-namespace).v2018_03_01.models.MetricDimension] + :ivar skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. - :type skip_metric_validation: bool - :param operator: Required. the criteria operator. Possible values include: "Equals", + :vartype skip_metric_validation: bool + :ivar operator: Required. the criteria operator. Possible values include: "Equals", "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or ~$(python-base-namespace).v2018_03_01.models.Operator - :param threshold: Required. the criteria threshold value that activates the alert. - :type threshold: float + :vartype operator: str or ~$(python-base-namespace).v2018_03_01.models.Operator + :ivar threshold: Required. the criteria threshold value that activates the alert. + :vartype threshold: float """ _validation = { @@ -1156,6 +1477,31 @@ def __init__( self, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword name: Required. Name of the criteria. + :paramtype name: str + :keyword metric_name: Required. Name of the metric. + :paramtype metric_name: str + :keyword metric_namespace: Namespace of the metric. + :paramtype metric_namespace: str + :keyword time_aggregation: Required. the criteria time aggregation types. Possible values + include: "Average", "Count", "Minimum", "Maximum", "Total". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum + :keyword dimensions: List of dimension conditions. + :paramtype dimensions: list[~$(python-base-namespace).v2018_03_01.models.MetricDimension] + :keyword skip_metric_validation: Allows creating an alert rule on a custom metric that isn't + yet emitted, by causing the metric validation to be skipped. + :paramtype skip_metric_validation: bool + :keyword operator: Required. the criteria operator. Possible values include: "Equals", + "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :paramtype operator: str or ~$(python-base-namespace).v2018_03_01.models.Operator + :keyword threshold: Required. the criteria threshold value that activates the alert. + :paramtype threshold: float + """ super(MetricCriteria, self).__init__(**kwargs) self.criterion_type = 'StaticThresholdCriterion' # type: str self.operator = kwargs['operator'] @@ -1167,12 +1513,12 @@ class MetricDimension(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the dimension. - :type name: str - :param operator: Required. the dimension operator. Only 'Include' and 'Exclude' are supported. - :type operator: str - :param values: Required. list of dimension values. - :type values: list[str] + :ivar name: Required. Name of the dimension. + :vartype name: str + :ivar operator: Required. the dimension operator. Only 'Include' and 'Exclude' are supported. + :vartype operator: str + :ivar values: Required. list of dimension values. + :vartype values: list[str] """ _validation = { @@ -1191,6 +1537,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. Name of the dimension. + :paramtype name: str + :keyword operator: Required. the dimension operator. Only 'Include' and 'Exclude' are + supported. + :paramtype operator: str + :keyword values: Required. list of dimension values. + :paramtype values: list[str] + """ super(MetricDimension, self).__init__(**kwargs) self.name = kwargs['name'] self.operator = kwargs['operator'] @@ -1204,13 +1559,13 @@ class SmsReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SMS receiver. Names must be unique across all receivers + :ivar name: Required. The name of the SMS receiver. Names must be unique across all receivers within an action group. - :type name: str - :param country_code: Required. The country code of the SMS receiver. - :type country_code: str - :param phone_number: Required. The phone number of the SMS receiver. - :type phone_number: str + :vartype name: str + :ivar country_code: Required. The country code of the SMS receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the SMS receiver. + :vartype phone_number: str :ivar status: The status of the receiver. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2018_03_01.models.ReceiverStatus @@ -1234,6 +1589,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the SMS receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the SMS receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the SMS receiver. + :paramtype phone_number: str + """ super(SmsReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.country_code = kwargs['country_code'] @@ -1246,13 +1610,13 @@ class VoiceReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the voice receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param country_code: Required. The country code of the voice receiver. - :type country_code: str - :param phone_number: Required. The phone number of the voice receiver. - :type phone_number: str + :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar country_code: Required. The country code of the voice receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the voice receiver. + :vartype phone_number: str """ _validation = { @@ -1271,6 +1635,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the voice receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the voice receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the voice receiver. + :paramtype phone_number: str + """ super(VoiceReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.country_code = kwargs['country_code'] @@ -1282,11 +1655,11 @@ class WebhookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the webhook receiver. Names must be unique across all + :ivar name: Required. The name of the webhook receiver. Names must be unique across all receivers within an action group. - :type name: str - :param service_uri: Required. The URI where webhooks should be sent. - :type service_uri: str + :vartype name: str + :ivar service_uri: Required. The URI where webhooks should be sent. + :vartype service_uri: str """ _validation = { @@ -1303,6 +1676,13 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the webhook receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword service_uri: Required. The URI where webhooks should be sent. + :paramtype service_uri: str + """ super(WebhookReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.service_uri = kwargs['service_uri'] @@ -1313,21 +1693,20 @@ class WebtestLocationAvailabilityCriteria(MetricAlertCriteria): All required parameters must be populated in order to send to Azure. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param odata_type: Required. specifies the type of the alert criteria.Constant filled by - server. Possible values include: - "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + :vartype additional_properties: dict[str, any] + :ivar odata_type: Required. specifies the type of the alert criteria.Constant filled by server. + Possible values include: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". - :type odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype - :param web_test_id: Required. The Application Insights web test Id. - :type web_test_id: str - :param component_id: Required. The Application Insights resource Id. - :type component_id: str - :param failed_location_count: Required. The number of failed locations. - :type failed_location_count: float + :vartype odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype + :ivar web_test_id: Required. The Application Insights web test Id. + :vartype web_test_id: str + :ivar component_id: Required. The Application Insights resource Id. + :vartype component_id: str + :ivar failed_location_count: Required. The number of failed locations. + :vartype failed_location_count: float """ _validation = { @@ -1349,6 +1728,17 @@ def __init__( self, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword web_test_id: Required. The Application Insights web test Id. + :paramtype web_test_id: str + :keyword component_id: Required. The Application Insights resource Id. + :paramtype component_id: str + :keyword failed_location_count: Required. The number of failed locations. + :paramtype failed_location_count: float + """ super(WebtestLocationAvailabilityCriteria, self).__init__(**kwargs) self.odata_type = 'Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria' # type: str self.web_test_id = kwargs['web_test_id'] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models_py3.py index fb4bbdf427c7e..2c3669778fdb7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_models_py3.py @@ -18,10 +18,10 @@ class ActionGroupList(msrest.serialization.Model): """A list of action groups. - :param value: The list of action groups. - :type value: list[~$(python-base-namespace).v2018_03_01.models.ActionGroupResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar value: The list of action groups. + :vartype value: list[~$(python-base-namespace).v2018_03_01.models.ActionGroupResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -36,6 +36,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of action groups. + :paramtype value: list[~$(python-base-namespace).v2018_03_01.models.ActionGroupResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(ActionGroupList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -44,11 +50,11 @@ def __init__( class ActionGroupPatchBody(msrest.serialization.Model): """An action group object for the body of patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. - :type enabled: bool + :vartype enabled: bool """ _attribute_map = { @@ -63,6 +69,13 @@ def __init__( enabled: Optional[bool] = True, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ super(ActionGroupPatchBody, self).__init__(**kwargs) self.tags = tags self.enabled = enabled @@ -81,10 +94,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -109,6 +122,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -130,38 +149,39 @@ class ActionGroupResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param group_short_name: The short name of the action group. This will be used in SMS messages. - :type group_short_name: str - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar group_short_name: The short name of the action group. This will be used in SMS messages. + :vartype group_short_name: str + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. - :type enabled: bool - :param email_receivers: The list of email receivers that are part of this action group. - :type email_receivers: list[~$(python-base-namespace).v2018_03_01.models.EmailReceiver] - :param sms_receivers: The list of SMS receivers that are part of this action group. - :type sms_receivers: list[~$(python-base-namespace).v2018_03_01.models.SmsReceiver] - :param webhook_receivers: The list of webhook receivers that are part of this action group. - :type webhook_receivers: list[~$(python-base-namespace).v2018_03_01.models.WebhookReceiver] - :param itsm_receivers: The list of ITSM receivers that are part of this action group. - :type itsm_receivers: list[~$(python-base-namespace).v2018_03_01.models.ItsmReceiver] - :param azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :type azure_app_push_receivers: + :vartype enabled: bool + :ivar email_receivers: The list of email receivers that are part of this action group. + :vartype email_receivers: list[~$(python-base-namespace).v2018_03_01.models.EmailReceiver] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~$(python-base-namespace).v2018_03_01.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~$(python-base-namespace).v2018_03_01.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~$(python-base-namespace).v2018_03_01.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: list[~$(python-base-namespace).v2018_03_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of this action group. - :type automation_runbook_receivers: + :vartype automation_runbook_receivers: list[~$(python-base-namespace).v2018_03_01.models.AutomationRunbookReceiver] - :param voice_receivers: The list of voice receivers that are part of this action group. - :type voice_receivers: list[~$(python-base-namespace).v2018_03_01.models.VoiceReceiver] - :param logic_app_receivers: The list of logic app receivers that are part of this action group. - :type logic_app_receivers: list[~$(python-base-namespace).v2018_03_01.models.LogicAppReceiver] - :param azure_function_receivers: The list of azure function receivers that are part of this + :ivar voice_receivers: The list of voice receivers that are part of this action group. + :vartype voice_receivers: list[~$(python-base-namespace).v2018_03_01.models.VoiceReceiver] + :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. + :vartype logic_app_receivers: + list[~$(python-base-namespace).v2018_03_01.models.LogicAppReceiver] + :ivar azure_function_receivers: The list of azure function receivers that are part of this action group. - :type azure_function_receivers: + :vartype azure_function_receivers: list[~$(python-base-namespace).v2018_03_01.models.AzureFunctionReceiver] """ @@ -210,6 +230,45 @@ def __init__( azure_function_receivers: Optional[List["AzureFunctionReceiver"]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword group_short_name: The short name of the action group. This will be used in SMS + messages. + :paramtype group_short_name: str + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its receivers will receive communications. + :paramtype enabled: bool + :keyword email_receivers: The list of email receivers that are part of this action group. + :paramtype email_receivers: list[~$(python-base-namespace).v2018_03_01.models.EmailReceiver] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~$(python-base-namespace).v2018_03_01.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: + list[~$(python-base-namespace).v2018_03_01.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~$(python-base-namespace).v2018_03_01.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: + list[~$(python-base-namespace).v2018_03_01.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~$(python-base-namespace).v2018_03_01.models.AutomationRunbookReceiver] + :keyword voice_receivers: The list of voice receivers that are part of this action group. + :paramtype voice_receivers: list[~$(python-base-namespace).v2018_03_01.models.VoiceReceiver] + :keyword logic_app_receivers: The list of logic app receivers that are part of this action + group. + :paramtype logic_app_receivers: + list[~$(python-base-namespace).v2018_03_01.models.LogicAppReceiver] + :keyword azure_function_receivers: The list of azure function receivers that are part of this + action group. + :paramtype azure_function_receivers: + list[~$(python-base-namespace).v2018_03_01.models.AzureFunctionReceiver] + """ super(ActionGroupResource, self).__init__(location=location, tags=tags, **kwargs) self.group_short_name = group_short_name self.enabled = enabled @@ -229,19 +288,19 @@ class AutomationRunbookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. - :type automation_account_id: str - :param runbook_name: Required. The name for this runbook. - :type runbook_name: str - :param webhook_resource_id: Required. The resource id for webhook linked to this runbook. - :type webhook_resource_id: str - :param is_global_runbook: Required. Indicates whether this instance is global runbook. - :type is_global_runbook: bool - :param name: Indicates name of the webhook. - :type name: str - :param service_uri: The URI where webhooks should be sent. - :type service_uri: str + :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook + and authenticate to Azure resource. + :vartype automation_account_id: str + :ivar runbook_name: Required. The name for this runbook. + :vartype runbook_name: str + :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :vartype webhook_resource_id: str + :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :vartype is_global_runbook: bool + :ivar name: Indicates name of the webhook. + :vartype name: str + :ivar service_uri: The URI where webhooks should be sent. + :vartype service_uri: str """ _validation = { @@ -271,6 +330,21 @@ def __init__( service_uri: Optional[str] = None, **kwargs ): + """ + :keyword automation_account_id: Required. The Azure automation account Id which holds this + runbook and authenticate to Azure resource. + :paramtype automation_account_id: str + :keyword runbook_name: Required. The name for this runbook. + :paramtype runbook_name: str + :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :paramtype webhook_resource_id: str + :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :paramtype is_global_runbook: bool + :keyword name: Indicates name of the webhook. + :paramtype name: str + :keyword service_uri: The URI where webhooks should be sent. + :paramtype service_uri: str + """ super(AutomationRunbookReceiver, self).__init__(**kwargs) self.automation_account_id = automation_account_id self.runbook_name = runbook_name @@ -285,11 +359,11 @@ class AzureAppPushReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Azure mobile app push receiver. Names must be unique + :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. - :type name: str - :param email_address: Required. The email address registered for the Azure mobile app. - :type email_address: str + :vartype name: str + :ivar email_address: Required. The email address registered for the Azure mobile app. + :vartype email_address: str """ _validation = { @@ -309,6 +383,13 @@ def __init__( email_address: str, **kwargs ): + """ + :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique + across all receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address registered for the Azure mobile app. + :paramtype email_address: str + """ super(AzureAppPushReceiver, self).__init__(**kwargs) self.name = name self.email_address = email_address @@ -319,15 +400,15 @@ class AzureFunctionReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the azure function receiver. Names must be unique across all + :ivar name: Required. The name of the azure function receiver. Names must be unique across all receivers within an action group. - :type name: str - :param function_app_resource_id: Required. The azure resource id of the function app. - :type function_app_resource_id: str - :param function_name: Required. The function name in the function app. - :type function_name: str - :param http_trigger_url: Required. The http trigger url where http request sent to. - :type http_trigger_url: str + :vartype name: str + :ivar function_app_resource_id: Required. The azure resource id of the function app. + :vartype function_app_resource_id: str + :ivar function_name: Required. The function name in the function app. + :vartype function_name: str + :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :vartype http_trigger_url: str """ _validation = { @@ -353,6 +434,17 @@ def __init__( http_trigger_url: str, **kwargs ): + """ + :keyword name: Required. The name of the azure function receiver. Names must be unique across + all receivers within an action group. + :paramtype name: str + :keyword function_app_resource_id: Required. The azure resource id of the function app. + :paramtype function_app_resource_id: str + :keyword function_name: Required. The function name in the function app. + :paramtype function_name: str + :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :paramtype http_trigger_url: str + """ super(AzureFunctionReceiver, self).__init__(**kwargs) self.name = name self.function_app_resource_id = function_app_resource_id @@ -368,26 +460,27 @@ class MultiMetricCriteria(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param criterion_type: Required. Specifies the type of threshold criteria.Constant filled by - server. Possible values include: "StaticThresholdCriterion", "DynamicThresholdCriterion". - :type criterion_type: str or ~$(python-base-namespace).v2018_03_01.models.CriterionType - :param name: Required. Name of the criteria. - :type name: str - :param metric_name: Required. Name of the metric. - :type metric_name: str - :param metric_namespace: Namespace of the metric. - :type metric_namespace: str - :param time_aggregation: Required. the criteria time aggregation types. Possible values - include: "Average", "Count", "Minimum", "Maximum", "Total". - :type time_aggregation: str or ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum - :param dimensions: List of dimension conditions. - :type dimensions: list[~$(python-base-namespace).v2018_03_01.models.MetricDimension] - :param skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet + :vartype additional_properties: dict[str, any] + :ivar criterion_type: Required. Specifies the type of threshold criteria.Constant filled by + server. Possible values include: "StaticThresholdCriterion", "DynamicThresholdCriterion". + :vartype criterion_type: str or ~$(python-base-namespace).v2018_03_01.models.CriterionType + :ivar name: Required. Name of the criteria. + :vartype name: str + :ivar metric_name: Required. Name of the metric. + :vartype metric_name: str + :ivar metric_namespace: Namespace of the metric. + :vartype metric_namespace: str + :ivar time_aggregation: Required. the criteria time aggregation types. Possible values include: + "Average", "Count", "Minimum", "Maximum", "Total". + :vartype time_aggregation: str or + ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum + :ivar dimensions: List of dimension conditions. + :vartype dimensions: list[~$(python-base-namespace).v2018_03_01.models.MetricDimension] + :ivar skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. - :type skip_metric_validation: bool + :vartype skip_metric_validation: bool """ _validation = { @@ -424,6 +517,26 @@ def __init__( skip_metric_validation: Optional[bool] = None, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword name: Required. Name of the criteria. + :paramtype name: str + :keyword metric_name: Required. Name of the metric. + :paramtype metric_name: str + :keyword metric_namespace: Namespace of the metric. + :paramtype metric_namespace: str + :keyword time_aggregation: Required. the criteria time aggregation types. Possible values + include: "Average", "Count", "Minimum", "Maximum", "Total". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum + :keyword dimensions: List of dimension conditions. + :paramtype dimensions: list[~$(python-base-namespace).v2018_03_01.models.MetricDimension] + :keyword skip_metric_validation: Allows creating an alert rule on a custom metric that isn't + yet emitted, by causing the metric validation to be skipped. + :paramtype skip_metric_validation: bool + """ super(MultiMetricCriteria, self).__init__(**kwargs) self.additional_properties = additional_properties self.criterion_type = 'MultiMetricCriteria' # type: str @@ -440,41 +553,42 @@ class DynamicMetricCriteria(MultiMetricCriteria): All required parameters must be populated in order to send to Azure. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param criterion_type: Required. Specifies the type of threshold criteria.Constant filled by - server. Possible values include: "StaticThresholdCriterion", "DynamicThresholdCriterion". - :type criterion_type: str or ~$(python-base-namespace).v2018_03_01.models.CriterionType - :param name: Required. Name of the criteria. - :type name: str - :param metric_name: Required. Name of the metric. - :type metric_name: str - :param metric_namespace: Namespace of the metric. - :type metric_namespace: str - :param time_aggregation: Required. the criteria time aggregation types. Possible values - include: "Average", "Count", "Minimum", "Maximum", "Total". - :type time_aggregation: str or ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum - :param dimensions: List of dimension conditions. - :type dimensions: list[~$(python-base-namespace).v2018_03_01.models.MetricDimension] - :param skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet + :vartype additional_properties: dict[str, any] + :ivar criterion_type: Required. Specifies the type of threshold criteria.Constant filled by + server. Possible values include: "StaticThresholdCriterion", "DynamicThresholdCriterion". + :vartype criterion_type: str or ~$(python-base-namespace).v2018_03_01.models.CriterionType + :ivar name: Required. Name of the criteria. + :vartype name: str + :ivar metric_name: Required. Name of the metric. + :vartype metric_name: str + :ivar metric_namespace: Namespace of the metric. + :vartype metric_namespace: str + :ivar time_aggregation: Required. the criteria time aggregation types. Possible values include: + "Average", "Count", "Minimum", "Maximum", "Total". + :vartype time_aggregation: str or + ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum + :ivar dimensions: List of dimension conditions. + :vartype dimensions: list[~$(python-base-namespace).v2018_03_01.models.MetricDimension] + :ivar skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. - :type skip_metric_validation: bool - :param operator: Required. The operator used to compare the metric value against the threshold. + :vartype skip_metric_validation: bool + :ivar operator: Required. The operator used to compare the metric value against the threshold. Possible values include: "GreaterThan", "LessThan", "GreaterOrLessThan". - :type operator: str or ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdOperator - :param alert_sensitivity: Required. The extent of deviation required to trigger an alert. This + :vartype operator: str or ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdOperator + :ivar alert_sensitivity: Required. The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. Possible values include: "Low", "Medium", "High". - :type alert_sensitivity: str or + :vartype alert_sensitivity: str or ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdSensitivity - :param failing_periods: Required. The minimum number of violations required within the selected + :ivar failing_periods: Required. The minimum number of violations required within the selected lookback time window required to raise an alert. - :type failing_periods: + :vartype failing_periods: ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdFailingPeriods - :param ignore_data_before: Use this option to set the date from which to start learning the + :ivar ignore_data_before: Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format). - :type ignore_data_before: ~datetime.datetime + :vartype ignore_data_before: ~datetime.datetime """ _validation = { @@ -518,6 +632,42 @@ def __init__( ignore_data_before: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword name: Required. Name of the criteria. + :paramtype name: str + :keyword metric_name: Required. Name of the metric. + :paramtype metric_name: str + :keyword metric_namespace: Namespace of the metric. + :paramtype metric_namespace: str + :keyword time_aggregation: Required. the criteria time aggregation types. Possible values + include: "Average", "Count", "Minimum", "Maximum", "Total". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum + :keyword dimensions: List of dimension conditions. + :paramtype dimensions: list[~$(python-base-namespace).v2018_03_01.models.MetricDimension] + :keyword skip_metric_validation: Allows creating an alert rule on a custom metric that isn't + yet emitted, by causing the metric validation to be skipped. + :paramtype skip_metric_validation: bool + :keyword operator: Required. The operator used to compare the metric value against the + threshold. Possible values include: "GreaterThan", "LessThan", "GreaterOrLessThan". + :paramtype operator: str or + ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdOperator + :keyword alert_sensitivity: Required. The extent of deviation required to trigger an alert. + This will affect how tight the threshold is to the metric series pattern. Possible values + include: "Low", "Medium", "High". + :paramtype alert_sensitivity: str or + ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdSensitivity + :keyword failing_periods: Required. The minimum number of violations required within the + selected lookback time window required to raise an alert. + :paramtype failing_periods: + ~$(python-base-namespace).v2018_03_01.models.DynamicThresholdFailingPeriods + :keyword ignore_data_before: Use this option to set the date from which to start learning the + metric historical data and calculate the dynamic thresholds (in ISO8601 format). + :paramtype ignore_data_before: ~datetime.datetime + """ super(DynamicMetricCriteria, self).__init__(additional_properties=additional_properties, name=name, metric_name=metric_name, metric_namespace=metric_namespace, time_aggregation=time_aggregation, dimensions=dimensions, skip_metric_validation=skip_metric_validation, **kwargs) self.criterion_type = 'DynamicThresholdCriterion' # type: str self.operator = operator @@ -531,13 +681,13 @@ class DynamicThresholdFailingPeriods(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param number_of_evaluation_periods: Required. The number of aggregated lookback points. The + :ivar number_of_evaluation_periods: Required. The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. - :type number_of_evaluation_periods: float - :param min_failing_periods_to_alert: Required. The number of violations to trigger an alert. + :vartype number_of_evaluation_periods: float + :ivar min_failing_periods_to_alert: Required. The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. - :type min_failing_periods_to_alert: float + :vartype min_failing_periods_to_alert: float """ _validation = { @@ -557,6 +707,15 @@ def __init__( min_failing_periods_to_alert: float, **kwargs ): + """ + :keyword number_of_evaluation_periods: Required. The number of aggregated lookback points. The + lookback time window is calculated based on the aggregation granularity (windowSize) and the + selected number of aggregated points. + :paramtype number_of_evaluation_periods: float + :keyword min_failing_periods_to_alert: Required. The number of violations to trigger an alert. + Should be smaller or equal to numberOfEvaluationPeriods. + :paramtype min_failing_periods_to_alert: float + """ super(DynamicThresholdFailingPeriods, self).__init__(**kwargs) self.number_of_evaluation_periods = number_of_evaluation_periods self.min_failing_periods_to_alert = min_failing_periods_to_alert @@ -569,11 +728,11 @@ class EmailReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param email_address: Required. The email address of this receiver. - :type email_address: str + :ivar name: Required. The name of the email receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar email_address: Required. The email address of this receiver. + :vartype email_address: str :ivar status: The receiver status of the e-mail. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2018_03_01.models.ReceiverStatus @@ -598,6 +757,13 @@ def __init__( email_address: str, **kwargs ): + """ + :keyword name: Required. The name of the email receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address of this receiver. + :paramtype email_address: str + """ super(EmailReceiver, self).__init__(**kwargs) self.name = name self.email_address = email_address @@ -609,8 +775,8 @@ class EnableRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param receiver_name: Required. The name of the receiver to resubscribe. - :type receiver_name: str + :ivar receiver_name: Required. The name of the receiver to resubscribe. + :vartype receiver_name: str """ _validation = { @@ -627,6 +793,10 @@ def __init__( receiver_name: str, **kwargs ): + """ + :keyword receiver_name: Required. The name of the receiver to resubscribe. + :paramtype receiver_name: str + """ super(EnableRequest, self).__init__(**kwargs) self.receiver_name = receiver_name @@ -634,10 +804,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -652,6 +822,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -662,20 +838,20 @@ class ItsmReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Itsm receiver. Names must be unique across all receivers + :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers within an action group. - :type name: str - :param workspace_id: Required. OMS LA instance identifier. - :type workspace_id: str - :param connection_id: Required. Unique identification of ITSM connection among multiple defined + :vartype name: str + :ivar workspace_id: Required. OMS LA instance identifier. + :vartype workspace_id: str + :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined in above workspace. - :type connection_id: str - :param ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + :vartype connection_id: str + :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as well. - :type ticket_configuration: str - :param region: Required. Region in which workspace resides. Supported + :vartype ticket_configuration: str + :ivar region: Required. Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - :type region: str + :vartype region: str """ _validation = { @@ -704,6 +880,22 @@ def __init__( region: str, **kwargs ): + """ + :keyword name: Required. The name of the Itsm receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword workspace_id: Required. OMS LA instance identifier. + :paramtype workspace_id: str + :keyword connection_id: Required. Unique identification of ITSM connection among multiple + defined in above workspace. + :paramtype connection_id: str + :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. + :paramtype ticket_configuration: str + :keyword region: Required. Region in which workspace resides. Supported + values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + :paramtype region: str + """ super(ItsmReceiver, self).__init__(**kwargs) self.name = name self.workspace_id = workspace_id @@ -717,13 +909,13 @@ class LogicAppReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the logic app receiver. Names must be unique across all + :ivar name: Required. The name of the logic app receiver. Names must be unique across all receivers within an action group. - :type name: str - :param resource_id: Required. The azure resource id of the logic app receiver. - :type resource_id: str - :param callback_url: Required. The callback url where http request sent to. - :type callback_url: str + :vartype name: str + :ivar resource_id: Required. The azure resource id of the logic app receiver. + :vartype resource_id: str + :ivar callback_url: Required. The callback url where http request sent to. + :vartype callback_url: str """ _validation = { @@ -746,6 +938,15 @@ def __init__( callback_url: str, **kwargs ): + """ + :keyword name: Required. The name of the logic app receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword resource_id: Required. The azure resource id of the logic app receiver. + :paramtype resource_id: str + :keyword callback_url: Required. The callback url where http request sent to. + :paramtype callback_url: str + """ super(LogicAppReceiver, self).__init__(**kwargs) self.name = name self.resource_id = resource_id @@ -755,11 +956,11 @@ def __init__( class MetricAlertAction(msrest.serialization.Model): """An alert action. - :param action_group_id: the id of the action group to use. - :type action_group_id: str - :param web_hook_properties: This field allows specifying custom properties, which would be + :ivar action_group_id: the id of the action group to use. + :vartype action_group_id: str + :ivar web_hook_properties: This field allows specifying custom properties, which would be appended to the alert payload sent as input to the webhook. - :type web_hook_properties: dict[str, str] + :vartype web_hook_properties: dict[str, str] """ _attribute_map = { @@ -774,6 +975,13 @@ def __init__( web_hook_properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword action_group_id: the id of the action group to use. + :paramtype action_group_id: str + :keyword web_hook_properties: This field allows specifying custom properties, which would be + appended to the alert payload sent as input to the webhook. + :paramtype web_hook_properties: dict[str, str] + """ super(MetricAlertAction, self).__init__(**kwargs) self.action_group_id = action_group_id self.web_hook_properties = web_hook_properties @@ -787,15 +995,14 @@ class MetricAlertCriteria(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param odata_type: Required. specifies the type of the alert criteria.Constant filled by - server. Possible values include: - "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + :vartype additional_properties: dict[str, any] + :ivar odata_type: Required. specifies the type of the alert criteria.Constant filled by server. + Possible values include: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". - :type odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype + :vartype odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype """ _validation = { @@ -817,6 +1024,11 @@ def __init__( additional_properties: Optional[Dict[str, Any]] = None, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + """ super(MetricAlertCriteria, self).__init__(**kwargs) self.additional_properties = additional_properties self.odata_type = 'MetricAlertCriteria' # type: str @@ -827,17 +1039,16 @@ class MetricAlertMultipleResourceMultipleMetricCriteria(MetricAlertCriteria): All required parameters must be populated in order to send to Azure. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param odata_type: Required. specifies the type of the alert criteria.Constant filled by - server. Possible values include: - "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + :vartype additional_properties: dict[str, any] + :ivar odata_type: Required. specifies the type of the alert criteria.Constant filled by server. + Possible values include: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". - :type odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype - :param all_of: the list of multiple metric criteria for this 'all of' operation. - :type all_of: list[~$(python-base-namespace).v2018_03_01.models.MultiMetricCriteria] + :vartype odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype + :ivar all_of: the list of multiple metric criteria for this 'all of' operation. + :vartype all_of: list[~$(python-base-namespace).v2018_03_01.models.MultiMetricCriteria] """ _validation = { @@ -857,6 +1068,13 @@ def __init__( all_of: Optional[List["MultiMetricCriteria"]] = None, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword all_of: the list of multiple metric criteria for this 'all of' operation. + :paramtype all_of: list[~$(python-base-namespace).v2018_03_01.models.MultiMetricCriteria] + """ super(MetricAlertMultipleResourceMultipleMetricCriteria, self).__init__(additional_properties=additional_properties, **kwargs) self.odata_type = 'Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria' # type: str self.all_of = all_of @@ -875,41 +1093,41 @@ class MetricAlertResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param description: the description of the metric alert that will be included in the alert + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar description: the description of the metric alert that will be included in the alert email. - :type description: str - :param severity: Required. Alert severity {0, 1, 2, 3, 4}. - :type severity: int - :param enabled: Required. the flag that indicates whether the metric alert is enabled. - :type enabled: bool - :param scopes: Required. the list of resource id's that this metric alert is scoped to. - :type scopes: list[str] - :param evaluation_frequency: Required. how often the metric alert is evaluated represented in + :vartype description: str + :ivar severity: Required. Alert severity {0, 1, 2, 3, 4}. + :vartype severity: int + :ivar enabled: Required. the flag that indicates whether the metric alert is enabled. + :vartype enabled: bool + :ivar scopes: Required. the list of resource id's that this metric alert is scoped to. + :vartype scopes: list[str] + :ivar evaluation_frequency: Required. how often the metric alert is evaluated represented in ISO 8601 duration format. - :type evaluation_frequency: ~datetime.timedelta - :param window_size: Required. the period of time (in ISO 8601 duration format) that is used to + :vartype evaluation_frequency: ~datetime.timedelta + :ivar window_size: Required. the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. - :type window_size: ~datetime.timedelta - :param target_resource_type: the resource type of the target resource(s) on which the alert is + :vartype window_size: ~datetime.timedelta + :ivar target_resource_type: the resource type of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource. - :type target_resource_type: str - :param target_resource_region: the region of the target resource(s) on which the alert is + :vartype target_resource_type: str + :ivar target_resource_region: the region of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource. - :type target_resource_region: str - :param criteria: Required. defines the specific alert criteria information. - :type criteria: ~$(python-base-namespace).v2018_03_01.models.MetricAlertCriteria - :param auto_mitigate: the flag that indicates whether the alert should be auto resolved or not. + :vartype target_resource_region: str + :ivar criteria: Required. defines the specific alert criteria information. + :vartype criteria: ~$(python-base-namespace).v2018_03_01.models.MetricAlertCriteria + :ivar auto_mitigate: the flag that indicates whether the alert should be auto resolved or not. The default is true. - :type auto_mitigate: bool - :param actions: the array of actions that are performed when the alert rule becomes active, and + :vartype auto_mitigate: bool + :ivar actions: the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. - :type actions: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertAction] + :vartype actions: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertAction] :ivar last_updated_time: Last time the rule was updated in ISO8601 format. :vartype last_updated_time: ~datetime.datetime :ivar is_migrated: the value indicating whether this alert rule is migrated. @@ -970,6 +1188,43 @@ def __init__( actions: Optional[List["MetricAlertAction"]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword description: the description of the metric alert that will be included in the alert + email. + :paramtype description: str + :keyword severity: Required. Alert severity {0, 1, 2, 3, 4}. + :paramtype severity: int + :keyword enabled: Required. the flag that indicates whether the metric alert is enabled. + :paramtype enabled: bool + :keyword scopes: Required. the list of resource id's that this metric alert is scoped to. + :paramtype scopes: list[str] + :keyword evaluation_frequency: Required. how often the metric alert is evaluated represented in + ISO 8601 duration format. + :paramtype evaluation_frequency: ~datetime.timedelta + :keyword window_size: Required. the period of time (in ISO 8601 duration format) that is used + to monitor alert activity based on the threshold. + :paramtype window_size: ~datetime.timedelta + :keyword target_resource_type: the resource type of the target resource(s) on which the alert + is created/updated. Mandatory if the scope contains a subscription, resource group, or more + than one resource. + :paramtype target_resource_type: str + :keyword target_resource_region: the region of the target resource(s) on which the alert is + created/updated. Mandatory if the scope contains a subscription, resource group, or more than + one resource. + :paramtype target_resource_region: str + :keyword criteria: Required. defines the specific alert criteria information. + :paramtype criteria: ~$(python-base-namespace).v2018_03_01.models.MetricAlertCriteria + :keyword auto_mitigate: the flag that indicates whether the alert should be auto resolved or + not. The default is true. + :paramtype auto_mitigate: bool + :keyword actions: the array of actions that are performed when the alert rule becomes active, + and when an alert condition is resolved. + :paramtype actions: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertAction] + """ super(MetricAlertResource, self).__init__(location=location, tags=tags, **kwargs) self.description = description self.severity = severity @@ -989,8 +1244,8 @@ def __init__( class MetricAlertResourceCollection(msrest.serialization.Model): """Represents a collection of alert rule resources. - :param value: the values for the alert rule resources. - :type value: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertResource] + :ivar value: the values for the alert rule resources. + :vartype value: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertResource] """ _attribute_map = { @@ -1003,6 +1258,10 @@ def __init__( value: Optional[List["MetricAlertResource"]] = None, **kwargs ): + """ + :keyword value: the values for the alert rule resources. + :paramtype value: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertResource] + """ super(MetricAlertResourceCollection, self).__init__(**kwargs) self.value = value @@ -1012,37 +1271,37 @@ class MetricAlertResourcePatch(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param description: the description of the metric alert that will be included in the alert + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar description: the description of the metric alert that will be included in the alert email. - :type description: str - :param severity: Alert severity {0, 1, 2, 3, 4}. - :type severity: int - :param enabled: the flag that indicates whether the metric alert is enabled. - :type enabled: bool - :param scopes: the list of resource id's that this metric alert is scoped to. - :type scopes: list[str] - :param evaluation_frequency: how often the metric alert is evaluated represented in ISO 8601 + :vartype description: str + :ivar severity: Alert severity {0, 1, 2, 3, 4}. + :vartype severity: int + :ivar enabled: the flag that indicates whether the metric alert is enabled. + :vartype enabled: bool + :ivar scopes: the list of resource id's that this metric alert is scoped to. + :vartype scopes: list[str] + :ivar evaluation_frequency: how often the metric alert is evaluated represented in ISO 8601 duration format. - :type evaluation_frequency: ~datetime.timedelta - :param window_size: the period of time (in ISO 8601 duration format) that is used to monitor + :vartype evaluation_frequency: ~datetime.timedelta + :ivar window_size: the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. - :type window_size: ~datetime.timedelta - :param target_resource_type: the resource type of the target resource(s) on which the alert is + :vartype window_size: ~datetime.timedelta + :ivar target_resource_type: the resource type of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. - :type target_resource_type: str - :param target_resource_region: the region of the target resource(s) on which the alert is + :vartype target_resource_type: str + :ivar target_resource_region: the region of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. - :type target_resource_region: str - :param criteria: defines the specific alert criteria information. - :type criteria: ~$(python-base-namespace).v2018_03_01.models.MetricAlertCriteria - :param auto_mitigate: the flag that indicates whether the alert should be auto resolved or not. + :vartype target_resource_region: str + :ivar criteria: defines the specific alert criteria information. + :vartype criteria: ~$(python-base-namespace).v2018_03_01.models.MetricAlertCriteria + :ivar auto_mitigate: the flag that indicates whether the alert should be auto resolved or not. The default is true. - :type auto_mitigate: bool - :param actions: the array of actions that are performed when the alert rule becomes active, and + :vartype auto_mitigate: bool + :ivar actions: the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. - :type actions: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertAction] + :vartype actions: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertAction] :ivar last_updated_time: Last time the rule was updated in ISO8601 format. :vartype last_updated_time: ~datetime.datetime :ivar is_migrated: the value indicating whether this alert rule is migrated. @@ -1088,6 +1347,39 @@ def __init__( actions: Optional[List["MetricAlertAction"]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword description: the description of the metric alert that will be included in the alert + email. + :paramtype description: str + :keyword severity: Alert severity {0, 1, 2, 3, 4}. + :paramtype severity: int + :keyword enabled: the flag that indicates whether the metric alert is enabled. + :paramtype enabled: bool + :keyword scopes: the list of resource id's that this metric alert is scoped to. + :paramtype scopes: list[str] + :keyword evaluation_frequency: how often the metric alert is evaluated represented in ISO 8601 + duration format. + :paramtype evaluation_frequency: ~datetime.timedelta + :keyword window_size: the period of time (in ISO 8601 duration format) that is used to monitor + alert activity based on the threshold. + :paramtype window_size: ~datetime.timedelta + :keyword target_resource_type: the resource type of the target resource(s) on which the alert + is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + :paramtype target_resource_type: str + :keyword target_resource_region: the region of the target resource(s) on which the alert is + created/updated. Mandatory for MultipleResourceMultipleMetricCriteria. + :paramtype target_resource_region: str + :keyword criteria: defines the specific alert criteria information. + :paramtype criteria: ~$(python-base-namespace).v2018_03_01.models.MetricAlertCriteria + :keyword auto_mitigate: the flag that indicates whether the alert should be auto resolved or + not. The default is true. + :paramtype auto_mitigate: bool + :keyword actions: the array of actions that are performed when the alert rule becomes active, + and when an alert condition is resolved. + :paramtype actions: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertAction] + """ super(MetricAlertResourcePatch, self).__init__(**kwargs) self.tags = tags self.description = description @@ -1110,17 +1402,16 @@ class MetricAlertSingleResourceMultipleMetricCriteria(MetricAlertCriteria): All required parameters must be populated in order to send to Azure. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param odata_type: Required. specifies the type of the alert criteria.Constant filled by - server. Possible values include: - "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + :vartype additional_properties: dict[str, any] + :ivar odata_type: Required. specifies the type of the alert criteria.Constant filled by server. + Possible values include: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". - :type odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype - :param all_of: The list of metric criteria for this 'all of' operation. - :type all_of: list[~$(python-base-namespace).v2018_03_01.models.MetricCriteria] + :vartype odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype + :ivar all_of: The list of metric criteria for this 'all of' operation. + :vartype all_of: list[~$(python-base-namespace).v2018_03_01.models.MetricCriteria] """ _validation = { @@ -1140,6 +1431,13 @@ def __init__( all_of: Optional[List["MetricCriteria"]] = None, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword all_of: The list of metric criteria for this 'all of' operation. + :paramtype all_of: list[~$(python-base-namespace).v2018_03_01.models.MetricCriteria] + """ super(MetricAlertSingleResourceMultipleMetricCriteria, self).__init__(additional_properties=additional_properties, **kwargs) self.odata_type = 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria' # type: str self.all_of = all_of @@ -1148,14 +1446,14 @@ def __init__( class MetricAlertStatus(msrest.serialization.Model): """An alert status. - :param name: The status name. - :type name: str - :param id: The alert rule arm id. - :type id: str - :param type: The extended resource type name. - :type type: str - :param properties: The alert status properties of the metric alert status. - :type properties: ~$(python-base-namespace).v2018_03_01.models.MetricAlertStatusProperties + :ivar name: The status name. + :vartype name: str + :ivar id: The alert rule arm id. + :vartype id: str + :ivar type: The extended resource type name. + :vartype type: str + :ivar properties: The alert status properties of the metric alert status. + :vartype properties: ~$(python-base-namespace).v2018_03_01.models.MetricAlertStatusProperties """ _attribute_map = { @@ -1174,6 +1472,16 @@ def __init__( properties: Optional["MetricAlertStatusProperties"] = None, **kwargs ): + """ + :keyword name: The status name. + :paramtype name: str + :keyword id: The alert rule arm id. + :paramtype id: str + :keyword type: The extended resource type name. + :paramtype type: str + :keyword properties: The alert status properties of the metric alert status. + :paramtype properties: ~$(python-base-namespace).v2018_03_01.models.MetricAlertStatusProperties + """ super(MetricAlertStatus, self).__init__(**kwargs) self.name = name self.id = id @@ -1184,8 +1492,8 @@ def __init__( class MetricAlertStatusCollection(msrest.serialization.Model): """Represents a collection of alert rule resources. - :param value: the values for the alert rule resources. - :type value: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertStatus] + :ivar value: the values for the alert rule resources. + :vartype value: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertStatus] """ _attribute_map = { @@ -1198,6 +1506,10 @@ def __init__( value: Optional[List["MetricAlertStatus"]] = None, **kwargs ): + """ + :keyword value: the values for the alert rule resources. + :paramtype value: list[~$(python-base-namespace).v2018_03_01.models.MetricAlertStatus] + """ super(MetricAlertStatusCollection, self).__init__(**kwargs) self.value = value @@ -1205,12 +1517,12 @@ def __init__( class MetricAlertStatusProperties(msrest.serialization.Model): """An alert status properties. - :param dimensions: An object describing the type of the dimensions. - :type dimensions: dict[str, str] - :param status: status value. - :type status: str - :param timestamp: UTC time when the status was checked. - :type timestamp: ~datetime.datetime + :ivar dimensions: An object describing the type of the dimensions. + :vartype dimensions: dict[str, str] + :ivar status: status value. + :vartype status: str + :ivar timestamp: UTC time when the status was checked. + :vartype timestamp: ~datetime.datetime """ _attribute_map = { @@ -1227,6 +1539,14 @@ def __init__( timestamp: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword dimensions: An object describing the type of the dimensions. + :paramtype dimensions: dict[str, str] + :keyword status: status value. + :paramtype status: str + :keyword timestamp: UTC time when the status was checked. + :paramtype timestamp: ~datetime.datetime + """ super(MetricAlertStatusProperties, self).__init__(**kwargs) self.dimensions = dimensions self.status = status @@ -1238,31 +1558,32 @@ class MetricCriteria(MultiMetricCriteria): All required parameters must be populated in order to send to Azure. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param criterion_type: Required. Specifies the type of threshold criteria.Constant filled by - server. Possible values include: "StaticThresholdCriterion", "DynamicThresholdCriterion". - :type criterion_type: str or ~$(python-base-namespace).v2018_03_01.models.CriterionType - :param name: Required. Name of the criteria. - :type name: str - :param metric_name: Required. Name of the metric. - :type metric_name: str - :param metric_namespace: Namespace of the metric. - :type metric_namespace: str - :param time_aggregation: Required. the criteria time aggregation types. Possible values - include: "Average", "Count", "Minimum", "Maximum", "Total". - :type time_aggregation: str or ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum - :param dimensions: List of dimension conditions. - :type dimensions: list[~$(python-base-namespace).v2018_03_01.models.MetricDimension] - :param skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet + :vartype additional_properties: dict[str, any] + :ivar criterion_type: Required. Specifies the type of threshold criteria.Constant filled by + server. Possible values include: "StaticThresholdCriterion", "DynamicThresholdCriterion". + :vartype criterion_type: str or ~$(python-base-namespace).v2018_03_01.models.CriterionType + :ivar name: Required. Name of the criteria. + :vartype name: str + :ivar metric_name: Required. Name of the metric. + :vartype metric_name: str + :ivar metric_namespace: Namespace of the metric. + :vartype metric_namespace: str + :ivar time_aggregation: Required. the criteria time aggregation types. Possible values include: + "Average", "Count", "Minimum", "Maximum", "Total". + :vartype time_aggregation: str or + ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum + :ivar dimensions: List of dimension conditions. + :vartype dimensions: list[~$(python-base-namespace).v2018_03_01.models.MetricDimension] + :ivar skip_metric_validation: Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped. - :type skip_metric_validation: bool - :param operator: Required. the criteria operator. Possible values include: "Equals", + :vartype skip_metric_validation: bool + :ivar operator: Required. the criteria operator. Possible values include: "Equals", "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or ~$(python-base-namespace).v2018_03_01.models.Operator - :param threshold: Required. the criteria threshold value that activates the alert. - :type threshold: float + :vartype operator: str or ~$(python-base-namespace).v2018_03_01.models.Operator + :ivar threshold: Required. the criteria threshold value that activates the alert. + :vartype threshold: float """ _validation = { @@ -1301,6 +1622,31 @@ def __init__( skip_metric_validation: Optional[bool] = None, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword name: Required. Name of the criteria. + :paramtype name: str + :keyword metric_name: Required. Name of the metric. + :paramtype metric_name: str + :keyword metric_namespace: Namespace of the metric. + :paramtype metric_namespace: str + :keyword time_aggregation: Required. the criteria time aggregation types. Possible values + include: "Average", "Count", "Minimum", "Maximum", "Total". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2018_03_01.models.AggregationTypeEnum + :keyword dimensions: List of dimension conditions. + :paramtype dimensions: list[~$(python-base-namespace).v2018_03_01.models.MetricDimension] + :keyword skip_metric_validation: Allows creating an alert rule on a custom metric that isn't + yet emitted, by causing the metric validation to be skipped. + :paramtype skip_metric_validation: bool + :keyword operator: Required. the criteria operator. Possible values include: "Equals", + "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :paramtype operator: str or ~$(python-base-namespace).v2018_03_01.models.Operator + :keyword threshold: Required. the criteria threshold value that activates the alert. + :paramtype threshold: float + """ super(MetricCriteria, self).__init__(additional_properties=additional_properties, name=name, metric_name=metric_name, metric_namespace=metric_namespace, time_aggregation=time_aggregation, dimensions=dimensions, skip_metric_validation=skip_metric_validation, **kwargs) self.criterion_type = 'StaticThresholdCriterion' # type: str self.operator = operator @@ -1312,12 +1658,12 @@ class MetricDimension(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the dimension. - :type name: str - :param operator: Required. the dimension operator. Only 'Include' and 'Exclude' are supported. - :type operator: str - :param values: Required. list of dimension values. - :type values: list[str] + :ivar name: Required. Name of the dimension. + :vartype name: str + :ivar operator: Required. the dimension operator. Only 'Include' and 'Exclude' are supported. + :vartype operator: str + :ivar values: Required. list of dimension values. + :vartype values: list[str] """ _validation = { @@ -1340,6 +1686,15 @@ def __init__( values: List[str], **kwargs ): + """ + :keyword name: Required. Name of the dimension. + :paramtype name: str + :keyword operator: Required. the dimension operator. Only 'Include' and 'Exclude' are + supported. + :paramtype operator: str + :keyword values: Required. list of dimension values. + :paramtype values: list[str] + """ super(MetricDimension, self).__init__(**kwargs) self.name = name self.operator = operator @@ -1353,13 +1708,13 @@ class SmsReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SMS receiver. Names must be unique across all receivers + :ivar name: Required. The name of the SMS receiver. Names must be unique across all receivers within an action group. - :type name: str - :param country_code: Required. The country code of the SMS receiver. - :type country_code: str - :param phone_number: Required. The phone number of the SMS receiver. - :type phone_number: str + :vartype name: str + :ivar country_code: Required. The country code of the SMS receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the SMS receiver. + :vartype phone_number: str :ivar status: The status of the receiver. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2018_03_01.models.ReceiverStatus @@ -1387,6 +1742,15 @@ def __init__( phone_number: str, **kwargs ): + """ + :keyword name: Required. The name of the SMS receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the SMS receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the SMS receiver. + :paramtype phone_number: str + """ super(SmsReceiver, self).__init__(**kwargs) self.name = name self.country_code = country_code @@ -1399,13 +1763,13 @@ class VoiceReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the voice receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param country_code: Required. The country code of the voice receiver. - :type country_code: str - :param phone_number: Required. The phone number of the voice receiver. - :type phone_number: str + :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar country_code: Required. The country code of the voice receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the voice receiver. + :vartype phone_number: str """ _validation = { @@ -1428,6 +1792,15 @@ def __init__( phone_number: str, **kwargs ): + """ + :keyword name: Required. The name of the voice receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the voice receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the voice receiver. + :paramtype phone_number: str + """ super(VoiceReceiver, self).__init__(**kwargs) self.name = name self.country_code = country_code @@ -1439,11 +1812,11 @@ class WebhookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the webhook receiver. Names must be unique across all + :ivar name: Required. The name of the webhook receiver. Names must be unique across all receivers within an action group. - :type name: str - :param service_uri: Required. The URI where webhooks should be sent. - :type service_uri: str + :vartype name: str + :ivar service_uri: Required. The URI where webhooks should be sent. + :vartype service_uri: str """ _validation = { @@ -1463,6 +1836,13 @@ def __init__( service_uri: str, **kwargs ): + """ + :keyword name: Required. The name of the webhook receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword service_uri: Required. The URI where webhooks should be sent. + :paramtype service_uri: str + """ super(WebhookReceiver, self).__init__(**kwargs) self.name = name self.service_uri = service_uri @@ -1473,21 +1853,20 @@ class WebtestLocationAvailabilityCriteria(MetricAlertCriteria): All required parameters must be populated in order to send to Azure. - :param additional_properties: Unmatched properties from the message are deserialized to this + :ivar additional_properties: Unmatched properties from the message are deserialized to this collection. - :type additional_properties: dict[str, any] - :param odata_type: Required. specifies the type of the alert criteria.Constant filled by - server. Possible values include: - "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", + :vartype additional_properties: dict[str, any] + :ivar odata_type: Required. specifies the type of the alert criteria.Constant filled by server. + Possible values include: "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria", "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria". - :type odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype - :param web_test_id: Required. The Application Insights web test Id. - :type web_test_id: str - :param component_id: Required. The Application Insights resource Id. - :type component_id: str - :param failed_location_count: Required. The number of failed locations. - :type failed_location_count: float + :vartype odata_type: str or ~$(python-base-namespace).v2018_03_01.models.Odatatype + :ivar web_test_id: Required. The Application Insights web test Id. + :vartype web_test_id: str + :ivar component_id: Required. The Application Insights resource Id. + :vartype component_id: str + :ivar failed_location_count: Required. The number of failed locations. + :vartype failed_location_count: float """ _validation = { @@ -1514,6 +1893,17 @@ def __init__( additional_properties: Optional[Dict[str, Any]] = None, **kwargs ): + """ + :keyword additional_properties: Unmatched properties from the message are deserialized to this + collection. + :paramtype additional_properties: dict[str, any] + :keyword web_test_id: Required. The Application Insights web test Id. + :paramtype web_test_id: str + :keyword component_id: Required. The Application Insights resource Id. + :paramtype component_id: str + :keyword failed_location_count: Required. The number of failed locations. + :paramtype failed_location_count: float + """ super(WebtestLocationAvailabilityCriteria, self).__init__(additional_properties=additional_properties, **kwargs) self.odata_type = 'Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria' # type: str self.web_test_id = web_test_id diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_monitor_management_client_enums.py index 3cb30eec4074f..66dfce38fc14a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/models/_monitor_management_client_enums.py @@ -6,27 +6,12 @@ # 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 AggregationTypeEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AggregationTypeEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the criteria time aggregation types. """ @@ -36,14 +21,14 @@ class AggregationTypeEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MAXIMUM = "Maximum" TOTAL = "Total" -class CriterionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CriterionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the type of threshold criteria """ STATIC_THRESHOLD_CRITERION = "StaticThresholdCriterion" DYNAMIC_THRESHOLD_CRITERION = "DynamicThresholdCriterion" -class DynamicThresholdOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DynamicThresholdOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The operator used to compare the metric value against the threshold. """ @@ -51,7 +36,7 @@ class DynamicThresholdOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enu LESS_THAN = "LessThan" GREATER_OR_LESS_THAN = "GreaterOrLessThan" -class DynamicThresholdSensitivity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DynamicThresholdSensitivity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. """ @@ -60,7 +45,7 @@ class DynamicThresholdSensitivity(with_metaclass(_CaseInsensitiveEnumMeta, str, MEDIUM = "Medium" HIGH = "High" -class Odatatype(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Odatatype(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """specifies the type of the alert criteria. """ @@ -68,7 +53,7 @@ class Odatatype(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_AZURE_MONITOR_MULTIPLE_RESOURCE_MULTIPLE_METRIC_CRITERIA = "Microsoft.Azure.Monitor.MultipleResourceMultipleMetricCriteria" MICROSOFT_AZURE_MONITOR_WEBTEST_LOCATION_AVAILABILITY_CRITERIA = "Microsoft.Azure.Monitor.WebtestLocationAvailabilityCriteria" -class Operator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Operator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the criteria operator. """ @@ -78,7 +63,7 @@ class Operator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" -class ReceiverStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReceiverStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates the status of the receiver. Receivers that are not Enabled will not receive any communications. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_action_groups_operations.py index d50c72b70007f..c323470d87c79 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_action_groups_operations.py @@ -5,24 +5,290 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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_delete_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + action_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_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] + 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, + **kwargs + ) + + +def build_list_by_subscription_id_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups') + 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( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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_enable_receiver_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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] + 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class ActionGroupsOperations(object): """ActionGroupsOperations operations. @@ -45,6 +311,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -55,7 +322,7 @@ def create_or_update( # type: (...) -> "_models.ActionGroupResource" """Create a new action group or update an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -71,38 +338,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group, 'ActionGroupResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group, 'ActionGroupResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -115,8 +372,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -126,7 +386,7 @@ def get( # type: (...) -> "_models.ActionGroupResource" """Get an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -140,33 +400,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -175,8 +425,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -186,7 +439,7 @@ def delete( # type: (...) -> None """Delete an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -200,33 +453,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -234,6 +477,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -244,7 +489,7 @@ def update( # type: (...) -> "_models.ActionGroupResource" """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -260,38 +505,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - 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'), - 'actionGroupName': self._serialize.url("action_group_name", action_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -300,8 +535,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def list_by_subscription_id( self, **kwargs # type: Any @@ -311,7 +549,8 @@ def list_by_subscription_id( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ActionGroupList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupList] + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -319,34 +558,29 @@ def list_by_subscription_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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_subscription_id.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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription_id.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_list_by_subscription_id_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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -359,17 +593,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -378,11 +614,12 @@ def list_by_resource_group( # type: (...) -> Iterable["_models.ActionGroupList"] """Get a list of all action groups in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 ActionGroupList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupList] + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -390,35 +627,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -431,17 +664,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.insights/actionGroups'} # type: ignore + @distributed_trace def enable_receiver( self, resource_group_name, # type: str @@ -453,7 +688,7 @@ def enable_receiver( """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -469,41 +704,32 @@ def enable_receiver( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.enable_receiver.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(enable_request, 'EnableRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_enable_receiver_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.enable_receiver.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(enable_request, 'EnableRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(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, 409]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) enable_receiver.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_operations.py index 4a6efc48270ef..b86f5ebcbba12 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_operations.py @@ -5,24 +5,250 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/metricAlerts') + 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, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, 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_get_request( + subscription_id, # type: str + resource_group_name, # type: str + rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", 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, # type: str + resource_group_name, # type: str + rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", 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, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", 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, + **kwargs + ) + + +def build_delete_request( + subscription_id, # type: str + resource_group_name, # type: str + rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", 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 + ) + +# fmt: on class MetricAlertsOperations(object): """MetricAlertsOperations operations. @@ -45,6 +271,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, **kwargs # type: Any @@ -53,8 +280,10 @@ def list_by_subscription( """Retrieve alert rule definitions 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 MetricAlertResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResourceCollection] + :return: An iterator like instance of either MetricAlertResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricAlertResourceCollection"] @@ -62,34 +291,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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_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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('MetricAlertResourceCollection', pipeline_response) + deserialized = self._deserialize("MetricAlertResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,17 +326,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Insights/metricAlerts'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -121,11 +347,13 @@ def list_by_resource_group( # type: (...) -> Iterable["_models.MetricAlertResourceCollection"] """Retrieve alert rule definitions in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 MetricAlertResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResourceCollection] + :return: An iterator like instance of either MetricAlertResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_03_01.models.MetricAlertResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricAlertResourceCollection"] @@ -133,35 +361,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('MetricAlertResourceCollection', pipeline_response) + deserialized = self._deserialize("MetricAlertResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -174,17 +398,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Insights/metricAlerts'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -194,7 +420,7 @@ def get( # type: (...) -> "_models.MetricAlertResource" """Retrieve an alert rule definition. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -208,33 +434,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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'), - 'ruleName': self._serialize.url("rule_name", 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 = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=rule_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MetricAlertResource', pipeline_response) @@ -243,8 +459,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -255,7 +474,7 @@ def create_or_update( # type: (...) -> "_models.MetricAlertResource" """Create or update an metric alert definition. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -271,38 +490,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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'), - 'ruleName': self._serialize.url("rule_name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'MetricAlertResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'MetricAlertResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MetricAlertResource', pipeline_response) @@ -311,8 +520,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -323,7 +535,7 @@ def update( # type: (...) -> "_models.MetricAlertResource" """Update an metric alert definition. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -339,38 +551,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - 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'), - 'ruleName': self._serialize.url("rule_name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'MetricAlertResourcePatch') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'MetricAlertResourcePatch') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MetricAlertResource', pipeline_response) @@ -379,8 +581,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -390,7 +595,7 @@ def delete( # type: (...) -> None """Delete an alert rule definition. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -404,36 +609,27 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-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'), - 'ruleName': self._serialize.url("rule_name", 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 = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=rule_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_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.Insights/metricAlerts/{ruleName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_status_operations.py index 121c90a9fdaaa..9104ddf1d766d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_status_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_03_01/operations/_metric_alerts_status_operations.py @@ -5,23 +5,105 @@ # 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 TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + subscription_id, # type: str + resource_group_name, # type: str + rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", 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_list_by_name_request( + subscription_id, # type: str + resource_group_name, # type: str + rule_name, # type: str + status_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "statusName": _SERIALIZER.url("status_name", status_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 + ) + +# fmt: on class MetricAlertsStatusOperations(object): """MetricAlertsStatusOperations operations. @@ -44,6 +126,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_group_name, # type: str @@ -53,7 +136,7 @@ def list( # type: (...) -> "_models.MetricAlertStatusCollection" """Retrieve an alert rule status. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -67,33 +150,23 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # 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), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", 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 = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=rule_name, + 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) 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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MetricAlertStatusCollection', pipeline_response) @@ -102,8 +175,11 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status'} # type: ignore + + @distributed_trace def list_by_name( self, resource_group_name, # type: str @@ -114,7 +190,7 @@ def list_by_name( # type: (...) -> "_models.MetricAlertStatusCollection" """Retrieve an alert rule status. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -130,34 +206,24 @@ def list_by_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-03-01" - accept = "application/json" - - # Construct URL - url = self.list_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'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - 'statusName': self._serialize.url("status_name", status_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 = build_list_by_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=rule_name, + status_name=status_name, + template_url=self.list_by_name.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MetricAlertStatusCollection', pipeline_response) @@ -166,4 +232,6 @@ def list_by_name( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/metricAlerts/{ruleName}/status/{statusName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_configuration.py index b6128ee1573c7..bc8c9ba5e31ea 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_metadata.json index 1096c3229c333..14e0dd2031244 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "scheduled_query_rules": "ScheduledQueryRulesOperations" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_monitor_management_client.py index 956b94a97ccb6..afdcdec31d92a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_monitor_management_client.py @@ -6,73 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ScheduledQueryRulesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import ScheduledQueryRulesOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. :ivar scheduled_query_rules: ScheduledQueryRulesOperations operations - :vartype scheduled_query_rules: $(python-base-namespace).v2018_04_16.operations.ScheduledQueryRulesOperations + :vartype scheduled_query_rules: + $(python-base-namespace).v2018_04_16.operations.ScheduledQueryRulesOperations :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.scheduled_query_rules = ScheduledQueryRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.scheduled_query_rules = ScheduledQueryRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_configuration.py index 601c1798da2a0..8af9a49138cd7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_monitor_management_client.py index ea933cca6b443..c73fd5d4fc0e6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_monitor_management_client.py @@ -6,69 +6,77 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import MonitorManagementClientConfiguration from .operations import ScheduledQueryRulesOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar scheduled_query_rules: ScheduledQueryRulesOperations operations - :vartype scheduled_query_rules: $(python-base-namespace).v2018_04_16.aio.operations.ScheduledQueryRulesOperations + :vartype scheduled_query_rules: + $(python-base-namespace).v2018_04_16.aio.operations.ScheduledQueryRulesOperations :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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.scheduled_query_rules = ScheduledQueryRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.scheduled_query_rules = ScheduledQueryRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_scheduled_query_rules_operations.py index 67665d0db68e9..e85418a0b0303 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_scheduled_query_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/aio/operations/_scheduled_query_rules_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._scheduled_query_rules_operations import build_create_or_update_request, build_delete_request, build_get_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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -50,7 +56,7 @@ async def create_or_update( ) -> "_models.LogSearchRuleResource": """Creates or updates an log search rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -66,38 +72,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-16" - 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'), - 'ruleName': self._serialize.url("rule_name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'LogSearchRuleResource') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'LogSearchRuleResource') - 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.failsafe_deserialize(_models.ErrorContract, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -110,8 +106,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -120,7 +119,7 @@ async def get( ) -> "_models.LogSearchRuleResource": """Gets an Log Search rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -134,33 +133,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-16" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorContract, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('LogSearchRuleResource', pipeline_response) @@ -169,8 +158,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -180,7 +172,7 @@ async def update( ) -> "_models.LogSearchRuleResource": """Update log search Rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -196,38 +188,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-16" - 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'), - 'ruleName': self._serialize.url("rule_name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'LogSearchRuleResourcePatch') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'LogSearchRuleResourcePatch') - 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.failsafe_deserialize(_models.ErrorContract, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('LogSearchRuleResource', pipeline_response) @@ -236,8 +218,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -246,7 +231,7 @@ async def delete( ) -> None: """Deletes a Log Search rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -260,33 +245,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-16" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorContract, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -294,6 +269,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, filter: Optional[str] = None, @@ -305,8 +282,10 @@ def list_by_subscription( https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogSearchRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourceCollection] + :return: An iterator like instance of either LogSearchRuleResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LogSearchRuleResourceCollection"] @@ -314,36 +293,31 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-16" - 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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_subscription.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_list_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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('LogSearchRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("LogSearchRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -356,17 +330,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, 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.Insights/scheduledQueryRules'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -375,14 +351,16 @@ def list_by_resource_group( ) -> AsyncIterable["_models.LogSearchRuleResourceCollection"]: """List the Log Search rules within a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param filter: The filter to apply on the operation. For more information please see https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogSearchRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourceCollection] + :return: An iterator like instance of either LogSearchRuleResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LogSearchRuleResourceCollection"] @@ -390,37 +368,33 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-16" - 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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 filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + 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('LogSearchRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("LogSearchRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -433,12 +407,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models.py index b59b0546318ab..3026ff4c5df7e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models.py @@ -18,9 +18,9 @@ class Action(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. Specifies the action. Supported values - AlertingAction, + :ivar odata_type: Required. Specifies the action. Supported values - AlertingAction, LogToMetricAction.Constant filled by server. - :type odata_type: str + :vartype odata_type: str """ _validation = { @@ -39,6 +39,8 @@ def __init__( self, **kwargs ): + """ + """ super(Action, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] @@ -48,18 +50,18 @@ class AlertingAction(Action): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. Specifies the action. Supported values - AlertingAction, + :ivar odata_type: Required. Specifies the action. Supported values - AlertingAction, LogToMetricAction.Constant filled by server. - :type odata_type: str - :param severity: Required. Severity of the alert. Possible values include: "0", "1", "2", "3", + :vartype odata_type: str + :ivar severity: Required. Severity of the alert. Possible values include: "0", "1", "2", "3", "4". - :type severity: str or ~$(python-base-namespace).v2018_04_16.models.AlertSeverity - :param azns_action: Azure action group reference. - :type azns_action: ~$(python-base-namespace).v2018_04_16.models.AzNsActionGroup - :param throttling_in_min: time (in minutes) for which Alerts should be throttled or suppressed. - :type throttling_in_min: int - :param trigger: Required. The trigger condition that results in the alert rule being. - :type trigger: ~$(python-base-namespace).v2018_04_16.models.TriggerCondition + :vartype severity: str or ~$(python-base-namespace).v2018_04_16.models.AlertSeverity + :ivar azns_action: Azure action group reference. + :vartype azns_action: ~$(python-base-namespace).v2018_04_16.models.AzNsActionGroup + :ivar throttling_in_min: time (in minutes) for which Alerts should be throttled or suppressed. + :vartype throttling_in_min: int + :ivar trigger: Required. The trigger condition that results in the alert rule being. + :vartype trigger: ~$(python-base-namespace).v2018_04_16.models.TriggerCondition """ _validation = { @@ -80,6 +82,18 @@ def __init__( self, **kwargs ): + """ + :keyword severity: Required. Severity of the alert. Possible values include: "0", "1", "2", + "3", "4". + :paramtype severity: str or ~$(python-base-namespace).v2018_04_16.models.AlertSeverity + :keyword azns_action: Azure action group reference. + :paramtype azns_action: ~$(python-base-namespace).v2018_04_16.models.AzNsActionGroup + :keyword throttling_in_min: time (in minutes) for which Alerts should be throttled or + suppressed. + :paramtype throttling_in_min: int + :keyword trigger: Required. The trigger condition that results in the alert rule being. + :paramtype trigger: ~$(python-base-namespace).v2018_04_16.models.TriggerCondition + """ super(AlertingAction, self).__init__(**kwargs) self.odata_type = 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction' # type: str self.severity = kwargs['severity'] @@ -91,13 +105,13 @@ def __init__( class AzNsActionGroup(msrest.serialization.Model): """Azure action group. - :param action_group: Azure Action Group reference. - :type action_group: list[str] - :param email_subject: Custom subject override for all email ids in Azure action group. - :type email_subject: str - :param custom_webhook_payload: Custom payload to be sent for all webhook URI in Azure action + :ivar action_group: Azure Action Group reference. + :vartype action_group: list[str] + :ivar email_subject: Custom subject override for all email ids in Azure action group. + :vartype email_subject: str + :ivar custom_webhook_payload: Custom payload to be sent for all webhook URI in Azure action group. - :type custom_webhook_payload: str + :vartype custom_webhook_payload: str """ _attribute_map = { @@ -110,6 +124,15 @@ def __init__( self, **kwargs ): + """ + :keyword action_group: Azure Action Group reference. + :paramtype action_group: list[str] + :keyword email_subject: Custom subject override for all email ids in Azure action group. + :paramtype email_subject: str + :keyword custom_webhook_payload: Custom payload to be sent for all webhook URI in Azure action + group. + :paramtype custom_webhook_payload: str + """ super(AzNsActionGroup, self).__init__(**kwargs) self.action_group = kwargs.get('action_group', None) self.email_subject = kwargs.get('email_subject', None) @@ -121,10 +144,10 @@ class Criteria(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param metric_name: Required. Name of the metric. - :type metric_name: str - :param dimensions: List of Dimensions for creating metric. - :type dimensions: list[~$(python-base-namespace).v2018_04_16.models.Dimension] + :ivar metric_name: Required. Name of the metric. + :vartype metric_name: str + :ivar dimensions: List of Dimensions for creating metric. + :vartype dimensions: list[~$(python-base-namespace).v2018_04_16.models.Dimension] """ _validation = { @@ -140,6 +163,12 @@ def __init__( self, **kwargs ): + """ + :keyword metric_name: Required. Name of the metric. + :paramtype metric_name: str + :keyword dimensions: List of Dimensions for creating metric. + :paramtype dimensions: list[~$(python-base-namespace).v2018_04_16.models.Dimension] + """ super(Criteria, self).__init__(**kwargs) self.metric_name = kwargs['metric_name'] self.dimensions = kwargs.get('dimensions', None) @@ -150,12 +179,12 @@ class Dimension(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the dimension. - :type name: str - :param operator: Required. Operator for dimension values. Possible values include: "Include". - :type operator: str or ~$(python-base-namespace).v2018_04_16.models.Operator - :param values: Required. List of dimension values. - :type values: list[str] + :ivar name: Required. Name of the dimension. + :vartype name: str + :ivar operator: Required. Operator for dimension values. Possible values include: "Include". + :vartype operator: str or ~$(python-base-namespace).v2018_04_16.models.Operator + :ivar values: Required. List of dimension values. + :vartype values: list[str] """ _validation = { @@ -174,6 +203,14 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. Name of the dimension. + :paramtype name: str + :keyword operator: Required. Operator for dimension values. Possible values include: "Include". + :paramtype operator: str or ~$(python-base-namespace).v2018_04_16.models.Operator + :keyword values: Required. List of dimension values. + :paramtype values: list[str] + """ super(Dimension, self).__init__(**kwargs) self.name = kwargs['name'] self.operator = kwargs['operator'] @@ -183,8 +220,8 @@ def __init__( class ErrorContract(msrest.serialization.Model): """Describes the format of Error response. - :param error: The error details. - :type error: ~$(python-base-namespace).v2018_04_16.models.ErrorResponse + :ivar error: The error details. + :vartype error: ~$(python-base-namespace).v2018_04_16.models.ErrorResponse """ _attribute_map = { @@ -195,6 +232,10 @@ def __init__( self, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~$(python-base-namespace).v2018_04_16.models.ErrorResponse + """ super(ErrorContract, self).__init__(**kwargs) self.error = kwargs.get('error', None) @@ -202,10 +243,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -217,6 +258,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -225,19 +272,19 @@ def __init__( class LogMetricTrigger(msrest.serialization.Model): """A log metrics trigger descriptor. - :param threshold_operator: Evaluation operation for Metric -'GreaterThan' or 'LessThan' or + :ivar threshold_operator: Evaluation operation for Metric -'GreaterThan' or 'LessThan' or 'Equal'. Possible values include: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", "Equal". Default value: "GreaterThanOrEqual". - :type threshold_operator: str or + :vartype threshold_operator: str or ~$(python-base-namespace).v2018_04_16.models.ConditionalOperator - :param threshold: The threshold of the metric trigger. - :type threshold: float - :param metric_trigger_type: Metric Trigger Type - 'Consecutive' or 'Total'. Possible values + :ivar threshold: The threshold of the metric trigger. + :vartype threshold: float + :ivar metric_trigger_type: Metric Trigger Type - 'Consecutive' or 'Total'. Possible values include: "Consecutive", "Total". Default value: "Consecutive". - :type metric_trigger_type: str or + :vartype metric_trigger_type: str or ~$(python-base-namespace).v2018_04_16.models.MetricTriggerType - :param metric_column: Evaluation of metric on a particular column. - :type metric_column: str + :ivar metric_column: Evaluation of metric on a particular column. + :vartype metric_column: str """ _attribute_map = { @@ -251,6 +298,21 @@ def __init__( self, **kwargs ): + """ + :keyword threshold_operator: Evaluation operation for Metric -'GreaterThan' or 'LessThan' or + 'Equal'. Possible values include: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", + "LessThan", "Equal". Default value: "GreaterThanOrEqual". + :paramtype threshold_operator: str or + ~$(python-base-namespace).v2018_04_16.models.ConditionalOperator + :keyword threshold: The threshold of the metric trigger. + :paramtype threshold: float + :keyword metric_trigger_type: Metric Trigger Type - 'Consecutive' or 'Total'. Possible values + include: "Consecutive", "Total". Default value: "Consecutive". + :paramtype metric_trigger_type: str or + ~$(python-base-namespace).v2018_04_16.models.MetricTriggerType + :keyword metric_column: Evaluation of metric on a particular column. + :paramtype metric_column: str + """ super(LogMetricTrigger, self).__init__(**kwargs) self.threshold_operator = kwargs.get('threshold_operator', "GreaterThanOrEqual") self.threshold = kwargs.get('threshold', None) @@ -271,10 +333,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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] :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. @@ -310,6 +372,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -333,10 +401,10 @@ class LogSearchRuleResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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] :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. @@ -351,29 +419,29 @@ class LogSearchRuleResource(Resource): :vartype created_with_api_version: str :ivar is_legacy_log_analytics_rule: True if alert rule is legacy Log Analytic rule. :vartype is_legacy_log_analytics_rule: bool - :param description: The description of the Log Search rule. - :type description: str - :param display_name: The display name of the alert rule. - :type display_name: str - :param auto_mitigate: The flag that indicates whether the alert should be automatically - resolved or not. The default is false. - :type auto_mitigate: bool - :param enabled: The flag which indicates whether the Log Search rule is enabled. Value should - be true or false. Possible values include: "true", "false". - :type enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled + :ivar description: The description of the Log Search rule. + :vartype description: str + :ivar display_name: The display name of the alert rule. + :vartype display_name: str + :ivar auto_mitigate: The flag that indicates whether the alert should be automatically resolved + or not. The default is false. + :vartype auto_mitigate: bool + :ivar enabled: The flag which indicates whether the Log Search rule is enabled. Value should be + true or false. Possible values include: "true", "false". + :vartype enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled :ivar last_updated_time: Last time the rule was updated in IS08601 format. :vartype last_updated_time: ~datetime.datetime :ivar provisioning_state: Provisioning state of the scheduled query rule. Possible values include: "Succeeded", "Deploying", "Canceled", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2018_04_16.models.ProvisioningState - :param source: Required. Data Source against which rule will Query Data. - :type source: ~$(python-base-namespace).v2018_04_16.models.Source - :param schedule: Schedule (Frequency, Time Window) for rule. Required for action type - + :ivar source: Required. Data Source against which rule will Query Data. + :vartype source: ~$(python-base-namespace).v2018_04_16.models.Source + :ivar schedule: Schedule (Frequency, Time Window) for rule. Required for action type - AlertingAction. - :type schedule: ~$(python-base-namespace).v2018_04_16.models.Schedule - :param action: Required. Action needs to be taken on rule execution. - :type action: ~$(python-base-namespace).v2018_04_16.models.Action + :vartype schedule: ~$(python-base-namespace).v2018_04_16.models.Schedule + :ivar action: Required. Action needs to be taken on rule execution. + :vartype action: ~$(python-base-namespace).v2018_04_16.models.Action """ _validation = { @@ -416,6 +484,29 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword description: The description of the Log Search rule. + :paramtype description: str + :keyword display_name: The display name of the alert rule. + :paramtype display_name: str + :keyword auto_mitigate: The flag that indicates whether the alert should be automatically + resolved or not. The default is false. + :paramtype auto_mitigate: bool + :keyword enabled: The flag which indicates whether the Log Search rule is enabled. Value should + be true or false. Possible values include: "true", "false". + :paramtype enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled + :keyword source: Required. Data Source against which rule will Query Data. + :paramtype source: ~$(python-base-namespace).v2018_04_16.models.Source + :keyword schedule: Schedule (Frequency, Time Window) for rule. Required for action type - + AlertingAction. + :paramtype schedule: ~$(python-base-namespace).v2018_04_16.models.Schedule + :keyword action: Required. Action needs to be taken on rule execution. + :paramtype action: ~$(python-base-namespace).v2018_04_16.models.Action + """ super(LogSearchRuleResource, self).__init__(**kwargs) self.created_with_api_version = None self.is_legacy_log_analytics_rule = None @@ -433,8 +524,8 @@ def __init__( class LogSearchRuleResourceCollection(msrest.serialization.Model): """Represents a collection of Log Search rule resources. - :param value: The values for the Log Search Rule resources. - :type value: list[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource] + :ivar value: The values for the Log Search Rule resources. + :vartype value: list[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource] """ _attribute_map = { @@ -445,6 +536,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: The values for the Log Search Rule resources. + :paramtype value: list[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource] + """ super(LogSearchRuleResourceCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -452,11 +547,11 @@ def __init__( class LogSearchRuleResourcePatch(msrest.serialization.Model): """The log search rule resource for patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param enabled: The flag which indicates whether the Log Search rule is enabled. Value should - be true or false. Possible values include: "true", "false". - :type enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: The flag which indicates whether the Log Search rule is enabled. Value should be + true or false. Possible values include: "true", "false". + :vartype enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled """ _attribute_map = { @@ -468,6 +563,13 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: The flag which indicates whether the Log Search rule is enabled. Value should + be true or false. Possible values include: "true", "false". + :paramtype enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled + """ super(LogSearchRuleResourcePatch, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.enabled = kwargs.get('enabled', None) @@ -478,11 +580,11 @@ class LogToMetricAction(Action): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. Specifies the action. Supported values - AlertingAction, + :ivar odata_type: Required. Specifies the action. Supported values - AlertingAction, LogToMetricAction.Constant filled by server. - :type odata_type: str - :param criteria: Required. Criteria of Metric. - :type criteria: list[~$(python-base-namespace).v2018_04_16.models.Criteria] + :vartype odata_type: str + :ivar criteria: Required. Criteria of Metric. + :vartype criteria: list[~$(python-base-namespace).v2018_04_16.models.Criteria] """ _validation = { @@ -499,6 +601,10 @@ def __init__( self, **kwargs ): + """ + :keyword criteria: Required. Criteria of Metric. + :paramtype criteria: list[~$(python-base-namespace).v2018_04_16.models.Criteria] + """ super(LogToMetricAction, self).__init__(**kwargs) self.odata_type = 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction' # type: str self.criteria = kwargs['criteria'] @@ -509,12 +615,12 @@ class Schedule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param frequency_in_minutes: Required. frequency (in minutes) at which rule condition should be + :ivar frequency_in_minutes: Required. frequency (in minutes) at which rule condition should be evaluated. - :type frequency_in_minutes: int - :param time_window_in_minutes: Required. Time window for which data needs to be fetched for + :vartype frequency_in_minutes: int + :ivar time_window_in_minutes: Required. Time window for which data needs to be fetched for query (should be greater than or equal to frequencyInMinutes). - :type time_window_in_minutes: int + :vartype time_window_in_minutes: int """ _validation = { @@ -531,6 +637,14 @@ def __init__( self, **kwargs ): + """ + :keyword frequency_in_minutes: Required. frequency (in minutes) at which rule condition should + be evaluated. + :paramtype frequency_in_minutes: int + :keyword time_window_in_minutes: Required. Time window for which data needs to be fetched for + query (should be greater than or equal to frequencyInMinutes). + :paramtype time_window_in_minutes: int + """ super(Schedule, self).__init__(**kwargs) self.frequency_in_minutes = kwargs['frequency_in_minutes'] self.time_window_in_minutes = kwargs['time_window_in_minutes'] @@ -541,14 +655,14 @@ class Source(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param query: Log search query. Required for action type - AlertingAction. - :type query: str - :param authorized_resources: List of Resource referred into query. - :type authorized_resources: list[str] - :param data_source_id: Required. The resource uri over which log search query is to be run. - :type data_source_id: str - :param query_type: Set value to 'ResultCount' . Possible values include: "ResultCount". - :type query_type: str or ~$(python-base-namespace).v2018_04_16.models.QueryType + :ivar query: Log search query. Required for action type - AlertingAction. + :vartype query: str + :ivar authorized_resources: List of Resource referred into query. + :vartype authorized_resources: list[str] + :ivar data_source_id: Required. The resource uri over which log search query is to be run. + :vartype data_source_id: str + :ivar query_type: Set value to 'ResultCount' . Possible values include: "ResultCount". + :vartype query_type: str or ~$(python-base-namespace).v2018_04_16.models.QueryType """ _validation = { @@ -566,6 +680,16 @@ def __init__( self, **kwargs ): + """ + :keyword query: Log search query. Required for action type - AlertingAction. + :paramtype query: str + :keyword authorized_resources: List of Resource referred into query. + :paramtype authorized_resources: list[str] + :keyword data_source_id: Required. The resource uri over which log search query is to be run. + :paramtype data_source_id: str + :keyword query_type: Set value to 'ResultCount' . Possible values include: "ResultCount". + :paramtype query_type: str or ~$(python-base-namespace).v2018_04_16.models.QueryType + """ super(Source, self).__init__(**kwargs) self.query = kwargs.get('query', None) self.authorized_resources = kwargs.get('authorized_resources', None) @@ -578,15 +702,15 @@ class TriggerCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param threshold_operator: Required. Evaluation operation for rule - 'GreaterThan' or - 'LessThan. Possible values include: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", - "LessThan", "Equal". Default value: "GreaterThanOrEqual". - :type threshold_operator: str or + :ivar threshold_operator: Required. Evaluation operation for rule - 'GreaterThan' or 'LessThan. + Possible values include: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", + "Equal". Default value: "GreaterThanOrEqual". + :vartype threshold_operator: str or ~$(python-base-namespace).v2018_04_16.models.ConditionalOperator - :param threshold: Required. Result or count threshold based on which rule should be triggered. - :type threshold: float - :param metric_trigger: Trigger condition for metric query rule. - :type metric_trigger: ~$(python-base-namespace).v2018_04_16.models.LogMetricTrigger + :ivar threshold: Required. Result or count threshold based on which rule should be triggered. + :vartype threshold: float + :ivar metric_trigger: Trigger condition for metric query rule. + :vartype metric_trigger: ~$(python-base-namespace).v2018_04_16.models.LogMetricTrigger """ _validation = { @@ -604,6 +728,18 @@ def __init__( self, **kwargs ): + """ + :keyword threshold_operator: Required. Evaluation operation for rule - 'GreaterThan' or + 'LessThan. Possible values include: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", + "LessThan", "Equal". Default value: "GreaterThanOrEqual". + :paramtype threshold_operator: str or + ~$(python-base-namespace).v2018_04_16.models.ConditionalOperator + :keyword threshold: Required. Result or count threshold based on which rule should be + triggered. + :paramtype threshold: float + :keyword metric_trigger: Trigger condition for metric query rule. + :paramtype metric_trigger: ~$(python-base-namespace).v2018_04_16.models.LogMetricTrigger + """ super(TriggerCondition, self).__init__(**kwargs) self.threshold_operator = kwargs.get('threshold_operator', "GreaterThanOrEqual") self.threshold = kwargs['threshold'] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models_py3.py index 97d28d3679a99..f4941e6938ed9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_models_py3.py @@ -22,9 +22,9 @@ class Action(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. Specifies the action. Supported values - AlertingAction, + :ivar odata_type: Required. Specifies the action. Supported values - AlertingAction, LogToMetricAction.Constant filled by server. - :type odata_type: str + :vartype odata_type: str """ _validation = { @@ -43,6 +43,8 @@ def __init__( self, **kwargs ): + """ + """ super(Action, self).__init__(**kwargs) self.odata_type = None # type: Optional[str] @@ -52,18 +54,18 @@ class AlertingAction(Action): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. Specifies the action. Supported values - AlertingAction, + :ivar odata_type: Required. Specifies the action. Supported values - AlertingAction, LogToMetricAction.Constant filled by server. - :type odata_type: str - :param severity: Required. Severity of the alert. Possible values include: "0", "1", "2", "3", + :vartype odata_type: str + :ivar severity: Required. Severity of the alert. Possible values include: "0", "1", "2", "3", "4". - :type severity: str or ~$(python-base-namespace).v2018_04_16.models.AlertSeverity - :param azns_action: Azure action group reference. - :type azns_action: ~$(python-base-namespace).v2018_04_16.models.AzNsActionGroup - :param throttling_in_min: time (in minutes) for which Alerts should be throttled or suppressed. - :type throttling_in_min: int - :param trigger: Required. The trigger condition that results in the alert rule being. - :type trigger: ~$(python-base-namespace).v2018_04_16.models.TriggerCondition + :vartype severity: str or ~$(python-base-namespace).v2018_04_16.models.AlertSeverity + :ivar azns_action: Azure action group reference. + :vartype azns_action: ~$(python-base-namespace).v2018_04_16.models.AzNsActionGroup + :ivar throttling_in_min: time (in minutes) for which Alerts should be throttled or suppressed. + :vartype throttling_in_min: int + :ivar trigger: Required. The trigger condition that results in the alert rule being. + :vartype trigger: ~$(python-base-namespace).v2018_04_16.models.TriggerCondition """ _validation = { @@ -89,6 +91,18 @@ def __init__( throttling_in_min: Optional[int] = None, **kwargs ): + """ + :keyword severity: Required. Severity of the alert. Possible values include: "0", "1", "2", + "3", "4". + :paramtype severity: str or ~$(python-base-namespace).v2018_04_16.models.AlertSeverity + :keyword azns_action: Azure action group reference. + :paramtype azns_action: ~$(python-base-namespace).v2018_04_16.models.AzNsActionGroup + :keyword throttling_in_min: time (in minutes) for which Alerts should be throttled or + suppressed. + :paramtype throttling_in_min: int + :keyword trigger: Required. The trigger condition that results in the alert rule being. + :paramtype trigger: ~$(python-base-namespace).v2018_04_16.models.TriggerCondition + """ super(AlertingAction, self).__init__(**kwargs) self.odata_type = 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction' # type: str self.severity = severity @@ -100,13 +114,13 @@ def __init__( class AzNsActionGroup(msrest.serialization.Model): """Azure action group. - :param action_group: Azure Action Group reference. - :type action_group: list[str] - :param email_subject: Custom subject override for all email ids in Azure action group. - :type email_subject: str - :param custom_webhook_payload: Custom payload to be sent for all webhook URI in Azure action + :ivar action_group: Azure Action Group reference. + :vartype action_group: list[str] + :ivar email_subject: Custom subject override for all email ids in Azure action group. + :vartype email_subject: str + :ivar custom_webhook_payload: Custom payload to be sent for all webhook URI in Azure action group. - :type custom_webhook_payload: str + :vartype custom_webhook_payload: str """ _attribute_map = { @@ -123,6 +137,15 @@ def __init__( custom_webhook_payload: Optional[str] = None, **kwargs ): + """ + :keyword action_group: Azure Action Group reference. + :paramtype action_group: list[str] + :keyword email_subject: Custom subject override for all email ids in Azure action group. + :paramtype email_subject: str + :keyword custom_webhook_payload: Custom payload to be sent for all webhook URI in Azure action + group. + :paramtype custom_webhook_payload: str + """ super(AzNsActionGroup, self).__init__(**kwargs) self.action_group = action_group self.email_subject = email_subject @@ -134,10 +157,10 @@ class Criteria(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param metric_name: Required. Name of the metric. - :type metric_name: str - :param dimensions: List of Dimensions for creating metric. - :type dimensions: list[~$(python-base-namespace).v2018_04_16.models.Dimension] + :ivar metric_name: Required. Name of the metric. + :vartype metric_name: str + :ivar dimensions: List of Dimensions for creating metric. + :vartype dimensions: list[~$(python-base-namespace).v2018_04_16.models.Dimension] """ _validation = { @@ -156,6 +179,12 @@ def __init__( dimensions: Optional[List["Dimension"]] = None, **kwargs ): + """ + :keyword metric_name: Required. Name of the metric. + :paramtype metric_name: str + :keyword dimensions: List of Dimensions for creating metric. + :paramtype dimensions: list[~$(python-base-namespace).v2018_04_16.models.Dimension] + """ super(Criteria, self).__init__(**kwargs) self.metric_name = metric_name self.dimensions = dimensions @@ -166,12 +195,12 @@ class Dimension(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the dimension. - :type name: str - :param operator: Required. Operator for dimension values. Possible values include: "Include". - :type operator: str or ~$(python-base-namespace).v2018_04_16.models.Operator - :param values: Required. List of dimension values. - :type values: list[str] + :ivar name: Required. Name of the dimension. + :vartype name: str + :ivar operator: Required. Operator for dimension values. Possible values include: "Include". + :vartype operator: str or ~$(python-base-namespace).v2018_04_16.models.Operator + :ivar values: Required. List of dimension values. + :vartype values: list[str] """ _validation = { @@ -194,6 +223,14 @@ def __init__( values: List[str], **kwargs ): + """ + :keyword name: Required. Name of the dimension. + :paramtype name: str + :keyword operator: Required. Operator for dimension values. Possible values include: "Include". + :paramtype operator: str or ~$(python-base-namespace).v2018_04_16.models.Operator + :keyword values: Required. List of dimension values. + :paramtype values: list[str] + """ super(Dimension, self).__init__(**kwargs) self.name = name self.operator = operator @@ -203,8 +240,8 @@ def __init__( class ErrorContract(msrest.serialization.Model): """Describes the format of Error response. - :param error: The error details. - :type error: ~$(python-base-namespace).v2018_04_16.models.ErrorResponse + :ivar error: The error details. + :vartype error: ~$(python-base-namespace).v2018_04_16.models.ErrorResponse """ _attribute_map = { @@ -217,6 +254,10 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~$(python-base-namespace).v2018_04_16.models.ErrorResponse + """ super(ErrorContract, self).__init__(**kwargs) self.error = error @@ -224,10 +265,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -242,6 +283,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -250,19 +297,19 @@ def __init__( class LogMetricTrigger(msrest.serialization.Model): """A log metrics trigger descriptor. - :param threshold_operator: Evaluation operation for Metric -'GreaterThan' or 'LessThan' or + :ivar threshold_operator: Evaluation operation for Metric -'GreaterThan' or 'LessThan' or 'Equal'. Possible values include: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", "Equal". Default value: "GreaterThanOrEqual". - :type threshold_operator: str or + :vartype threshold_operator: str or ~$(python-base-namespace).v2018_04_16.models.ConditionalOperator - :param threshold: The threshold of the metric trigger. - :type threshold: float - :param metric_trigger_type: Metric Trigger Type - 'Consecutive' or 'Total'. Possible values + :ivar threshold: The threshold of the metric trigger. + :vartype threshold: float + :ivar metric_trigger_type: Metric Trigger Type - 'Consecutive' or 'Total'. Possible values include: "Consecutive", "Total". Default value: "Consecutive". - :type metric_trigger_type: str or + :vartype metric_trigger_type: str or ~$(python-base-namespace).v2018_04_16.models.MetricTriggerType - :param metric_column: Evaluation of metric on a particular column. - :type metric_column: str + :ivar metric_column: Evaluation of metric on a particular column. + :vartype metric_column: str """ _attribute_map = { @@ -281,6 +328,21 @@ def __init__( metric_column: Optional[str] = None, **kwargs ): + """ + :keyword threshold_operator: Evaluation operation for Metric -'GreaterThan' or 'LessThan' or + 'Equal'. Possible values include: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", + "LessThan", "Equal". Default value: "GreaterThanOrEqual". + :paramtype threshold_operator: str or + ~$(python-base-namespace).v2018_04_16.models.ConditionalOperator + :keyword threshold: The threshold of the metric trigger. + :paramtype threshold: float + :keyword metric_trigger_type: Metric Trigger Type - 'Consecutive' or 'Total'. Possible values + include: "Consecutive", "Total". Default value: "Consecutive". + :paramtype metric_trigger_type: str or + ~$(python-base-namespace).v2018_04_16.models.MetricTriggerType + :keyword metric_column: Evaluation of metric on a particular column. + :paramtype metric_column: str + """ super(LogMetricTrigger, self).__init__(**kwargs) self.threshold_operator = threshold_operator self.threshold = threshold @@ -301,10 +363,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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] :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. @@ -343,6 +405,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -366,10 +434,10 @@ class LogSearchRuleResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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] :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. @@ -384,29 +452,29 @@ class LogSearchRuleResource(Resource): :vartype created_with_api_version: str :ivar is_legacy_log_analytics_rule: True if alert rule is legacy Log Analytic rule. :vartype is_legacy_log_analytics_rule: bool - :param description: The description of the Log Search rule. - :type description: str - :param display_name: The display name of the alert rule. - :type display_name: str - :param auto_mitigate: The flag that indicates whether the alert should be automatically - resolved or not. The default is false. - :type auto_mitigate: bool - :param enabled: The flag which indicates whether the Log Search rule is enabled. Value should - be true or false. Possible values include: "true", "false". - :type enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled + :ivar description: The description of the Log Search rule. + :vartype description: str + :ivar display_name: The display name of the alert rule. + :vartype display_name: str + :ivar auto_mitigate: The flag that indicates whether the alert should be automatically resolved + or not. The default is false. + :vartype auto_mitigate: bool + :ivar enabled: The flag which indicates whether the Log Search rule is enabled. Value should be + true or false. Possible values include: "true", "false". + :vartype enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled :ivar last_updated_time: Last time the rule was updated in IS08601 format. :vartype last_updated_time: ~datetime.datetime :ivar provisioning_state: Provisioning state of the scheduled query rule. Possible values include: "Succeeded", "Deploying", "Canceled", "Failed". :vartype provisioning_state: str or ~$(python-base-namespace).v2018_04_16.models.ProvisioningState - :param source: Required. Data Source against which rule will Query Data. - :type source: ~$(python-base-namespace).v2018_04_16.models.Source - :param schedule: Schedule (Frequency, Time Window) for rule. Required for action type - + :ivar source: Required. Data Source against which rule will Query Data. + :vartype source: ~$(python-base-namespace).v2018_04_16.models.Source + :ivar schedule: Schedule (Frequency, Time Window) for rule. Required for action type - AlertingAction. - :type schedule: ~$(python-base-namespace).v2018_04_16.models.Schedule - :param action: Required. Action needs to be taken on rule execution. - :type action: ~$(python-base-namespace).v2018_04_16.models.Action + :vartype schedule: ~$(python-base-namespace).v2018_04_16.models.Schedule + :ivar action: Required. Action needs to be taken on rule execution. + :vartype action: ~$(python-base-namespace).v2018_04_16.models.Action """ _validation = { @@ -459,6 +527,29 @@ def __init__( schedule: Optional["Schedule"] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword description: The description of the Log Search rule. + :paramtype description: str + :keyword display_name: The display name of the alert rule. + :paramtype display_name: str + :keyword auto_mitigate: The flag that indicates whether the alert should be automatically + resolved or not. The default is false. + :paramtype auto_mitigate: bool + :keyword enabled: The flag which indicates whether the Log Search rule is enabled. Value should + be true or false. Possible values include: "true", "false". + :paramtype enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled + :keyword source: Required. Data Source against which rule will Query Data. + :paramtype source: ~$(python-base-namespace).v2018_04_16.models.Source + :keyword schedule: Schedule (Frequency, Time Window) for rule. Required for action type - + AlertingAction. + :paramtype schedule: ~$(python-base-namespace).v2018_04_16.models.Schedule + :keyword action: Required. Action needs to be taken on rule execution. + :paramtype action: ~$(python-base-namespace).v2018_04_16.models.Action + """ super(LogSearchRuleResource, self).__init__(location=location, tags=tags, **kwargs) self.created_with_api_version = None self.is_legacy_log_analytics_rule = None @@ -476,8 +567,8 @@ def __init__( class LogSearchRuleResourceCollection(msrest.serialization.Model): """Represents a collection of Log Search rule resources. - :param value: The values for the Log Search Rule resources. - :type value: list[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource] + :ivar value: The values for the Log Search Rule resources. + :vartype value: list[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource] """ _attribute_map = { @@ -490,6 +581,10 @@ def __init__( value: Optional[List["LogSearchRuleResource"]] = None, **kwargs ): + """ + :keyword value: The values for the Log Search Rule resources. + :paramtype value: list[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResource] + """ super(LogSearchRuleResourceCollection, self).__init__(**kwargs) self.value = value @@ -497,11 +592,11 @@ def __init__( class LogSearchRuleResourcePatch(msrest.serialization.Model): """The log search rule resource for patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param enabled: The flag which indicates whether the Log Search rule is enabled. Value should - be true or false. Possible values include: "true", "false". - :type enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: The flag which indicates whether the Log Search rule is enabled. Value should be + true or false. Possible values include: "true", "false". + :vartype enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled """ _attribute_map = { @@ -516,6 +611,13 @@ def __init__( enabled: Optional[Union[str, "Enabled"]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: The flag which indicates whether the Log Search rule is enabled. Value should + be true or false. Possible values include: "true", "false". + :paramtype enabled: str or ~$(python-base-namespace).v2018_04_16.models.Enabled + """ super(LogSearchRuleResourcePatch, self).__init__(**kwargs) self.tags = tags self.enabled = enabled @@ -526,11 +628,11 @@ class LogToMetricAction(Action): All required parameters must be populated in order to send to Azure. - :param odata_type: Required. Specifies the action. Supported values - AlertingAction, + :ivar odata_type: Required. Specifies the action. Supported values - AlertingAction, LogToMetricAction.Constant filled by server. - :type odata_type: str - :param criteria: Required. Criteria of Metric. - :type criteria: list[~$(python-base-namespace).v2018_04_16.models.Criteria] + :vartype odata_type: str + :ivar criteria: Required. Criteria of Metric. + :vartype criteria: list[~$(python-base-namespace).v2018_04_16.models.Criteria] """ _validation = { @@ -549,6 +651,10 @@ def __init__( criteria: List["Criteria"], **kwargs ): + """ + :keyword criteria: Required. Criteria of Metric. + :paramtype criteria: list[~$(python-base-namespace).v2018_04_16.models.Criteria] + """ super(LogToMetricAction, self).__init__(**kwargs) self.odata_type = 'Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.LogToMetricAction' # type: str self.criteria = criteria @@ -559,12 +665,12 @@ class Schedule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param frequency_in_minutes: Required. frequency (in minutes) at which rule condition should be + :ivar frequency_in_minutes: Required. frequency (in minutes) at which rule condition should be evaluated. - :type frequency_in_minutes: int - :param time_window_in_minutes: Required. Time window for which data needs to be fetched for + :vartype frequency_in_minutes: int + :ivar time_window_in_minutes: Required. Time window for which data needs to be fetched for query (should be greater than or equal to frequencyInMinutes). - :type time_window_in_minutes: int + :vartype time_window_in_minutes: int """ _validation = { @@ -584,6 +690,14 @@ def __init__( time_window_in_minutes: int, **kwargs ): + """ + :keyword frequency_in_minutes: Required. frequency (in minutes) at which rule condition should + be evaluated. + :paramtype frequency_in_minutes: int + :keyword time_window_in_minutes: Required. Time window for which data needs to be fetched for + query (should be greater than or equal to frequencyInMinutes). + :paramtype time_window_in_minutes: int + """ super(Schedule, self).__init__(**kwargs) self.frequency_in_minutes = frequency_in_minutes self.time_window_in_minutes = time_window_in_minutes @@ -594,14 +708,14 @@ class Source(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param query: Log search query. Required for action type - AlertingAction. - :type query: str - :param authorized_resources: List of Resource referred into query. - :type authorized_resources: list[str] - :param data_source_id: Required. The resource uri over which log search query is to be run. - :type data_source_id: str - :param query_type: Set value to 'ResultCount' . Possible values include: "ResultCount". - :type query_type: str or ~$(python-base-namespace).v2018_04_16.models.QueryType + :ivar query: Log search query. Required for action type - AlertingAction. + :vartype query: str + :ivar authorized_resources: List of Resource referred into query. + :vartype authorized_resources: list[str] + :ivar data_source_id: Required. The resource uri over which log search query is to be run. + :vartype data_source_id: str + :ivar query_type: Set value to 'ResultCount' . Possible values include: "ResultCount". + :vartype query_type: str or ~$(python-base-namespace).v2018_04_16.models.QueryType """ _validation = { @@ -624,6 +738,16 @@ def __init__( query_type: Optional[Union[str, "QueryType"]] = None, **kwargs ): + """ + :keyword query: Log search query. Required for action type - AlertingAction. + :paramtype query: str + :keyword authorized_resources: List of Resource referred into query. + :paramtype authorized_resources: list[str] + :keyword data_source_id: Required. The resource uri over which log search query is to be run. + :paramtype data_source_id: str + :keyword query_type: Set value to 'ResultCount' . Possible values include: "ResultCount". + :paramtype query_type: str or ~$(python-base-namespace).v2018_04_16.models.QueryType + """ super(Source, self).__init__(**kwargs) self.query = query self.authorized_resources = authorized_resources @@ -636,15 +760,15 @@ class TriggerCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param threshold_operator: Required. Evaluation operation for rule - 'GreaterThan' or - 'LessThan. Possible values include: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", - "LessThan", "Equal". Default value: "GreaterThanOrEqual". - :type threshold_operator: str or + :ivar threshold_operator: Required. Evaluation operation for rule - 'GreaterThan' or 'LessThan. + Possible values include: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", "LessThan", + "Equal". Default value: "GreaterThanOrEqual". + :vartype threshold_operator: str or ~$(python-base-namespace).v2018_04_16.models.ConditionalOperator - :param threshold: Required. Result or count threshold based on which rule should be triggered. - :type threshold: float - :param metric_trigger: Trigger condition for metric query rule. - :type metric_trigger: ~$(python-base-namespace).v2018_04_16.models.LogMetricTrigger + :ivar threshold: Required. Result or count threshold based on which rule should be triggered. + :vartype threshold: float + :ivar metric_trigger: Trigger condition for metric query rule. + :vartype metric_trigger: ~$(python-base-namespace).v2018_04_16.models.LogMetricTrigger """ _validation = { @@ -666,6 +790,18 @@ def __init__( metric_trigger: Optional["LogMetricTrigger"] = None, **kwargs ): + """ + :keyword threshold_operator: Required. Evaluation operation for rule - 'GreaterThan' or + 'LessThan. Possible values include: "GreaterThanOrEqual", "LessThanOrEqual", "GreaterThan", + "LessThan", "Equal". Default value: "GreaterThanOrEqual". + :paramtype threshold_operator: str or + ~$(python-base-namespace).v2018_04_16.models.ConditionalOperator + :keyword threshold: Required. Result or count threshold based on which rule should be + triggered. + :paramtype threshold: float + :keyword metric_trigger: Trigger condition for metric query rule. + :paramtype metric_trigger: ~$(python-base-namespace).v2018_04_16.models.LogMetricTrigger + """ super(TriggerCondition, self).__init__(**kwargs) self.threshold_operator = threshold_operator self.threshold = threshold diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_monitor_management_client_enums.py index ce9b4a5dd1d83..d0d3448a6a6e1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/models/_monitor_management_client_enums.py @@ -6,27 +6,12 @@ # 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 AlertSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AlertSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Severity Level of Alert """ @@ -36,9 +21,8 @@ class AlertSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): THREE = "3" FOUR = "4" -class ConditionalOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): - """Result Condition Evaluation criteria. Supported Values - 'GreaterThan' or 'LessThan' or - 'Equal'. +class ConditionalOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Result Condition Evaluation criteria. """ GREATER_THAN_OR_EQUAL = "GreaterThanOrEqual" @@ -47,27 +31,27 @@ class ConditionalOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): LESS_THAN = "LessThan" EQUAL = "Equal" -class Enabled(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Enabled(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The flag which indicates whether the Log Search rule is enabled. Value should be true or false """ TRUE = "true" FALSE = "false" -class MetricTriggerType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MetricTriggerType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Metric Trigger Evaluation Type """ CONSECUTIVE = "Consecutive" TOTAL = "Total" -class Operator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Operator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Operator for dimension values """ INCLUDE = "Include" -class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Provisioning state of the scheduled query rule """ @@ -76,7 +60,7 @@ class ProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): CANCELED = "Canceled" FAILED = "Failed" -class QueryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class QueryType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Set value to 'ResultAccount' """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_scheduled_query_rules_operations.py index 3df057ea56657..9dd31f207e4d4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_scheduled_query_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_04_16/operations/_scheduled_query_rules_operations.py @@ -5,24 +5,258 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + subscription_id, # type: str + resource_group_name, # type: str + rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-04-16" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + rule_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-04-16" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "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_update_request( + subscription_id, # type: str + resource_group_name, # type: str + rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-04-16" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", 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, + **kwargs + ) + + +def build_delete_request( + resource_group_name, # type: str + rule_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-04-16" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", rule_name, 'str'), + "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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2018-04-16" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules') + 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') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, '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( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2018-04-16" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, '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 + ) + +# fmt: on class ScheduledQueryRulesOperations(object): """ScheduledQueryRulesOperations operations. @@ -45,6 +279,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -55,7 +290,7 @@ def create_or_update( # type: (...) -> "_models.LogSearchRuleResource" """Creates or updates an log search rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -71,38 +306,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-16" - 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'), - 'ruleName': self._serialize.url("rule_name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'LogSearchRuleResource') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'LogSearchRuleResource') - 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.failsafe_deserialize(_models.ErrorContract, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -115,8 +340,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -126,7 +354,7 @@ def get( # type: (...) -> "_models.LogSearchRuleResource" """Gets an Log Search rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -140,33 +368,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-16" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorContract, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('LogSearchRuleResource', pipeline_response) @@ -175,8 +393,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -187,7 +408,7 @@ def update( # type: (...) -> "_models.LogSearchRuleResource" """Update log search Rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -203,38 +424,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-16" - 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'), - 'ruleName': self._serialize.url("rule_name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'LogSearchRuleResourcePatch') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'LogSearchRuleResourcePatch') - 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.failsafe_deserialize(_models.ErrorContract, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('LogSearchRuleResource', pipeline_response) @@ -243,8 +454,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -254,7 +468,7 @@ def delete( # type: (...) -> None """Deletes a Log Search rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -268,33 +482,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-16" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'ruleName': self._serialize.url("rule_name", rule_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + rule_name=rule_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorContract, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -302,6 +506,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, filter=None, # type: Optional[str] @@ -314,8 +520,10 @@ def list_by_subscription( https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogSearchRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourceCollection] + :return: An iterator like instance of either LogSearchRuleResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LogSearchRuleResourceCollection"] @@ -323,36 +531,31 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-16" - 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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_subscription.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_list_by_subscription_request( + subscription_id=self._config.subscription_id, + filter=filter, + 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('LogSearchRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("LogSearchRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -365,17 +568,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, 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.Insights/scheduledQueryRules'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -385,14 +590,16 @@ def list_by_resource_group( # type: (...) -> Iterable["_models.LogSearchRuleResourceCollection"] """List the Log Search rules within a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param filter: The filter to apply on the operation. For more information please see https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either LogSearchRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourceCollection] + :return: An iterator like instance of either LogSearchRuleResourceCollection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_04_16.models.LogSearchRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.LogSearchRuleResourceCollection"] @@ -400,37 +607,33 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-16" - 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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 filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + filter=filter, + 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('LogSearchRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("LogSearchRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -443,12 +646,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_configuration.py index f6b03c03aaa59..88367262dd325 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_metadata.json index cfd4d8a7a17be..5aeafd91a05de 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "guest_diagnostics_settings_association": "GuestDiagnosticsSettingsAssociationOperations", diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_monitor_management_client.py index 9eec57542a682..9512991da4387 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_monitor_management_client.py @@ -6,78 +6,86 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import GuestDiagnosticsSettingsAssociationOperations, GuestDiagnosticsSettingsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import GuestDiagnosticsSettingsAssociationOperations -from .operations import GuestDiagnosticsSettingsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. - :ivar guest_diagnostics_settings_association: GuestDiagnosticsSettingsAssociationOperations operations - :vartype guest_diagnostics_settings_association: $(python-base-namespace).v2018_06_01_preview.operations.GuestDiagnosticsSettingsAssociationOperations + :ivar guest_diagnostics_settings_association: GuestDiagnosticsSettingsAssociationOperations + operations + :vartype guest_diagnostics_settings_association: + $(python-base-namespace).v2018_06_01_preview.operations.GuestDiagnosticsSettingsAssociationOperations :ivar guest_diagnostics_settings: GuestDiagnosticsSettingsOperations operations - :vartype guest_diagnostics_settings: $(python-base-namespace).v2018_06_01_preview.operations.GuestDiagnosticsSettingsOperations + :vartype guest_diagnostics_settings: + $(python-base-namespace).v2018_06_01_preview.operations.GuestDiagnosticsSettingsOperations :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.guest_diagnostics_settings_association = GuestDiagnosticsSettingsAssociationOperations(self._client, self._config, self._serialize, self._deserialize) + self.guest_diagnostics_settings = GuestDiagnosticsSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.guest_diagnostics_settings_association = GuestDiagnosticsSettingsAssociationOperations( - self._client, self._config, self._serialize, self._deserialize) - self.guest_diagnostics_settings = GuestDiagnosticsSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_configuration.py index 3219bb1c9dc8f..f4bfd21725968 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_monitor_management_client.py index 06402e692be06..6a2eb35ec8f39 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_monitor_management_client.py @@ -6,74 +6,82 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import GuestDiagnosticsSettingsAssociationOperations, GuestDiagnosticsSettingsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MonitorManagementClientConfiguration -from .operations import GuestDiagnosticsSettingsAssociationOperations -from .operations import GuestDiagnosticsSettingsOperations -from .. import models - - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. - :ivar guest_diagnostics_settings_association: GuestDiagnosticsSettingsAssociationOperations operations - :vartype guest_diagnostics_settings_association: $(python-base-namespace).v2018_06_01_preview.aio.operations.GuestDiagnosticsSettingsAssociationOperations + :ivar guest_diagnostics_settings_association: GuestDiagnosticsSettingsAssociationOperations + operations + :vartype guest_diagnostics_settings_association: + $(python-base-namespace).v2018_06_01_preview.aio.operations.GuestDiagnosticsSettingsAssociationOperations :ivar guest_diagnostics_settings: GuestDiagnosticsSettingsOperations operations - :vartype guest_diagnostics_settings: $(python-base-namespace).v2018_06_01_preview.aio.operations.GuestDiagnosticsSettingsOperations + :vartype guest_diagnostics_settings: + $(python-base-namespace).v2018_06_01_preview.aio.operations.GuestDiagnosticsSettingsOperations :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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.guest_diagnostics_settings_association = GuestDiagnosticsSettingsAssociationOperations(self._client, self._config, self._serialize, self._deserialize) + self.guest_diagnostics_settings = GuestDiagnosticsSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.guest_diagnostics_settings_association = GuestDiagnosticsSettingsAssociationOperations( - self._client, self._config, self._serialize, self._deserialize) - self.guest_diagnostics_settings = GuestDiagnosticsSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_association_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_association_operations.py index 897035d273d32..80d6e126d47d4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_association_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_association_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._guest_diagnostics_settings_association_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_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_async async def create_or_update( self, resource_uri: str, @@ -57,10 +63,12 @@ async def create_or_update( :type association_name: str :param diagnostic_settings_association: The diagnostic settings association to create or update. - :type diagnostic_settings_association: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + :type diagnostic_settings_association: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource :keyword callable cls: A custom type or function that will be passed the direct response :return: GuestDiagnosticSettingsAssociationResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + :rtype: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationResource"] @@ -68,37 +76,27 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-preview" - 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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'associationName': self._serialize.url("association_name", association_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(diagnostic_settings_association, 'GuestDiagnosticSettingsAssociationResource') + + request = build_create_or_update_request( + resource_uri=resource_uri, + association_name=association_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(diagnostic_settings_association, 'GuestDiagnosticSettingsAssociationResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -111,8 +109,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_uri: str, @@ -128,7 +129,8 @@ async def get( :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GuestDiagnosticSettingsAssociationResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + :rtype: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationResource"] @@ -136,32 +138,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'associationName': self._serialize.url("association_name", association_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 = build_get_request( + resource_uri=resource_uri, + association_name=association_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestDiagnosticSettingsAssociationResource', pipeline_response) @@ -170,8 +162,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_uri: str, @@ -195,32 +190,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'associationName': self._serialize.url("association_name", association_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 = build_delete_request( + resource_uri=resource_uri, + association_name=association_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -228,6 +213,8 @@ async def delete( delete.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_uri: str, @@ -244,10 +231,12 @@ async def update( :param association_name: The name of the diagnostic settings association. :type association_name: str :param parameters: Parameters supplied to the operation. - :type parameters: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResourcePatch + :type parameters: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResourcePatch :keyword callable cls: A custom type or function that will be passed the direct response :return: GuestDiagnosticSettingsAssociationResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + :rtype: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationResource"] @@ -255,37 +244,27 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'associationName': self._serialize.url("association_name", association_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'GuestDiagnosticSettingsAssociationResourcePatch') + + request = build_update_request( + resource_uri=resource_uri, + association_name=association_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GuestDiagnosticSettingsAssociationResourcePatch') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestDiagnosticSettingsAssociationResource', pipeline_response) @@ -294,8 +273,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -303,8 +285,10 @@ def list( """Get a list of all guest diagnostic settings association 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 GuestDiagnosticSettingsAssociationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationList] + :return: An iterator like instance of either GuestDiagnosticSettingsAssociationList or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationList"] @@ -312,34 +296,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-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 - 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_list_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('GuestDiagnosticSettingsAssociationList', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -352,17 +331,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -370,11 +351,13 @@ def list_by_resource_group( ) -> AsyncIterable["_models.GuestDiagnosticSettingsAssociationList"]: """Get a list of all guest diagnostic settings association in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 GuestDiagnosticSettingsAssociationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationList] + :return: An iterator like instance of either GuestDiagnosticSettingsAssociationList or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationList"] @@ -382,35 +365,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('GuestDiagnosticSettingsAssociationList', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -423,12 +402,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_operations.py index 3e4d561f62566..2caa8649a8896 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/aio/operations/_guest_diagnostics_settings_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._guest_diagnostics_settings_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_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_async async def create_or_update( self, resource_group_name: str, @@ -50,12 +56,13 @@ async def create_or_update( ) -> "_models.GuestDiagnosticSettingsResource": """Creates or updates guest diagnostics settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param diagnostic_settings_name: The name of the diagnostic setting. :type diagnostic_settings_name: str :param diagnostic_settings: The configuration to create or update. - :type diagnostic_settings: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource + :type diagnostic_settings: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: GuestDiagnosticSettingsResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource @@ -66,38 +73,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-preview" - 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'diagnosticSettingsName': self._serialize.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(diagnostic_settings, 'GuestDiagnosticSettingsResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + diagnostic_settings_name=diagnostic_settings_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(diagnostic_settings, 'GuestDiagnosticSettingsResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -110,8 +107,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -120,7 +120,7 @@ async def get( ) -> "_models.GuestDiagnosticSettingsResource": """Gets guest diagnostics settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param diagnostic_settings_name: The name of the diagnostic setting. :type diagnostic_settings_name: str @@ -134,33 +134,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'diagnosticSettingsName': self._serialize.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + diagnostic_settings_name=diagnostic_settings_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestDiagnosticSettingsResource', pipeline_response) @@ -169,8 +159,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -180,12 +173,13 @@ async def update( ) -> "_models.GuestDiagnosticSettingsResource": """Updates guest diagnostics settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param diagnostic_settings_name: The name of the diagnostic setting. :type diagnostic_settings_name: str :param parameters: The configuration to patch. - :type parameters: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsPatchResource + :type parameters: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsPatchResource :keyword callable cls: A custom type or function that will be passed the direct response :return: GuestDiagnosticSettingsResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource @@ -196,38 +190,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'diagnosticSettingsName': self._serialize.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GuestDiagnosticSettingsPatchResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + resource_group_name=resource_group_name, + diagnostic_settings_name=diagnostic_settings_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GuestDiagnosticSettingsPatchResource') - 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, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -240,8 +224,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -250,7 +237,7 @@ async def delete( ) -> None: """Delete guest diagnostics settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param diagnostic_settings_name: The name of the diagnostic setting. :type diagnostic_settings_name: str @@ -264,33 +251,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'diagnosticSettingsName': self._serialize.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + diagnostic_settings_name=diagnostic_settings_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -298,6 +275,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -305,8 +284,10 @@ def list( """Get a list of all guest diagnostic settings 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 GuestDiagnosticSettingsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsList] + :return: An iterator like instance of either GuestDiagnosticSettingsList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsList"] @@ -314,34 +295,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-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 - 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_list_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('GuestDiagnosticSettingsList', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -354,17 +330,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -372,11 +350,13 @@ def list_by_resource_group( ) -> AsyncIterable["_models.GuestDiagnosticSettingsList"]: """Get a list of all guest diagnostic settings in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 GuestDiagnosticSettingsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsList] + :return: An iterator like instance of either GuestDiagnosticSettingsList or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsList"] @@ -384,35 +364,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('GuestDiagnosticSettingsList', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -425,12 +401,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models.py index 06ae1bbd2382c..a9516fd377055 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models.py @@ -15,14 +15,14 @@ class DataSource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param kind: Required. Datasource kind. Possible values include: "PerformanceCounter", + :ivar kind: Required. Datasource kind. Possible values include: "PerformanceCounter", "ETWProviders", "WindowsEventLogs". - :type kind: str or ~$(python-base-namespace).v2018_06_01_preview.models.DataSourceKind - :param configuration: Required. - :type configuration: + :vartype kind: str or ~$(python-base-namespace).v2018_06_01_preview.models.DataSourceKind + :ivar configuration: Required. + :vartype configuration: ~$(python-base-namespace).v2018_06_01_preview.models.DataSourceConfiguration - :param sinks: Required. - :type sinks: list[~$(python-base-namespace).v2018_06_01_preview.models.SinkConfiguration] + :ivar sinks: Required. + :vartype sinks: list[~$(python-base-namespace).v2018_06_01_preview.models.SinkConfiguration] """ _validation = { @@ -41,6 +41,16 @@ def __init__( self, **kwargs ): + """ + :keyword kind: Required. Datasource kind. Possible values include: "PerformanceCounter", + "ETWProviders", "WindowsEventLogs". + :paramtype kind: str or ~$(python-base-namespace).v2018_06_01_preview.models.DataSourceKind + :keyword configuration: Required. + :paramtype configuration: + ~$(python-base-namespace).v2018_06_01_preview.models.DataSourceConfiguration + :keyword sinks: Required. + :paramtype sinks: list[~$(python-base-namespace).v2018_06_01_preview.models.SinkConfiguration] + """ super(DataSource, self).__init__(**kwargs) self.kind = kwargs['kind'] self.configuration = kwargs['configuration'] @@ -50,14 +60,14 @@ def __init__( class DataSourceConfiguration(msrest.serialization.Model): """DataSourceConfiguration. - :param providers: ETW providers configuration. - :type providers: + :ivar providers: ETW providers configuration. + :vartype providers: list[~$(python-base-namespace).v2018_06_01_preview.models.EtwProviderConfiguration] - :param perf_counters: Performance counter configuration. - :type perf_counters: + :ivar perf_counters: Performance counter configuration. + :vartype perf_counters: list[~$(python-base-namespace).v2018_06_01_preview.models.PerformanceCounterConfiguration] - :param event_logs: Windows event logs configuration. - :type event_logs: + :ivar event_logs: Windows event logs configuration. + :vartype event_logs: list[~$(python-base-namespace).v2018_06_01_preview.models.EventLogConfiguration] """ @@ -71,6 +81,17 @@ def __init__( self, **kwargs ): + """ + :keyword providers: ETW providers configuration. + :paramtype providers: + list[~$(python-base-namespace).v2018_06_01_preview.models.EtwProviderConfiguration] + :keyword perf_counters: Performance counter configuration. + :paramtype perf_counters: + list[~$(python-base-namespace).v2018_06_01_preview.models.PerformanceCounterConfiguration] + :keyword event_logs: Windows event logs configuration. + :paramtype event_logs: + list[~$(python-base-namespace).v2018_06_01_preview.models.EventLogConfiguration] + """ super(DataSourceConfiguration, self).__init__(**kwargs) self.providers = kwargs.get('providers', None) self.perf_counters = kwargs.get('perf_counters', None) @@ -80,10 +101,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -95,6 +116,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -105,12 +132,12 @@ class EtwEventConfiguration(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. - :type name: str - :param id: Required. - :type id: int - :param filter: - :type filter: str + :ivar name: Required. + :vartype name: str + :ivar id: Required. + :vartype id: int + :ivar filter: + :vartype filter: str """ _validation = { @@ -128,6 +155,14 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. + :paramtype name: str + :keyword id: Required. + :paramtype id: int + :keyword filter: + :paramtype filter: str + """ super(EtwEventConfiguration, self).__init__(**kwargs) self.name = kwargs['name'] self.id = kwargs['id'] @@ -139,10 +174,11 @@ class EtwProviderConfiguration(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. - :type id: str - :param events: Required. - :type events: list[~$(python-base-namespace).v2018_06_01_preview.models.EtwEventConfiguration] + :ivar id: Required. + :vartype id: str + :ivar events: Required. + :vartype events: + list[~$(python-base-namespace).v2018_06_01_preview.models.EtwEventConfiguration] """ _validation = { @@ -159,6 +195,13 @@ def __init__( self, **kwargs ): + """ + :keyword id: Required. + :paramtype id: str + :keyword events: Required. + :paramtype events: + list[~$(python-base-namespace).v2018_06_01_preview.models.EtwEventConfiguration] + """ super(EtwProviderConfiguration, self).__init__(**kwargs) self.id = kwargs['id'] self.events = kwargs['events'] @@ -169,10 +212,10 @@ class EventLogConfiguration(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param log_name: Required. - :type log_name: str - :param filter: - :type filter: str + :ivar log_name: Required. + :vartype log_name: str + :ivar filter: + :vartype filter: str """ _validation = { @@ -188,6 +231,12 @@ def __init__( self, **kwargs ): + """ + :keyword log_name: Required. + :paramtype log_name: str + :keyword filter: + :paramtype filter: str + """ super(EventLogConfiguration, self).__init__(**kwargs) self.log_name = kwargs['log_name'] self.filter = kwargs.get('filter', None) @@ -196,11 +245,11 @@ def __init__( class GuestDiagnosticSettingsAssociationList(msrest.serialization.Model): """A list of guest diagnostic settings association. - :param value: The list of guest diagnostic settings association. - :type value: + :ivar value: The list of guest diagnostic settings association. + :vartype value: list[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -212,6 +261,13 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of guest diagnostic settings association. + :paramtype value: + list[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(GuestDiagnosticSettingsAssociationList, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -230,10 +286,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -255,6 +311,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -276,12 +338,12 @@ class GuestDiagnosticSettingsAssociationResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param guest_diagnostic_settings_name: Required. The guest diagnostic settings name. - :type guest_diagnostic_settings_name: str + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar guest_diagnostic_settings_name: Required. The guest diagnostic settings name. + :vartype guest_diagnostic_settings_name: str """ _validation = { @@ -305,6 +367,14 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword guest_diagnostic_settings_name: Required. The guest diagnostic settings name. + :paramtype guest_diagnostic_settings_name: str + """ super(GuestDiagnosticSettingsAssociationResource, self).__init__(**kwargs) self.guest_diagnostic_settings_name = kwargs['guest_diagnostic_settings_name'] @@ -312,10 +382,10 @@ def __init__( class GuestDiagnosticSettingsAssociationResourcePatch(msrest.serialization.Model): """Guest diagnostic setting resource for patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param guest_diagnostic_settings_name: The guest diagnostic settings name. - :type guest_diagnostic_settings_name: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar guest_diagnostic_settings_name: The guest diagnostic settings name. + :vartype guest_diagnostic_settings_name: str """ _attribute_map = { @@ -327,6 +397,12 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword guest_diagnostic_settings_name: The guest diagnostic settings name. + :paramtype guest_diagnostic_settings_name: str + """ super(GuestDiagnosticSettingsAssociationResourcePatch, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.guest_diagnostic_settings_name = kwargs.get('guest_diagnostic_settings_name', None) @@ -335,11 +411,11 @@ def __init__( class GuestDiagnosticSettingsList(msrest.serialization.Model): """A list of guest diagnostic settings. - :param value: The list of guest diagnostic settings. - :type value: + :ivar value: The list of guest diagnostic settings. + :vartype value: list[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -351,6 +427,13 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of guest diagnostic settings. + :paramtype value: + list[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(GuestDiagnosticSettingsList, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -359,17 +442,17 @@ def __init__( class GuestDiagnosticSettingsPatchResource(msrest.serialization.Model): """An diagnostic settings object for the body of patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param os_type: Operating system type for the configuration. Possible values include: - "Windows", "Linux". - :type os_type: str or + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar os_type: Operating system type for the configuration. Possible values include: "Windows", + "Linux". + :vartype os_type: str or ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsOsType - :param data_sources: the array of data source object which are configured to collect and send + :ivar data_sources: the array of data source object which are configured to collect and send data. - :type data_sources: list[~$(python-base-namespace).v2018_06_01_preview.models.DataSource] - :param proxy_setting: - :type proxy_setting: str + :vartype data_sources: list[~$(python-base-namespace).v2018_06_01_preview.models.DataSource] + :ivar proxy_setting: + :vartype proxy_setting: str """ _attribute_map = { @@ -383,6 +466,19 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword os_type: Operating system type for the configuration. Possible values include: + "Windows", "Linux". + :paramtype os_type: str or + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsOsType + :keyword data_sources: the array of data source object which are configured to collect and send + data. + :paramtype data_sources: list[~$(python-base-namespace).v2018_06_01_preview.models.DataSource] + :keyword proxy_setting: + :paramtype proxy_setting: str + """ super(GuestDiagnosticSettingsPatchResource, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.os_type = kwargs.get('os_type', None) @@ -403,19 +499,19 @@ class GuestDiagnosticSettingsResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param os_type: Operating system type for the configuration. Possible values include: - "Windows", "Linux". - :type os_type: str or + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar os_type: Operating system type for the configuration. Possible values include: "Windows", + "Linux". + :vartype os_type: str or ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsOsType - :param data_sources: the array of data source object which are configured to collect and send + :ivar data_sources: the array of data source object which are configured to collect and send data. - :type data_sources: list[~$(python-base-namespace).v2018_06_01_preview.models.DataSource] - :param proxy_setting: - :type proxy_setting: str + :vartype data_sources: list[~$(python-base-namespace).v2018_06_01_preview.models.DataSource] + :ivar proxy_setting: + :vartype proxy_setting: str """ _validation = { @@ -440,6 +536,21 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword os_type: Operating system type for the configuration. Possible values include: + "Windows", "Linux". + :paramtype os_type: str or + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsOsType + :keyword data_sources: the array of data source object which are configured to collect and send + data. + :paramtype data_sources: list[~$(python-base-namespace).v2018_06_01_preview.models.DataSource] + :keyword proxy_setting: + :paramtype proxy_setting: str + """ super(GuestDiagnosticSettingsResource, self).__init__(**kwargs) self.os_type = kwargs.get('os_type', None) self.data_sources = kwargs.get('data_sources', None) @@ -451,12 +562,12 @@ class PerformanceCounterConfiguration(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. - :type name: str - :param sampling_period: Required. - :type sampling_period: str - :param instance: - :type instance: str + :ivar name: Required. + :vartype name: str + :ivar sampling_period: Required. + :vartype sampling_period: str + :ivar instance: + :vartype instance: str """ _validation = { @@ -474,6 +585,14 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. + :paramtype name: str + :keyword sampling_period: Required. + :paramtype sampling_period: str + :keyword instance: + :paramtype instance: str + """ super(PerformanceCounterConfiguration, self).__init__(**kwargs) self.name = kwargs['name'] self.sampling_period = kwargs['sampling_period'] @@ -485,9 +604,10 @@ class SinkConfiguration(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param kind: Required. Possible values include: "EventHub", "ApplicationInsights", + :ivar kind: Required. Possible values include: "EventHub", "ApplicationInsights", "LogAnalytics". - :type kind: str or ~$(python-base-namespace).v2018_06_01_preview.models.SinkConfigurationKind + :vartype kind: str or + ~$(python-base-namespace).v2018_06_01_preview.models.SinkConfigurationKind """ _validation = { @@ -502,5 +622,11 @@ def __init__( self, **kwargs ): + """ + :keyword kind: Required. Possible values include: "EventHub", "ApplicationInsights", + "LogAnalytics". + :paramtype kind: str or + ~$(python-base-namespace).v2018_06_01_preview.models.SinkConfigurationKind + """ super(SinkConfiguration, self).__init__(**kwargs) self.kind = kwargs['kind'] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models_py3.py index 9f72f55fcb223..dffaff76a32fd 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_models_py3.py @@ -19,14 +19,14 @@ class DataSource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param kind: Required. Datasource kind. Possible values include: "PerformanceCounter", + :ivar kind: Required. Datasource kind. Possible values include: "PerformanceCounter", "ETWProviders", "WindowsEventLogs". - :type kind: str or ~$(python-base-namespace).v2018_06_01_preview.models.DataSourceKind - :param configuration: Required. - :type configuration: + :vartype kind: str or ~$(python-base-namespace).v2018_06_01_preview.models.DataSourceKind + :ivar configuration: Required. + :vartype configuration: ~$(python-base-namespace).v2018_06_01_preview.models.DataSourceConfiguration - :param sinks: Required. - :type sinks: list[~$(python-base-namespace).v2018_06_01_preview.models.SinkConfiguration] + :ivar sinks: Required. + :vartype sinks: list[~$(python-base-namespace).v2018_06_01_preview.models.SinkConfiguration] """ _validation = { @@ -49,6 +49,16 @@ def __init__( sinks: List["SinkConfiguration"], **kwargs ): + """ + :keyword kind: Required. Datasource kind. Possible values include: "PerformanceCounter", + "ETWProviders", "WindowsEventLogs". + :paramtype kind: str or ~$(python-base-namespace).v2018_06_01_preview.models.DataSourceKind + :keyword configuration: Required. + :paramtype configuration: + ~$(python-base-namespace).v2018_06_01_preview.models.DataSourceConfiguration + :keyword sinks: Required. + :paramtype sinks: list[~$(python-base-namespace).v2018_06_01_preview.models.SinkConfiguration] + """ super(DataSource, self).__init__(**kwargs) self.kind = kind self.configuration = configuration @@ -58,14 +68,14 @@ def __init__( class DataSourceConfiguration(msrest.serialization.Model): """DataSourceConfiguration. - :param providers: ETW providers configuration. - :type providers: + :ivar providers: ETW providers configuration. + :vartype providers: list[~$(python-base-namespace).v2018_06_01_preview.models.EtwProviderConfiguration] - :param perf_counters: Performance counter configuration. - :type perf_counters: + :ivar perf_counters: Performance counter configuration. + :vartype perf_counters: list[~$(python-base-namespace).v2018_06_01_preview.models.PerformanceCounterConfiguration] - :param event_logs: Windows event logs configuration. - :type event_logs: + :ivar event_logs: Windows event logs configuration. + :vartype event_logs: list[~$(python-base-namespace).v2018_06_01_preview.models.EventLogConfiguration] """ @@ -83,6 +93,17 @@ def __init__( event_logs: Optional[List["EventLogConfiguration"]] = None, **kwargs ): + """ + :keyword providers: ETW providers configuration. + :paramtype providers: + list[~$(python-base-namespace).v2018_06_01_preview.models.EtwProviderConfiguration] + :keyword perf_counters: Performance counter configuration. + :paramtype perf_counters: + list[~$(python-base-namespace).v2018_06_01_preview.models.PerformanceCounterConfiguration] + :keyword event_logs: Windows event logs configuration. + :paramtype event_logs: + list[~$(python-base-namespace).v2018_06_01_preview.models.EventLogConfiguration] + """ super(DataSourceConfiguration, self).__init__(**kwargs) self.providers = providers self.perf_counters = perf_counters @@ -92,10 +113,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -110,6 +131,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -120,12 +147,12 @@ class EtwEventConfiguration(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. - :type name: str - :param id: Required. - :type id: int - :param filter: - :type filter: str + :ivar name: Required. + :vartype name: str + :ivar id: Required. + :vartype id: int + :ivar filter: + :vartype filter: str """ _validation = { @@ -147,6 +174,14 @@ def __init__( filter: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. + :paramtype name: str + :keyword id: Required. + :paramtype id: int + :keyword filter: + :paramtype filter: str + """ super(EtwEventConfiguration, self).__init__(**kwargs) self.name = name self.id = id @@ -158,10 +193,11 @@ class EtwProviderConfiguration(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. - :type id: str - :param events: Required. - :type events: list[~$(python-base-namespace).v2018_06_01_preview.models.EtwEventConfiguration] + :ivar id: Required. + :vartype id: str + :ivar events: Required. + :vartype events: + list[~$(python-base-namespace).v2018_06_01_preview.models.EtwEventConfiguration] """ _validation = { @@ -181,6 +217,13 @@ def __init__( events: List["EtwEventConfiguration"], **kwargs ): + """ + :keyword id: Required. + :paramtype id: str + :keyword events: Required. + :paramtype events: + list[~$(python-base-namespace).v2018_06_01_preview.models.EtwEventConfiguration] + """ super(EtwProviderConfiguration, self).__init__(**kwargs) self.id = id self.events = events @@ -191,10 +234,10 @@ class EventLogConfiguration(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param log_name: Required. - :type log_name: str - :param filter: - :type filter: str + :ivar log_name: Required. + :vartype log_name: str + :ivar filter: + :vartype filter: str """ _validation = { @@ -213,6 +256,12 @@ def __init__( filter: Optional[str] = None, **kwargs ): + """ + :keyword log_name: Required. + :paramtype log_name: str + :keyword filter: + :paramtype filter: str + """ super(EventLogConfiguration, self).__init__(**kwargs) self.log_name = log_name self.filter = filter @@ -221,11 +270,11 @@ def __init__( class GuestDiagnosticSettingsAssociationList(msrest.serialization.Model): """A list of guest diagnostic settings association. - :param value: The list of guest diagnostic settings association. - :type value: + :ivar value: The list of guest diagnostic settings association. + :vartype value: list[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -240,6 +289,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of guest diagnostic settings association. + :paramtype value: + list[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(GuestDiagnosticSettingsAssociationList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -258,10 +314,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -286,6 +342,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -307,12 +369,12 @@ class GuestDiagnosticSettingsAssociationResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param guest_diagnostic_settings_name: Required. The guest diagnostic settings name. - :type guest_diagnostic_settings_name: str + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar guest_diagnostic_settings_name: Required. The guest diagnostic settings name. + :vartype guest_diagnostic_settings_name: str """ _validation = { @@ -340,6 +402,14 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword guest_diagnostic_settings_name: Required. The guest diagnostic settings name. + :paramtype guest_diagnostic_settings_name: str + """ super(GuestDiagnosticSettingsAssociationResource, self).__init__(location=location, tags=tags, **kwargs) self.guest_diagnostic_settings_name = guest_diagnostic_settings_name @@ -347,10 +417,10 @@ def __init__( class GuestDiagnosticSettingsAssociationResourcePatch(msrest.serialization.Model): """Guest diagnostic setting resource for patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param guest_diagnostic_settings_name: The guest diagnostic settings name. - :type guest_diagnostic_settings_name: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar guest_diagnostic_settings_name: The guest diagnostic settings name. + :vartype guest_diagnostic_settings_name: str """ _attribute_map = { @@ -365,6 +435,12 @@ def __init__( guest_diagnostic_settings_name: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword guest_diagnostic_settings_name: The guest diagnostic settings name. + :paramtype guest_diagnostic_settings_name: str + """ super(GuestDiagnosticSettingsAssociationResourcePatch, self).__init__(**kwargs) self.tags = tags self.guest_diagnostic_settings_name = guest_diagnostic_settings_name @@ -373,11 +449,11 @@ def __init__( class GuestDiagnosticSettingsList(msrest.serialization.Model): """A list of guest diagnostic settings. - :param value: The list of guest diagnostic settings. - :type value: + :ivar value: The list of guest diagnostic settings. + :vartype value: list[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -392,6 +468,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of guest diagnostic settings. + :paramtype value: + list[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(GuestDiagnosticSettingsList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -400,17 +483,17 @@ def __init__( class GuestDiagnosticSettingsPatchResource(msrest.serialization.Model): """An diagnostic settings object for the body of patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param os_type: Operating system type for the configuration. Possible values include: - "Windows", "Linux". - :type os_type: str or + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar os_type: Operating system type for the configuration. Possible values include: "Windows", + "Linux". + :vartype os_type: str or ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsOsType - :param data_sources: the array of data source object which are configured to collect and send + :ivar data_sources: the array of data source object which are configured to collect and send data. - :type data_sources: list[~$(python-base-namespace).v2018_06_01_preview.models.DataSource] - :param proxy_setting: - :type proxy_setting: str + :vartype data_sources: list[~$(python-base-namespace).v2018_06_01_preview.models.DataSource] + :ivar proxy_setting: + :vartype proxy_setting: str """ _attribute_map = { @@ -429,6 +512,19 @@ def __init__( proxy_setting: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword os_type: Operating system type for the configuration. Possible values include: + "Windows", "Linux". + :paramtype os_type: str or + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsOsType + :keyword data_sources: the array of data source object which are configured to collect and send + data. + :paramtype data_sources: list[~$(python-base-namespace).v2018_06_01_preview.models.DataSource] + :keyword proxy_setting: + :paramtype proxy_setting: str + """ super(GuestDiagnosticSettingsPatchResource, self).__init__(**kwargs) self.tags = tags self.os_type = os_type @@ -449,19 +545,19 @@ class GuestDiagnosticSettingsResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param os_type: Operating system type for the configuration. Possible values include: - "Windows", "Linux". - :type os_type: str or + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar os_type: Operating system type for the configuration. Possible values include: "Windows", + "Linux". + :vartype os_type: str or ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsOsType - :param data_sources: the array of data source object which are configured to collect and send + :ivar data_sources: the array of data source object which are configured to collect and send data. - :type data_sources: list[~$(python-base-namespace).v2018_06_01_preview.models.DataSource] - :param proxy_setting: - :type proxy_setting: str + :vartype data_sources: list[~$(python-base-namespace).v2018_06_01_preview.models.DataSource] + :ivar proxy_setting: + :vartype proxy_setting: str """ _validation = { @@ -492,6 +588,21 @@ def __init__( proxy_setting: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword os_type: Operating system type for the configuration. Possible values include: + "Windows", "Linux". + :paramtype os_type: str or + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsOsType + :keyword data_sources: the array of data source object which are configured to collect and send + data. + :paramtype data_sources: list[~$(python-base-namespace).v2018_06_01_preview.models.DataSource] + :keyword proxy_setting: + :paramtype proxy_setting: str + """ super(GuestDiagnosticSettingsResource, self).__init__(location=location, tags=tags, **kwargs) self.os_type = os_type self.data_sources = data_sources @@ -503,12 +614,12 @@ class PerformanceCounterConfiguration(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. - :type name: str - :param sampling_period: Required. - :type sampling_period: str - :param instance: - :type instance: str + :ivar name: Required. + :vartype name: str + :ivar sampling_period: Required. + :vartype sampling_period: str + :ivar instance: + :vartype instance: str """ _validation = { @@ -530,6 +641,14 @@ def __init__( instance: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. + :paramtype name: str + :keyword sampling_period: Required. + :paramtype sampling_period: str + :keyword instance: + :paramtype instance: str + """ super(PerformanceCounterConfiguration, self).__init__(**kwargs) self.name = name self.sampling_period = sampling_period @@ -541,9 +660,10 @@ class SinkConfiguration(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param kind: Required. Possible values include: "EventHub", "ApplicationInsights", + :ivar kind: Required. Possible values include: "EventHub", "ApplicationInsights", "LogAnalytics". - :type kind: str or ~$(python-base-namespace).v2018_06_01_preview.models.SinkConfigurationKind + :vartype kind: str or + ~$(python-base-namespace).v2018_06_01_preview.models.SinkConfigurationKind """ _validation = { @@ -560,5 +680,11 @@ def __init__( kind: Union[str, "SinkConfigurationKind"], **kwargs ): + """ + :keyword kind: Required. Possible values include: "EventHub", "ApplicationInsights", + "LogAnalytics". + :paramtype kind: str or + ~$(python-base-namespace).v2018_06_01_preview.models.SinkConfigurationKind + """ super(SinkConfiguration, self).__init__(**kwargs) self.kind = kind diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_monitor_management_client_enums.py index fdd4cc87df813..c0cdf7ff95e62 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/models/_monitor_management_client_enums.py @@ -6,27 +6,12 @@ # 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 DataSourceKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DataSourceKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Datasource kind """ @@ -34,14 +19,14 @@ class DataSourceKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ETW_PROVIDERS = "ETWProviders" WINDOWS_EVENT_LOGS = "WindowsEventLogs" -class GuestDiagnosticSettingsOsType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class GuestDiagnosticSettingsOsType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Operating system type for the configuration """ WINDOWS = "Windows" LINUX = "Linux" -class SinkConfigurationKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class SinkConfigurationKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): EVENT_HUB = "EventHub" APPLICATION_INSIGHTS = "ApplicationInsights" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_association_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_association_operations.py index 21e8b221b17a8..029e3fc88bd11 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_association_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_association_operations.py @@ -5,24 +5,242 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + resource_uri, # type: str + association_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "associationName": _SERIALIZER.url("association_name", association_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, + **kwargs + ) + + +def build_get_request( + resource_uri, # type: str + association_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "associationName": _SERIALIZER.url("association_name", association_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_delete_request( + resource_uri, # type: str + association_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "associationName": _SERIALIZER.url("association_name", association_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( + resource_uri, # type: str + association_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "associationName": _SERIALIZER.url("association_name", association_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, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations') + 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( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettingsAssociations') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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 + ) + +# fmt: on class GuestDiagnosticsSettingsAssociationOperations(object): """GuestDiagnosticsSettingsAssociationOperations operations. @@ -45,6 +263,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, resource_uri, # type: str @@ -62,10 +281,12 @@ def create_or_update( :type association_name: str :param diagnostic_settings_association: The diagnostic settings association to create or update. - :type diagnostic_settings_association: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + :type diagnostic_settings_association: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource :keyword callable cls: A custom type or function that will be passed the direct response :return: GuestDiagnosticSettingsAssociationResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + :rtype: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationResource"] @@ -73,37 +294,27 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-preview" - 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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'associationName': self._serialize.url("association_name", association_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(diagnostic_settings_association, 'GuestDiagnosticSettingsAssociationResource') + + request = build_create_or_update_request( + resource_uri=resource_uri, + association_name=association_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(diagnostic_settings_association, 'GuestDiagnosticSettingsAssociationResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -116,8 +327,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}'} # type: ignore + + @distributed_trace def get( self, resource_uri, # type: str @@ -134,7 +348,8 @@ def get( :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: GuestDiagnosticSettingsAssociationResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + :rtype: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationResource"] @@ -142,32 +357,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'associationName': self._serialize.url("association_name", association_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 = build_get_request( + resource_uri=resource_uri, + association_name=association_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestDiagnosticSettingsAssociationResource', pipeline_response) @@ -176,8 +381,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}'} # type: ignore + + @distributed_trace def delete( self, resource_uri, # type: str @@ -202,32 +410,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'associationName': self._serialize.url("association_name", association_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 = build_delete_request( + resource_uri=resource_uri, + association_name=association_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -235,6 +433,8 @@ def delete( delete.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}'} # type: ignore + + @distributed_trace def update( self, resource_uri, # type: str @@ -252,10 +452,12 @@ def update( :param association_name: The name of the diagnostic settings association. :type association_name: str :param parameters: Parameters supplied to the operation. - :type parameters: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResourcePatch + :type parameters: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResourcePatch :keyword callable cls: A custom type or function that will be passed the direct response :return: GuestDiagnosticSettingsAssociationResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource + :rtype: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationResource"] @@ -263,37 +465,27 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'associationName': self._serialize.url("association_name", association_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'GuestDiagnosticSettingsAssociationResourcePatch') + + request = build_update_request( + resource_uri=resource_uri, + association_name=association_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GuestDiagnosticSettingsAssociationResourcePatch') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestDiagnosticSettingsAssociationResource', pipeline_response) @@ -302,8 +494,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/{resourceUri}/providers/microsoft.insights/guestDiagnosticSettingsAssociation/{associationName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -312,8 +507,10 @@ def list( """Get a list of all guest diagnostic settings association 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 GuestDiagnosticSettingsAssociationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationList] + :return: An iterator like instance of either GuestDiagnosticSettingsAssociationList or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationList"] @@ -321,34 +518,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-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 - 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_list_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('GuestDiagnosticSettingsAssociationList', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -361,17 +553,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettingsAssociations'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -380,11 +574,13 @@ def list_by_resource_group( # type: (...) -> Iterable["_models.GuestDiagnosticSettingsAssociationList"] """Get a list of all guest diagnostic settings association in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 GuestDiagnosticSettingsAssociationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationList] + :return: An iterator like instance of either GuestDiagnosticSettingsAssociationList or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsAssociationList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsAssociationList"] @@ -392,35 +588,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('GuestDiagnosticSettingsAssociationList', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsAssociationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -433,12 +625,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_operations.py index c7b5ae16539e8..d7540c28bc8c3 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_06_01_preview/operations/_guest_diagnostics_settings_operations.py @@ -5,24 +5,250 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + resource_group_name, # type: str + diagnostic_settings_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), + "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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + diagnostic_settings_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), + "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_update_request( + resource_group_name, # type: str + diagnostic_settings_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), + "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] + 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, + **kwargs + ) + + +def build_delete_request( + resource_group_name, # type: str + diagnostic_settings_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "diagnosticSettingsName": _SERIALIZER.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), + "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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings') + 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( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-06-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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 + ) + +# fmt: on class GuestDiagnosticsSettingsOperations(object): """GuestDiagnosticsSettingsOperations operations. @@ -45,6 +271,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -55,12 +282,13 @@ def create_or_update( # type: (...) -> "_models.GuestDiagnosticSettingsResource" """Creates or updates guest diagnostics settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param diagnostic_settings_name: The name of the diagnostic setting. :type diagnostic_settings_name: str :param diagnostic_settings: The configuration to create or update. - :type diagnostic_settings: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource + :type diagnostic_settings: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: GuestDiagnosticSettingsResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource @@ -71,38 +299,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-preview" - 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'diagnosticSettingsName': self._serialize.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(diagnostic_settings, 'GuestDiagnosticSettingsResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + diagnostic_settings_name=diagnostic_settings_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(diagnostic_settings, 'GuestDiagnosticSettingsResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -115,8 +333,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -126,7 +347,7 @@ def get( # type: (...) -> "_models.GuestDiagnosticSettingsResource" """Gets guest diagnostics settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param diagnostic_settings_name: The name of the diagnostic setting. :type diagnostic_settings_name: str @@ -140,33 +361,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'diagnosticSettingsName': self._serialize.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + diagnostic_settings_name=diagnostic_settings_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GuestDiagnosticSettingsResource', pipeline_response) @@ -175,8 +386,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -187,12 +401,13 @@ def update( # type: (...) -> "_models.GuestDiagnosticSettingsResource" """Updates guest diagnostics settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param diagnostic_settings_name: The name of the diagnostic setting. :type diagnostic_settings_name: str :param parameters: The configuration to patch. - :type parameters: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsPatchResource + :type parameters: + ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsPatchResource :keyword callable cls: A custom type or function that will be passed the direct response :return: GuestDiagnosticSettingsResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsResource @@ -203,38 +418,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'diagnosticSettingsName': self._serialize.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'GuestDiagnosticSettingsPatchResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + resource_group_name=resource_group_name, + diagnostic_settings_name=diagnostic_settings_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'GuestDiagnosticSettingsPatchResource') - 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, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -247,8 +452,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -258,7 +466,7 @@ def delete( # type: (...) -> None """Delete guest diagnostics settings. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param diagnostic_settings_name: The name of the diagnostic setting. :type diagnostic_settings_name: str @@ -272,33 +480,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'diagnosticSettingsName': self._serialize.url("diagnostic_settings_name", diagnostic_settings_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + diagnostic_settings_name=diagnostic_settings_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -306,6 +504,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/guestDiagnosticSettings/{diagnosticSettingsName}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -314,8 +514,10 @@ def list( """Get a list of all guest diagnostic settings 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 GuestDiagnosticSettingsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsList] + :return: An iterator like instance of either GuestDiagnosticSettingsList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsList"] @@ -323,34 +525,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-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 - 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_list_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('GuestDiagnosticSettingsList', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -363,17 +560,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/guestDiagnosticSettings'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -382,11 +581,13 @@ def list_by_resource_group( # type: (...) -> Iterable["_models.GuestDiagnosticSettingsList"] """Get a list of all guest diagnostic settings in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 GuestDiagnosticSettingsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsList] + :return: An iterator like instance of either GuestDiagnosticSettingsList or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_06_01_preview.models.GuestDiagnosticSettingsList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.GuestDiagnosticSettingsList"] @@ -394,35 +595,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-06-01-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('GuestDiagnosticSettingsList', pipeline_response) + deserialized = self._deserialize("GuestDiagnosticSettingsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -435,12 +632,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_configuration.py index 08864a6775762..7de60d5f82fb8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_metadata.json index 11badcc855fc4..55a9c50840f2c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "action_groups": "ActionGroupsOperations", diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_monitor_management_client.py index cdaddbe303282..06cb737742b85 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_monitor_management_client.py @@ -6,24 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ActionGroupsOperations, BaselineOperations, MetricBaselineOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations -from .operations import MetricBaselineOperations -from .operations import BaselineOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. @@ -31,58 +29,64 @@ class MonitorManagementClient(object): :ivar action_groups: ActionGroupsOperations operations :vartype action_groups: $(python-base-namespace).v2018_09_01.operations.ActionGroupsOperations :ivar metric_baseline: MetricBaselineOperations operations - :vartype metric_baseline: $(python-base-namespace).v2018_09_01.operations.MetricBaselineOperations + :vartype metric_baseline: + $(python-base-namespace).v2018_09_01.operations.MetricBaselineOperations :ivar baseline: BaselineOperations operations :vartype baseline: $(python-base-namespace).v2018_09_01.operations.BaselineOperations :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_baseline = MetricBaselineOperations(self._client, self._config, self._serialize, self._deserialize) + self.baseline = BaselineOperations(self._client, self._config, self._serialize, self._deserialize) - self.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.metric_baseline = MetricBaselineOperations( - self._client, self._config, self._serialize, self._deserialize) - self.baseline = BaselineOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_configuration.py index c2ff4d18ad786..3149ad11a3626 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_monitor_management_client.py index 52c95081d8ecc..13df9dc4d0553 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_monitor_management_client.py @@ -6,79 +6,84 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ActionGroupsOperations, BaselineOperations, MetricBaselineOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations -from .operations import MetricBaselineOperations -from .operations import BaselineOperations -from .. import models - - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: $(python-base-namespace).v2018_09_01.aio.operations.ActionGroupsOperations + :vartype action_groups: + $(python-base-namespace).v2018_09_01.aio.operations.ActionGroupsOperations :ivar metric_baseline: MetricBaselineOperations operations - :vartype metric_baseline: $(python-base-namespace).v2018_09_01.aio.operations.MetricBaselineOperations + :vartype metric_baseline: + $(python-base-namespace).v2018_09_01.aio.operations.MetricBaselineOperations :ivar baseline: BaselineOperations operations :vartype baseline: $(python-base-namespace).v2018_09_01.aio.operations.BaselineOperations :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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.metric_baseline = MetricBaselineOperations(self._client, self._config, self._serialize, self._deserialize) + self.baseline = BaselineOperations(self._client, self._config, self._serialize, self._deserialize) - self.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.metric_baseline = MetricBaselineOperations( - self._client, self._config, self._serialize, self._deserialize) - self.baseline = BaselineOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_action_groups_operations.py index fbf6c3294322c..0ba01330e7c1a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_action_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._action_groups_operations import build_create_or_update_request, build_delete_request, build_enable_receiver_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_update_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_async async def create_or_update( self, resource_group_name: str, @@ -50,7 +56,7 @@ async def create_or_update( ) -> "_models.ActionGroupResource": """Create a new action group or update an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -66,38 +72,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group, 'ActionGroupResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group, 'ActionGroupResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -110,8 +106,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -120,7 +119,7 @@ async def get( ) -> "_models.ActionGroupResource": """Get an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -134,33 +133,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -169,8 +158,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -179,7 +171,7 @@ async def delete( ) -> None: """Delete an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -193,33 +185,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -227,6 +209,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -236,7 +220,7 @@ async def update( ) -> "_models.ActionGroupResource": """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -252,38 +236,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01" - 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'), - 'actionGroupName': self._serialize.url("action_group_name", action_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -292,8 +266,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def list_by_subscription_id( self, **kwargs: Any @@ -302,7 +279,8 @@ def list_by_subscription_id( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ActionGroupList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -310,34 +288,29 @@ def list_by_subscription_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-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_subscription_id.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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription_id.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_list_by_subscription_id_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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -350,17 +323,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -368,11 +343,12 @@ def list_by_resource_group( ) -> AsyncIterable["_models.ActionGroupList"]: """Get a list of all action groups in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 ActionGroupList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -380,35 +356,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -421,17 +393,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.insights/actionGroups'} # type: ignore + @distributed_trace_async async def enable_receiver( self, resource_group_name: str, @@ -442,7 +416,7 @@ async def enable_receiver( """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -458,41 +432,32 @@ async def enable_receiver( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.enable_receiver.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(enable_request, 'EnableRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_enable_receiver_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.enable_receiver.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(enable_request, 'EnableRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(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, 409]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) enable_receiver.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baseline_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baseline_operations.py index c8c76e693c6ae..13ea4d73c051a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baseline_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_baseline_operations.py @@ -6,16 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._baseline_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_uri: str, @@ -92,47 +97,29 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01" - accept = "application/json" - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if metricnames is not None: - query_parameters['metricnames'] = self._serialize.query("metricnames", metricnames, 'str') - if timespan is not None: - query_parameters['timespan'] = self._serialize.query("timespan", timespan, 'str') - if interval is not None: - query_parameters['interval'] = self._serialize.query("interval", interval, 'duration') - if aggregation is not None: - query_parameters['aggregation'] = self._serialize.query("aggregation", aggregation, 'str') - if sensitivities is not None: - query_parameters['sensitivities'] = self._serialize.query("sensitivities", sensitivities, 'str') - if result_type is not None: - query_parameters['resultType'] = self._serialize.query("result_type", result_type, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if metricnamespace is not None: - query_parameters['metricnamespace'] = self._serialize.query("metricnamespace", metricnamespace, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, '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_request( + resource_uri=resource_uri, + metricnames=metricnames, + timespan=timespan, + interval=interval, + aggregation=aggregation, + sensitivities=sensitivities, + result_type=result_type, + metricnamespace=metricnamespace, + filter=filter, + template_url=self.get.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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BaselineResponse', pipeline_response) @@ -141,4 +128,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/baseline'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_metric_baseline_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_metric_baseline_operations.py index 0bc346ea0e7e6..2837800f421e9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_metric_baseline_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/aio/operations/_metric_baseline_operations.py @@ -6,16 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings 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_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._metric_baseline_operations import build_calculate_baseline_request, build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_uri: str, @@ -90,46 +95,29 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'metricName': self._serialize.url("metric_name", metric_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if timespan is not None: - query_parameters['timespan'] = self._serialize.query("timespan", timespan, 'str') - if interval is not None: - query_parameters['interval'] = self._serialize.query("interval", interval, 'duration') - if aggregation is not None: - query_parameters['aggregation'] = self._serialize.query("aggregation", aggregation, 'str') - if sensitivities is not None: - query_parameters['sensitivities'] = self._serialize.query("sensitivities", sensitivities, 'str') - if result_type is not None: - query_parameters['resultType'] = self._serialize.query("result_type", result_type, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if metricnamespace is not None: - query_parameters['metricnamespace'] = self._serialize.query("metricnamespace", metricnamespace, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, '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_request( + resource_uri=resource_uri, + metric_name=metric_name, + timespan=timespan, + interval=interval, + aggregation=aggregation, + sensitivities=sensitivities, + result_type=result_type, + metricnamespace=metricnamespace, + filter=filter, + template_url=self.get.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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BaselineResponse', pipeline_response) @@ -138,8 +126,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/baseline/{metricName}'} # type: ignore + + @distributed_trace_async async def calculate_baseline( self, resource_uri: str, @@ -155,7 +146,8 @@ async def calculate_baseline( :type resource_uri: str :param time_series_information: Information that need to be specified to calculate a baseline on a time series. - :type time_series_information: ~$(python-base-namespace).v2018_09_01.models.TimeSeriesInformation + :type time_series_information: + ~$(python-base-namespace).v2018_09_01.models.TimeSeriesInformation :keyword callable cls: A custom type or function that will be passed the direct response :return: CalculateBaselineResponse, or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_09_01.models.CalculateBaselineResponse @@ -166,36 +158,26 @@ async def calculate_baseline( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_baseline.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(time_series_information, 'TimeSeriesInformation') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_calculate_baseline_request( + resource_uri=resource_uri, + content_type=content_type, + json=_json, + template_url=self.calculate_baseline.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(time_series_information, 'TimeSeriesInformation') - body_content_kwargs['content'] = body_content - request = self._client.post(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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CalculateBaselineResponse', pipeline_response) @@ -204,4 +186,6 @@ async def calculate_baseline( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_baseline.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/calculatebaseline'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models.py index 5e39f2d75afc1..5d41016c62538 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models.py @@ -13,10 +13,10 @@ class ActionGroupList(msrest.serialization.Model): """A list of action groups. - :param value: The list of action groups. - :type value: list[~$(python-base-namespace).v2018_09_01.models.ActionGroupResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar value: The list of action groups. + :vartype value: list[~$(python-base-namespace).v2018_09_01.models.ActionGroupResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -28,6 +28,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of action groups. + :paramtype value: list[~$(python-base-namespace).v2018_09_01.models.ActionGroupResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(ActionGroupList, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -36,11 +42,11 @@ def __init__( class ActionGroupPatchBody(msrest.serialization.Model): """An action group object for the body of patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. - :type enabled: bool + :vartype enabled: bool """ _attribute_map = { @@ -52,6 +58,13 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ super(ActionGroupPatchBody, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.enabled = kwargs.get('enabled', True) @@ -70,10 +83,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -95,6 +108,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -116,42 +135,43 @@ class ActionGroupResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param group_short_name: The short name of the action group. This will be used in SMS messages. - :type group_short_name: str - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar group_short_name: The short name of the action group. This will be used in SMS messages. + :vartype group_short_name: str + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. - :type enabled: bool - :param email_receivers: The list of email receivers that are part of this action group. - :type email_receivers: list[~$(python-base-namespace).v2018_09_01.models.EmailReceiver] - :param sms_receivers: The list of SMS receivers that are part of this action group. - :type sms_receivers: list[~$(python-base-namespace).v2018_09_01.models.SmsReceiver] - :param webhook_receivers: The list of webhook receivers that are part of this action group. - :type webhook_receivers: list[~$(python-base-namespace).v2018_09_01.models.WebhookReceiver] - :param itsm_receivers: The list of ITSM receivers that are part of this action group. - :type itsm_receivers: list[~$(python-base-namespace).v2018_09_01.models.ItsmReceiver] - :param azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :type azure_app_push_receivers: + :vartype enabled: bool + :ivar email_receivers: The list of email receivers that are part of this action group. + :vartype email_receivers: list[~$(python-base-namespace).v2018_09_01.models.EmailReceiver] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~$(python-base-namespace).v2018_09_01.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~$(python-base-namespace).v2018_09_01.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~$(python-base-namespace).v2018_09_01.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: list[~$(python-base-namespace).v2018_09_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of this action group. - :type automation_runbook_receivers: + :vartype automation_runbook_receivers: list[~$(python-base-namespace).v2018_09_01.models.AutomationRunbookReceiver] - :param voice_receivers: The list of voice receivers that are part of this action group. - :type voice_receivers: list[~$(python-base-namespace).v2018_09_01.models.VoiceReceiver] - :param logic_app_receivers: The list of logic app receivers that are part of this action group. - :type logic_app_receivers: list[~$(python-base-namespace).v2018_09_01.models.LogicAppReceiver] - :param azure_function_receivers: The list of azure function receivers that are part of this + :ivar voice_receivers: The list of voice receivers that are part of this action group. + :vartype voice_receivers: list[~$(python-base-namespace).v2018_09_01.models.VoiceReceiver] + :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. + :vartype logic_app_receivers: + list[~$(python-base-namespace).v2018_09_01.models.LogicAppReceiver] + :ivar azure_function_receivers: The list of azure function receivers that are part of this action group. - :type azure_function_receivers: + :vartype azure_function_receivers: list[~$(python-base-namespace).v2018_09_01.models.AzureFunctionReceiver] - :param arm_role_receivers: The list of ARM role receivers that are part of this action group. + :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. Roles are Azure RBAC roles and only built-in roles are supported. - :type arm_role_receivers: list[~$(python-base-namespace).v2018_09_01.models.ArmRoleReceiver] + :vartype arm_role_receivers: list[~$(python-base-namespace).v2018_09_01.models.ArmRoleReceiver] """ _validation = { @@ -186,6 +206,49 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword group_short_name: The short name of the action group. This will be used in SMS + messages. + :paramtype group_short_name: str + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its receivers will receive communications. + :paramtype enabled: bool + :keyword email_receivers: The list of email receivers that are part of this action group. + :paramtype email_receivers: list[~$(python-base-namespace).v2018_09_01.models.EmailReceiver] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~$(python-base-namespace).v2018_09_01.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: + list[~$(python-base-namespace).v2018_09_01.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~$(python-base-namespace).v2018_09_01.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: + list[~$(python-base-namespace).v2018_09_01.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~$(python-base-namespace).v2018_09_01.models.AutomationRunbookReceiver] + :keyword voice_receivers: The list of voice receivers that are part of this action group. + :paramtype voice_receivers: list[~$(python-base-namespace).v2018_09_01.models.VoiceReceiver] + :keyword logic_app_receivers: The list of logic app receivers that are part of this action + group. + :paramtype logic_app_receivers: + list[~$(python-base-namespace).v2018_09_01.models.LogicAppReceiver] + :keyword azure_function_receivers: The list of azure function receivers that are part of this + action group. + :paramtype azure_function_receivers: + list[~$(python-base-namespace).v2018_09_01.models.AzureFunctionReceiver] + :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :paramtype arm_role_receivers: + list[~$(python-base-namespace).v2018_09_01.models.ArmRoleReceiver] + """ super(ActionGroupResource, self).__init__(**kwargs) self.group_short_name = kwargs.get('group_short_name', None) self.enabled = kwargs.get('enabled', True) @@ -206,11 +269,11 @@ class ArmRoleReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the arm role receiver. Names must be unique across all + :ivar name: Required. The name of the arm role receiver. Names must be unique across all receivers within an action group. - :type name: str - :param role_id: Required. The arm role id. - :type role_id: str + :vartype name: str + :ivar role_id: Required. The arm role id. + :vartype role_id: str """ _validation = { @@ -227,6 +290,13 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the arm role receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword role_id: Required. The arm role id. + :paramtype role_id: str + """ super(ArmRoleReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.role_id = kwargs['role_id'] @@ -237,19 +307,19 @@ class AutomationRunbookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. - :type automation_account_id: str - :param runbook_name: Required. The name for this runbook. - :type runbook_name: str - :param webhook_resource_id: Required. The resource id for webhook linked to this runbook. - :type webhook_resource_id: str - :param is_global_runbook: Required. Indicates whether this instance is global runbook. - :type is_global_runbook: bool - :param name: Indicates name of the webhook. - :type name: str - :param service_uri: The URI where webhooks should be sent. - :type service_uri: str + :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook + and authenticate to Azure resource. + :vartype automation_account_id: str + :ivar runbook_name: Required. The name for this runbook. + :vartype runbook_name: str + :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :vartype webhook_resource_id: str + :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :vartype is_global_runbook: bool + :ivar name: Indicates name of the webhook. + :vartype name: str + :ivar service_uri: The URI where webhooks should be sent. + :vartype service_uri: str """ _validation = { @@ -272,6 +342,21 @@ def __init__( self, **kwargs ): + """ + :keyword automation_account_id: Required. The Azure automation account Id which holds this + runbook and authenticate to Azure resource. + :paramtype automation_account_id: str + :keyword runbook_name: Required. The name for this runbook. + :paramtype runbook_name: str + :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :paramtype webhook_resource_id: str + :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :paramtype is_global_runbook: bool + :keyword name: Indicates name of the webhook. + :paramtype name: str + :keyword service_uri: The URI where webhooks should be sent. + :paramtype service_uri: str + """ super(AutomationRunbookReceiver, self).__init__(**kwargs) self.automation_account_id = kwargs['automation_account_id'] self.runbook_name = kwargs['runbook_name'] @@ -286,11 +371,11 @@ class AzureAppPushReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Azure mobile app push receiver. Names must be unique + :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. - :type name: str - :param email_address: Required. The email address registered for the Azure mobile app. - :type email_address: str + :vartype name: str + :ivar email_address: Required. The email address registered for the Azure mobile app. + :vartype email_address: str """ _validation = { @@ -307,6 +392,13 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique + across all receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address registered for the Azure mobile app. + :paramtype email_address: str + """ super(AzureAppPushReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.email_address = kwargs['email_address'] @@ -317,15 +409,15 @@ class AzureFunctionReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the azure function receiver. Names must be unique across all + :ivar name: Required. The name of the azure function receiver. Names must be unique across all receivers within an action group. - :type name: str - :param function_app_resource_id: Required. The azure resource id of the function app. - :type function_app_resource_id: str - :param function_name: Required. The function name in the function app. - :type function_name: str - :param http_trigger_url: Required. The http trigger url where http request sent to. - :type http_trigger_url: str + :vartype name: str + :ivar function_app_resource_id: Required. The azure resource id of the function app. + :vartype function_app_resource_id: str + :ivar function_name: Required. The function name in the function app. + :vartype function_name: str + :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :vartype http_trigger_url: str """ _validation = { @@ -346,6 +438,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the azure function receiver. Names must be unique across + all receivers within an action group. + :paramtype name: str + :keyword function_app_resource_id: Required. The azure resource id of the function app. + :paramtype function_app_resource_id: str + :keyword function_name: Required. The function name in the function app. + :paramtype function_name: str + :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :paramtype http_trigger_url: str + """ super(AzureFunctionReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.function_app_resource_id = kwargs['function_app_resource_id'] @@ -358,22 +461,22 @@ class Baseline(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sensitivity: Required. The sensitivity of the baseline. Possible values include: "Low", + :ivar sensitivity: Required. The sensitivity of the baseline. Possible values include: "Low", "Medium", "High". - :type sensitivity: str or ~$(python-base-namespace).v2018_09_01.models.Sensitivity - :param low_thresholds: Required. The low thresholds of the baseline. - :type low_thresholds: list[float] - :param high_thresholds: Required. The high thresholds of the baseline. - :type high_thresholds: list[float] - :param timestamps: the array of timestamps of the baselines. - :type timestamps: list[~datetime.datetime] - :param prediction_result_type: The prediction result type of the baseline. Possible values - include: "0", "1", "2". - :type prediction_result_type: str or + :vartype sensitivity: str or ~$(python-base-namespace).v2018_09_01.models.Sensitivity + :ivar low_thresholds: Required. The low thresholds of the baseline. + :vartype low_thresholds: list[float] + :ivar high_thresholds: Required. The high thresholds of the baseline. + :vartype high_thresholds: list[float] + :ivar timestamps: the array of timestamps of the baselines. + :vartype timestamps: list[~datetime.datetime] + :ivar prediction_result_type: The prediction result type of the baseline. Possible values + include: 0, 1, 2. + :vartype prediction_result_type: int or ~$(python-base-namespace).v2018_09_01.models.PredictionResultType - :param error_type: The error type of the baseline. Possible values include: "0", "1", "2", "3", - "4", "100", "200". - :type error_type: str or ~$(python-base-namespace).v2018_09_01.models.ErrorType + :ivar error_type: The error type of the baseline. Possible values include: 0, 1, 2, 3, 4, 100, + 200. + :vartype error_type: int or ~$(python-base-namespace).v2018_09_01.models.ErrorType """ _validation = { @@ -387,14 +490,32 @@ class Baseline(msrest.serialization.Model): 'low_thresholds': {'key': 'lowThresholds', 'type': '[float]'}, 'high_thresholds': {'key': 'highThresholds', 'type': '[float]'}, 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, - 'prediction_result_type': {'key': 'PredictionResultType', 'type': 'str'}, - 'error_type': {'key': 'ErrorType', 'type': 'str'}, + 'prediction_result_type': {'key': 'PredictionResultType', 'type': 'int'}, + 'error_type': {'key': 'ErrorType', 'type': 'int'}, } def __init__( self, **kwargs ): + """ + :keyword sensitivity: Required. The sensitivity of the baseline. Possible values include: + "Low", "Medium", "High". + :paramtype sensitivity: str or ~$(python-base-namespace).v2018_09_01.models.Sensitivity + :keyword low_thresholds: Required. The low thresholds of the baseline. + :paramtype low_thresholds: list[float] + :keyword high_thresholds: Required. The high thresholds of the baseline. + :paramtype high_thresholds: list[float] + :keyword timestamps: the array of timestamps of the baselines. + :paramtype timestamps: list[~datetime.datetime] + :keyword prediction_result_type: The prediction result type of the baseline. Possible values + include: 0, 1, 2. + :paramtype prediction_result_type: int or + ~$(python-base-namespace).v2018_09_01.models.PredictionResultType + :keyword error_type: The error type of the baseline. Possible values include: 0, 1, 2, 3, 4, + 100, 200. + :paramtype error_type: int or ~$(python-base-namespace).v2018_09_01.models.ErrorType + """ super(Baseline, self).__init__(**kwargs) self.sensitivity = kwargs['sensitivity'] self.low_thresholds = kwargs['low_thresholds'] @@ -407,10 +528,10 @@ def __init__( class BaselineMetadataValue(msrest.serialization.Model): """Represents a baseline metadata value. - :param name: The name of the metadata. - :type name: ~$(python-base-namespace).v2018_09_01.models.LocalizableString - :param value: The value of the metadata. - :type value: str + :ivar name: The name of the metadata. + :vartype name: ~$(python-base-namespace).v2018_09_01.models.LocalizableString + :ivar value: The value of the metadata. + :vartype value: str """ _attribute_map = { @@ -422,6 +543,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: The name of the metadata. + :paramtype name: ~$(python-base-namespace).v2018_09_01.models.LocalizableString + :keyword value: The value of the metadata. + :paramtype value: str + """ super(BaselineMetadataValue, self).__init__(**kwargs) self.name = kwargs.get('name', None) self.value = kwargs.get('value', None) @@ -438,29 +565,29 @@ class BaselineResponse(msrest.serialization.Model): :vartype type: str :ivar name: The name and the display name of the metric, i.e. it is localizable string. :vartype name: ~$(python-base-namespace).v2018_09_01.models.LocalizableString - :param timestamps: The array of timestamps of the baselines. - :type timestamps: list[~datetime.datetime] - :param baseline: The baseline values for each sensitivity. - :type baseline: list[~$(python-base-namespace).v2018_09_01.models.Baseline] - :param metdata: The baseline metadata values. - :type metdata: list[~$(python-base-namespace).v2018_09_01.models.BaselineMetadataValue] - :param prediction_result_type: The prediction result type of the baseline. Possible values - include: "0", "1", "2". - :type prediction_result_type: str or + :ivar timestamps: The array of timestamps of the baselines. + :vartype timestamps: list[~datetime.datetime] + :ivar baseline: The baseline values for each sensitivity. + :vartype baseline: list[~$(python-base-namespace).v2018_09_01.models.Baseline] + :ivar metdata: The baseline metadata values. + :vartype metdata: list[~$(python-base-namespace).v2018_09_01.models.BaselineMetadataValue] + :ivar prediction_result_type: The prediction result type of the baseline. Possible values + include: 0, 1, 2. + :vartype prediction_result_type: int or ~$(python-base-namespace).v2018_09_01.models.PredictionResultType - :param error_type: The error type of the baseline. Possible values include: "0", "1", "2", "3", - "4", "100", "200". - :type error_type: str or ~$(python-base-namespace).v2018_09_01.models.ErrorType - :param timespan: The timespan for which the data was retrieved. Its value consists of two + :ivar error_type: The error type of the baseline. Possible values include: 0, 1, 2, 3, 4, 100, + 200. + :vartype error_type: int or ~$(python-base-namespace).v2018_09_01.models.ErrorType + :ivar timespan: The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. - :type timespan: str - :param interval: The interval (window size) for which the metric data was returned in. This - may be adjusted in the future and returned back from what was originally requested. This is - not present if a metadata request was made. - :type interval: ~datetime.timedelta - :param aggregation: The aggregation type of the metric. - :type aggregation: str + :vartype timespan: str + :ivar interval: The interval (window size) for which the metric data was returned in. This may + be adjusted in the future and returned back from what was originally requested. This is not + present if a metadata request was made. + :vartype interval: ~datetime.timedelta + :ivar aggregation: The aggregation type of the metric. + :vartype aggregation: str :ivar internal_operation_id: internal operation id. :vartype internal_operation_id: str """ @@ -479,8 +606,8 @@ class BaselineResponse(msrest.serialization.Model): 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, 'baseline': {'key': 'baseline', 'type': '[Baseline]'}, 'metdata': {'key': 'metdata', 'type': '[BaselineMetadataValue]'}, - 'prediction_result_type': {'key': 'predictionResultType', 'type': 'str'}, - 'error_type': {'key': 'errorType', 'type': 'str'}, + 'prediction_result_type': {'key': 'predictionResultType', 'type': 'int'}, + 'error_type': {'key': 'errorType', 'type': 'int'}, 'timespan': {'key': 'properties.timespan', 'type': 'str'}, 'interval': {'key': 'properties.interval', 'type': 'duration'}, 'aggregation': {'key': 'properties.aggregation', 'type': 'str'}, @@ -491,6 +618,31 @@ def __init__( self, **kwargs ): + """ + :keyword timestamps: The array of timestamps of the baselines. + :paramtype timestamps: list[~datetime.datetime] + :keyword baseline: The baseline values for each sensitivity. + :paramtype baseline: list[~$(python-base-namespace).v2018_09_01.models.Baseline] + :keyword metdata: The baseline metadata values. + :paramtype metdata: list[~$(python-base-namespace).v2018_09_01.models.BaselineMetadataValue] + :keyword prediction_result_type: The prediction result type of the baseline. Possible values + include: 0, 1, 2. + :paramtype prediction_result_type: int or + ~$(python-base-namespace).v2018_09_01.models.PredictionResultType + :keyword error_type: The error type of the baseline. Possible values include: 0, 1, 2, 3, 4, + 100, 200. + :paramtype error_type: int or ~$(python-base-namespace).v2018_09_01.models.ErrorType + :keyword timespan: The timespan for which the data was retrieved. Its value consists of two + datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back + from what was originally requested. + :paramtype timespan: str + :keyword interval: The interval (window size) for which the metric data was returned in. This + may be adjusted in the future and returned back from what was originally requested. This is + not present if a metadata request was made. + :paramtype interval: ~datetime.timedelta + :keyword aggregation: The aggregation type of the metric. + :paramtype aggregation: str + """ super(BaselineResponse, self).__init__(**kwargs) self.id = None self.type = None @@ -513,20 +665,20 @@ class CalculateBaselineResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. The resource type of the baseline resource. - :type type: str - :param timestamps: The array of timestamps of the baselines. - :type timestamps: list[~datetime.datetime] - :param baseline: Required. The baseline values for each sensitivity. - :type baseline: list[~$(python-base-namespace).v2018_09_01.models.Baseline] - :param statistics: The statistics. - :type statistics: + :ivar type: Required. The resource type of the baseline resource. + :vartype type: str + :ivar timestamps: The array of timestamps of the baselines. + :vartype timestamps: list[~datetime.datetime] + :ivar baseline: Required. The baseline values for each sensitivity. + :vartype baseline: list[~$(python-base-namespace).v2018_09_01.models.Baseline] + :ivar statistics: The statistics. + :vartype statistics: ~$(python-base-namespace).v2018_09_01.models.CalculateBaselineResponseStatistics :ivar internal_operation_id: internal operation id. :vartype internal_operation_id: str - :param error_type: The error type for calculating the baseline. Possible values include: "0", - "1", "2", "3", "4", "100", "200". - :type error_type: str or ~$(python-base-namespace).v2018_09_01.models.ErrorType + :ivar error_type: The error type for calculating the baseline. Possible values include: 0, 1, + 2, 3, 4, 100, 200. + :vartype error_type: int or ~$(python-base-namespace).v2018_09_01.models.ErrorType """ _validation = { @@ -541,13 +693,27 @@ class CalculateBaselineResponse(msrest.serialization.Model): 'baseline': {'key': 'baseline', 'type': '[Baseline]'}, 'statistics': {'key': 'statistics', 'type': 'CalculateBaselineResponseStatistics'}, 'internal_operation_id': {'key': 'internalOperationId', 'type': 'str'}, - 'error_type': {'key': 'errorType', 'type': 'str'}, + 'error_type': {'key': 'errorType', 'type': 'int'}, } def __init__( self, **kwargs ): + """ + :keyword type: Required. The resource type of the baseline resource. + :paramtype type: str + :keyword timestamps: The array of timestamps of the baselines. + :paramtype timestamps: list[~datetime.datetime] + :keyword baseline: Required. The baseline values for each sensitivity. + :paramtype baseline: list[~$(python-base-namespace).v2018_09_01.models.Baseline] + :keyword statistics: The statistics. + :paramtype statistics: + ~$(python-base-namespace).v2018_09_01.models.CalculateBaselineResponseStatistics + :keyword error_type: The error type for calculating the baseline. Possible values include: 0, + 1, 2, 3, 4, 100, 200. + :paramtype error_type: int or ~$(python-base-namespace).v2018_09_01.models.ErrorType + """ super(CalculateBaselineResponse, self).__init__(**kwargs) self.type = kwargs['type'] self.timestamps = kwargs.get('timestamps', None) @@ -560,12 +726,12 @@ def __init__( class CalculateBaselineResponseStatistics(msrest.serialization.Model): """The statistics. - :param is_eligible: is series eligible for dynamic threshold analysis. - :type is_eligible: bool - :param status: The list of extended status for calculating the baseline. - :type status: list[str] - :param seasonality_period: The seasonality period for calculating the baseline. - :type seasonality_period: int + :ivar is_eligible: is series eligible for dynamic threshold analysis. + :vartype is_eligible: bool + :ivar status: The list of extended status for calculating the baseline. + :vartype status: list[str] + :ivar seasonality_period: The seasonality period for calculating the baseline. + :vartype seasonality_period: int """ _attribute_map = { @@ -578,6 +744,14 @@ def __init__( self, **kwargs ): + """ + :keyword is_eligible: is series eligible for dynamic threshold analysis. + :paramtype is_eligible: bool + :keyword status: The list of extended status for calculating the baseline. + :paramtype status: list[str] + :keyword seasonality_period: The seasonality period for calculating the baseline. + :paramtype seasonality_period: int + """ super(CalculateBaselineResponseStatistics, self).__init__(**kwargs) self.is_eligible = kwargs.get('is_eligible', None) self.status = kwargs.get('status', None) @@ -591,11 +765,11 @@ class EmailReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param email_address: Required. The email address of this receiver. - :type email_address: str + :ivar name: Required. The name of the email receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar email_address: Required. The email address of this receiver. + :vartype email_address: str :ivar status: The receiver status of the e-mail. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2018_09_01.models.ReceiverStatus @@ -617,6 +791,13 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the email receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address of this receiver. + :paramtype email_address: str + """ super(EmailReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.email_address = kwargs['email_address'] @@ -628,8 +809,8 @@ class EnableRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param receiver_name: Required. The name of the receiver to resubscribe. - :type receiver_name: str + :ivar receiver_name: Required. The name of the receiver to resubscribe. + :vartype receiver_name: str """ _validation = { @@ -644,6 +825,10 @@ def __init__( self, **kwargs ): + """ + :keyword receiver_name: Required. The name of the receiver to resubscribe. + :paramtype receiver_name: str + """ super(EnableRequest, self).__init__(**kwargs) self.receiver_name = kwargs['receiver_name'] @@ -651,10 +836,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -666,6 +851,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -676,20 +867,20 @@ class ItsmReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Itsm receiver. Names must be unique across all receivers + :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers within an action group. - :type name: str - :param workspace_id: Required. OMS LA instance identifier. - :type workspace_id: str - :param connection_id: Required. Unique identification of ITSM connection among multiple defined + :vartype name: str + :ivar workspace_id: Required. OMS LA instance identifier. + :vartype workspace_id: str + :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined in above workspace. - :type connection_id: str - :param ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + :vartype connection_id: str + :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as well. - :type ticket_configuration: str - :param region: Required. Region in which workspace resides. Supported + :vartype ticket_configuration: str + :ivar region: Required. Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - :type region: str + :vartype region: str """ _validation = { @@ -712,6 +903,22 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the Itsm receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword workspace_id: Required. OMS LA instance identifier. + :paramtype workspace_id: str + :keyword connection_id: Required. Unique identification of ITSM connection among multiple + defined in above workspace. + :paramtype connection_id: str + :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. + :paramtype ticket_configuration: str + :keyword region: Required. Region in which workspace resides. Supported + values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + :paramtype region: str + """ super(ItsmReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.workspace_id = kwargs['workspace_id'] @@ -725,10 +932,10 @@ class LocalizableString(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. The invariant value. - :type value: str - :param localized_value: The locale specific value. - :type localized_value: str + :ivar value: Required. The invariant value. + :vartype value: str + :ivar localized_value: The locale specific value. + :vartype localized_value: str """ _validation = { @@ -744,6 +951,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. The invariant value. + :paramtype value: str + :keyword localized_value: The locale specific value. + :paramtype localized_value: str + """ super(LocalizableString, self).__init__(**kwargs) self.value = kwargs['value'] self.localized_value = kwargs.get('localized_value', None) @@ -754,13 +967,13 @@ class LogicAppReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the logic app receiver. Names must be unique across all + :ivar name: Required. The name of the logic app receiver. Names must be unique across all receivers within an action group. - :type name: str - :param resource_id: Required. The azure resource id of the logic app receiver. - :type resource_id: str - :param callback_url: Required. The callback url where http request sent to. - :type callback_url: str + :vartype name: str + :ivar resource_id: Required. The azure resource id of the logic app receiver. + :vartype resource_id: str + :ivar callback_url: Required. The callback url where http request sent to. + :vartype callback_url: str """ _validation = { @@ -779,6 +992,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the logic app receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword resource_id: Required. The azure resource id of the logic app receiver. + :paramtype resource_id: str + :keyword callback_url: Required. The callback url where http request sent to. + :paramtype callback_url: str + """ super(LogicAppReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.resource_id = kwargs['resource_id'] @@ -792,13 +1014,13 @@ class SmsReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SMS receiver. Names must be unique across all receivers + :ivar name: Required. The name of the SMS receiver. Names must be unique across all receivers within an action group. - :type name: str - :param country_code: Required. The country code of the SMS receiver. - :type country_code: str - :param phone_number: Required. The phone number of the SMS receiver. - :type phone_number: str + :vartype name: str + :ivar country_code: Required. The country code of the SMS receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the SMS receiver. + :vartype phone_number: str :ivar status: The status of the receiver. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2018_09_01.models.ReceiverStatus @@ -822,6 +1044,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the SMS receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the SMS receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the SMS receiver. + :paramtype phone_number: str + """ super(SmsReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.country_code = kwargs['country_code'] @@ -834,12 +1065,12 @@ class TimeSeriesInformation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sensitivities: Required. The list of sensitivities for calculating the baseline. - :type sensitivities: list[str] - :param values: Required. The metric values to calculate the baseline. - :type values: list[float] - :param timestamps: The array of timestamps of the baselines. - :type timestamps: list[~datetime.datetime] + :ivar sensitivities: Required. The list of sensitivities for calculating the baseline. + :vartype sensitivities: list[str] + :ivar values: Required. The metric values to calculate the baseline. + :vartype values: list[float] + :ivar timestamps: The array of timestamps of the baselines. + :vartype timestamps: list[~datetime.datetime] """ _validation = { @@ -857,6 +1088,14 @@ def __init__( self, **kwargs ): + """ + :keyword sensitivities: Required. The list of sensitivities for calculating the baseline. + :paramtype sensitivities: list[str] + :keyword values: Required. The metric values to calculate the baseline. + :paramtype values: list[float] + :keyword timestamps: The array of timestamps of the baselines. + :paramtype timestamps: list[~datetime.datetime] + """ super(TimeSeriesInformation, self).__init__(**kwargs) self.sensitivities = kwargs['sensitivities'] self.values = kwargs['values'] @@ -868,13 +1107,13 @@ class VoiceReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the voice receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param country_code: Required. The country code of the voice receiver. - :type country_code: str - :param phone_number: Required. The phone number of the voice receiver. - :type phone_number: str + :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar country_code: Required. The country code of the voice receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the voice receiver. + :vartype phone_number: str """ _validation = { @@ -893,6 +1132,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the voice receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the voice receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the voice receiver. + :paramtype phone_number: str + """ super(VoiceReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.country_code = kwargs['country_code'] @@ -904,11 +1152,11 @@ class WebhookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the webhook receiver. Names must be unique across all + :ivar name: Required. The name of the webhook receiver. Names must be unique across all receivers within an action group. - :type name: str - :param service_uri: Required. The URI where webhooks should be sent. - :type service_uri: str + :vartype name: str + :ivar service_uri: Required. The URI where webhooks should be sent. + :vartype service_uri: str """ _validation = { @@ -925,6 +1173,13 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the webhook receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword service_uri: Required. The URI where webhooks should be sent. + :paramtype service_uri: str + """ super(WebhookReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.service_uri = kwargs['service_uri'] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models_py3.py index 6bb97b5a84c68..6f09b8bfb067d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_models_py3.py @@ -18,10 +18,10 @@ class ActionGroupList(msrest.serialization.Model): """A list of action groups. - :param value: The list of action groups. - :type value: list[~$(python-base-namespace).v2018_09_01.models.ActionGroupResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar value: The list of action groups. + :vartype value: list[~$(python-base-namespace).v2018_09_01.models.ActionGroupResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -36,6 +36,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of action groups. + :paramtype value: list[~$(python-base-namespace).v2018_09_01.models.ActionGroupResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(ActionGroupList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -44,11 +50,11 @@ def __init__( class ActionGroupPatchBody(msrest.serialization.Model): """An action group object for the body of patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. - :type enabled: bool + :vartype enabled: bool """ _attribute_map = { @@ -63,6 +69,13 @@ def __init__( enabled: Optional[bool] = True, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ super(ActionGroupPatchBody, self).__init__(**kwargs) self.tags = tags self.enabled = enabled @@ -81,10 +94,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -109,6 +122,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -130,42 +149,43 @@ class ActionGroupResource(Resource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param group_short_name: The short name of the action group. This will be used in SMS messages. - :type group_short_name: str - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar group_short_name: The short name of the action group. This will be used in SMS messages. + :vartype group_short_name: str + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. - :type enabled: bool - :param email_receivers: The list of email receivers that are part of this action group. - :type email_receivers: list[~$(python-base-namespace).v2018_09_01.models.EmailReceiver] - :param sms_receivers: The list of SMS receivers that are part of this action group. - :type sms_receivers: list[~$(python-base-namespace).v2018_09_01.models.SmsReceiver] - :param webhook_receivers: The list of webhook receivers that are part of this action group. - :type webhook_receivers: list[~$(python-base-namespace).v2018_09_01.models.WebhookReceiver] - :param itsm_receivers: The list of ITSM receivers that are part of this action group. - :type itsm_receivers: list[~$(python-base-namespace).v2018_09_01.models.ItsmReceiver] - :param azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :type azure_app_push_receivers: + :vartype enabled: bool + :ivar email_receivers: The list of email receivers that are part of this action group. + :vartype email_receivers: list[~$(python-base-namespace).v2018_09_01.models.EmailReceiver] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~$(python-base-namespace).v2018_09_01.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~$(python-base-namespace).v2018_09_01.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~$(python-base-namespace).v2018_09_01.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: list[~$(python-base-namespace).v2018_09_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of this action group. - :type automation_runbook_receivers: + :vartype automation_runbook_receivers: list[~$(python-base-namespace).v2018_09_01.models.AutomationRunbookReceiver] - :param voice_receivers: The list of voice receivers that are part of this action group. - :type voice_receivers: list[~$(python-base-namespace).v2018_09_01.models.VoiceReceiver] - :param logic_app_receivers: The list of logic app receivers that are part of this action group. - :type logic_app_receivers: list[~$(python-base-namespace).v2018_09_01.models.LogicAppReceiver] - :param azure_function_receivers: The list of azure function receivers that are part of this + :ivar voice_receivers: The list of voice receivers that are part of this action group. + :vartype voice_receivers: list[~$(python-base-namespace).v2018_09_01.models.VoiceReceiver] + :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. + :vartype logic_app_receivers: + list[~$(python-base-namespace).v2018_09_01.models.LogicAppReceiver] + :ivar azure_function_receivers: The list of azure function receivers that are part of this action group. - :type azure_function_receivers: + :vartype azure_function_receivers: list[~$(python-base-namespace).v2018_09_01.models.AzureFunctionReceiver] - :param arm_role_receivers: The list of ARM role receivers that are part of this action group. + :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. Roles are Azure RBAC roles and only built-in roles are supported. - :type arm_role_receivers: list[~$(python-base-namespace).v2018_09_01.models.ArmRoleReceiver] + :vartype arm_role_receivers: list[~$(python-base-namespace).v2018_09_01.models.ArmRoleReceiver] """ _validation = { @@ -215,6 +235,49 @@ def __init__( arm_role_receivers: Optional[List["ArmRoleReceiver"]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword group_short_name: The short name of the action group. This will be used in SMS + messages. + :paramtype group_short_name: str + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its receivers will receive communications. + :paramtype enabled: bool + :keyword email_receivers: The list of email receivers that are part of this action group. + :paramtype email_receivers: list[~$(python-base-namespace).v2018_09_01.models.EmailReceiver] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~$(python-base-namespace).v2018_09_01.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: + list[~$(python-base-namespace).v2018_09_01.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~$(python-base-namespace).v2018_09_01.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: + list[~$(python-base-namespace).v2018_09_01.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~$(python-base-namespace).v2018_09_01.models.AutomationRunbookReceiver] + :keyword voice_receivers: The list of voice receivers that are part of this action group. + :paramtype voice_receivers: list[~$(python-base-namespace).v2018_09_01.models.VoiceReceiver] + :keyword logic_app_receivers: The list of logic app receivers that are part of this action + group. + :paramtype logic_app_receivers: + list[~$(python-base-namespace).v2018_09_01.models.LogicAppReceiver] + :keyword azure_function_receivers: The list of azure function receivers that are part of this + action group. + :paramtype azure_function_receivers: + list[~$(python-base-namespace).v2018_09_01.models.AzureFunctionReceiver] + :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :paramtype arm_role_receivers: + list[~$(python-base-namespace).v2018_09_01.models.ArmRoleReceiver] + """ super(ActionGroupResource, self).__init__(location=location, tags=tags, **kwargs) self.group_short_name = group_short_name self.enabled = enabled @@ -235,11 +298,11 @@ class ArmRoleReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the arm role receiver. Names must be unique across all + :ivar name: Required. The name of the arm role receiver. Names must be unique across all receivers within an action group. - :type name: str - :param role_id: Required. The arm role id. - :type role_id: str + :vartype name: str + :ivar role_id: Required. The arm role id. + :vartype role_id: str """ _validation = { @@ -259,6 +322,13 @@ def __init__( role_id: str, **kwargs ): + """ + :keyword name: Required. The name of the arm role receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword role_id: Required. The arm role id. + :paramtype role_id: str + """ super(ArmRoleReceiver, self).__init__(**kwargs) self.name = name self.role_id = role_id @@ -269,19 +339,19 @@ class AutomationRunbookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. - :type automation_account_id: str - :param runbook_name: Required. The name for this runbook. - :type runbook_name: str - :param webhook_resource_id: Required. The resource id for webhook linked to this runbook. - :type webhook_resource_id: str - :param is_global_runbook: Required. Indicates whether this instance is global runbook. - :type is_global_runbook: bool - :param name: Indicates name of the webhook. - :type name: str - :param service_uri: The URI where webhooks should be sent. - :type service_uri: str + :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook + and authenticate to Azure resource. + :vartype automation_account_id: str + :ivar runbook_name: Required. The name for this runbook. + :vartype runbook_name: str + :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :vartype webhook_resource_id: str + :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :vartype is_global_runbook: bool + :ivar name: Indicates name of the webhook. + :vartype name: str + :ivar service_uri: The URI where webhooks should be sent. + :vartype service_uri: str """ _validation = { @@ -311,6 +381,21 @@ def __init__( service_uri: Optional[str] = None, **kwargs ): + """ + :keyword automation_account_id: Required. The Azure automation account Id which holds this + runbook and authenticate to Azure resource. + :paramtype automation_account_id: str + :keyword runbook_name: Required. The name for this runbook. + :paramtype runbook_name: str + :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :paramtype webhook_resource_id: str + :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :paramtype is_global_runbook: bool + :keyword name: Indicates name of the webhook. + :paramtype name: str + :keyword service_uri: The URI where webhooks should be sent. + :paramtype service_uri: str + """ super(AutomationRunbookReceiver, self).__init__(**kwargs) self.automation_account_id = automation_account_id self.runbook_name = runbook_name @@ -325,11 +410,11 @@ class AzureAppPushReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Azure mobile app push receiver. Names must be unique + :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. - :type name: str - :param email_address: Required. The email address registered for the Azure mobile app. - :type email_address: str + :vartype name: str + :ivar email_address: Required. The email address registered for the Azure mobile app. + :vartype email_address: str """ _validation = { @@ -349,6 +434,13 @@ def __init__( email_address: str, **kwargs ): + """ + :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique + across all receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address registered for the Azure mobile app. + :paramtype email_address: str + """ super(AzureAppPushReceiver, self).__init__(**kwargs) self.name = name self.email_address = email_address @@ -359,15 +451,15 @@ class AzureFunctionReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the azure function receiver. Names must be unique across all + :ivar name: Required. The name of the azure function receiver. Names must be unique across all receivers within an action group. - :type name: str - :param function_app_resource_id: Required. The azure resource id of the function app. - :type function_app_resource_id: str - :param function_name: Required. The function name in the function app. - :type function_name: str - :param http_trigger_url: Required. The http trigger url where http request sent to. - :type http_trigger_url: str + :vartype name: str + :ivar function_app_resource_id: Required. The azure resource id of the function app. + :vartype function_app_resource_id: str + :ivar function_name: Required. The function name in the function app. + :vartype function_name: str + :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :vartype http_trigger_url: str """ _validation = { @@ -393,6 +485,17 @@ def __init__( http_trigger_url: str, **kwargs ): + """ + :keyword name: Required. The name of the azure function receiver. Names must be unique across + all receivers within an action group. + :paramtype name: str + :keyword function_app_resource_id: Required. The azure resource id of the function app. + :paramtype function_app_resource_id: str + :keyword function_name: Required. The function name in the function app. + :paramtype function_name: str + :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :paramtype http_trigger_url: str + """ super(AzureFunctionReceiver, self).__init__(**kwargs) self.name = name self.function_app_resource_id = function_app_resource_id @@ -405,22 +508,22 @@ class Baseline(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sensitivity: Required. The sensitivity of the baseline. Possible values include: "Low", + :ivar sensitivity: Required. The sensitivity of the baseline. Possible values include: "Low", "Medium", "High". - :type sensitivity: str or ~$(python-base-namespace).v2018_09_01.models.Sensitivity - :param low_thresholds: Required. The low thresholds of the baseline. - :type low_thresholds: list[float] - :param high_thresholds: Required. The high thresholds of the baseline. - :type high_thresholds: list[float] - :param timestamps: the array of timestamps of the baselines. - :type timestamps: list[~datetime.datetime] - :param prediction_result_type: The prediction result type of the baseline. Possible values - include: "0", "1", "2". - :type prediction_result_type: str or + :vartype sensitivity: str or ~$(python-base-namespace).v2018_09_01.models.Sensitivity + :ivar low_thresholds: Required. The low thresholds of the baseline. + :vartype low_thresholds: list[float] + :ivar high_thresholds: Required. The high thresholds of the baseline. + :vartype high_thresholds: list[float] + :ivar timestamps: the array of timestamps of the baselines. + :vartype timestamps: list[~datetime.datetime] + :ivar prediction_result_type: The prediction result type of the baseline. Possible values + include: 0, 1, 2. + :vartype prediction_result_type: int or ~$(python-base-namespace).v2018_09_01.models.PredictionResultType - :param error_type: The error type of the baseline. Possible values include: "0", "1", "2", "3", - "4", "100", "200". - :type error_type: str or ~$(python-base-namespace).v2018_09_01.models.ErrorType + :ivar error_type: The error type of the baseline. Possible values include: 0, 1, 2, 3, 4, 100, + 200. + :vartype error_type: int or ~$(python-base-namespace).v2018_09_01.models.ErrorType """ _validation = { @@ -434,8 +537,8 @@ class Baseline(msrest.serialization.Model): 'low_thresholds': {'key': 'lowThresholds', 'type': '[float]'}, 'high_thresholds': {'key': 'highThresholds', 'type': '[float]'}, 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, - 'prediction_result_type': {'key': 'PredictionResultType', 'type': 'str'}, - 'error_type': {'key': 'ErrorType', 'type': 'str'}, + 'prediction_result_type': {'key': 'PredictionResultType', 'type': 'int'}, + 'error_type': {'key': 'ErrorType', 'type': 'int'}, } def __init__( @@ -445,10 +548,28 @@ def __init__( low_thresholds: List[float], high_thresholds: List[float], timestamps: Optional[List[datetime.datetime]] = None, - prediction_result_type: Optional[Union[str, "PredictionResultType"]] = None, - error_type: Optional[Union[str, "ErrorType"]] = None, + prediction_result_type: Optional[Union[int, "PredictionResultType"]] = None, + error_type: Optional[Union[int, "ErrorType"]] = None, **kwargs ): + """ + :keyword sensitivity: Required. The sensitivity of the baseline. Possible values include: + "Low", "Medium", "High". + :paramtype sensitivity: str or ~$(python-base-namespace).v2018_09_01.models.Sensitivity + :keyword low_thresholds: Required. The low thresholds of the baseline. + :paramtype low_thresholds: list[float] + :keyword high_thresholds: Required. The high thresholds of the baseline. + :paramtype high_thresholds: list[float] + :keyword timestamps: the array of timestamps of the baselines. + :paramtype timestamps: list[~datetime.datetime] + :keyword prediction_result_type: The prediction result type of the baseline. Possible values + include: 0, 1, 2. + :paramtype prediction_result_type: int or + ~$(python-base-namespace).v2018_09_01.models.PredictionResultType + :keyword error_type: The error type of the baseline. Possible values include: 0, 1, 2, 3, 4, + 100, 200. + :paramtype error_type: int or ~$(python-base-namespace).v2018_09_01.models.ErrorType + """ super(Baseline, self).__init__(**kwargs) self.sensitivity = sensitivity self.low_thresholds = low_thresholds @@ -461,10 +582,10 @@ def __init__( class BaselineMetadataValue(msrest.serialization.Model): """Represents a baseline metadata value. - :param name: The name of the metadata. - :type name: ~$(python-base-namespace).v2018_09_01.models.LocalizableString - :param value: The value of the metadata. - :type value: str + :ivar name: The name of the metadata. + :vartype name: ~$(python-base-namespace).v2018_09_01.models.LocalizableString + :ivar value: The value of the metadata. + :vartype value: str """ _attribute_map = { @@ -479,6 +600,12 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword name: The name of the metadata. + :paramtype name: ~$(python-base-namespace).v2018_09_01.models.LocalizableString + :keyword value: The value of the metadata. + :paramtype value: str + """ super(BaselineMetadataValue, self).__init__(**kwargs) self.name = name self.value = value @@ -495,29 +622,29 @@ class BaselineResponse(msrest.serialization.Model): :vartype type: str :ivar name: The name and the display name of the metric, i.e. it is localizable string. :vartype name: ~$(python-base-namespace).v2018_09_01.models.LocalizableString - :param timestamps: The array of timestamps of the baselines. - :type timestamps: list[~datetime.datetime] - :param baseline: The baseline values for each sensitivity. - :type baseline: list[~$(python-base-namespace).v2018_09_01.models.Baseline] - :param metdata: The baseline metadata values. - :type metdata: list[~$(python-base-namespace).v2018_09_01.models.BaselineMetadataValue] - :param prediction_result_type: The prediction result type of the baseline. Possible values - include: "0", "1", "2". - :type prediction_result_type: str or + :ivar timestamps: The array of timestamps of the baselines. + :vartype timestamps: list[~datetime.datetime] + :ivar baseline: The baseline values for each sensitivity. + :vartype baseline: list[~$(python-base-namespace).v2018_09_01.models.Baseline] + :ivar metdata: The baseline metadata values. + :vartype metdata: list[~$(python-base-namespace).v2018_09_01.models.BaselineMetadataValue] + :ivar prediction_result_type: The prediction result type of the baseline. Possible values + include: 0, 1, 2. + :vartype prediction_result_type: int or ~$(python-base-namespace).v2018_09_01.models.PredictionResultType - :param error_type: The error type of the baseline. Possible values include: "0", "1", "2", "3", - "4", "100", "200". - :type error_type: str or ~$(python-base-namespace).v2018_09_01.models.ErrorType - :param timespan: The timespan for which the data was retrieved. Its value consists of two + :ivar error_type: The error type of the baseline. Possible values include: 0, 1, 2, 3, 4, 100, + 200. + :vartype error_type: int or ~$(python-base-namespace).v2018_09_01.models.ErrorType + :ivar timespan: The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. - :type timespan: str - :param interval: The interval (window size) for which the metric data was returned in. This - may be adjusted in the future and returned back from what was originally requested. This is - not present if a metadata request was made. - :type interval: ~datetime.timedelta - :param aggregation: The aggregation type of the metric. - :type aggregation: str + :vartype timespan: str + :ivar interval: The interval (window size) for which the metric data was returned in. This may + be adjusted in the future and returned back from what was originally requested. This is not + present if a metadata request was made. + :vartype interval: ~datetime.timedelta + :ivar aggregation: The aggregation type of the metric. + :vartype aggregation: str :ivar internal_operation_id: internal operation id. :vartype internal_operation_id: str """ @@ -536,8 +663,8 @@ class BaselineResponse(msrest.serialization.Model): 'timestamps': {'key': 'timestamps', 'type': '[iso-8601]'}, 'baseline': {'key': 'baseline', 'type': '[Baseline]'}, 'metdata': {'key': 'metdata', 'type': '[BaselineMetadataValue]'}, - 'prediction_result_type': {'key': 'predictionResultType', 'type': 'str'}, - 'error_type': {'key': 'errorType', 'type': 'str'}, + 'prediction_result_type': {'key': 'predictionResultType', 'type': 'int'}, + 'error_type': {'key': 'errorType', 'type': 'int'}, 'timespan': {'key': 'properties.timespan', 'type': 'str'}, 'interval': {'key': 'properties.interval', 'type': 'duration'}, 'aggregation': {'key': 'properties.aggregation', 'type': 'str'}, @@ -550,13 +677,38 @@ def __init__( timestamps: Optional[List[datetime.datetime]] = None, baseline: Optional[List["Baseline"]] = None, metdata: Optional[List["BaselineMetadataValue"]] = None, - prediction_result_type: Optional[Union[str, "PredictionResultType"]] = None, - error_type: Optional[Union[str, "ErrorType"]] = None, + prediction_result_type: Optional[Union[int, "PredictionResultType"]] = None, + error_type: Optional[Union[int, "ErrorType"]] = None, timespan: Optional[str] = None, interval: Optional[datetime.timedelta] = None, aggregation: Optional[str] = None, **kwargs ): + """ + :keyword timestamps: The array of timestamps of the baselines. + :paramtype timestamps: list[~datetime.datetime] + :keyword baseline: The baseline values for each sensitivity. + :paramtype baseline: list[~$(python-base-namespace).v2018_09_01.models.Baseline] + :keyword metdata: The baseline metadata values. + :paramtype metdata: list[~$(python-base-namespace).v2018_09_01.models.BaselineMetadataValue] + :keyword prediction_result_type: The prediction result type of the baseline. Possible values + include: 0, 1, 2. + :paramtype prediction_result_type: int or + ~$(python-base-namespace).v2018_09_01.models.PredictionResultType + :keyword error_type: The error type of the baseline. Possible values include: 0, 1, 2, 3, 4, + 100, 200. + :paramtype error_type: int or ~$(python-base-namespace).v2018_09_01.models.ErrorType + :keyword timespan: The timespan for which the data was retrieved. Its value consists of two + datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back + from what was originally requested. + :paramtype timespan: str + :keyword interval: The interval (window size) for which the metric data was returned in. This + may be adjusted in the future and returned back from what was originally requested. This is + not present if a metadata request was made. + :paramtype interval: ~datetime.timedelta + :keyword aggregation: The aggregation type of the metric. + :paramtype aggregation: str + """ super(BaselineResponse, self).__init__(**kwargs) self.id = None self.type = None @@ -579,20 +731,20 @@ class CalculateBaselineResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param type: Required. The resource type of the baseline resource. - :type type: str - :param timestamps: The array of timestamps of the baselines. - :type timestamps: list[~datetime.datetime] - :param baseline: Required. The baseline values for each sensitivity. - :type baseline: list[~$(python-base-namespace).v2018_09_01.models.Baseline] - :param statistics: The statistics. - :type statistics: + :ivar type: Required. The resource type of the baseline resource. + :vartype type: str + :ivar timestamps: The array of timestamps of the baselines. + :vartype timestamps: list[~datetime.datetime] + :ivar baseline: Required. The baseline values for each sensitivity. + :vartype baseline: list[~$(python-base-namespace).v2018_09_01.models.Baseline] + :ivar statistics: The statistics. + :vartype statistics: ~$(python-base-namespace).v2018_09_01.models.CalculateBaselineResponseStatistics :ivar internal_operation_id: internal operation id. :vartype internal_operation_id: str - :param error_type: The error type for calculating the baseline. Possible values include: "0", - "1", "2", "3", "4", "100", "200". - :type error_type: str or ~$(python-base-namespace).v2018_09_01.models.ErrorType + :ivar error_type: The error type for calculating the baseline. Possible values include: 0, 1, + 2, 3, 4, 100, 200. + :vartype error_type: int or ~$(python-base-namespace).v2018_09_01.models.ErrorType """ _validation = { @@ -607,7 +759,7 @@ class CalculateBaselineResponse(msrest.serialization.Model): 'baseline': {'key': 'baseline', 'type': '[Baseline]'}, 'statistics': {'key': 'statistics', 'type': 'CalculateBaselineResponseStatistics'}, 'internal_operation_id': {'key': 'internalOperationId', 'type': 'str'}, - 'error_type': {'key': 'errorType', 'type': 'str'}, + 'error_type': {'key': 'errorType', 'type': 'int'}, } def __init__( @@ -617,9 +769,23 @@ def __init__( baseline: List["Baseline"], timestamps: Optional[List[datetime.datetime]] = None, statistics: Optional["CalculateBaselineResponseStatistics"] = None, - error_type: Optional[Union[str, "ErrorType"]] = None, + error_type: Optional[Union[int, "ErrorType"]] = None, **kwargs ): + """ + :keyword type: Required. The resource type of the baseline resource. + :paramtype type: str + :keyword timestamps: The array of timestamps of the baselines. + :paramtype timestamps: list[~datetime.datetime] + :keyword baseline: Required. The baseline values for each sensitivity. + :paramtype baseline: list[~$(python-base-namespace).v2018_09_01.models.Baseline] + :keyword statistics: The statistics. + :paramtype statistics: + ~$(python-base-namespace).v2018_09_01.models.CalculateBaselineResponseStatistics + :keyword error_type: The error type for calculating the baseline. Possible values include: 0, + 1, 2, 3, 4, 100, 200. + :paramtype error_type: int or ~$(python-base-namespace).v2018_09_01.models.ErrorType + """ super(CalculateBaselineResponse, self).__init__(**kwargs) self.type = type self.timestamps = timestamps @@ -632,12 +798,12 @@ def __init__( class CalculateBaselineResponseStatistics(msrest.serialization.Model): """The statistics. - :param is_eligible: is series eligible for dynamic threshold analysis. - :type is_eligible: bool - :param status: The list of extended status for calculating the baseline. - :type status: list[str] - :param seasonality_period: The seasonality period for calculating the baseline. - :type seasonality_period: int + :ivar is_eligible: is series eligible for dynamic threshold analysis. + :vartype is_eligible: bool + :ivar status: The list of extended status for calculating the baseline. + :vartype status: list[str] + :ivar seasonality_period: The seasonality period for calculating the baseline. + :vartype seasonality_period: int """ _attribute_map = { @@ -654,6 +820,14 @@ def __init__( seasonality_period: Optional[int] = None, **kwargs ): + """ + :keyword is_eligible: is series eligible for dynamic threshold analysis. + :paramtype is_eligible: bool + :keyword status: The list of extended status for calculating the baseline. + :paramtype status: list[str] + :keyword seasonality_period: The seasonality period for calculating the baseline. + :paramtype seasonality_period: int + """ super(CalculateBaselineResponseStatistics, self).__init__(**kwargs) self.is_eligible = is_eligible self.status = status @@ -667,11 +841,11 @@ class EmailReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param email_address: Required. The email address of this receiver. - :type email_address: str + :ivar name: Required. The name of the email receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar email_address: Required. The email address of this receiver. + :vartype email_address: str :ivar status: The receiver status of the e-mail. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2018_09_01.models.ReceiverStatus @@ -696,6 +870,13 @@ def __init__( email_address: str, **kwargs ): + """ + :keyword name: Required. The name of the email receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address of this receiver. + :paramtype email_address: str + """ super(EmailReceiver, self).__init__(**kwargs) self.name = name self.email_address = email_address @@ -707,8 +888,8 @@ class EnableRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param receiver_name: Required. The name of the receiver to resubscribe. - :type receiver_name: str + :ivar receiver_name: Required. The name of the receiver to resubscribe. + :vartype receiver_name: str """ _validation = { @@ -725,6 +906,10 @@ def __init__( receiver_name: str, **kwargs ): + """ + :keyword receiver_name: Required. The name of the receiver to resubscribe. + :paramtype receiver_name: str + """ super(EnableRequest, self).__init__(**kwargs) self.receiver_name = receiver_name @@ -732,10 +917,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -750,6 +935,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -760,20 +951,20 @@ class ItsmReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Itsm receiver. Names must be unique across all receivers + :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers within an action group. - :type name: str - :param workspace_id: Required. OMS LA instance identifier. - :type workspace_id: str - :param connection_id: Required. Unique identification of ITSM connection among multiple defined + :vartype name: str + :ivar workspace_id: Required. OMS LA instance identifier. + :vartype workspace_id: str + :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined in above workspace. - :type connection_id: str - :param ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + :vartype connection_id: str + :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as well. - :type ticket_configuration: str - :param region: Required. Region in which workspace resides. Supported + :vartype ticket_configuration: str + :ivar region: Required. Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - :type region: str + :vartype region: str """ _validation = { @@ -802,6 +993,22 @@ def __init__( region: str, **kwargs ): + """ + :keyword name: Required. The name of the Itsm receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword workspace_id: Required. OMS LA instance identifier. + :paramtype workspace_id: str + :keyword connection_id: Required. Unique identification of ITSM connection among multiple + defined in above workspace. + :paramtype connection_id: str + :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. + :paramtype ticket_configuration: str + :keyword region: Required. Region in which workspace resides. Supported + values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + :paramtype region: str + """ super(ItsmReceiver, self).__init__(**kwargs) self.name = name self.workspace_id = workspace_id @@ -815,10 +1022,10 @@ class LocalizableString(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. The invariant value. - :type value: str - :param localized_value: The locale specific value. - :type localized_value: str + :ivar value: Required. The invariant value. + :vartype value: str + :ivar localized_value: The locale specific value. + :vartype localized_value: str """ _validation = { @@ -837,6 +1044,12 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. The invariant value. + :paramtype value: str + :keyword localized_value: The locale specific value. + :paramtype localized_value: str + """ super(LocalizableString, self).__init__(**kwargs) self.value = value self.localized_value = localized_value @@ -847,13 +1060,13 @@ class LogicAppReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the logic app receiver. Names must be unique across all + :ivar name: Required. The name of the logic app receiver. Names must be unique across all receivers within an action group. - :type name: str - :param resource_id: Required. The azure resource id of the logic app receiver. - :type resource_id: str - :param callback_url: Required. The callback url where http request sent to. - :type callback_url: str + :vartype name: str + :ivar resource_id: Required. The azure resource id of the logic app receiver. + :vartype resource_id: str + :ivar callback_url: Required. The callback url where http request sent to. + :vartype callback_url: str """ _validation = { @@ -876,6 +1089,15 @@ def __init__( callback_url: str, **kwargs ): + """ + :keyword name: Required. The name of the logic app receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword resource_id: Required. The azure resource id of the logic app receiver. + :paramtype resource_id: str + :keyword callback_url: Required. The callback url where http request sent to. + :paramtype callback_url: str + """ super(LogicAppReceiver, self).__init__(**kwargs) self.name = name self.resource_id = resource_id @@ -889,13 +1111,13 @@ class SmsReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SMS receiver. Names must be unique across all receivers + :ivar name: Required. The name of the SMS receiver. Names must be unique across all receivers within an action group. - :type name: str - :param country_code: Required. The country code of the SMS receiver. - :type country_code: str - :param phone_number: Required. The phone number of the SMS receiver. - :type phone_number: str + :vartype name: str + :ivar country_code: Required. The country code of the SMS receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the SMS receiver. + :vartype phone_number: str :ivar status: The status of the receiver. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2018_09_01.models.ReceiverStatus @@ -923,6 +1145,15 @@ def __init__( phone_number: str, **kwargs ): + """ + :keyword name: Required. The name of the SMS receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the SMS receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the SMS receiver. + :paramtype phone_number: str + """ super(SmsReceiver, self).__init__(**kwargs) self.name = name self.country_code = country_code @@ -935,12 +1166,12 @@ class TimeSeriesInformation(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sensitivities: Required. The list of sensitivities for calculating the baseline. - :type sensitivities: list[str] - :param values: Required. The metric values to calculate the baseline. - :type values: list[float] - :param timestamps: The array of timestamps of the baselines. - :type timestamps: list[~datetime.datetime] + :ivar sensitivities: Required. The list of sensitivities for calculating the baseline. + :vartype sensitivities: list[str] + :ivar values: Required. The metric values to calculate the baseline. + :vartype values: list[float] + :ivar timestamps: The array of timestamps of the baselines. + :vartype timestamps: list[~datetime.datetime] """ _validation = { @@ -962,6 +1193,14 @@ def __init__( timestamps: Optional[List[datetime.datetime]] = None, **kwargs ): + """ + :keyword sensitivities: Required. The list of sensitivities for calculating the baseline. + :paramtype sensitivities: list[str] + :keyword values: Required. The metric values to calculate the baseline. + :paramtype values: list[float] + :keyword timestamps: The array of timestamps of the baselines. + :paramtype timestamps: list[~datetime.datetime] + """ super(TimeSeriesInformation, self).__init__(**kwargs) self.sensitivities = sensitivities self.values = values @@ -973,13 +1212,13 @@ class VoiceReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the voice receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param country_code: Required. The country code of the voice receiver. - :type country_code: str - :param phone_number: Required. The phone number of the voice receiver. - :type phone_number: str + :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar country_code: Required. The country code of the voice receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the voice receiver. + :vartype phone_number: str """ _validation = { @@ -1002,6 +1241,15 @@ def __init__( phone_number: str, **kwargs ): + """ + :keyword name: Required. The name of the voice receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the voice receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the voice receiver. + :paramtype phone_number: str + """ super(VoiceReceiver, self).__init__(**kwargs) self.name = name self.country_code = country_code @@ -1013,11 +1261,11 @@ class WebhookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the webhook receiver. Names must be unique across all + :ivar name: Required. The name of the webhook receiver. Names must be unique across all receivers within an action group. - :type name: str - :param service_uri: Required. The URI where webhooks should be sent. - :type service_uri: str + :vartype name: str + :ivar service_uri: Required. The URI where webhooks should be sent. + :vartype service_uri: str """ _validation = { @@ -1037,6 +1285,13 @@ def __init__( service_uri: str, **kwargs ): + """ + :keyword name: Required. The name of the webhook receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword service_uri: Required. The URI where webhooks should be sent. + :paramtype service_uri: str + """ super(WebhookReceiver, self).__init__(**kwargs) self.name = name self.service_uri = service_uri diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_monitor_management_client_enums.py index 2968ce09e7c21..200d8caf46bbf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/models/_monitor_management_client_enums.py @@ -6,47 +6,32 @@ # 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 ErrorType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ErrorType(with_metaclass(CaseInsensitiveEnumMeta, int, Enum)): """The error type of the baseline. """ - ZERO = "0" - ONE = "1" - TWO = "2" - THREE = "3" - FOUR = "4" - ONE_HUNDRED = "100" - TWO_HUNDRED = "200" + ZERO = 0 + ONE = 1 + TWO = 2 + THREE = 3 + FOUR = 4 + ONE_HUNDRED = 100 + TWO_HUNDRED = 200 -class PredictionResultType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PredictionResultType(with_metaclass(CaseInsensitiveEnumMeta, int, Enum)): """The prediction result type of the baseline. """ - ZERO = "0" - ONE = "1" - TWO = "2" + ZERO = 0 + ONE = 1 + TWO = 2 -class ReceiverStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReceiverStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates the status of the receiver. Receivers that are not Enabled will not receive any communications. """ @@ -55,12 +40,12 @@ class ReceiverStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ENABLED = "Enabled" DISABLED = "Disabled" -class ResultType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResultType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DATA = "Data" METADATA = "Metadata" -class Sensitivity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Sensitivity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The sensitivity of the baseline. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_action_groups_operations.py index cbaa9affec088..e78a709c15305 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_action_groups_operations.py @@ -5,24 +5,290 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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_delete_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + action_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_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] + 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, + **kwargs + ) + + +def build_list_by_subscription_id_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups') + 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( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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_enable_receiver_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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] + 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class ActionGroupsOperations(object): """ActionGroupsOperations operations. @@ -45,6 +311,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -55,7 +322,7 @@ def create_or_update( # type: (...) -> "_models.ActionGroupResource" """Create a new action group or update an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -71,38 +338,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group, 'ActionGroupResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group, 'ActionGroupResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -115,8 +372,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -126,7 +386,7 @@ def get( # type: (...) -> "_models.ActionGroupResource" """Get an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -140,33 +400,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -175,8 +425,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -186,7 +439,7 @@ def delete( # type: (...) -> None """Delete an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -200,33 +453,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -234,6 +477,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -244,7 +489,7 @@ def update( # type: (...) -> "_models.ActionGroupResource" """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -260,38 +505,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01" - 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'), - 'actionGroupName': self._serialize.url("action_group_name", action_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -300,8 +535,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def list_by_subscription_id( self, **kwargs # type: Any @@ -311,7 +549,8 @@ def list_by_subscription_id( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ActionGroupList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupList] + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -319,34 +558,29 @@ def list_by_subscription_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-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_subscription_id.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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription_id.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_list_by_subscription_id_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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -359,17 +593,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -378,11 +614,12 @@ def list_by_resource_group( # type: (...) -> Iterable["_models.ActionGroupList"] """Get a list of all action groups in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 ActionGroupList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupList] + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2018_09_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -390,35 +627,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -431,17 +664,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.insights/actionGroups'} # type: ignore + @distributed_trace def enable_receiver( self, resource_group_name, # type: str @@ -453,7 +688,7 @@ def enable_receiver( """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -469,41 +704,32 @@ def enable_receiver( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.enable_receiver.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(enable_request, 'EnableRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_enable_receiver_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.enable_receiver.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(enable_request, 'EnableRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(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, 409]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) enable_receiver.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baseline_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baseline_operations.py index 15dd5f3f22de6..f24307b7a69f2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baseline_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_baseline_operations.py @@ -6,23 +6,88 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + metricnames = kwargs.pop('metricnames', None) # type: Optional[str] + timespan = kwargs.pop('timespan', None) # type: Optional[str] + interval = kwargs.pop('interval', None) # type: Optional[datetime.timedelta] + aggregation = kwargs.pop('aggregation', None) # type: Optional[str] + sensitivities = kwargs.pop('sensitivities', None) # type: Optional[str] + result_type = kwargs.pop('result_type', None) # type: Optional[Union[str, "_models.ResultType"]] + metricnamespace = kwargs.pop('metricnamespace', None) # type: Optional[str] + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2018-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/baseline') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if metricnames is not None: + query_parameters['metricnames'] = _SERIALIZER.query("metricnames", metricnames, 'str') + if timespan is not None: + query_parameters['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') + if interval is not None: + query_parameters['interval'] = _SERIALIZER.query("interval", interval, 'duration') + if aggregation is not None: + query_parameters['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') + if sensitivities is not None: + query_parameters['sensitivities'] = _SERIALIZER.query("sensitivities", sensitivities, 'str') + if result_type is not None: + query_parameters['resultType'] = _SERIALIZER.query("result_type", result_type, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if metricnamespace is not None: + query_parameters['metricnamespace'] = _SERIALIZER.query("metricnamespace", metricnamespace, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, '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 + ) + +# fmt: on class BaselineOperations(object): """BaselineOperations operations. @@ -45,6 +110,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_uri, # type: str @@ -97,47 +163,29 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01" - accept = "application/json" - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if metricnames is not None: - query_parameters['metricnames'] = self._serialize.query("metricnames", metricnames, 'str') - if timespan is not None: - query_parameters['timespan'] = self._serialize.query("timespan", timespan, 'str') - if interval is not None: - query_parameters['interval'] = self._serialize.query("interval", interval, 'duration') - if aggregation is not None: - query_parameters['aggregation'] = self._serialize.query("aggregation", aggregation, 'str') - if sensitivities is not None: - query_parameters['sensitivities'] = self._serialize.query("sensitivities", sensitivities, 'str') - if result_type is not None: - query_parameters['resultType'] = self._serialize.query("result_type", result_type, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if metricnamespace is not None: - query_parameters['metricnamespace'] = self._serialize.query("metricnamespace", metricnamespace, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, '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_request( + resource_uri=resource_uri, + metricnames=metricnames, + timespan=timespan, + interval=interval, + aggregation=aggregation, + sensitivities=sensitivities, + result_type=result_type, + metricnamespace=metricnamespace, + filter=filter, + template_url=self.get.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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BaselineResponse', pipeline_response) @@ -146,4 +194,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/baseline'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_metric_baseline_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_metric_baseline_operations.py index a5b894a44c006..50cbed79f15e1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_metric_baseline_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_09_01/operations/_metric_baseline_operations.py @@ -6,23 +6,123 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + resource_uri, # type: str + metric_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + timespan = kwargs.pop('timespan', None) # type: Optional[str] + interval = kwargs.pop('interval', None) # type: Optional[datetime.timedelta] + aggregation = kwargs.pop('aggregation', None) # type: Optional[str] + sensitivities = kwargs.pop('sensitivities', None) # type: Optional[str] + result_type = kwargs.pop('result_type', None) # type: Optional[Union[str, "_models.ResultType"]] + metricnamespace = kwargs.pop('metricnamespace', None) # type: Optional[str] + filter = kwargs.pop('filter', None) # type: Optional[str] + + api_version = "2018-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/baseline/{metricName}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "metricName": _SERIALIZER.url("metric_name", metric_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if timespan is not None: + query_parameters['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') + if interval is not None: + query_parameters['interval'] = _SERIALIZER.query("interval", interval, 'duration') + if aggregation is not None: + query_parameters['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') + if sensitivities is not None: + query_parameters['sensitivities'] = _SERIALIZER.query("sensitivities", sensitivities, 'str') + if result_type is not None: + query_parameters['resultType'] = _SERIALIZER.query("result_type", result_type, 'str') + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if metricnamespace is not None: + query_parameters['metricnamespace'] = _SERIALIZER.query("metricnamespace", metricnamespace, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, '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_calculate_baseline_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/calculatebaseline') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class MetricBaselineOperations(object): """MetricBaselineOperations operations. @@ -45,6 +145,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_uri, # type: str @@ -95,46 +196,29 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'metricName': self._serialize.url("metric_name", metric_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if timespan is not None: - query_parameters['timespan'] = self._serialize.query("timespan", timespan, 'str') - if interval is not None: - query_parameters['interval'] = self._serialize.query("interval", interval, 'duration') - if aggregation is not None: - query_parameters['aggregation'] = self._serialize.query("aggregation", aggregation, 'str') - if sensitivities is not None: - query_parameters['sensitivities'] = self._serialize.query("sensitivities", sensitivities, 'str') - if result_type is not None: - query_parameters['resultType'] = self._serialize.query("result_type", result_type, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if metricnamespace is not None: - query_parameters['metricnamespace'] = self._serialize.query("metricnamespace", metricnamespace, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, '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_request( + resource_uri=resource_uri, + metric_name=metric_name, + timespan=timespan, + interval=interval, + aggregation=aggregation, + sensitivities=sensitivities, + result_type=result_type, + metricnamespace=metricnamespace, + filter=filter, + template_url=self.get.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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('BaselineResponse', pipeline_response) @@ -143,8 +227,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/baseline/{metricName}'} # type: ignore + + @distributed_trace def calculate_baseline( self, resource_uri, # type: str @@ -161,7 +248,8 @@ def calculate_baseline( :type resource_uri: str :param time_series_information: Information that need to be specified to calculate a baseline on a time series. - :type time_series_information: ~$(python-base-namespace).v2018_09_01.models.TimeSeriesInformation + :type time_series_information: + ~$(python-base-namespace).v2018_09_01.models.TimeSeriesInformation :keyword callable cls: A custom type or function that will be passed the direct response :return: CalculateBaselineResponse, or the result of cls(response) :rtype: ~$(python-base-namespace).v2018_09_01.models.CalculateBaselineResponse @@ -172,36 +260,26 @@ def calculate_baseline( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.calculate_baseline.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(time_series_information, 'TimeSeriesInformation') + + request = build_calculate_baseline_request( + resource_uri=resource_uri, + content_type=content_type, + json=_json, + template_url=self.calculate_baseline.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(time_series_information, 'TimeSeriesInformation') - body_content_kwargs['content'] = body_content - request = self._client.post(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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CalculateBaselineResponse', pipeline_response) @@ -210,4 +288,6 @@ def calculate_baseline( return cls(pipeline_response, deserialized, {}) return deserialized + calculate_baseline.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/calculatebaseline'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_configuration.py index 3b7dbb10194cd..d8150c295089e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -37,9 +37,9 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2018-11-27-preview" @@ -62,4 +62,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_metadata.json index 108ef76686e18..f48dd53064873 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,11 +79,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "vm_insights": "VMInsightsOperations" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_monitor_management_client.py index 4c8063f8d99dd..0861101edfa0b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_monitor_management_client.py @@ -6,67 +6,78 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import VMInsightsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import VMInsightsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. :ivar vm_insights: VMInsightsOperations operations - :vartype vm_insights: $(python-base-namespace).v2018_11_27_preview.operations.VMInsightsOperations + :vartype vm_insights: + $(python-base-namespace).v2018_11_27_preview.operations.VMInsightsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :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" - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, **kwargs) + self._config = MonitorManagementClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.vm_insights = VMInsightsOperations(self._client, self._config, self._serialize, self._deserialize) - self.vm_insights = VMInsightsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_configuration.py index d8d2e140bf30b..77ea6d2eeeadb 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/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 @@ -34,9 +34,9 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(MonitorManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2018-11-27-preview" @@ -58,4 +58,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_monitor_management_client.py index d517e654aef76..d7e018bff1c27 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_monitor_management_client.py @@ -6,63 +6,74 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import MonitorManagementClientConfiguration from .operations import VMInsightsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar vm_insights: VMInsightsOperations operations - :vartype vm_insights: $(python-base-namespace).v2018_11_27_preview.aio.operations.VMInsightsOperations + :vartype vm_insights: + $(python-base-namespace).v2018_11_27_preview.aio.operations.VMInsightsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :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", - 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 = MonitorManagementClientConfiguration(credential, **kwargs) + self._config = MonitorManagementClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.vm_insights = VMInsightsOperations(self._client, self._config, self._serialize, self._deserialize) - self.vm_insights = VMInsightsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_vm_insights_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_vm_insights_operations.py index fa9ce068a20a4..19cbf3f37127a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_vm_insights_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/aio/operations/_vm_insights_operations.py @@ -5,16 +5,20 @@ # 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, Optional, TypeVar import warnings 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_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._vm_insights_operations import build_get_onboarding_status_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_onboarding_status( self, resource_uri: str, @@ -60,31 +65,21 @@ async def get_onboarding_status( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-11-27-preview" - accept = "application/json" - - # Construct URL - url = self.get_onboarding_status.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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') + + request = build_get_onboarding_status_request( + resource_uri=resource_uri, + template_url=self.get_onboarding_status.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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.failsafe_deserialize(_models.ResponseWithError, response) + error = self._deserialize.failsafe_deserialize(_models.ResponseWithError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VMInsightsOnboardingStatus', pipeline_response) @@ -93,4 +88,6 @@ async def get_onboarding_status( return cls(pipeline_response, deserialized, {}) return deserialized + get_onboarding_status.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models.py index 05352ea9024f8..3e938b163919e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models.py @@ -15,8 +15,8 @@ class DataContainer(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param workspace: Required. Log Analytics workspace information. - :type workspace: ~$(python-base-namespace).v2018_11_27_preview.models.WorkspaceInfo + :ivar workspace: Required. Log Analytics workspace information. + :vartype workspace: ~$(python-base-namespace).v2018_11_27_preview.models.WorkspaceInfo """ _validation = { @@ -31,6 +31,10 @@ def __init__( self, **kwargs ): + """ + :keyword workspace: Required. Log Analytics workspace information. + :paramtype workspace: ~$(python-base-namespace).v2018_11_27_preview.models.WorkspaceInfo + """ super(DataContainer, self).__init__(**kwargs) self.workspace = kwargs['workspace'] @@ -40,10 +44,10 @@ class Error(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param code: Required. Error code identifying the specific error. - :type code: str - :param message: Error message in the caller's locale. - :type message: str + :ivar code: Required. Error code identifying the specific error. + :vartype code: str + :ivar message: Error message in the caller's locale. + :vartype message: str """ _validation = { @@ -59,6 +63,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Required. Error code identifying the specific error. + :paramtype code: str + :keyword message: Error message in the caller's locale. + :paramtype message: str + """ super(Error, self).__init__(**kwargs) self.code = kwargs['code'] self.message = kwargs.get('message', None) @@ -93,6 +103,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProxyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -104,8 +116,8 @@ class ResponseWithError(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param error: Required. Error information. - :type error: ~$(python-base-namespace).v2018_11_27_preview.models.Error + :ivar error: Required. Error information. + :vartype error: ~$(python-base-namespace).v2018_11_27_preview.models.Error """ _validation = { @@ -120,6 +132,10 @@ def __init__( self, **kwargs ): + """ + :keyword error: Required. Error information. + :paramtype error: ~$(python-base-namespace).v2018_11_27_preview.models.Error + """ super(ResponseWithError, self).__init__(**kwargs) self.error = kwargs['error'] @@ -135,20 +151,20 @@ class VMInsightsOnboardingStatus(ProxyResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param resource_id: Azure Resource Manager identifier of the resource whose onboarding status - is being represented. - :type resource_id: str - :param onboarding_status: The onboarding status for the resource. Note that, a higher level + :ivar resource_id: Azure Resource Manager identifier of the resource whose onboarding status is + being represented. + :vartype resource_id: str + :ivar onboarding_status: The onboarding status for the resource. Note that, a higher level scope, e.g., resource group or subscription, is considered onboarded if at least one resource under it is onboarded. Possible values include: "onboarded", "notOnboarded", "unknown". - :type onboarding_status: str or + :vartype onboarding_status: str or ~$(python-base-namespace).v2018_11_27_preview.models.OnboardingStatus - :param data_status: The status of VM Insights data from the resource. When reported as + :ivar data_status: The status of VM Insights data from the resource. When reported as ``present`` the data array will contain information about the data containers to which data for the specified resource is being routed. Possible values include: "present", "notPresent". - :type data_status: str or ~$(python-base-namespace).v2018_11_27_preview.models.DataStatus - :param data: Containers that currently store VM Insights data for the specified resource. - :type data: list[~$(python-base-namespace).v2018_11_27_preview.models.DataContainer] + :vartype data_status: str or ~$(python-base-namespace).v2018_11_27_preview.models.DataStatus + :ivar data: Containers that currently store VM Insights data for the specified resource. + :vartype data: list[~$(python-base-namespace).v2018_11_27_preview.models.DataContainer] """ _validation = { @@ -171,6 +187,22 @@ def __init__( self, **kwargs ): + """ + :keyword resource_id: Azure Resource Manager identifier of the resource whose onboarding status + is being represented. + :paramtype resource_id: str + :keyword onboarding_status: The onboarding status for the resource. Note that, a higher level + scope, e.g., resource group or subscription, is considered onboarded if at least one resource + under it is onboarded. Possible values include: "onboarded", "notOnboarded", "unknown". + :paramtype onboarding_status: str or + ~$(python-base-namespace).v2018_11_27_preview.models.OnboardingStatus + :keyword data_status: The status of VM Insights data from the resource. When reported as + ``present`` the data array will contain information about the data containers to which data for + the specified resource is being routed. Possible values include: "present", "notPresent". + :paramtype data_status: str or ~$(python-base-namespace).v2018_11_27_preview.models.DataStatus + :keyword data: Containers that currently store VM Insights data for the specified resource. + :paramtype data: list[~$(python-base-namespace).v2018_11_27_preview.models.DataContainer] + """ super(VMInsightsOnboardingStatus, self).__init__(**kwargs) self.resource_id = kwargs.get('resource_id', None) self.onboarding_status = kwargs.get('onboarding_status', None) @@ -183,12 +215,12 @@ class WorkspaceInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Azure Resource Manager identifier of the Log Analytics Workspace. - :type id: str - :param location: Required. Location of the Log Analytics workspace. - :type location: str - :param customer_id: Required. Log Analytics workspace identifier. - :type customer_id: str + :ivar id: Required. Azure Resource Manager identifier of the Log Analytics Workspace. + :vartype id: str + :ivar location: Required. Location of the Log Analytics workspace. + :vartype location: str + :ivar customer_id: Required. Log Analytics workspace identifier. + :vartype customer_id: str """ _validation = { @@ -207,6 +239,14 @@ def __init__( self, **kwargs ): + """ + :keyword id: Required. Azure Resource Manager identifier of the Log Analytics Workspace. + :paramtype id: str + :keyword location: Required. Location of the Log Analytics workspace. + :paramtype location: str + :keyword customer_id: Required. Log Analytics workspace identifier. + :paramtype customer_id: str + """ super(WorkspaceInfo, self).__init__(**kwargs) self.id = kwargs['id'] self.location = kwargs['location'] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models_py3.py index d377f3d4a19cb..c30e574ee7a68 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_models_py3.py @@ -19,8 +19,8 @@ class DataContainer(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param workspace: Required. Log Analytics workspace information. - :type workspace: ~$(python-base-namespace).v2018_11_27_preview.models.WorkspaceInfo + :ivar workspace: Required. Log Analytics workspace information. + :vartype workspace: ~$(python-base-namespace).v2018_11_27_preview.models.WorkspaceInfo """ _validation = { @@ -37,6 +37,10 @@ def __init__( workspace: "WorkspaceInfo", **kwargs ): + """ + :keyword workspace: Required. Log Analytics workspace information. + :paramtype workspace: ~$(python-base-namespace).v2018_11_27_preview.models.WorkspaceInfo + """ super(DataContainer, self).__init__(**kwargs) self.workspace = workspace @@ -46,10 +50,10 @@ class Error(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param code: Required. Error code identifying the specific error. - :type code: str - :param message: Error message in the caller's locale. - :type message: str + :ivar code: Required. Error code identifying the specific error. + :vartype code: str + :ivar message: Error message in the caller's locale. + :vartype message: str """ _validation = { @@ -68,6 +72,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Required. Error code identifying the specific error. + :paramtype code: str + :keyword message: Error message in the caller's locale. + :paramtype message: str + """ super(Error, self).__init__(**kwargs) self.code = code self.message = message @@ -102,6 +112,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProxyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -113,8 +125,8 @@ class ResponseWithError(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param error: Required. Error information. - :type error: ~$(python-base-namespace).v2018_11_27_preview.models.Error + :ivar error: Required. Error information. + :vartype error: ~$(python-base-namespace).v2018_11_27_preview.models.Error """ _validation = { @@ -131,6 +143,10 @@ def __init__( error: "Error", **kwargs ): + """ + :keyword error: Required. Error information. + :paramtype error: ~$(python-base-namespace).v2018_11_27_preview.models.Error + """ super(ResponseWithError, self).__init__(**kwargs) self.error = error @@ -146,20 +162,20 @@ class VMInsightsOnboardingStatus(ProxyResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param resource_id: Azure Resource Manager identifier of the resource whose onboarding status - is being represented. - :type resource_id: str - :param onboarding_status: The onboarding status for the resource. Note that, a higher level + :ivar resource_id: Azure Resource Manager identifier of the resource whose onboarding status is + being represented. + :vartype resource_id: str + :ivar onboarding_status: The onboarding status for the resource. Note that, a higher level scope, e.g., resource group or subscription, is considered onboarded if at least one resource under it is onboarded. Possible values include: "onboarded", "notOnboarded", "unknown". - :type onboarding_status: str or + :vartype onboarding_status: str or ~$(python-base-namespace).v2018_11_27_preview.models.OnboardingStatus - :param data_status: The status of VM Insights data from the resource. When reported as + :ivar data_status: The status of VM Insights data from the resource. When reported as ``present`` the data array will contain information about the data containers to which data for the specified resource is being routed. Possible values include: "present", "notPresent". - :type data_status: str or ~$(python-base-namespace).v2018_11_27_preview.models.DataStatus - :param data: Containers that currently store VM Insights data for the specified resource. - :type data: list[~$(python-base-namespace).v2018_11_27_preview.models.DataContainer] + :vartype data_status: str or ~$(python-base-namespace).v2018_11_27_preview.models.DataStatus + :ivar data: Containers that currently store VM Insights data for the specified resource. + :vartype data: list[~$(python-base-namespace).v2018_11_27_preview.models.DataContainer] """ _validation = { @@ -187,6 +203,22 @@ def __init__( data: Optional[List["DataContainer"]] = None, **kwargs ): + """ + :keyword resource_id: Azure Resource Manager identifier of the resource whose onboarding status + is being represented. + :paramtype resource_id: str + :keyword onboarding_status: The onboarding status for the resource. Note that, a higher level + scope, e.g., resource group or subscription, is considered onboarded if at least one resource + under it is onboarded. Possible values include: "onboarded", "notOnboarded", "unknown". + :paramtype onboarding_status: str or + ~$(python-base-namespace).v2018_11_27_preview.models.OnboardingStatus + :keyword data_status: The status of VM Insights data from the resource. When reported as + ``present`` the data array will contain information about the data containers to which data for + the specified resource is being routed. Possible values include: "present", "notPresent". + :paramtype data_status: str or ~$(python-base-namespace).v2018_11_27_preview.models.DataStatus + :keyword data: Containers that currently store VM Insights data for the specified resource. + :paramtype data: list[~$(python-base-namespace).v2018_11_27_preview.models.DataContainer] + """ super(VMInsightsOnboardingStatus, self).__init__(**kwargs) self.resource_id = resource_id self.onboarding_status = onboarding_status @@ -199,12 +231,12 @@ class WorkspaceInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. Azure Resource Manager identifier of the Log Analytics Workspace. - :type id: str - :param location: Required. Location of the Log Analytics workspace. - :type location: str - :param customer_id: Required. Log Analytics workspace identifier. - :type customer_id: str + :ivar id: Required. Azure Resource Manager identifier of the Log Analytics Workspace. + :vartype id: str + :ivar location: Required. Location of the Log Analytics workspace. + :vartype location: str + :ivar customer_id: Required. Log Analytics workspace identifier. + :vartype customer_id: str """ _validation = { @@ -227,6 +259,14 @@ def __init__( customer_id: str, **kwargs ): + """ + :keyword id: Required. Azure Resource Manager identifier of the Log Analytics Workspace. + :paramtype id: str + :keyword location: Required. Location of the Log Analytics workspace. + :paramtype location: str + :keyword customer_id: Required. Log Analytics workspace identifier. + :paramtype customer_id: str + """ super(WorkspaceInfo, self).__init__(**kwargs) self.id = id self.location = location diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_monitor_management_client_enums.py index 6e32583e2c0c0..b3c335135ef79 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/models/_monitor_management_client_enums.py @@ -6,27 +6,12 @@ # 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 DataStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DataStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of VM Insights data from the resource. When reported as ``present`` the data array will contain information about the data containers to which data for the specified resource is being routed. @@ -35,7 +20,7 @@ class DataStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PRESENT = "present" NOT_PRESENT = "notPresent" -class OnboardingStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OnboardingStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The onboarding status for the resource. Note that, a higher level scope, e.g., resource group or subscription, is considered onboarded if at least one resource under it is onboarded. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_vm_insights_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_vm_insights_operations.py index 323b2fefa1b0f..37439111f41df 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_vm_insights_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2018_11_27_preview/operations/_vm_insights_operations.py @@ -5,23 +5,63 @@ # 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 TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_onboarding_status_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2018-11-27-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + 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 + ) + +# fmt: on class VMInsightsOperations(object): """VMInsightsOperations operations. @@ -44,6 +84,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_onboarding_status( self, resource_uri, # type: str @@ -65,31 +106,21 @@ def get_onboarding_status( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-11-27-preview" - accept = "application/json" - - # Construct URL - url = self.get_onboarding_status.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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') + + request = build_get_onboarding_status_request( + resource_uri=resource_uri, + template_url=self.get_onboarding_status.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # 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.failsafe_deserialize(_models.ResponseWithError, response) + error = self._deserialize.failsafe_deserialize(_models.ResponseWithError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('VMInsightsOnboardingStatus', pipeline_response) @@ -98,4 +129,6 @@ def get_onboarding_status( return cls(pipeline_response, deserialized, {}) return deserialized + get_onboarding_status.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/vmInsightsOnboardingStatuses/default'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_configuration.py index bae7197d43612..346acecd250ac 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_metadata.json index 1195426a660ac..ec859da410c43 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "action_groups": "ActionGroupsOperations", diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_monitor_management_client.py index e8cda37fc5dec..09a4dbc1f38eb 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_monitor_management_client.py @@ -6,23 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ActionGroupsOperations, BaselinesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations -from .operations import BaselinesOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. @@ -35,49 +34,55 @@ class MonitorManagementClient(object): :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.baselines = BaselinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.baselines = BaselinesOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_configuration.py index 14d8957671d3c..1c02bc997da3e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_monitor_management_client.py index 1c5b2606dd68b..a91a75c74e1c9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_monitor_management_client.py @@ -6,74 +6,80 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ActionGroupsOperations, BaselinesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations -from .operations import BaselinesOperations -from .. import models - - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: $(python-base-namespace).v2019_03_01.aio.operations.ActionGroupsOperations + :vartype action_groups: + $(python-base-namespace).v2019_03_01.aio.operations.ActionGroupsOperations :ivar baselines: BaselinesOperations operations :vartype baselines: $(python-base-namespace).v2019_03_01.aio.operations.BaselinesOperations :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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.baselines = BaselinesOperations(self._client, self._config, self._serialize, self._deserialize) - self.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.baselines = BaselinesOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_action_groups_operations.py index 809dc6eb6dc61..676c2e368db1b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_action_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._action_groups_operations import build_create_or_update_request, build_delete_request, build_enable_receiver_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_update_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_async async def create_or_update( self, resource_group_name: str, @@ -50,7 +56,7 @@ async def create_or_update( ) -> "_models.ActionGroupResource": """Create a new action group or update an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -66,38 +72,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group, 'ActionGroupResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group, 'ActionGroupResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -110,8 +106,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -120,7 +119,7 @@ async def get( ) -> "_models.ActionGroupResource": """Get an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -134,33 +133,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -169,8 +158,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -179,7 +171,7 @@ async def delete( ) -> None: """Delete an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -193,33 +185,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -227,6 +209,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -236,7 +220,7 @@ async def update( ) -> "_models.ActionGroupResource": """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -252,38 +236,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - 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'), - 'actionGroupName': self._serialize.url("action_group_name", action_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -292,8 +266,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def list_by_subscription_id( self, **kwargs: Any @@ -302,7 +279,8 @@ def list_by_subscription_id( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ActionGroupList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -310,34 +288,29 @@ def list_by_subscription_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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_subscription_id.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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription_id.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_list_by_subscription_id_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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -350,17 +323,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -368,11 +343,12 @@ def list_by_resource_group( ) -> AsyncIterable["_models.ActionGroupList"]: """Get a list of all action groups in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 ActionGroupList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -380,35 +356,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -421,17 +393,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.insights/actionGroups'} # type: ignore + @distributed_trace_async async def enable_receiver( self, resource_group_name: str, @@ -442,7 +416,7 @@ async def enable_receiver( """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -458,41 +432,32 @@ async def enable_receiver( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.enable_receiver.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(enable_request, 'EnableRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_enable_receiver_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.enable_receiver.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(enable_request, 'EnableRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(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, 409]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) enable_receiver.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_baselines_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_baselines_operations.py index da5a7bec335fd..d785c4ebe121f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_baselines_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/aio/operations/_baselines_operations.py @@ -6,17 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +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._baselines_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -42,6 +47,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_uri: str, @@ -91,8 +97,10 @@ def list( information is retrieved. :type result_type: str or ~$(python-base-namespace).v2019_03_01.models.ResultType :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricBaselinesResponse or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_03_01.models.MetricBaselinesResponse] + :return: An iterator like instance of either MetricBaselinesResponse or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_03_01.models.MetricBaselinesResponse] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricBaselinesResponse"] @@ -100,50 +108,45 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if metricnames is not None: - query_parameters['metricnames'] = self._serialize.query("metricnames", metricnames, 'str') - if metricnamespace is not None: - query_parameters['metricnamespace'] = self._serialize.query("metricnamespace", metricnamespace, 'str') - if timespan is not None: - query_parameters['timespan'] = self._serialize.query("timespan", timespan, 'str') - if interval is not None: - query_parameters['interval'] = self._serialize.query("interval", interval, 'duration') - if aggregation is not None: - query_parameters['aggregation'] = self._serialize.query("aggregation", aggregation, 'str') - if sensitivities is not None: - query_parameters['sensitivities'] = self._serialize.query("sensitivities", sensitivities, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if result_type is not None: - query_parameters['resultType'] = self._serialize.query("result_type", result_type, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + metricnames=metricnames, + metricnamespace=metricnamespace, + timespan=timespan, + interval=interval, + aggregation=aggregation, + sensitivities=sensitivities, + filter=filter, + result_type=result_type, + template_url=self.list.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_list_request( + resource_uri=resource_uri, + metricnames=metricnames, + metricnamespace=metricnamespace, + timespan=timespan, + interval=interval, + aggregation=aggregation, + sensitivities=sensitivities, + filter=filter, + result_type=result_type, + 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('MetricBaselinesResponse', pipeline_response) + deserialized = self._deserialize("MetricBaselinesResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -156,12 +159,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models.py index 2276db6bcae09..c1dcdd09ea5e9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models.py @@ -13,10 +13,10 @@ class ActionGroupList(msrest.serialization.Model): """A list of action groups. - :param value: The list of action groups. - :type value: list[~$(python-base-namespace).v2019_03_01.models.ActionGroupResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar value: The list of action groups. + :vartype value: list[~$(python-base-namespace).v2019_03_01.models.ActionGroupResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -28,6 +28,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of action groups. + :paramtype value: list[~$(python-base-namespace).v2019_03_01.models.ActionGroupResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(ActionGroupList, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -36,11 +42,11 @@ def __init__( class ActionGroupPatchBody(msrest.serialization.Model): """An action group object for the body of patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. - :type enabled: bool + :vartype enabled: bool """ _attribute_map = { @@ -52,6 +58,13 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ super(ActionGroupPatchBody, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.enabled = kwargs.get('enabled', True) @@ -74,10 +87,10 @@ class AzureResource(msrest.serialization.Model): :vartype kind: str :ivar identity: Azure resource identity. :vartype identity: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -103,6 +116,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(AzureResource, self).__init__(**kwargs) self.id = None self.name = None @@ -130,42 +149,43 @@ class ActionGroupResource(AzureResource): :vartype kind: str :ivar identity: Azure resource identity. :vartype identity: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param group_short_name: The short name of the action group. This will be used in SMS messages. - :type group_short_name: str - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar group_short_name: The short name of the action group. This will be used in SMS messages. + :vartype group_short_name: str + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. - :type enabled: bool - :param email_receivers: The list of email receivers that are part of this action group. - :type email_receivers: list[~$(python-base-namespace).v2019_03_01.models.EmailReceiver] - :param sms_receivers: The list of SMS receivers that are part of this action group. - :type sms_receivers: list[~$(python-base-namespace).v2019_03_01.models.SmsReceiver] - :param webhook_receivers: The list of webhook receivers that are part of this action group. - :type webhook_receivers: list[~$(python-base-namespace).v2019_03_01.models.WebhookReceiver] - :param itsm_receivers: The list of ITSM receivers that are part of this action group. - :type itsm_receivers: list[~$(python-base-namespace).v2019_03_01.models.ItsmReceiver] - :param azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :type azure_app_push_receivers: + :vartype enabled: bool + :ivar email_receivers: The list of email receivers that are part of this action group. + :vartype email_receivers: list[~$(python-base-namespace).v2019_03_01.models.EmailReceiver] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~$(python-base-namespace).v2019_03_01.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~$(python-base-namespace).v2019_03_01.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~$(python-base-namespace).v2019_03_01.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: list[~$(python-base-namespace).v2019_03_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of this action group. - :type automation_runbook_receivers: + :vartype automation_runbook_receivers: list[~$(python-base-namespace).v2019_03_01.models.AutomationRunbookReceiver] - :param voice_receivers: The list of voice receivers that are part of this action group. - :type voice_receivers: list[~$(python-base-namespace).v2019_03_01.models.VoiceReceiver] - :param logic_app_receivers: The list of logic app receivers that are part of this action group. - :type logic_app_receivers: list[~$(python-base-namespace).v2019_03_01.models.LogicAppReceiver] - :param azure_function_receivers: The list of azure function receivers that are part of this + :ivar voice_receivers: The list of voice receivers that are part of this action group. + :vartype voice_receivers: list[~$(python-base-namespace).v2019_03_01.models.VoiceReceiver] + :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. + :vartype logic_app_receivers: + list[~$(python-base-namespace).v2019_03_01.models.LogicAppReceiver] + :ivar azure_function_receivers: The list of azure function receivers that are part of this action group. - :type azure_function_receivers: + :vartype azure_function_receivers: list[~$(python-base-namespace).v2019_03_01.models.AzureFunctionReceiver] - :param arm_role_receivers: The list of ARM role receivers that are part of this action group. + :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. Roles are Azure RBAC roles and only built-in roles are supported. - :type arm_role_receivers: list[~$(python-base-namespace).v2019_03_01.models.ArmRoleReceiver] + :vartype arm_role_receivers: list[~$(python-base-namespace).v2019_03_01.models.ArmRoleReceiver] """ _validation = { @@ -204,6 +224,49 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword group_short_name: The short name of the action group. This will be used in SMS + messages. + :paramtype group_short_name: str + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its receivers will receive communications. + :paramtype enabled: bool + :keyword email_receivers: The list of email receivers that are part of this action group. + :paramtype email_receivers: list[~$(python-base-namespace).v2019_03_01.models.EmailReceiver] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~$(python-base-namespace).v2019_03_01.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: + list[~$(python-base-namespace).v2019_03_01.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~$(python-base-namespace).v2019_03_01.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: + list[~$(python-base-namespace).v2019_03_01.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~$(python-base-namespace).v2019_03_01.models.AutomationRunbookReceiver] + :keyword voice_receivers: The list of voice receivers that are part of this action group. + :paramtype voice_receivers: list[~$(python-base-namespace).v2019_03_01.models.VoiceReceiver] + :keyword logic_app_receivers: The list of logic app receivers that are part of this action + group. + :paramtype logic_app_receivers: + list[~$(python-base-namespace).v2019_03_01.models.LogicAppReceiver] + :keyword azure_function_receivers: The list of azure function receivers that are part of this + action group. + :paramtype azure_function_receivers: + list[~$(python-base-namespace).v2019_03_01.models.AzureFunctionReceiver] + :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :paramtype arm_role_receivers: + list[~$(python-base-namespace).v2019_03_01.models.ArmRoleReceiver] + """ super(ActionGroupResource, self).__init__(**kwargs) self.group_short_name = kwargs.get('group_short_name', None) self.enabled = kwargs.get('enabled', True) @@ -224,13 +287,13 @@ class ArmRoleReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the arm role receiver. Names must be unique across all + :ivar name: Required. The name of the arm role receiver. Names must be unique across all receivers within an action group. - :type name: str - :param role_id: Required. The arm role id. - :type role_id: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar role_id: Required. The arm role id. + :vartype role_id: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -248,6 +311,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the arm role receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword role_id: Required. The arm role id. + :paramtype role_id: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(ArmRoleReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.role_id = kwargs['role_id'] @@ -259,21 +331,21 @@ class AutomationRunbookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. - :type automation_account_id: str - :param runbook_name: Required. The name for this runbook. - :type runbook_name: str - :param webhook_resource_id: Required. The resource id for webhook linked to this runbook. - :type webhook_resource_id: str - :param is_global_runbook: Required. Indicates whether this instance is global runbook. - :type is_global_runbook: bool - :param name: Indicates name of the webhook. - :type name: str - :param service_uri: The URI where webhooks should be sent. - :type service_uri: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook + and authenticate to Azure resource. + :vartype automation_account_id: str + :ivar runbook_name: Required. The name for this runbook. + :vartype runbook_name: str + :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :vartype webhook_resource_id: str + :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :vartype is_global_runbook: bool + :ivar name: Indicates name of the webhook. + :vartype name: str + :ivar service_uri: The URI where webhooks should be sent. + :vartype service_uri: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -297,6 +369,23 @@ def __init__( self, **kwargs ): + """ + :keyword automation_account_id: Required. The Azure automation account Id which holds this + runbook and authenticate to Azure resource. + :paramtype automation_account_id: str + :keyword runbook_name: Required. The name for this runbook. + :paramtype runbook_name: str + :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :paramtype webhook_resource_id: str + :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :paramtype is_global_runbook: bool + :keyword name: Indicates name of the webhook. + :paramtype name: str + :keyword service_uri: The URI where webhooks should be sent. + :paramtype service_uri: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(AutomationRunbookReceiver, self).__init__(**kwargs) self.automation_account_id = kwargs['automation_account_id'] self.runbook_name = kwargs['runbook_name'] @@ -312,11 +401,11 @@ class AzureAppPushReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Azure mobile app push receiver. Names must be unique + :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. - :type name: str - :param email_address: Required. The email address registered for the Azure mobile app. - :type email_address: str + :vartype name: str + :ivar email_address: Required. The email address registered for the Azure mobile app. + :vartype email_address: str """ _validation = { @@ -333,6 +422,13 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique + across all receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address registered for the Azure mobile app. + :paramtype email_address: str + """ super(AzureAppPushReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.email_address = kwargs['email_address'] @@ -343,17 +439,17 @@ class AzureFunctionReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the azure function receiver. Names must be unique across all + :ivar name: Required. The name of the azure function receiver. Names must be unique across all receivers within an action group. - :type name: str - :param function_app_resource_id: Required. The azure resource id of the function app. - :type function_app_resource_id: str - :param function_name: Required. The function name in the function app. - :type function_name: str - :param http_trigger_url: Required. The http trigger url where http request sent to. - :type http_trigger_url: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar function_app_resource_id: Required. The azure resource id of the function app. + :vartype function_app_resource_id: str + :ivar function_name: Required. The function name in the function app. + :vartype function_name: str + :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :vartype http_trigger_url: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -375,6 +471,19 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the azure function receiver. Names must be unique across + all receivers within an action group. + :paramtype name: str + :keyword function_app_resource_id: Required. The azure resource id of the function app. + :paramtype function_app_resource_id: str + :keyword function_name: Required. The function name in the function app. + :paramtype function_name: str + :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :paramtype http_trigger_url: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(AzureFunctionReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.function_app_resource_id = kwargs['function_app_resource_id'] @@ -388,10 +497,10 @@ class BaselineMetadata(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the baseline metadata. - :type name: str - :param value: Required. Value of the baseline metadata. - :type value: str + :ivar name: Required. Name of the baseline metadata. + :vartype name: str + :ivar value: Required. Value of the baseline metadata. + :vartype value: str """ _validation = { @@ -408,6 +517,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. Name of the baseline metadata. + :paramtype name: str + :keyword value: Required. Value of the baseline metadata. + :paramtype value: str + """ super(BaselineMetadata, self).__init__(**kwargs) self.name = kwargs['name'] self.value = kwargs['value'] @@ -420,13 +535,13 @@ class EmailReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param email_address: Required. The email address of this receiver. - :type email_address: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :ivar name: Required. The name of the email receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar email_address: Required. The email address of this receiver. + :vartype email_address: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool :ivar status: The receiver status of the e-mail. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2019_03_01.models.ReceiverStatus @@ -449,6 +564,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the email receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address of this receiver. + :paramtype email_address: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(EmailReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.email_address = kwargs['email_address'] @@ -461,8 +585,8 @@ class EnableRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param receiver_name: Required. The name of the receiver to resubscribe. - :type receiver_name: str + :ivar receiver_name: Required. The name of the receiver to resubscribe. + :vartype receiver_name: str """ _validation = { @@ -477,6 +601,10 @@ def __init__( self, **kwargs ): + """ + :keyword receiver_name: Required. The name of the receiver to resubscribe. + :paramtype receiver_name: str + """ super(EnableRequest, self).__init__(**kwargs) self.receiver_name = kwargs['receiver_name'] @@ -484,10 +612,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -499,6 +627,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -509,20 +643,20 @@ class ItsmReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Itsm receiver. Names must be unique across all receivers + :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers within an action group. - :type name: str - :param workspace_id: Required. OMS LA instance identifier. - :type workspace_id: str - :param connection_id: Required. Unique identification of ITSM connection among multiple defined + :vartype name: str + :ivar workspace_id: Required. OMS LA instance identifier. + :vartype workspace_id: str + :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined in above workspace. - :type connection_id: str - :param ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + :vartype connection_id: str + :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as well. - :type ticket_configuration: str - :param region: Required. Region in which workspace resides. Supported + :vartype ticket_configuration: str + :ivar region: Required. Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - :type region: str + :vartype region: str """ _validation = { @@ -545,6 +679,22 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the Itsm receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword workspace_id: Required. OMS LA instance identifier. + :paramtype workspace_id: str + :keyword connection_id: Required. Unique identification of ITSM connection among multiple + defined in above workspace. + :paramtype connection_id: str + :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. + :paramtype ticket_configuration: str + :keyword region: Required. Region in which workspace resides. Supported + values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + :paramtype region: str + """ super(ItsmReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.workspace_id = kwargs['workspace_id'] @@ -558,15 +708,15 @@ class LogicAppReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the logic app receiver. Names must be unique across all + :ivar name: Required. The name of the logic app receiver. Names must be unique across all receivers within an action group. - :type name: str - :param resource_id: Required. The azure resource id of the logic app receiver. - :type resource_id: str - :param callback_url: Required. The callback url where http request sent to. - :type callback_url: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar resource_id: Required. The azure resource id of the logic app receiver. + :vartype resource_id: str + :ivar callback_url: Required. The callback url where http request sent to. + :vartype callback_url: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -586,6 +736,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the logic app receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword resource_id: Required. The azure resource id of the logic app receiver. + :paramtype resource_id: str + :keyword callback_url: Required. The callback url where http request sent to. + :paramtype callback_url: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(LogicAppReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.resource_id = kwargs['resource_id'] @@ -596,8 +757,8 @@ def __init__( class MetricBaselinesResponse(msrest.serialization.Model): """A list of metric baselines. - :param value: The list of metric baselines. - :type value: list[~$(python-base-namespace).v2019_03_01.models.SingleMetricBaseline] + :ivar value: The list of metric baselines. + :vartype value: list[~$(python-base-namespace).v2019_03_01.models.SingleMetricBaseline] """ _attribute_map = { @@ -608,6 +769,10 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of metric baselines. + :paramtype value: list[~$(python-base-namespace).v2019_03_01.models.SingleMetricBaseline] + """ super(MetricBaselinesResponse, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -617,10 +782,10 @@ class MetricSingleDimension(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the dimension. - :type name: str - :param value: Required. Value of the dimension. - :type value: str + :ivar name: Required. Name of the dimension. + :vartype name: str + :ivar value: Required. Value of the dimension. + :vartype value: str """ _validation = { @@ -637,6 +802,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. Name of the dimension. + :paramtype name: str + :keyword value: Required. Value of the dimension. + :paramtype value: str + """ super(MetricSingleDimension, self).__init__(**kwargs) self.name = kwargs['name'] self.value = kwargs['value'] @@ -647,13 +818,13 @@ class SingleBaseline(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sensitivity: Required. the sensitivity of the baseline. Possible values include: "Low", + :ivar sensitivity: Required. the sensitivity of the baseline. Possible values include: "Low", "Medium", "High". - :type sensitivity: str or ~$(python-base-namespace).v2019_03_01.models.BaselineSensitivity - :param low_thresholds: Required. The low thresholds of the baseline. - :type low_thresholds: list[float] - :param high_thresholds: Required. The high thresholds of the baseline. - :type high_thresholds: list[float] + :vartype sensitivity: str or ~$(python-base-namespace).v2019_03_01.models.BaselineSensitivity + :ivar low_thresholds: Required. The low thresholds of the baseline. + :vartype low_thresholds: list[float] + :ivar high_thresholds: Required. The high thresholds of the baseline. + :vartype high_thresholds: list[float] """ _validation = { @@ -672,6 +843,15 @@ def __init__( self, **kwargs ): + """ + :keyword sensitivity: Required. the sensitivity of the baseline. Possible values include: + "Low", "Medium", "High". + :paramtype sensitivity: str or ~$(python-base-namespace).v2019_03_01.models.BaselineSensitivity + :keyword low_thresholds: Required. The low thresholds of the baseline. + :paramtype low_thresholds: list[float] + :keyword high_thresholds: Required. The high thresholds of the baseline. + :paramtype high_thresholds: list[float] + """ super(SingleBaseline, self).__init__(**kwargs) self.sensitivity = kwargs['sensitivity'] self.low_thresholds = kwargs['low_thresholds'] @@ -683,24 +863,24 @@ class SingleMetricBaseline(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. The metric baseline Id. - :type id: str - :param type: Required. The resource type of the metric baseline resource. - :type type: str - :param name: Required. The name of the metric for which the baselines were retrieved. - :type name: str - :param timespan: Required. The timespan for which the data was retrieved. Its value consists of + :ivar id: Required. The metric baseline Id. + :vartype id: str + :ivar type: Required. The resource type of the metric baseline resource. + :vartype type: str + :ivar name: Required. The name of the metric for which the baselines were retrieved. + :vartype name: str + :ivar timespan: Required. The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. - :type timespan: str - :param interval: Required. The interval (window size) for which the metric data was returned - in. This may be adjusted in the future and returned back from what was originally requested. - This is not present if a metadata request was made. - :type interval: ~datetime.timedelta - :param namespace: The namespace of the metrics been queried. - :type namespace: str - :param baselines: Required. The baseline for each time series that was queried. - :type baselines: list[~$(python-base-namespace).v2019_03_01.models.TimeSeriesBaseline] + :vartype timespan: str + :ivar interval: Required. The interval (window size) for which the metric data was returned in. + This may be adjusted in the future and returned back from what was originally requested. This + is not present if a metadata request was made. + :vartype interval: ~datetime.timedelta + :ivar namespace: The namespace of the metrics been queried. + :vartype namespace: str + :ivar baselines: Required. The baseline for each time series that was queried. + :vartype baselines: list[~$(python-base-namespace).v2019_03_01.models.TimeSeriesBaseline] """ _validation = { @@ -726,6 +906,26 @@ def __init__( self, **kwargs ): + """ + :keyword id: Required. The metric baseline Id. + :paramtype id: str + :keyword type: Required. The resource type of the metric baseline resource. + :paramtype type: str + :keyword name: Required. The name of the metric for which the baselines were retrieved. + :paramtype name: str + :keyword timespan: Required. The timespan for which the data was retrieved. Its value consists + of two datetimes concatenated, separated by '/'. This may be adjusted in the future and + returned back from what was originally requested. + :paramtype timespan: str + :keyword interval: Required. The interval (window size) for which the metric data was returned + in. This may be adjusted in the future and returned back from what was originally requested. + This is not present if a metadata request was made. + :paramtype interval: ~datetime.timedelta + :keyword namespace: The namespace of the metrics been queried. + :paramtype namespace: str + :keyword baselines: Required. The baseline for each time series that was queried. + :paramtype baselines: list[~$(python-base-namespace).v2019_03_01.models.TimeSeriesBaseline] + """ super(SingleMetricBaseline, self).__init__(**kwargs) self.id = kwargs['id'] self.type = kwargs['type'] @@ -743,13 +943,13 @@ class SmsReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SMS receiver. Names must be unique across all receivers + :ivar name: Required. The name of the SMS receiver. Names must be unique across all receivers within an action group. - :type name: str - :param country_code: Required. The country code of the SMS receiver. - :type country_code: str - :param phone_number: Required. The phone number of the SMS receiver. - :type phone_number: str + :vartype name: str + :ivar country_code: Required. The country code of the SMS receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the SMS receiver. + :vartype phone_number: str :ivar status: The status of the receiver. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2019_03_01.models.ReceiverStatus @@ -773,6 +973,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the SMS receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the SMS receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the SMS receiver. + :paramtype phone_number: str + """ super(SmsReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.country_code = kwargs['country_code'] @@ -785,16 +994,16 @@ class TimeSeriesBaseline(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param aggregation: Required. The aggregation type of the metric. - :type aggregation: str - :param dimensions: The dimensions of this time series. - :type dimensions: list[~$(python-base-namespace).v2019_03_01.models.MetricSingleDimension] - :param timestamps: Required. The list of timestamps of the baselines. - :type timestamps: list[~datetime.datetime] - :param data: Required. The baseline values for each sensitivity. - :type data: list[~$(python-base-namespace).v2019_03_01.models.SingleBaseline] - :param metadata_values: The baseline metadata values. - :type metadata_values: list[~$(python-base-namespace).v2019_03_01.models.BaselineMetadata] + :ivar aggregation: Required. The aggregation type of the metric. + :vartype aggregation: str + :ivar dimensions: The dimensions of this time series. + :vartype dimensions: list[~$(python-base-namespace).v2019_03_01.models.MetricSingleDimension] + :ivar timestamps: Required. The list of timestamps of the baselines. + :vartype timestamps: list[~datetime.datetime] + :ivar data: Required. The baseline values for each sensitivity. + :vartype data: list[~$(python-base-namespace).v2019_03_01.models.SingleBaseline] + :ivar metadata_values: The baseline metadata values. + :vartype metadata_values: list[~$(python-base-namespace).v2019_03_01.models.BaselineMetadata] """ _validation = { @@ -815,6 +1024,18 @@ def __init__( self, **kwargs ): + """ + :keyword aggregation: Required. The aggregation type of the metric. + :paramtype aggregation: str + :keyword dimensions: The dimensions of this time series. + :paramtype dimensions: list[~$(python-base-namespace).v2019_03_01.models.MetricSingleDimension] + :keyword timestamps: Required. The list of timestamps of the baselines. + :paramtype timestamps: list[~datetime.datetime] + :keyword data: Required. The baseline values for each sensitivity. + :paramtype data: list[~$(python-base-namespace).v2019_03_01.models.SingleBaseline] + :keyword metadata_values: The baseline metadata values. + :paramtype metadata_values: list[~$(python-base-namespace).v2019_03_01.models.BaselineMetadata] + """ super(TimeSeriesBaseline, self).__init__(**kwargs) self.aggregation = kwargs['aggregation'] self.dimensions = kwargs.get('dimensions', None) @@ -828,13 +1049,13 @@ class VoiceReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the voice receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param country_code: Required. The country code of the voice receiver. - :type country_code: str - :param phone_number: Required. The phone number of the voice receiver. - :type phone_number: str + :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar country_code: Required. The country code of the voice receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the voice receiver. + :vartype phone_number: str """ _validation = { @@ -853,6 +1074,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the voice receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the voice receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the voice receiver. + :paramtype phone_number: str + """ super(VoiceReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.country_code = kwargs['country_code'] @@ -864,13 +1094,13 @@ class WebhookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the webhook receiver. Names must be unique across all + :ivar name: Required. The name of the webhook receiver. Names must be unique across all receivers within an action group. - :type name: str - :param service_uri: Required. The URI where webhooks should be sent. - :type service_uri: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar service_uri: Required. The URI where webhooks should be sent. + :vartype service_uri: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -888,6 +1118,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the webhook receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword service_uri: Required. The URI where webhooks should be sent. + :paramtype service_uri: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(WebhookReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.service_uri = kwargs['service_uri'] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models_py3.py index fcf507eee0814..2d8ad2bb56325 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_models_py3.py @@ -18,10 +18,10 @@ class ActionGroupList(msrest.serialization.Model): """A list of action groups. - :param value: The list of action groups. - :type value: list[~$(python-base-namespace).v2019_03_01.models.ActionGroupResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar value: The list of action groups. + :vartype value: list[~$(python-base-namespace).v2019_03_01.models.ActionGroupResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -36,6 +36,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of action groups. + :paramtype value: list[~$(python-base-namespace).v2019_03_01.models.ActionGroupResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(ActionGroupList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -44,11 +50,11 @@ def __init__( class ActionGroupPatchBody(msrest.serialization.Model): """An action group object for the body of patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. - :type enabled: bool + :vartype enabled: bool """ _attribute_map = { @@ -63,6 +69,13 @@ def __init__( enabled: Optional[bool] = True, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ super(ActionGroupPatchBody, self).__init__(**kwargs) self.tags = tags self.enabled = enabled @@ -85,10 +98,10 @@ class AzureResource(msrest.serialization.Model): :vartype kind: str :ivar identity: Azure resource identity. :vartype identity: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -117,6 +130,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(AzureResource, self).__init__(**kwargs) self.id = None self.name = None @@ -144,42 +163,43 @@ class ActionGroupResource(AzureResource): :vartype kind: str :ivar identity: Azure resource identity. :vartype identity: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param group_short_name: The short name of the action group. This will be used in SMS messages. - :type group_short_name: str - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar group_short_name: The short name of the action group. This will be used in SMS messages. + :vartype group_short_name: str + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. - :type enabled: bool - :param email_receivers: The list of email receivers that are part of this action group. - :type email_receivers: list[~$(python-base-namespace).v2019_03_01.models.EmailReceiver] - :param sms_receivers: The list of SMS receivers that are part of this action group. - :type sms_receivers: list[~$(python-base-namespace).v2019_03_01.models.SmsReceiver] - :param webhook_receivers: The list of webhook receivers that are part of this action group. - :type webhook_receivers: list[~$(python-base-namespace).v2019_03_01.models.WebhookReceiver] - :param itsm_receivers: The list of ITSM receivers that are part of this action group. - :type itsm_receivers: list[~$(python-base-namespace).v2019_03_01.models.ItsmReceiver] - :param azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :type azure_app_push_receivers: + :vartype enabled: bool + :ivar email_receivers: The list of email receivers that are part of this action group. + :vartype email_receivers: list[~$(python-base-namespace).v2019_03_01.models.EmailReceiver] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~$(python-base-namespace).v2019_03_01.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~$(python-base-namespace).v2019_03_01.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~$(python-base-namespace).v2019_03_01.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: list[~$(python-base-namespace).v2019_03_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of this action group. - :type automation_runbook_receivers: + :vartype automation_runbook_receivers: list[~$(python-base-namespace).v2019_03_01.models.AutomationRunbookReceiver] - :param voice_receivers: The list of voice receivers that are part of this action group. - :type voice_receivers: list[~$(python-base-namespace).v2019_03_01.models.VoiceReceiver] - :param logic_app_receivers: The list of logic app receivers that are part of this action group. - :type logic_app_receivers: list[~$(python-base-namespace).v2019_03_01.models.LogicAppReceiver] - :param azure_function_receivers: The list of azure function receivers that are part of this + :ivar voice_receivers: The list of voice receivers that are part of this action group. + :vartype voice_receivers: list[~$(python-base-namespace).v2019_03_01.models.VoiceReceiver] + :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. + :vartype logic_app_receivers: + list[~$(python-base-namespace).v2019_03_01.models.LogicAppReceiver] + :ivar azure_function_receivers: The list of azure function receivers that are part of this action group. - :type azure_function_receivers: + :vartype azure_function_receivers: list[~$(python-base-namespace).v2019_03_01.models.AzureFunctionReceiver] - :param arm_role_receivers: The list of ARM role receivers that are part of this action group. + :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. Roles are Azure RBAC roles and only built-in roles are supported. - :type arm_role_receivers: list[~$(python-base-namespace).v2019_03_01.models.ArmRoleReceiver] + :vartype arm_role_receivers: list[~$(python-base-namespace).v2019_03_01.models.ArmRoleReceiver] """ _validation = { @@ -233,6 +253,49 @@ def __init__( arm_role_receivers: Optional[List["ArmRoleReceiver"]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword group_short_name: The short name of the action group. This will be used in SMS + messages. + :paramtype group_short_name: str + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its receivers will receive communications. + :paramtype enabled: bool + :keyword email_receivers: The list of email receivers that are part of this action group. + :paramtype email_receivers: list[~$(python-base-namespace).v2019_03_01.models.EmailReceiver] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~$(python-base-namespace).v2019_03_01.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: + list[~$(python-base-namespace).v2019_03_01.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~$(python-base-namespace).v2019_03_01.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: + list[~$(python-base-namespace).v2019_03_01.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~$(python-base-namespace).v2019_03_01.models.AutomationRunbookReceiver] + :keyword voice_receivers: The list of voice receivers that are part of this action group. + :paramtype voice_receivers: list[~$(python-base-namespace).v2019_03_01.models.VoiceReceiver] + :keyword logic_app_receivers: The list of logic app receivers that are part of this action + group. + :paramtype logic_app_receivers: + list[~$(python-base-namespace).v2019_03_01.models.LogicAppReceiver] + :keyword azure_function_receivers: The list of azure function receivers that are part of this + action group. + :paramtype azure_function_receivers: + list[~$(python-base-namespace).v2019_03_01.models.AzureFunctionReceiver] + :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :paramtype arm_role_receivers: + list[~$(python-base-namespace).v2019_03_01.models.ArmRoleReceiver] + """ super(ActionGroupResource, self).__init__(location=location, tags=tags, **kwargs) self.group_short_name = group_short_name self.enabled = enabled @@ -253,13 +316,13 @@ class ArmRoleReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the arm role receiver. Names must be unique across all + :ivar name: Required. The name of the arm role receiver. Names must be unique across all receivers within an action group. - :type name: str - :param role_id: Required. The arm role id. - :type role_id: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar role_id: Required. The arm role id. + :vartype role_id: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -281,6 +344,15 @@ def __init__( use_common_alert_schema: Optional[bool] = False, **kwargs ): + """ + :keyword name: Required. The name of the arm role receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword role_id: Required. The arm role id. + :paramtype role_id: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(ArmRoleReceiver, self).__init__(**kwargs) self.name = name self.role_id = role_id @@ -292,21 +364,21 @@ class AutomationRunbookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. - :type automation_account_id: str - :param runbook_name: Required. The name for this runbook. - :type runbook_name: str - :param webhook_resource_id: Required. The resource id for webhook linked to this runbook. - :type webhook_resource_id: str - :param is_global_runbook: Required. Indicates whether this instance is global runbook. - :type is_global_runbook: bool - :param name: Indicates name of the webhook. - :type name: str - :param service_uri: The URI where webhooks should be sent. - :type service_uri: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook + and authenticate to Azure resource. + :vartype automation_account_id: str + :ivar runbook_name: Required. The name for this runbook. + :vartype runbook_name: str + :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :vartype webhook_resource_id: str + :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :vartype is_global_runbook: bool + :ivar name: Indicates name of the webhook. + :vartype name: str + :ivar service_uri: The URI where webhooks should be sent. + :vartype service_uri: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -338,6 +410,23 @@ def __init__( use_common_alert_schema: Optional[bool] = False, **kwargs ): + """ + :keyword automation_account_id: Required. The Azure automation account Id which holds this + runbook and authenticate to Azure resource. + :paramtype automation_account_id: str + :keyword runbook_name: Required. The name for this runbook. + :paramtype runbook_name: str + :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :paramtype webhook_resource_id: str + :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :paramtype is_global_runbook: bool + :keyword name: Indicates name of the webhook. + :paramtype name: str + :keyword service_uri: The URI where webhooks should be sent. + :paramtype service_uri: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(AutomationRunbookReceiver, self).__init__(**kwargs) self.automation_account_id = automation_account_id self.runbook_name = runbook_name @@ -353,11 +442,11 @@ class AzureAppPushReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Azure mobile app push receiver. Names must be unique + :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. - :type name: str - :param email_address: Required. The email address registered for the Azure mobile app. - :type email_address: str + :vartype name: str + :ivar email_address: Required. The email address registered for the Azure mobile app. + :vartype email_address: str """ _validation = { @@ -377,6 +466,13 @@ def __init__( email_address: str, **kwargs ): + """ + :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique + across all receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address registered for the Azure mobile app. + :paramtype email_address: str + """ super(AzureAppPushReceiver, self).__init__(**kwargs) self.name = name self.email_address = email_address @@ -387,17 +483,17 @@ class AzureFunctionReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the azure function receiver. Names must be unique across all + :ivar name: Required. The name of the azure function receiver. Names must be unique across all receivers within an action group. - :type name: str - :param function_app_resource_id: Required. The azure resource id of the function app. - :type function_app_resource_id: str - :param function_name: Required. The function name in the function app. - :type function_name: str - :param http_trigger_url: Required. The http trigger url where http request sent to. - :type http_trigger_url: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar function_app_resource_id: Required. The azure resource id of the function app. + :vartype function_app_resource_id: str + :ivar function_name: Required. The function name in the function app. + :vartype function_name: str + :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :vartype http_trigger_url: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -425,6 +521,19 @@ def __init__( use_common_alert_schema: Optional[bool] = False, **kwargs ): + """ + :keyword name: Required. The name of the azure function receiver. Names must be unique across + all receivers within an action group. + :paramtype name: str + :keyword function_app_resource_id: Required. The azure resource id of the function app. + :paramtype function_app_resource_id: str + :keyword function_name: Required. The function name in the function app. + :paramtype function_name: str + :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :paramtype http_trigger_url: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(AzureFunctionReceiver, self).__init__(**kwargs) self.name = name self.function_app_resource_id = function_app_resource_id @@ -438,10 +547,10 @@ class BaselineMetadata(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the baseline metadata. - :type name: str - :param value: Required. Value of the baseline metadata. - :type value: str + :ivar name: Required. Name of the baseline metadata. + :vartype name: str + :ivar value: Required. Value of the baseline metadata. + :vartype value: str """ _validation = { @@ -461,6 +570,12 @@ def __init__( value: str, **kwargs ): + """ + :keyword name: Required. Name of the baseline metadata. + :paramtype name: str + :keyword value: Required. Value of the baseline metadata. + :paramtype value: str + """ super(BaselineMetadata, self).__init__(**kwargs) self.name = name self.value = value @@ -473,13 +588,13 @@ class EmailReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param email_address: Required. The email address of this receiver. - :type email_address: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :ivar name: Required. The name of the email receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar email_address: Required. The email address of this receiver. + :vartype email_address: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool :ivar status: The receiver status of the e-mail. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2019_03_01.models.ReceiverStatus @@ -506,6 +621,15 @@ def __init__( use_common_alert_schema: Optional[bool] = False, **kwargs ): + """ + :keyword name: Required. The name of the email receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address of this receiver. + :paramtype email_address: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(EmailReceiver, self).__init__(**kwargs) self.name = name self.email_address = email_address @@ -518,8 +642,8 @@ class EnableRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param receiver_name: Required. The name of the receiver to resubscribe. - :type receiver_name: str + :ivar receiver_name: Required. The name of the receiver to resubscribe. + :vartype receiver_name: str """ _validation = { @@ -536,6 +660,10 @@ def __init__( receiver_name: str, **kwargs ): + """ + :keyword receiver_name: Required. The name of the receiver to resubscribe. + :paramtype receiver_name: str + """ super(EnableRequest, self).__init__(**kwargs) self.receiver_name = receiver_name @@ -543,10 +671,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -561,6 +689,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -571,20 +705,20 @@ class ItsmReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Itsm receiver. Names must be unique across all receivers + :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers within an action group. - :type name: str - :param workspace_id: Required. OMS LA instance identifier. - :type workspace_id: str - :param connection_id: Required. Unique identification of ITSM connection among multiple defined + :vartype name: str + :ivar workspace_id: Required. OMS LA instance identifier. + :vartype workspace_id: str + :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined in above workspace. - :type connection_id: str - :param ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + :vartype connection_id: str + :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as well. - :type ticket_configuration: str - :param region: Required. Region in which workspace resides. Supported + :vartype ticket_configuration: str + :ivar region: Required. Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - :type region: str + :vartype region: str """ _validation = { @@ -613,6 +747,22 @@ def __init__( region: str, **kwargs ): + """ + :keyword name: Required. The name of the Itsm receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword workspace_id: Required. OMS LA instance identifier. + :paramtype workspace_id: str + :keyword connection_id: Required. Unique identification of ITSM connection among multiple + defined in above workspace. + :paramtype connection_id: str + :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. + :paramtype ticket_configuration: str + :keyword region: Required. Region in which workspace resides. Supported + values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + :paramtype region: str + """ super(ItsmReceiver, self).__init__(**kwargs) self.name = name self.workspace_id = workspace_id @@ -626,15 +776,15 @@ class LogicAppReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the logic app receiver. Names must be unique across all + :ivar name: Required. The name of the logic app receiver. Names must be unique across all receivers within an action group. - :type name: str - :param resource_id: Required. The azure resource id of the logic app receiver. - :type resource_id: str - :param callback_url: Required. The callback url where http request sent to. - :type callback_url: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar resource_id: Required. The azure resource id of the logic app receiver. + :vartype resource_id: str + :ivar callback_url: Required. The callback url where http request sent to. + :vartype callback_url: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -659,6 +809,17 @@ def __init__( use_common_alert_schema: Optional[bool] = False, **kwargs ): + """ + :keyword name: Required. The name of the logic app receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword resource_id: Required. The azure resource id of the logic app receiver. + :paramtype resource_id: str + :keyword callback_url: Required. The callback url where http request sent to. + :paramtype callback_url: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(LogicAppReceiver, self).__init__(**kwargs) self.name = name self.resource_id = resource_id @@ -669,8 +830,8 @@ def __init__( class MetricBaselinesResponse(msrest.serialization.Model): """A list of metric baselines. - :param value: The list of metric baselines. - :type value: list[~$(python-base-namespace).v2019_03_01.models.SingleMetricBaseline] + :ivar value: The list of metric baselines. + :vartype value: list[~$(python-base-namespace).v2019_03_01.models.SingleMetricBaseline] """ _attribute_map = { @@ -683,6 +844,10 @@ def __init__( value: Optional[List["SingleMetricBaseline"]] = None, **kwargs ): + """ + :keyword value: The list of metric baselines. + :paramtype value: list[~$(python-base-namespace).v2019_03_01.models.SingleMetricBaseline] + """ super(MetricBaselinesResponse, self).__init__(**kwargs) self.value = value @@ -692,10 +857,10 @@ class MetricSingleDimension(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the dimension. - :type name: str - :param value: Required. Value of the dimension. - :type value: str + :ivar name: Required. Name of the dimension. + :vartype name: str + :ivar value: Required. Value of the dimension. + :vartype value: str """ _validation = { @@ -715,6 +880,12 @@ def __init__( value: str, **kwargs ): + """ + :keyword name: Required. Name of the dimension. + :paramtype name: str + :keyword value: Required. Value of the dimension. + :paramtype value: str + """ super(MetricSingleDimension, self).__init__(**kwargs) self.name = name self.value = value @@ -725,13 +896,13 @@ class SingleBaseline(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sensitivity: Required. the sensitivity of the baseline. Possible values include: "Low", + :ivar sensitivity: Required. the sensitivity of the baseline. Possible values include: "Low", "Medium", "High". - :type sensitivity: str or ~$(python-base-namespace).v2019_03_01.models.BaselineSensitivity - :param low_thresholds: Required. The low thresholds of the baseline. - :type low_thresholds: list[float] - :param high_thresholds: Required. The high thresholds of the baseline. - :type high_thresholds: list[float] + :vartype sensitivity: str or ~$(python-base-namespace).v2019_03_01.models.BaselineSensitivity + :ivar low_thresholds: Required. The low thresholds of the baseline. + :vartype low_thresholds: list[float] + :ivar high_thresholds: Required. The high thresholds of the baseline. + :vartype high_thresholds: list[float] """ _validation = { @@ -754,6 +925,15 @@ def __init__( high_thresholds: List[float], **kwargs ): + """ + :keyword sensitivity: Required. the sensitivity of the baseline. Possible values include: + "Low", "Medium", "High". + :paramtype sensitivity: str or ~$(python-base-namespace).v2019_03_01.models.BaselineSensitivity + :keyword low_thresholds: Required. The low thresholds of the baseline. + :paramtype low_thresholds: list[float] + :keyword high_thresholds: Required. The high thresholds of the baseline. + :paramtype high_thresholds: list[float] + """ super(SingleBaseline, self).__init__(**kwargs) self.sensitivity = sensitivity self.low_thresholds = low_thresholds @@ -765,24 +945,24 @@ class SingleMetricBaseline(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Required. The metric baseline Id. - :type id: str - :param type: Required. The resource type of the metric baseline resource. - :type type: str - :param name: Required. The name of the metric for which the baselines were retrieved. - :type name: str - :param timespan: Required. The timespan for which the data was retrieved. Its value consists of + :ivar id: Required. The metric baseline Id. + :vartype id: str + :ivar type: Required. The resource type of the metric baseline resource. + :vartype type: str + :ivar name: Required. The name of the metric for which the baselines were retrieved. + :vartype name: str + :ivar timespan: Required. The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. - :type timespan: str - :param interval: Required. The interval (window size) for which the metric data was returned - in. This may be adjusted in the future and returned back from what was originally requested. - This is not present if a metadata request was made. - :type interval: ~datetime.timedelta - :param namespace: The namespace of the metrics been queried. - :type namespace: str - :param baselines: Required. The baseline for each time series that was queried. - :type baselines: list[~$(python-base-namespace).v2019_03_01.models.TimeSeriesBaseline] + :vartype timespan: str + :ivar interval: Required. The interval (window size) for which the metric data was returned in. + This may be adjusted in the future and returned back from what was originally requested. This + is not present if a metadata request was made. + :vartype interval: ~datetime.timedelta + :ivar namespace: The namespace of the metrics been queried. + :vartype namespace: str + :ivar baselines: Required. The baseline for each time series that was queried. + :vartype baselines: list[~$(python-base-namespace).v2019_03_01.models.TimeSeriesBaseline] """ _validation = { @@ -816,6 +996,26 @@ def __init__( namespace: Optional[str] = None, **kwargs ): + """ + :keyword id: Required. The metric baseline Id. + :paramtype id: str + :keyword type: Required. The resource type of the metric baseline resource. + :paramtype type: str + :keyword name: Required. The name of the metric for which the baselines were retrieved. + :paramtype name: str + :keyword timespan: Required. The timespan for which the data was retrieved. Its value consists + of two datetimes concatenated, separated by '/'. This may be adjusted in the future and + returned back from what was originally requested. + :paramtype timespan: str + :keyword interval: Required. The interval (window size) for which the metric data was returned + in. This may be adjusted in the future and returned back from what was originally requested. + This is not present if a metadata request was made. + :paramtype interval: ~datetime.timedelta + :keyword namespace: The namespace of the metrics been queried. + :paramtype namespace: str + :keyword baselines: Required. The baseline for each time series that was queried. + :paramtype baselines: list[~$(python-base-namespace).v2019_03_01.models.TimeSeriesBaseline] + """ super(SingleMetricBaseline, self).__init__(**kwargs) self.id = id self.type = type @@ -833,13 +1033,13 @@ class SmsReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SMS receiver. Names must be unique across all receivers + :ivar name: Required. The name of the SMS receiver. Names must be unique across all receivers within an action group. - :type name: str - :param country_code: Required. The country code of the SMS receiver. - :type country_code: str - :param phone_number: Required. The phone number of the SMS receiver. - :type phone_number: str + :vartype name: str + :ivar country_code: Required. The country code of the SMS receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the SMS receiver. + :vartype phone_number: str :ivar status: The status of the receiver. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2019_03_01.models.ReceiverStatus @@ -867,6 +1067,15 @@ def __init__( phone_number: str, **kwargs ): + """ + :keyword name: Required. The name of the SMS receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the SMS receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the SMS receiver. + :paramtype phone_number: str + """ super(SmsReceiver, self).__init__(**kwargs) self.name = name self.country_code = country_code @@ -879,16 +1088,16 @@ class TimeSeriesBaseline(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param aggregation: Required. The aggregation type of the metric. - :type aggregation: str - :param dimensions: The dimensions of this time series. - :type dimensions: list[~$(python-base-namespace).v2019_03_01.models.MetricSingleDimension] - :param timestamps: Required. The list of timestamps of the baselines. - :type timestamps: list[~datetime.datetime] - :param data: Required. The baseline values for each sensitivity. - :type data: list[~$(python-base-namespace).v2019_03_01.models.SingleBaseline] - :param metadata_values: The baseline metadata values. - :type metadata_values: list[~$(python-base-namespace).v2019_03_01.models.BaselineMetadata] + :ivar aggregation: Required. The aggregation type of the metric. + :vartype aggregation: str + :ivar dimensions: The dimensions of this time series. + :vartype dimensions: list[~$(python-base-namespace).v2019_03_01.models.MetricSingleDimension] + :ivar timestamps: Required. The list of timestamps of the baselines. + :vartype timestamps: list[~datetime.datetime] + :ivar data: Required. The baseline values for each sensitivity. + :vartype data: list[~$(python-base-namespace).v2019_03_01.models.SingleBaseline] + :ivar metadata_values: The baseline metadata values. + :vartype metadata_values: list[~$(python-base-namespace).v2019_03_01.models.BaselineMetadata] """ _validation = { @@ -915,6 +1124,18 @@ def __init__( metadata_values: Optional[List["BaselineMetadata"]] = None, **kwargs ): + """ + :keyword aggregation: Required. The aggregation type of the metric. + :paramtype aggregation: str + :keyword dimensions: The dimensions of this time series. + :paramtype dimensions: list[~$(python-base-namespace).v2019_03_01.models.MetricSingleDimension] + :keyword timestamps: Required. The list of timestamps of the baselines. + :paramtype timestamps: list[~datetime.datetime] + :keyword data: Required. The baseline values for each sensitivity. + :paramtype data: list[~$(python-base-namespace).v2019_03_01.models.SingleBaseline] + :keyword metadata_values: The baseline metadata values. + :paramtype metadata_values: list[~$(python-base-namespace).v2019_03_01.models.BaselineMetadata] + """ super(TimeSeriesBaseline, self).__init__(**kwargs) self.aggregation = aggregation self.dimensions = dimensions @@ -928,13 +1149,13 @@ class VoiceReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the voice receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param country_code: Required. The country code of the voice receiver. - :type country_code: str - :param phone_number: Required. The phone number of the voice receiver. - :type phone_number: str + :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar country_code: Required. The country code of the voice receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the voice receiver. + :vartype phone_number: str """ _validation = { @@ -957,6 +1178,15 @@ def __init__( phone_number: str, **kwargs ): + """ + :keyword name: Required. The name of the voice receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the voice receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the voice receiver. + :paramtype phone_number: str + """ super(VoiceReceiver, self).__init__(**kwargs) self.name = name self.country_code = country_code @@ -968,13 +1198,13 @@ class WebhookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the webhook receiver. Names must be unique across all + :ivar name: Required. The name of the webhook receiver. Names must be unique across all receivers within an action group. - :type name: str - :param service_uri: Required. The URI where webhooks should be sent. - :type service_uri: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar service_uri: Required. The URI where webhooks should be sent. + :vartype service_uri: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -996,6 +1226,15 @@ def __init__( use_common_alert_schema: Optional[bool] = False, **kwargs ): + """ + :keyword name: Required. The name of the webhook receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword service_uri: Required. The URI where webhooks should be sent. + :paramtype service_uri: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(WebhookReceiver, self).__init__(**kwargs) self.name = name self.service_uri = service_uri diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_monitor_management_client_enums.py index 3c4ff02d458d3..1bae2278d5d3d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/models/_monitor_management_client_enums.py @@ -6,27 +6,12 @@ # 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 BaselineSensitivity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class BaselineSensitivity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the sensitivity of the baseline. """ @@ -34,7 +19,7 @@ class BaselineSensitivity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MEDIUM = "Medium" HIGH = "High" -class ReceiverStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReceiverStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates the status of the receiver. Receivers that are not Enabled will not receive any communications. """ @@ -43,7 +28,7 @@ class ReceiverStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): ENABLED = "Enabled" DISABLED = "Disabled" -class ResultType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResultType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DATA = "Data" METADATA = "Metadata" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_action_groups_operations.py index 7be428a477149..ac8f0df6ce4f2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_action_groups_operations.py @@ -5,24 +5,290 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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_delete_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + action_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_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] + 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, + **kwargs + ) + + +def build_list_by_subscription_id_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups') + 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( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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_enable_receiver_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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] + 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class ActionGroupsOperations(object): """ActionGroupsOperations operations. @@ -45,6 +311,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -55,7 +322,7 @@ def create_or_update( # type: (...) -> "_models.ActionGroupResource" """Create a new action group or update an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -71,38 +338,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group, 'ActionGroupResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group, 'ActionGroupResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -115,8 +372,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -126,7 +386,7 @@ def get( # type: (...) -> "_models.ActionGroupResource" """Get an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -140,33 +400,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -175,8 +425,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -186,7 +439,7 @@ def delete( # type: (...) -> None """Delete an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -200,33 +453,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -234,6 +477,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -244,7 +489,7 @@ def update( # type: (...) -> "_models.ActionGroupResource" """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -260,38 +505,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - 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'), - 'actionGroupName': self._serialize.url("action_group_name", action_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -300,8 +535,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def list_by_subscription_id( self, **kwargs # type: Any @@ -311,7 +549,8 @@ def list_by_subscription_id( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ActionGroupList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupList] + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -319,34 +558,29 @@ def list_by_subscription_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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_subscription_id.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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription_id.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_list_by_subscription_id_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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -359,17 +593,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -378,11 +614,12 @@ def list_by_resource_group( # type: (...) -> Iterable["_models.ActionGroupList"] """Get a list of all action groups in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 ActionGroupList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupList] + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_03_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -390,35 +627,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -431,17 +664,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.insights/actionGroups'} # type: ignore + @distributed_trace def enable_receiver( self, resource_group_name, # type: str @@ -453,7 +688,7 @@ def enable_receiver( """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -469,41 +704,32 @@ def enable_receiver( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.enable_receiver.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(enable_request, 'EnableRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_enable_receiver_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.enable_receiver.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(enable_request, 'EnableRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(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, 409]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) enable_receiver.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_baselines_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_baselines_operations.py index d880d7505e7bb..d3f3fe7cf65c1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_baselines_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_03_01/operations/_baselines_operations.py @@ -6,24 +6,89 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + metricnames = kwargs.pop('metricnames', None) # type: Optional[str] + metricnamespace = kwargs.pop('metricnamespace', None) # type: Optional[str] + timespan = kwargs.pop('timespan', None) # type: Optional[str] + interval = kwargs.pop('interval', None) # type: Optional[datetime.timedelta] + aggregation = kwargs.pop('aggregation', None) # type: Optional[str] + sensitivities = kwargs.pop('sensitivities', None) # type: Optional[str] + filter = kwargs.pop('filter', None) # type: Optional[str] + result_type = kwargs.pop('result_type', None) # type: Optional[Union[str, "_models.ResultType"]] + + api_version = "2019-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/metricBaselines') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if metricnames is not None: + query_parameters['metricnames'] = _SERIALIZER.query("metricnames", metricnames, 'str') + if metricnamespace is not None: + query_parameters['metricnamespace'] = _SERIALIZER.query("metricnamespace", metricnamespace, 'str') + if timespan is not None: + query_parameters['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') + if interval is not None: + query_parameters['interval'] = _SERIALIZER.query("interval", interval, 'duration') + if aggregation is not None: + query_parameters['aggregation'] = _SERIALIZER.query("aggregation", aggregation, 'str') + if sensitivities is not None: + query_parameters['sensitivities'] = _SERIALIZER.query("sensitivities", sensitivities, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if result_type is not None: + query_parameters['resultType'] = _SERIALIZER.query("result_type", result_type, '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 + ) + +# fmt: on class BaselinesOperations(object): """BaselinesOperations operations. @@ -46,6 +111,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_uri, # type: str @@ -96,8 +162,10 @@ def list( information is retrieved. :type result_type: str or ~$(python-base-namespace).v2019_03_01.models.ResultType :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either MetricBaselinesResponse or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_03_01.models.MetricBaselinesResponse] + :return: An iterator like instance of either MetricBaselinesResponse or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_03_01.models.MetricBaselinesResponse] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.MetricBaselinesResponse"] @@ -105,50 +173,45 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if metricnames is not None: - query_parameters['metricnames'] = self._serialize.query("metricnames", metricnames, 'str') - if metricnamespace is not None: - query_parameters['metricnamespace'] = self._serialize.query("metricnamespace", metricnamespace, 'str') - if timespan is not None: - query_parameters['timespan'] = self._serialize.query("timespan", timespan, 'str') - if interval is not None: - query_parameters['interval'] = self._serialize.query("interval", interval, 'duration') - if aggregation is not None: - query_parameters['aggregation'] = self._serialize.query("aggregation", aggregation, 'str') - if sensitivities is not None: - query_parameters['sensitivities'] = self._serialize.query("sensitivities", sensitivities, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if result_type is not None: - query_parameters['resultType'] = self._serialize.query("result_type", result_type, 'str') - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + metricnames=metricnames, + metricnamespace=metricnamespace, + timespan=timespan, + interval=interval, + aggregation=aggregation, + sensitivities=sensitivities, + filter=filter, + result_type=result_type, + template_url=self.list.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_list_request( + resource_uri=resource_uri, + metricnames=metricnames, + metricnamespace=metricnamespace, + timespan=timespan, + interval=interval, + aggregation=aggregation, + sensitivities=sensitivities, + filter=filter, + result_type=result_type, + 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('MetricBaselinesResponse', pipeline_response) + deserialized = self._deserialize("MetricBaselinesResponse", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -161,12 +224,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_configuration.py index 21e5e61b754ab..a29e4a08dd806 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_metadata.json index 5e2ddffbca2bc..86800ff33772a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "action_groups": "ActionGroupsOperations" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_monitor_management_client.py index aa90ea634327b..847e2050673f6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_monitor_management_client.py @@ -6,22 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ActionGroupsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. @@ -32,47 +32,54 @@ class MonitorManagementClient(object): :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_configuration.py index 95f4e81a04ba3..bbcc96275adc7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_monitor_management_client.py index e23a7c650d226..49caf9f19a615 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_monitor_management_client.py @@ -6,69 +6,77 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: $(python-base-namespace).v2019_06_01.aio.operations.ActionGroupsOperations + :vartype action_groups: + $(python-base-namespace).v2019_06_01.aio.operations.ActionGroupsOperations :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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_action_groups_operations.py index 2920b224b86ae..8c4ea96238766 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/aio/operations/_action_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._action_groups_operations import build_create_or_update_request, build_delete_request, build_enable_receiver_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_update_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_async async def create_or_update( self, resource_group_name: str, @@ -50,7 +56,7 @@ async def create_or_update( ) -> "_models.ActionGroupResource": """Create a new action group or update an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -66,38 +72,28 @@ async def create_or_update( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group, 'ActionGroupResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group, 'ActionGroupResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -110,8 +106,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -120,7 +119,7 @@ async def get( ) -> "_models.ActionGroupResource": """Get an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -134,33 +133,23 @@ async def get( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -169,8 +158,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -179,7 +171,7 @@ async def delete( ) -> None: """Delete an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -193,33 +185,23 @@ async def delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -227,6 +209,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -236,7 +220,7 @@ async def update( ) -> "_models.ActionGroupResource": """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -252,38 +236,28 @@ async def update( 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.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'), - 'actionGroupName': self._serialize.url("action_group_name", action_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -292,8 +266,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def list_by_subscription_id( self, **kwargs: Any @@ -302,7 +279,8 @@ def list_by_subscription_id( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ActionGroupList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -310,34 +288,29 @@ def list_by_subscription_id( 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_subscription_id.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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription_id.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_list_by_subscription_id_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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -350,17 +323,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -368,11 +343,12 @@ def list_by_resource_group( ) -> AsyncIterable["_models.ActionGroupList"]: """Get a list of all action groups in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 ActionGroupList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -380,35 +356,31 @@ def list_by_resource_group( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -421,17 +393,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.insights/actionGroups'} # type: ignore + @distributed_trace_async async def enable_receiver( self, resource_group_name: str, @@ -442,7 +416,7 @@ async def enable_receiver( """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -458,41 +432,32 @@ async def enable_receiver( 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.enable_receiver.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(enable_request, 'EnableRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_enable_receiver_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.enable_receiver.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(enable_request, 'EnableRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(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, 409]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) enable_receiver.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models.py index a23a384c9d9c9..1fa0515218657 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models.py @@ -13,10 +13,10 @@ class ActionGroupList(msrest.serialization.Model): """A list of action groups. - :param value: The list of action groups. - :type value: list[~$(python-base-namespace).v2019_06_01.models.ActionGroupResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar value: The list of action groups. + :vartype value: list[~$(python-base-namespace).v2019_06_01.models.ActionGroupResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -28,6 +28,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of action groups. + :paramtype value: list[~$(python-base-namespace).v2019_06_01.models.ActionGroupResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(ActionGroupList, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -36,11 +42,11 @@ def __init__( class ActionGroupPatchBody(msrest.serialization.Model): """An action group object for the body of patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. - :type enabled: bool + :vartype enabled: bool """ _attribute_map = { @@ -52,6 +58,13 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ super(ActionGroupPatchBody, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.enabled = kwargs.get('enabled', True) @@ -74,10 +87,10 @@ class AzureResource(msrest.serialization.Model): :vartype kind: str :ivar identity: Azure resource identity. :vartype identity: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -103,6 +116,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(AzureResource, self).__init__(**kwargs) self.id = None self.name = None @@ -130,42 +149,43 @@ class ActionGroupResource(AzureResource): :vartype kind: str :ivar identity: Azure resource identity. :vartype identity: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param group_short_name: The short name of the action group. This will be used in SMS messages. - :type group_short_name: str - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar group_short_name: The short name of the action group. This will be used in SMS messages. + :vartype group_short_name: str + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. - :type enabled: bool - :param email_receivers: The list of email receivers that are part of this action group. - :type email_receivers: list[~$(python-base-namespace).v2019_06_01.models.EmailReceiver] - :param sms_receivers: The list of SMS receivers that are part of this action group. - :type sms_receivers: list[~$(python-base-namespace).v2019_06_01.models.SmsReceiver] - :param webhook_receivers: The list of webhook receivers that are part of this action group. - :type webhook_receivers: list[~$(python-base-namespace).v2019_06_01.models.WebhookReceiver] - :param itsm_receivers: The list of ITSM receivers that are part of this action group. - :type itsm_receivers: list[~$(python-base-namespace).v2019_06_01.models.ItsmReceiver] - :param azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :type azure_app_push_receivers: + :vartype enabled: bool + :ivar email_receivers: The list of email receivers that are part of this action group. + :vartype email_receivers: list[~$(python-base-namespace).v2019_06_01.models.EmailReceiver] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~$(python-base-namespace).v2019_06_01.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~$(python-base-namespace).v2019_06_01.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~$(python-base-namespace).v2019_06_01.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: list[~$(python-base-namespace).v2019_06_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of this action group. - :type automation_runbook_receivers: + :vartype automation_runbook_receivers: list[~$(python-base-namespace).v2019_06_01.models.AutomationRunbookReceiver] - :param voice_receivers: The list of voice receivers that are part of this action group. - :type voice_receivers: list[~$(python-base-namespace).v2019_06_01.models.VoiceReceiver] - :param logic_app_receivers: The list of logic app receivers that are part of this action group. - :type logic_app_receivers: list[~$(python-base-namespace).v2019_06_01.models.LogicAppReceiver] - :param azure_function_receivers: The list of azure function receivers that are part of this + :ivar voice_receivers: The list of voice receivers that are part of this action group. + :vartype voice_receivers: list[~$(python-base-namespace).v2019_06_01.models.VoiceReceiver] + :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. + :vartype logic_app_receivers: + list[~$(python-base-namespace).v2019_06_01.models.LogicAppReceiver] + :ivar azure_function_receivers: The list of azure function receivers that are part of this action group. - :type azure_function_receivers: + :vartype azure_function_receivers: list[~$(python-base-namespace).v2019_06_01.models.AzureFunctionReceiver] - :param arm_role_receivers: The list of ARM role receivers that are part of this action group. + :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. Roles are Azure RBAC roles and only built-in roles are supported. - :type arm_role_receivers: list[~$(python-base-namespace).v2019_06_01.models.ArmRoleReceiver] + :vartype arm_role_receivers: list[~$(python-base-namespace).v2019_06_01.models.ArmRoleReceiver] """ _validation = { @@ -204,6 +224,49 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword group_short_name: The short name of the action group. This will be used in SMS + messages. + :paramtype group_short_name: str + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its receivers will receive communications. + :paramtype enabled: bool + :keyword email_receivers: The list of email receivers that are part of this action group. + :paramtype email_receivers: list[~$(python-base-namespace).v2019_06_01.models.EmailReceiver] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~$(python-base-namespace).v2019_06_01.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: + list[~$(python-base-namespace).v2019_06_01.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~$(python-base-namespace).v2019_06_01.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: + list[~$(python-base-namespace).v2019_06_01.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~$(python-base-namespace).v2019_06_01.models.AutomationRunbookReceiver] + :keyword voice_receivers: The list of voice receivers that are part of this action group. + :paramtype voice_receivers: list[~$(python-base-namespace).v2019_06_01.models.VoiceReceiver] + :keyword logic_app_receivers: The list of logic app receivers that are part of this action + group. + :paramtype logic_app_receivers: + list[~$(python-base-namespace).v2019_06_01.models.LogicAppReceiver] + :keyword azure_function_receivers: The list of azure function receivers that are part of this + action group. + :paramtype azure_function_receivers: + list[~$(python-base-namespace).v2019_06_01.models.AzureFunctionReceiver] + :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :paramtype arm_role_receivers: + list[~$(python-base-namespace).v2019_06_01.models.ArmRoleReceiver] + """ super(ActionGroupResource, self).__init__(**kwargs) self.group_short_name = kwargs.get('group_short_name', None) self.enabled = kwargs.get('enabled', True) @@ -224,13 +287,13 @@ class ArmRoleReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the arm role receiver. Names must be unique across all + :ivar name: Required. The name of the arm role receiver. Names must be unique across all receivers within an action group. - :type name: str - :param role_id: Required. The arm role id. - :type role_id: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar role_id: Required. The arm role id. + :vartype role_id: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -248,6 +311,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the arm role receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword role_id: Required. The arm role id. + :paramtype role_id: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(ArmRoleReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.role_id = kwargs['role_id'] @@ -259,21 +331,21 @@ class AutomationRunbookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. - :type automation_account_id: str - :param runbook_name: Required. The name for this runbook. - :type runbook_name: str - :param webhook_resource_id: Required. The resource id for webhook linked to this runbook. - :type webhook_resource_id: str - :param is_global_runbook: Required. Indicates whether this instance is global runbook. - :type is_global_runbook: bool - :param name: Indicates name of the webhook. - :type name: str - :param service_uri: The URI where webhooks should be sent. - :type service_uri: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook + and authenticate to Azure resource. + :vartype automation_account_id: str + :ivar runbook_name: Required. The name for this runbook. + :vartype runbook_name: str + :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :vartype webhook_resource_id: str + :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :vartype is_global_runbook: bool + :ivar name: Indicates name of the webhook. + :vartype name: str + :ivar service_uri: The URI where webhooks should be sent. + :vartype service_uri: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -297,6 +369,23 @@ def __init__( self, **kwargs ): + """ + :keyword automation_account_id: Required. The Azure automation account Id which holds this + runbook and authenticate to Azure resource. + :paramtype automation_account_id: str + :keyword runbook_name: Required. The name for this runbook. + :paramtype runbook_name: str + :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :paramtype webhook_resource_id: str + :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :paramtype is_global_runbook: bool + :keyword name: Indicates name of the webhook. + :paramtype name: str + :keyword service_uri: The URI where webhooks should be sent. + :paramtype service_uri: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(AutomationRunbookReceiver, self).__init__(**kwargs) self.automation_account_id = kwargs['automation_account_id'] self.runbook_name = kwargs['runbook_name'] @@ -312,11 +401,11 @@ class AzureAppPushReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Azure mobile app push receiver. Names must be unique + :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. - :type name: str - :param email_address: Required. The email address registered for the Azure mobile app. - :type email_address: str + :vartype name: str + :ivar email_address: Required. The email address registered for the Azure mobile app. + :vartype email_address: str """ _validation = { @@ -333,6 +422,13 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique + across all receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address registered for the Azure mobile app. + :paramtype email_address: str + """ super(AzureAppPushReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.email_address = kwargs['email_address'] @@ -343,17 +439,17 @@ class AzureFunctionReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the azure function receiver. Names must be unique across all + :ivar name: Required. The name of the azure function receiver. Names must be unique across all receivers within an action group. - :type name: str - :param function_app_resource_id: Required. The azure resource id of the function app. - :type function_app_resource_id: str - :param function_name: Required. The function name in the function app. - :type function_name: str - :param http_trigger_url: Required. The http trigger url where http request sent to. - :type http_trigger_url: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar function_app_resource_id: Required. The azure resource id of the function app. + :vartype function_app_resource_id: str + :ivar function_name: Required. The function name in the function app. + :vartype function_name: str + :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :vartype http_trigger_url: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -375,6 +471,19 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the azure function receiver. Names must be unique across + all receivers within an action group. + :paramtype name: str + :keyword function_app_resource_id: Required. The azure resource id of the function app. + :paramtype function_app_resource_id: str + :keyword function_name: Required. The function name in the function app. + :paramtype function_name: str + :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :paramtype http_trigger_url: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(AzureFunctionReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.function_app_resource_id = kwargs['function_app_resource_id'] @@ -390,13 +499,13 @@ class EmailReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param email_address: Required. The email address of this receiver. - :type email_address: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :ivar name: Required. The name of the email receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar email_address: Required. The email address of this receiver. + :vartype email_address: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool :ivar status: The receiver status of the e-mail. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2019_06_01.models.ReceiverStatus @@ -419,6 +528,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the email receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address of this receiver. + :paramtype email_address: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(EmailReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.email_address = kwargs['email_address'] @@ -431,8 +549,8 @@ class EnableRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param receiver_name: Required. The name of the receiver to resubscribe. - :type receiver_name: str + :ivar receiver_name: Required. The name of the receiver to resubscribe. + :vartype receiver_name: str """ _validation = { @@ -447,6 +565,10 @@ def __init__( self, **kwargs ): + """ + :keyword receiver_name: Required. The name of the receiver to resubscribe. + :paramtype receiver_name: str + """ super(EnableRequest, self).__init__(**kwargs) self.receiver_name = kwargs['receiver_name'] @@ -454,10 +576,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -469,6 +591,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -479,20 +607,20 @@ class ItsmReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Itsm receiver. Names must be unique across all receivers + :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers within an action group. - :type name: str - :param workspace_id: Required. OMS LA instance identifier. - :type workspace_id: str - :param connection_id: Required. Unique identification of ITSM connection among multiple defined + :vartype name: str + :ivar workspace_id: Required. OMS LA instance identifier. + :vartype workspace_id: str + :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined in above workspace. - :type connection_id: str - :param ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + :vartype connection_id: str + :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as well. - :type ticket_configuration: str - :param region: Required. Region in which workspace resides. Supported + :vartype ticket_configuration: str + :ivar region: Required. Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - :type region: str + :vartype region: str """ _validation = { @@ -515,6 +643,22 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the Itsm receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword workspace_id: Required. OMS LA instance identifier. + :paramtype workspace_id: str + :keyword connection_id: Required. Unique identification of ITSM connection among multiple + defined in above workspace. + :paramtype connection_id: str + :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. + :paramtype ticket_configuration: str + :keyword region: Required. Region in which workspace resides. Supported + values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + :paramtype region: str + """ super(ItsmReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.workspace_id = kwargs['workspace_id'] @@ -528,15 +672,15 @@ class LogicAppReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the logic app receiver. Names must be unique across all + :ivar name: Required. The name of the logic app receiver. Names must be unique across all receivers within an action group. - :type name: str - :param resource_id: Required. The azure resource id of the logic app receiver. - :type resource_id: str - :param callback_url: Required. The callback url where http request sent to. - :type callback_url: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar resource_id: Required. The azure resource id of the logic app receiver. + :vartype resource_id: str + :ivar callback_url: Required. The callback url where http request sent to. + :vartype callback_url: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -556,6 +700,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the logic app receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword resource_id: Required. The azure resource id of the logic app receiver. + :paramtype resource_id: str + :keyword callback_url: Required. The callback url where http request sent to. + :paramtype callback_url: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(LogicAppReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.resource_id = kwargs['resource_id'] @@ -570,13 +725,13 @@ class SmsReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SMS receiver. Names must be unique across all receivers + :ivar name: Required. The name of the SMS receiver. Names must be unique across all receivers within an action group. - :type name: str - :param country_code: Required. The country code of the SMS receiver. - :type country_code: str - :param phone_number: Required. The phone number of the SMS receiver. - :type phone_number: str + :vartype name: str + :ivar country_code: Required. The country code of the SMS receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the SMS receiver. + :vartype phone_number: str :ivar status: The status of the receiver. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2019_06_01.models.ReceiverStatus @@ -600,6 +755,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the SMS receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the SMS receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the SMS receiver. + :paramtype phone_number: str + """ super(SmsReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.country_code = kwargs['country_code'] @@ -612,13 +776,13 @@ class VoiceReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the voice receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param country_code: Required. The country code of the voice receiver. - :type country_code: str - :param phone_number: Required. The phone number of the voice receiver. - :type phone_number: str + :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar country_code: Required. The country code of the voice receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the voice receiver. + :vartype phone_number: str """ _validation = { @@ -637,6 +801,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the voice receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the voice receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the voice receiver. + :paramtype phone_number: str + """ super(VoiceReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.country_code = kwargs['country_code'] @@ -648,21 +821,21 @@ class WebhookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the webhook receiver. Names must be unique across all + :ivar name: Required. The name of the webhook receiver. Names must be unique across all receivers within an action group. - :type name: str - :param service_uri: Required. The URI where webhooks should be sent. - :type service_uri: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool - :param use_aad_auth: Indicates whether or not use AAD authentication. - :type use_aad_auth: bool - :param object_id: Indicates the webhook app object Id for aad auth. - :type object_id: str - :param identifier_uri: Indicates the identifier uri for aad auth. - :type identifier_uri: str - :param tenant_id: Indicates the tenant id for aad auth. - :type tenant_id: str + :vartype name: str + :ivar service_uri: Required. The URI where webhooks should be sent. + :vartype service_uri: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + :ivar use_aad_auth: Indicates whether or not use AAD authentication. + :vartype use_aad_auth: bool + :ivar object_id: Indicates the webhook app object Id for aad auth. + :vartype object_id: str + :ivar identifier_uri: Indicates the identifier uri for aad auth. + :vartype identifier_uri: str + :ivar tenant_id: Indicates the tenant id for aad auth. + :vartype tenant_id: str """ _validation = { @@ -684,6 +857,23 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the webhook receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword service_uri: Required. The URI where webhooks should be sent. + :paramtype service_uri: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + :keyword use_aad_auth: Indicates whether or not use AAD authentication. + :paramtype use_aad_auth: bool + :keyword object_id: Indicates the webhook app object Id for aad auth. + :paramtype object_id: str + :keyword identifier_uri: Indicates the identifier uri for aad auth. + :paramtype identifier_uri: str + :keyword tenant_id: Indicates the tenant id for aad auth. + :paramtype tenant_id: str + """ super(WebhookReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.service_uri = kwargs['service_uri'] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models_py3.py index 5d5c8528ce62f..5e0a25f65ada1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_models_py3.py @@ -15,10 +15,10 @@ class ActionGroupList(msrest.serialization.Model): """A list of action groups. - :param value: The list of action groups. - :type value: list[~$(python-base-namespace).v2019_06_01.models.ActionGroupResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar value: The list of action groups. + :vartype value: list[~$(python-base-namespace).v2019_06_01.models.ActionGroupResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -33,6 +33,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of action groups. + :paramtype value: list[~$(python-base-namespace).v2019_06_01.models.ActionGroupResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(ActionGroupList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -41,11 +47,11 @@ def __init__( class ActionGroupPatchBody(msrest.serialization.Model): """An action group object for the body of patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. - :type enabled: bool + :vartype enabled: bool """ _attribute_map = { @@ -60,6 +66,13 @@ def __init__( enabled: Optional[bool] = True, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ super(ActionGroupPatchBody, self).__init__(**kwargs) self.tags = tags self.enabled = enabled @@ -82,10 +95,10 @@ class AzureResource(msrest.serialization.Model): :vartype kind: str :ivar identity: Azure resource identity. :vartype identity: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -114,6 +127,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(AzureResource, self).__init__(**kwargs) self.id = None self.name = None @@ -141,42 +160,43 @@ class ActionGroupResource(AzureResource): :vartype kind: str :ivar identity: Azure resource identity. :vartype identity: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param group_short_name: The short name of the action group. This will be used in SMS messages. - :type group_short_name: str - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar group_short_name: The short name of the action group. This will be used in SMS messages. + :vartype group_short_name: str + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. - :type enabled: bool - :param email_receivers: The list of email receivers that are part of this action group. - :type email_receivers: list[~$(python-base-namespace).v2019_06_01.models.EmailReceiver] - :param sms_receivers: The list of SMS receivers that are part of this action group. - :type sms_receivers: list[~$(python-base-namespace).v2019_06_01.models.SmsReceiver] - :param webhook_receivers: The list of webhook receivers that are part of this action group. - :type webhook_receivers: list[~$(python-base-namespace).v2019_06_01.models.WebhookReceiver] - :param itsm_receivers: The list of ITSM receivers that are part of this action group. - :type itsm_receivers: list[~$(python-base-namespace).v2019_06_01.models.ItsmReceiver] - :param azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :type azure_app_push_receivers: + :vartype enabled: bool + :ivar email_receivers: The list of email receivers that are part of this action group. + :vartype email_receivers: list[~$(python-base-namespace).v2019_06_01.models.EmailReceiver] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~$(python-base-namespace).v2019_06_01.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~$(python-base-namespace).v2019_06_01.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~$(python-base-namespace).v2019_06_01.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: list[~$(python-base-namespace).v2019_06_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of this action group. - :type automation_runbook_receivers: + :vartype automation_runbook_receivers: list[~$(python-base-namespace).v2019_06_01.models.AutomationRunbookReceiver] - :param voice_receivers: The list of voice receivers that are part of this action group. - :type voice_receivers: list[~$(python-base-namespace).v2019_06_01.models.VoiceReceiver] - :param logic_app_receivers: The list of logic app receivers that are part of this action group. - :type logic_app_receivers: list[~$(python-base-namespace).v2019_06_01.models.LogicAppReceiver] - :param azure_function_receivers: The list of azure function receivers that are part of this + :ivar voice_receivers: The list of voice receivers that are part of this action group. + :vartype voice_receivers: list[~$(python-base-namespace).v2019_06_01.models.VoiceReceiver] + :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. + :vartype logic_app_receivers: + list[~$(python-base-namespace).v2019_06_01.models.LogicAppReceiver] + :ivar azure_function_receivers: The list of azure function receivers that are part of this action group. - :type azure_function_receivers: + :vartype azure_function_receivers: list[~$(python-base-namespace).v2019_06_01.models.AzureFunctionReceiver] - :param arm_role_receivers: The list of ARM role receivers that are part of this action group. + :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. Roles are Azure RBAC roles and only built-in roles are supported. - :type arm_role_receivers: list[~$(python-base-namespace).v2019_06_01.models.ArmRoleReceiver] + :vartype arm_role_receivers: list[~$(python-base-namespace).v2019_06_01.models.ArmRoleReceiver] """ _validation = { @@ -230,6 +250,49 @@ def __init__( arm_role_receivers: Optional[List["ArmRoleReceiver"]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword group_short_name: The short name of the action group. This will be used in SMS + messages. + :paramtype group_short_name: str + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its receivers will receive communications. + :paramtype enabled: bool + :keyword email_receivers: The list of email receivers that are part of this action group. + :paramtype email_receivers: list[~$(python-base-namespace).v2019_06_01.models.EmailReceiver] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~$(python-base-namespace).v2019_06_01.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: + list[~$(python-base-namespace).v2019_06_01.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~$(python-base-namespace).v2019_06_01.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: + list[~$(python-base-namespace).v2019_06_01.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~$(python-base-namespace).v2019_06_01.models.AutomationRunbookReceiver] + :keyword voice_receivers: The list of voice receivers that are part of this action group. + :paramtype voice_receivers: list[~$(python-base-namespace).v2019_06_01.models.VoiceReceiver] + :keyword logic_app_receivers: The list of logic app receivers that are part of this action + group. + :paramtype logic_app_receivers: + list[~$(python-base-namespace).v2019_06_01.models.LogicAppReceiver] + :keyword azure_function_receivers: The list of azure function receivers that are part of this + action group. + :paramtype azure_function_receivers: + list[~$(python-base-namespace).v2019_06_01.models.AzureFunctionReceiver] + :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :paramtype arm_role_receivers: + list[~$(python-base-namespace).v2019_06_01.models.ArmRoleReceiver] + """ super(ActionGroupResource, self).__init__(location=location, tags=tags, **kwargs) self.group_short_name = group_short_name self.enabled = enabled @@ -250,13 +313,13 @@ class ArmRoleReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the arm role receiver. Names must be unique across all + :ivar name: Required. The name of the arm role receiver. Names must be unique across all receivers within an action group. - :type name: str - :param role_id: Required. The arm role id. - :type role_id: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar role_id: Required. The arm role id. + :vartype role_id: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -278,6 +341,15 @@ def __init__( use_common_alert_schema: Optional[bool] = False, **kwargs ): + """ + :keyword name: Required. The name of the arm role receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword role_id: Required. The arm role id. + :paramtype role_id: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(ArmRoleReceiver, self).__init__(**kwargs) self.name = name self.role_id = role_id @@ -289,21 +361,21 @@ class AutomationRunbookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. - :type automation_account_id: str - :param runbook_name: Required. The name for this runbook. - :type runbook_name: str - :param webhook_resource_id: Required. The resource id for webhook linked to this runbook. - :type webhook_resource_id: str - :param is_global_runbook: Required. Indicates whether this instance is global runbook. - :type is_global_runbook: bool - :param name: Indicates name of the webhook. - :type name: str - :param service_uri: The URI where webhooks should be sent. - :type service_uri: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook + and authenticate to Azure resource. + :vartype automation_account_id: str + :ivar runbook_name: Required. The name for this runbook. + :vartype runbook_name: str + :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :vartype webhook_resource_id: str + :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :vartype is_global_runbook: bool + :ivar name: Indicates name of the webhook. + :vartype name: str + :ivar service_uri: The URI where webhooks should be sent. + :vartype service_uri: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -335,6 +407,23 @@ def __init__( use_common_alert_schema: Optional[bool] = False, **kwargs ): + """ + :keyword automation_account_id: Required. The Azure automation account Id which holds this + runbook and authenticate to Azure resource. + :paramtype automation_account_id: str + :keyword runbook_name: Required. The name for this runbook. + :paramtype runbook_name: str + :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :paramtype webhook_resource_id: str + :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :paramtype is_global_runbook: bool + :keyword name: Indicates name of the webhook. + :paramtype name: str + :keyword service_uri: The URI where webhooks should be sent. + :paramtype service_uri: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(AutomationRunbookReceiver, self).__init__(**kwargs) self.automation_account_id = automation_account_id self.runbook_name = runbook_name @@ -350,11 +439,11 @@ class AzureAppPushReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Azure mobile app push receiver. Names must be unique + :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. - :type name: str - :param email_address: Required. The email address registered for the Azure mobile app. - :type email_address: str + :vartype name: str + :ivar email_address: Required. The email address registered for the Azure mobile app. + :vartype email_address: str """ _validation = { @@ -374,6 +463,13 @@ def __init__( email_address: str, **kwargs ): + """ + :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique + across all receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address registered for the Azure mobile app. + :paramtype email_address: str + """ super(AzureAppPushReceiver, self).__init__(**kwargs) self.name = name self.email_address = email_address @@ -384,17 +480,17 @@ class AzureFunctionReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the azure function receiver. Names must be unique across all + :ivar name: Required. The name of the azure function receiver. Names must be unique across all receivers within an action group. - :type name: str - :param function_app_resource_id: Required. The azure resource id of the function app. - :type function_app_resource_id: str - :param function_name: Required. The function name in the function app. - :type function_name: str - :param http_trigger_url: Required. The http trigger url where http request sent to. - :type http_trigger_url: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar function_app_resource_id: Required. The azure resource id of the function app. + :vartype function_app_resource_id: str + :ivar function_name: Required. The function name in the function app. + :vartype function_name: str + :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :vartype http_trigger_url: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -422,6 +518,19 @@ def __init__( use_common_alert_schema: Optional[bool] = False, **kwargs ): + """ + :keyword name: Required. The name of the azure function receiver. Names must be unique across + all receivers within an action group. + :paramtype name: str + :keyword function_app_resource_id: Required. The azure resource id of the function app. + :paramtype function_app_resource_id: str + :keyword function_name: Required. The function name in the function app. + :paramtype function_name: str + :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :paramtype http_trigger_url: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(AzureFunctionReceiver, self).__init__(**kwargs) self.name = name self.function_app_resource_id = function_app_resource_id @@ -437,13 +546,13 @@ class EmailReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param email_address: Required. The email address of this receiver. - :type email_address: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :ivar name: Required. The name of the email receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar email_address: Required. The email address of this receiver. + :vartype email_address: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool :ivar status: The receiver status of the e-mail. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2019_06_01.models.ReceiverStatus @@ -470,6 +579,15 @@ def __init__( use_common_alert_schema: Optional[bool] = False, **kwargs ): + """ + :keyword name: Required. The name of the email receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address of this receiver. + :paramtype email_address: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(EmailReceiver, self).__init__(**kwargs) self.name = name self.email_address = email_address @@ -482,8 +600,8 @@ class EnableRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param receiver_name: Required. The name of the receiver to resubscribe. - :type receiver_name: str + :ivar receiver_name: Required. The name of the receiver to resubscribe. + :vartype receiver_name: str """ _validation = { @@ -500,6 +618,10 @@ def __init__( receiver_name: str, **kwargs ): + """ + :keyword receiver_name: Required. The name of the receiver to resubscribe. + :paramtype receiver_name: str + """ super(EnableRequest, self).__init__(**kwargs) self.receiver_name = receiver_name @@ -507,10 +629,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -525,6 +647,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -535,20 +663,20 @@ class ItsmReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Itsm receiver. Names must be unique across all receivers + :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers within an action group. - :type name: str - :param workspace_id: Required. OMS LA instance identifier. - :type workspace_id: str - :param connection_id: Required. Unique identification of ITSM connection among multiple defined + :vartype name: str + :ivar workspace_id: Required. OMS LA instance identifier. + :vartype workspace_id: str + :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined in above workspace. - :type connection_id: str - :param ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + :vartype connection_id: str + :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as well. - :type ticket_configuration: str - :param region: Required. Region in which workspace resides. Supported + :vartype ticket_configuration: str + :ivar region: Required. Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - :type region: str + :vartype region: str """ _validation = { @@ -577,6 +705,22 @@ def __init__( region: str, **kwargs ): + """ + :keyword name: Required. The name of the Itsm receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword workspace_id: Required. OMS LA instance identifier. + :paramtype workspace_id: str + :keyword connection_id: Required. Unique identification of ITSM connection among multiple + defined in above workspace. + :paramtype connection_id: str + :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. + :paramtype ticket_configuration: str + :keyword region: Required. Region in which workspace resides. Supported + values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + :paramtype region: str + """ super(ItsmReceiver, self).__init__(**kwargs) self.name = name self.workspace_id = workspace_id @@ -590,15 +734,15 @@ class LogicAppReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the logic app receiver. Names must be unique across all + :ivar name: Required. The name of the logic app receiver. Names must be unique across all receivers within an action group. - :type name: str - :param resource_id: Required. The azure resource id of the logic app receiver. - :type resource_id: str - :param callback_url: Required. The callback url where http request sent to. - :type callback_url: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar resource_id: Required. The azure resource id of the logic app receiver. + :vartype resource_id: str + :ivar callback_url: Required. The callback url where http request sent to. + :vartype callback_url: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -623,6 +767,17 @@ def __init__( use_common_alert_schema: Optional[bool] = False, **kwargs ): + """ + :keyword name: Required. The name of the logic app receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword resource_id: Required. The azure resource id of the logic app receiver. + :paramtype resource_id: str + :keyword callback_url: Required. The callback url where http request sent to. + :paramtype callback_url: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(LogicAppReceiver, self).__init__(**kwargs) self.name = name self.resource_id = resource_id @@ -637,13 +792,13 @@ class SmsReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SMS receiver. Names must be unique across all receivers + :ivar name: Required. The name of the SMS receiver. Names must be unique across all receivers within an action group. - :type name: str - :param country_code: Required. The country code of the SMS receiver. - :type country_code: str - :param phone_number: Required. The phone number of the SMS receiver. - :type phone_number: str + :vartype name: str + :ivar country_code: Required. The country code of the SMS receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the SMS receiver. + :vartype phone_number: str :ivar status: The status of the receiver. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2019_06_01.models.ReceiverStatus @@ -671,6 +826,15 @@ def __init__( phone_number: str, **kwargs ): + """ + :keyword name: Required. The name of the SMS receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the SMS receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the SMS receiver. + :paramtype phone_number: str + """ super(SmsReceiver, self).__init__(**kwargs) self.name = name self.country_code = country_code @@ -683,13 +847,13 @@ class VoiceReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the voice receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param country_code: Required. The country code of the voice receiver. - :type country_code: str - :param phone_number: Required. The phone number of the voice receiver. - :type phone_number: str + :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar country_code: Required. The country code of the voice receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the voice receiver. + :vartype phone_number: str """ _validation = { @@ -712,6 +876,15 @@ def __init__( phone_number: str, **kwargs ): + """ + :keyword name: Required. The name of the voice receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the voice receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the voice receiver. + :paramtype phone_number: str + """ super(VoiceReceiver, self).__init__(**kwargs) self.name = name self.country_code = country_code @@ -723,21 +896,21 @@ class WebhookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the webhook receiver. Names must be unique across all + :ivar name: Required. The name of the webhook receiver. Names must be unique across all receivers within an action group. - :type name: str - :param service_uri: Required. The URI where webhooks should be sent. - :type service_uri: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool - :param use_aad_auth: Indicates whether or not use AAD authentication. - :type use_aad_auth: bool - :param object_id: Indicates the webhook app object Id for aad auth. - :type object_id: str - :param identifier_uri: Indicates the identifier uri for aad auth. - :type identifier_uri: str - :param tenant_id: Indicates the tenant id for aad auth. - :type tenant_id: str + :vartype name: str + :ivar service_uri: Required. The URI where webhooks should be sent. + :vartype service_uri: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + :ivar use_aad_auth: Indicates whether or not use AAD authentication. + :vartype use_aad_auth: bool + :ivar object_id: Indicates the webhook app object Id for aad auth. + :vartype object_id: str + :ivar identifier_uri: Indicates the identifier uri for aad auth. + :vartype identifier_uri: str + :ivar tenant_id: Indicates the tenant id for aad auth. + :vartype tenant_id: str """ _validation = { @@ -767,6 +940,23 @@ def __init__( tenant_id: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. The name of the webhook receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword service_uri: Required. The URI where webhooks should be sent. + :paramtype service_uri: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + :keyword use_aad_auth: Indicates whether or not use AAD authentication. + :paramtype use_aad_auth: bool + :keyword object_id: Indicates the webhook app object Id for aad auth. + :paramtype object_id: str + :keyword identifier_uri: Indicates the identifier uri for aad auth. + :paramtype identifier_uri: str + :keyword tenant_id: Indicates the tenant id for aad auth. + :paramtype tenant_id: str + """ super(WebhookReceiver, self).__init__(**kwargs) self.name = name self.service_uri = service_uri diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_monitor_management_client_enums.py index 238df22ea2f0b..5e8a759db49cf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/models/_monitor_management_client_enums.py @@ -6,27 +6,12 @@ # 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 ReceiverStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReceiverStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates the status of the receiver. Receivers that are not Enabled will not receive any communications. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_action_groups_operations.py index cc8b99ea162a8..520e259701318 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_06_01/operations/_action_groups_operations.py @@ -5,24 +5,290 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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_delete_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + action_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_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] + 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, + **kwargs + ) + + +def build_list_by_subscription_id_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups') + 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( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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_enable_receiver_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-06-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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] + 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class ActionGroupsOperations(object): """ActionGroupsOperations operations. @@ -45,6 +311,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -55,7 +322,7 @@ def create_or_update( # type: (...) -> "_models.ActionGroupResource" """Create a new action group or update an existing one. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -71,38 +338,28 @@ def create_or_update( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group, 'ActionGroupResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group, 'ActionGroupResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -115,8 +372,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -126,7 +386,7 @@ def get( # type: (...) -> "_models.ActionGroupResource" """Get an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -140,33 +400,23 @@ def get( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -175,8 +425,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -186,7 +439,7 @@ def delete( # type: (...) -> None """Delete an action group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -200,33 +453,23 @@ def delete( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -234,6 +477,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -244,7 +489,7 @@ def update( # type: (...) -> "_models.ActionGroupResource" """Updates an existing action group's tags. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -260,38 +505,28 @@ def update( 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.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'), - 'actionGroupName': self._serialize.url("action_group_name", action_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -300,8 +535,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def list_by_subscription_id( self, **kwargs # type: Any @@ -311,7 +549,8 @@ def list_by_subscription_id( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ActionGroupList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupList] + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -319,34 +558,29 @@ def list_by_subscription_id( 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_subscription_id.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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription_id.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_list_by_subscription_id_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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -359,17 +593,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/actionGroups'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -378,11 +614,12 @@ def list_by_resource_group( # type: (...) -> Iterable["_models.ActionGroupList"] """Get a list of all action groups in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 ActionGroupList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupList] + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_06_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -390,35 +627,31 @@ def list_by_resource_group( 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -431,17 +664,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.insights/actionGroups'} # type: ignore + @distributed_trace def enable_receiver( self, resource_group_name, # type: str @@ -453,7 +688,7 @@ def enable_receiver( """Enable a receiver in an action group. This changes the receiver's status from Disabled to Enabled. This operation is only supported for Email or SMS receivers. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param action_group_name: The name of the action group. :type action_group_name: str @@ -469,41 +704,32 @@ def enable_receiver( 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.enable_receiver.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(enable_request, 'EnableRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_enable_receiver_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.enable_receiver.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(enable_request, 'EnableRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(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, 409]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) enable_receiver.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/actionGroups/{actionGroupName}/subscribe'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_configuration.py index 3dad54793336f..b72b6e53960a1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_metadata.json index fec9dc40f6cba..c1ab582041420 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "private_link_scopes": "PrivateLinkScopesOperations", diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_monitor_management_client.py index fed0b405d3090..337f4549ff6ae 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_monitor_management_client.py @@ -6,94 +6,99 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, PrivateLinkScopeOperationStatusOperations, PrivateLinkScopedResourcesOperations, PrivateLinkScopesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import PrivateLinkScopesOperations -from .operations import PrivateLinkScopeOperationStatusOperations -from .operations import PrivateLinkResourcesOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import PrivateLinkScopedResourcesOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. :ivar private_link_scopes: PrivateLinkScopesOperations operations - :vartype private_link_scopes: $(python-base-namespace).v2019_10_17.operations.PrivateLinkScopesOperations + :vartype private_link_scopes: + $(python-base-namespace).v2019_10_17.operations.PrivateLinkScopesOperations :ivar private_link_scope_operation_status: PrivateLinkScopeOperationStatusOperations operations - :vartype private_link_scope_operation_status: $(python-base-namespace).v2019_10_17.operations.PrivateLinkScopeOperationStatusOperations + :vartype private_link_scope_operation_status: + $(python-base-namespace).v2019_10_17.operations.PrivateLinkScopeOperationStatusOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: $(python-base-namespace).v2019_10_17.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + $(python-base-namespace).v2019_10_17.operations.PrivateLinkResourcesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: $(python-base-namespace).v2019_10_17.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + $(python-base-namespace).v2019_10_17.operations.PrivateEndpointConnectionsOperations :ivar private_link_scoped_resources: PrivateLinkScopedResourcesOperations operations - :vartype private_link_scoped_resources: $(python-base-namespace).v2019_10_17.operations.PrivateLinkScopedResourcesOperations + :vartype private_link_scoped_resources: + $(python-base-namespace).v2019_10_17.operations.PrivateLinkScopedResourcesOperations :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 - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.private_link_scopes = PrivateLinkScopesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_scope_operation_status = PrivateLinkScopeOperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_scoped_resources = PrivateLinkScopedResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + - self.private_link_scopes = PrivateLinkScopesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_scope_operation_status = PrivateLinkScopeOperationStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_scoped_resources = PrivateLinkScopedResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_configuration.py index 4579dfddfc722..26c8b9416b5db 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_monitor_management_client.py index 1fce9050d8f0a..33dce3625e851 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_monitor_management_client.py @@ -6,90 +6,95 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, PrivateLinkScopeOperationStatusOperations, PrivateLinkScopedResourcesOperations, PrivateLinkScopesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MonitorManagementClientConfiguration -from .operations import PrivateLinkScopesOperations -from .operations import PrivateLinkScopeOperationStatusOperations -from .operations import PrivateLinkResourcesOperations -from .operations import PrivateEndpointConnectionsOperations -from .operations import PrivateLinkScopedResourcesOperations -from .. import models - - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar private_link_scopes: PrivateLinkScopesOperations operations - :vartype private_link_scopes: $(python-base-namespace).v2019_10_17.aio.operations.PrivateLinkScopesOperations + :vartype private_link_scopes: + $(python-base-namespace).v2019_10_17.aio.operations.PrivateLinkScopesOperations :ivar private_link_scope_operation_status: PrivateLinkScopeOperationStatusOperations operations - :vartype private_link_scope_operation_status: $(python-base-namespace).v2019_10_17.aio.operations.PrivateLinkScopeOperationStatusOperations + :vartype private_link_scope_operation_status: + $(python-base-namespace).v2019_10_17.aio.operations.PrivateLinkScopeOperationStatusOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: $(python-base-namespace).v2019_10_17.aio.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + $(python-base-namespace).v2019_10_17.aio.operations.PrivateLinkResourcesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: $(python-base-namespace).v2019_10_17.aio.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + $(python-base-namespace).v2019_10_17.aio.operations.PrivateEndpointConnectionsOperations :ivar private_link_scoped_resources: PrivateLinkScopedResourcesOperations operations - :vartype private_link_scoped_resources: $(python-base-namespace).v2019_10_17.aio.operations.PrivateLinkScopedResourcesOperations + :vartype private_link_scoped_resources: + $(python-base-namespace).v2019_10_17.aio.operations.PrivateLinkScopedResourcesOperations :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 - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ 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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.private_link_scopes = PrivateLinkScopesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_scope_operation_status = PrivateLinkScopeOperationStatusOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.private_link_scoped_resources = PrivateLinkScopedResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + - self.private_link_scopes = PrivateLinkScopesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_scope_operation_status = PrivateLinkScopeOperationStatusOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_resources = PrivateLinkResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.private_link_scoped_resources = PrivateLinkScopedResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_endpoint_connections_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_endpoint_connections_operations.py index 239eddf9047e8..33fca8708f692 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_endpoint_connections_operations.py @@ -5,19 +5,24 @@ # 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_private_link_scope_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -52,7 +58,7 @@ async def get( ) -> "_models.PrivateEndpointConnection": """Gets a private endpoint connection. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str @@ -68,28 +74,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - 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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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 = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self.get.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 @@ -103,8 +99,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -118,33 +116,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PrivateEndpointConnection') - 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 @@ -160,8 +148,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -172,7 +163,7 @@ async def begin_create_or_update( ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: """Approve or reject a private endpoint connection with a given name. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str @@ -182,15 +173,20 @@ async def begin_create_or_update( :type parameters: ~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -203,28 +199,21 @@ async def begin_create_or_update( scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - 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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -236,6 +225,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore async def _delete_initial( @@ -250,26 +240,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - - # Construct URL - url = self._delete_initial.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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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] + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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 @@ -282,6 +264,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -291,7 +275,7 @@ async def begin_delete( ) -> AsyncLROPoller[None]: """Deletes a private endpoint connection with a given name. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str @@ -299,15 +283,17 @@ async def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -322,22 +308,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - 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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -349,8 +327,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + @distributed_trace def list_by_private_link_scope( self, resource_group_name: str, @@ -359,13 +339,15 @@ def list_by_private_link_scope( ) -> AsyncIterable["_models.PrivateEndpointConnectionListResult"]: """Gets all private endpoint connections on a private link scope. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnectionListResult] + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] @@ -373,36 +355,33 @@ def list_by_private_link_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-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_private_link_scope.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'), - 'scopeName': self._serialize.url("scope_name", scope_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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_private_link_scope_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + template_url=self.list_by_private_link_scope.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_list_by_private_link_scope_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_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('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -420,6 +399,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_resources_operations.py index 7f2fb98207283..4883f725b4392 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_resources_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_resources_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._private_link_resources_operations import build_get_request, build_list_by_private_link_scope_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 list_by_private_link_scope( self, resource_group_name: str, @@ -49,13 +55,15 @@ def list_by_private_link_scope( ) -> AsyncIterable["_models.PrivateLinkResourceListResult"]: """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateLinkResourceListResult] + :return: An iterator like instance of either PrivateLinkResourceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateLinkResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] @@ -63,36 +71,33 @@ def list_by_private_link_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-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_private_link_scope.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'), - 'scopeName': self._serialize.url("scope_name", scope_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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_private_link_scope_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + template_url=self.list_by_private_link_scope.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_list_by_private_link_scope_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_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('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,11 +115,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_private_link_scope.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -124,7 +131,7 @@ async def get( ) -> "_models.PrivateLinkResource": """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str @@ -140,28 +147,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - 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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'groupName': self._serialize.url("group_name", 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + group_name=group_name, + template_url=self.get.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 @@ -175,4 +172,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scope_operation_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scope_operation_status_operations.py index 398fb3531b9ff..722da8748b6be 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scope_operation_status_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scope_operation_status_operations.py @@ -5,16 +5,20 @@ # 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, Optional, TypeVar import warnings 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_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_link_scope_operation_status_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, async_operation_id: str, @@ -51,7 +56,7 @@ async def get( :param async_operation_id: The operation Id. :type async_operation_id: str - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationStatus, or the result of cls(response) @@ -63,27 +68,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'asyncOperationId': self._serialize.url("async_operation_id", async_operation_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + async_operation_id=async_operation_id, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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 @@ -97,4 +92,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scoped_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scoped_resources_operations.py index 577349ea983d5..b7a1d087b4410 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scoped_resources_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scoped_resources_operations.py @@ -5,19 +5,24 @@ # 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_link_scoped_resources_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_private_link_scope_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -52,7 +58,7 @@ async def get( ) -> "_models.ScopedResource": """Gets a scoped resource in a private link scope. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str @@ -68,28 +74,18 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - 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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'name': self._serialize.url("name", 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 = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + name=name, + template_url=self.get.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 @@ -103,8 +99,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -118,33 +116,23 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'name': self._serialize.url("name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'ScopedResource') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedResource') - 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 @@ -163,8 +151,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -175,7 +166,7 @@ async def begin_create_or_update( ) -> AsyncLROPoller["_models.ScopedResource"]: """Approve or reject a private endpoint connection with a given name. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str @@ -185,15 +176,20 @@ async def begin_create_or_update( :type parameters: ~$(python-base-namespace).v2019_10_17.models.ScopedResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either ScopedResource or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2019_10_17.models.ScopedResource] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ScopedResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2019_10_17.models.ScopedResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopedResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -206,28 +202,21 @@ async def begin_create_or_update( scope_name=scope_name, name=name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ScopedResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - 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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -239,6 +228,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}'} # type: ignore async def _delete_initial( @@ -253,26 +243,18 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - - # Construct URL - url = self._delete_initial.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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'name': self._serialize.url("name", 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] + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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 @@ -285,6 +267,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -294,7 +278,7 @@ async def begin_delete( ) -> AsyncLROPoller[None]: """Deletes a private endpoint connection with a given name. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str @@ -302,15 +286,17 @@ async def begin_delete( :type name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -325,22 +311,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - 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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -352,8 +330,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}'} # type: ignore + @distributed_trace def list_by_private_link_scope( self, resource_group_name: str, @@ -362,13 +342,15 @@ def list_by_private_link_scope( ) -> AsyncIterable["_models.ScopedResourceListResult"]: """Gets all private endpoint connections on a private link scope. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopedResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.ScopedResourceListResult] + :return: An iterator like instance of either ScopedResourceListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.ScopedResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopedResourceListResult"] @@ -376,36 +358,33 @@ def list_by_private_link_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-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_private_link_scope.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'), - 'scopeName': self._serialize.url("scope_name", scope_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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_private_link_scope_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + template_url=self.list_by_private_link_scope.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_list_by_private_link_scope_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_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('ScopedResourceListResult', pipeline_response) + deserialized = self._deserialize("ScopedResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -423,6 +402,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scopes_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scopes_operations.py index 1c9d4b02e0260..e0e17418bd24d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scopes_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/aio/operations/_private_link_scopes_operations.py @@ -5,19 +5,24 @@ # 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_link_scopes_operations import build_create_or_update_request, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_update_tags_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -50,8 +56,10 @@ def list( """Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureMonitorPrivateLinkScopeListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScopeListResult] + :return: An iterator like instance of either AzureMonitorPrivateLinkScopeListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureMonitorPrivateLinkScopeListResult"] @@ -59,34 +67,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-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 - 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_list_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('AzureMonitorPrivateLinkScopeListResult', pipeline_response) + deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -104,11 +107,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -116,11 +121,13 @@ def list_by_resource_group( ) -> AsyncIterable["_models.AzureMonitorPrivateLinkScopeListResult"]: """Gets a list of Azure Monitor PrivateLinkScopes within a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 AzureMonitorPrivateLinkScopeListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScopeListResult] + :return: An iterator like instance of either AzureMonitorPrivateLinkScopeListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureMonitorPrivateLinkScopeListResult"] @@ -128,35 +135,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('AzureMonitorPrivateLinkScopeListResult', pipeline_response) + deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -174,6 +177,7 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged( get_next, extract_data ) @@ -190,25 +194,17 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'scopeName': self._serialize.url("scope_name", scope_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] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + scope_name=scope_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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 @@ -221,6 +217,8 @@ async def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -229,21 +227,23 @@ async def begin_delete( ) -> AsyncLROPoller[None]: """Deletes a Azure Monitor PrivateLinkScope. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -257,21 +257,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -283,8 +276,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -293,7 +288,7 @@ async def get( ) -> "_models.AzureMonitorPrivateLinkScope": """Returns a Azure Monitor PrivateLinkScope. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str @@ -307,27 +302,17 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'scopeName': self._serialize.url("scope_name", scope_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 = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + scope_name=scope_name, + template_url=self.get.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 @@ -341,8 +326,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -353,13 +341,14 @@ async def create_or_update( """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different value for InstrumentationKey nor AppId in the Put operation. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create or update a Azure Monitor PrivateLinkScope. - :type azure_monitor_private_link_scope_payload: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope + :type azure_monitor_private_link_scope_payload: + ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope :keyword callable cls: A custom type or function that will be passed the direct response :return: AzureMonitorPrivateLinkScope, or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope @@ -370,32 +359,22 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'scopeName': self._serialize.url("scope_name", scope_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(azure_monitor_private_link_scope_payload, 'AzureMonitorPrivateLinkScope') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + scope_name=scope_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(azure_monitor_private_link_scope_payload, 'AzureMonitorPrivateLinkScope') - 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 @@ -413,8 +392,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}'} # type: ignore + + @distributed_trace_async async def update_tags( self, resource_group_name: str, @@ -425,7 +407,7 @@ async def update_tags( """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str @@ -442,32 +424,22 @@ async def update_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'scopeName': self._serialize.url("scope_name", scope_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(private_link_scope_tags, 'TagsResource') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + scope_name=scope_name, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(private_link_scope_tags, 'TagsResource') - 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 @@ -481,4 +453,6 @@ async def update_tags( return cls(pipeline_response, deserialized, {}) return deserialized + update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models.py index fbe1212940c53..c6e29b7754c58 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models.py @@ -22,10 +22,10 @@ class PrivateLinkScopesResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -47,6 +47,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(PrivateLinkScopesResource, self).__init__(**kwargs) self.id = None self.name = None @@ -68,10 +74,10 @@ class AzureMonitorPrivateLinkScope(PrivateLinkScopesResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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] :ivar provisioning_state: Current state of this PrivateLinkScope: whether or not is has been provisioned within the resource group it is defined. Users cannot change this value but are able to read from it. Values will include Provisioning ,Succeeded, Canceled and Failed. @@ -104,6 +110,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(AzureMonitorPrivateLinkScope, self).__init__(**kwargs) self.provisioning_state = None self.private_endpoint_connections = None @@ -114,11 +126,11 @@ class AzureMonitorPrivateLinkScopeListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. List of Azure Monitor PrivateLinkScope definitions. - :type value: list[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope] - :param next_link: The URI to get the next set of Azure Monitor PrivateLinkScope definitions if + :ivar value: Required. List of Azure Monitor PrivateLinkScope definitions. + :vartype value: list[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope] + :ivar next_link: The URI to get the next set of Azure Monitor PrivateLinkScope definitions if too many PrivateLinkScopes where returned in the result set. - :type next_link: str + :vartype next_link: str """ _validation = { @@ -134,6 +146,14 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. List of Azure Monitor PrivateLinkScope definitions. + :paramtype value: + list[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope] + :keyword next_link: The URI to get the next set of Azure Monitor PrivateLinkScope definitions + if too many PrivateLinkScopes where returned in the result set. + :paramtype next_link: str + """ super(AzureMonitorPrivateLinkScopeListResult, self).__init__(**kwargs) self.value = kwargs['value'] self.next_link = kwargs.get('next_link', None) @@ -164,6 +184,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -172,10 +194,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -187,6 +209,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -197,10 +225,10 @@ class ErrorResponseCommon(ErrorResponse): Variables are only populated by the server, and will be ignored when sending a request. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str :ivar details: The error details. :vartype details: list[~$(python-base-namespace).v2019_10_17.models.ErrorResponseCommon] :ivar additional_info: The error additional info. @@ -224,6 +252,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponseCommon, self).__init__(**kwargs) self.details = None self.additional_info = None @@ -232,18 +266,18 @@ def __init__( class OperationStatus(msrest.serialization.Model): """The status of operation. - :param id: The operation Id. - :type id: str - :param name: The operation name. - :type name: str - :param start_time: Start time of the job in standard ISO8601 format. - :type start_time: ~datetime.datetime - :param end_time: End time of the job in standard ISO8601 format. - :type end_time: ~datetime.datetime - :param status: The status of the operation. - :type status: str - :param error: The error detail of the operation if any. - :type error: ~$(python-base-namespace).v2019_10_17.models.ErrorResponseCommon + :ivar id: The operation Id. + :vartype id: str + :ivar name: The operation name. + :vartype name: str + :ivar start_time: Start time of the job in standard ISO8601 format. + :vartype start_time: ~datetime.datetime + :ivar end_time: End time of the job in standard ISO8601 format. + :vartype end_time: ~datetime.datetime + :ivar status: The status of the operation. + :vartype status: str + :ivar error: The error detail of the operation if any. + :vartype error: ~$(python-base-namespace).v2019_10_17.models.ErrorResponseCommon """ _attribute_map = { @@ -259,6 +293,20 @@ def __init__( self, **kwargs ): + """ + :keyword id: The operation Id. + :paramtype id: str + :keyword name: The operation name. + :paramtype name: str + :keyword start_time: Start time of the job in standard ISO8601 format. + :paramtype start_time: ~datetime.datetime + :keyword end_time: End time of the job in standard ISO8601 format. + :paramtype end_time: ~datetime.datetime + :keyword status: The status of the operation. + :paramtype status: str + :keyword error: The error detail of the operation if any. + :paramtype error: ~$(python-base-namespace).v2019_10_17.models.ErrorResponseCommon + """ super(OperationStatus, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.name = kwargs.get('name', None) @@ -297,6 +345,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProxyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -314,11 +364,11 @@ class PrivateEndpointConnection(ProxyResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param private_endpoint: Private endpoint which the connection belongs to. - :type private_endpoint: ~$(python-base-namespace).v2019_10_17.models.PrivateEndpointProperty - :param private_link_service_connection_state: Connection state of the private endpoint + :ivar private_endpoint: Private endpoint which the connection belongs to. + :vartype private_endpoint: ~$(python-base-namespace).v2019_10_17.models.PrivateEndpointProperty + :ivar private_link_service_connection_state: Connection state of the private endpoint connection. - :type private_link_service_connection_state: + :vartype private_link_service_connection_state: ~$(python-base-namespace).v2019_10_17.models.PrivateLinkServiceConnectionStateProperty :ivar provisioning_state: State of the private endpoint connection. :vartype provisioning_state: str @@ -344,6 +394,15 @@ def __init__( self, **kwargs ): + """ + :keyword private_endpoint: Private endpoint which the connection belongs to. + :paramtype private_endpoint: + ~$(python-base-namespace).v2019_10_17.models.PrivateEndpointProperty + :keyword private_link_service_connection_state: Connection state of the private endpoint + connection. + :paramtype private_link_service_connection_state: + ~$(python-base-namespace).v2019_10_17.models.PrivateLinkServiceConnectionStateProperty + """ super(PrivateEndpointConnection, self).__init__(**kwargs) self.private_endpoint = kwargs.get('private_endpoint', None) self.private_link_service_connection_state = kwargs.get('private_link_service_connection_state', None) @@ -375,6 +434,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -383,8 +444,8 @@ def __init__( class PrivateEndpointProperty(msrest.serialization.Model): """Private endpoint which the connection belongs to. - :param id: Resource id of the private endpoint. - :type id: str + :ivar id: Resource id of the private endpoint. + :vartype id: str """ _attribute_map = { @@ -395,6 +456,10 @@ def __init__( self, **kwargs ): + """ + :keyword id: Resource id of the private endpoint. + :paramtype id: str + """ super(PrivateEndpointProperty, self).__init__(**kwargs) self.id = kwargs.get('id', None) @@ -436,6 +501,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateLinkResource, self).__init__(**kwargs) self.group_id = None self.required_members = None @@ -466,6 +533,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateLinkResourceListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -478,10 +547,10 @@ class PrivateLinkServiceConnectionStateProperty(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param status: Required. The private link service connection status. - :type status: str - :param description: Required. The private link service connection description. - :type description: str + :ivar status: Required. The private link service connection status. + :vartype status: str + :ivar description: Required. The private link service connection description. + :vartype description: str :ivar actions_required: The actions required for private link service connection. :vartype actions_required: str """ @@ -502,6 +571,12 @@ def __init__( self, **kwargs ): + """ + :keyword status: Required. The private link service connection status. + :paramtype status: str + :keyword description: Required. The private link service connection description. + :paramtype description: str + """ super(PrivateLinkServiceConnectionStateProperty, self).__init__(**kwargs) self.status = kwargs['status'] self.description = kwargs['description'] @@ -519,8 +594,8 @@ class ScopedResource(ProxyResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param linked_resource_id: The resource id of the scoped Azure monitor resource. - :type linked_resource_id: str + :ivar linked_resource_id: The resource id of the scoped Azure monitor resource. + :vartype linked_resource_id: str :ivar provisioning_state: State of the private endpoint connection. :vartype provisioning_state: str """ @@ -544,6 +619,10 @@ def __init__( self, **kwargs ): + """ + :keyword linked_resource_id: The resource id of the scoped Azure monitor resource. + :paramtype linked_resource_id: str + """ super(ScopedResource, self).__init__(**kwargs) self.linked_resource_id = kwargs.get('linked_resource_id', None) self.provisioning_state = None @@ -574,6 +653,8 @@ def __init__( self, **kwargs ): + """ + """ super(ScopedResourceListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -582,8 +663,8 @@ def __init__( class TagsResource(msrest.serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on a PrivateLinkScope instance. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -594,5 +675,9 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TagsResource, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models_py3.py index a26b257a23279..58910cffafcdd 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/models/_models_py3.py @@ -25,10 +25,10 @@ class PrivateLinkScopesResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -53,6 +53,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(PrivateLinkScopesResource, self).__init__(**kwargs) self.id = None self.name = None @@ -74,10 +80,10 @@ class AzureMonitorPrivateLinkScope(PrivateLinkScopesResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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] :ivar provisioning_state: Current state of this PrivateLinkScope: whether or not is has been provisioned within the resource group it is defined. Users cannot change this value but are able to read from it. Values will include Provisioning ,Succeeded, Canceled and Failed. @@ -113,6 +119,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(AzureMonitorPrivateLinkScope, self).__init__(location=location, tags=tags, **kwargs) self.provisioning_state = None self.private_endpoint_connections = None @@ -123,11 +135,11 @@ class AzureMonitorPrivateLinkScopeListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. List of Azure Monitor PrivateLinkScope definitions. - :type value: list[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope] - :param next_link: The URI to get the next set of Azure Monitor PrivateLinkScope definitions if + :ivar value: Required. List of Azure Monitor PrivateLinkScope definitions. + :vartype value: list[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope] + :ivar next_link: The URI to get the next set of Azure Monitor PrivateLinkScope definitions if too many PrivateLinkScopes where returned in the result set. - :type next_link: str + :vartype next_link: str """ _validation = { @@ -146,6 +158,14 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. List of Azure Monitor PrivateLinkScope definitions. + :paramtype value: + list[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope] + :keyword next_link: The URI to get the next set of Azure Monitor PrivateLinkScope definitions + if too many PrivateLinkScopes where returned in the result set. + :paramtype next_link: str + """ super(AzureMonitorPrivateLinkScopeListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -176,6 +196,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -184,10 +206,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -202,6 +224,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -212,10 +240,10 @@ class ErrorResponseCommon(ErrorResponse): Variables are only populated by the server, and will be ignored when sending a request. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str :ivar details: The error details. :vartype details: list[~$(python-base-namespace).v2019_10_17.models.ErrorResponseCommon] :ivar additional_info: The error additional info. @@ -242,6 +270,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponseCommon, self).__init__(code=code, message=message, **kwargs) self.details = None self.additional_info = None @@ -250,18 +284,18 @@ def __init__( class OperationStatus(msrest.serialization.Model): """The status of operation. - :param id: The operation Id. - :type id: str - :param name: The operation name. - :type name: str - :param start_time: Start time of the job in standard ISO8601 format. - :type start_time: ~datetime.datetime - :param end_time: End time of the job in standard ISO8601 format. - :type end_time: ~datetime.datetime - :param status: The status of the operation. - :type status: str - :param error: The error detail of the operation if any. - :type error: ~$(python-base-namespace).v2019_10_17.models.ErrorResponseCommon + :ivar id: The operation Id. + :vartype id: str + :ivar name: The operation name. + :vartype name: str + :ivar start_time: Start time of the job in standard ISO8601 format. + :vartype start_time: ~datetime.datetime + :ivar end_time: End time of the job in standard ISO8601 format. + :vartype end_time: ~datetime.datetime + :ivar status: The status of the operation. + :vartype status: str + :ivar error: The error detail of the operation if any. + :vartype error: ~$(python-base-namespace).v2019_10_17.models.ErrorResponseCommon """ _attribute_map = { @@ -284,6 +318,20 @@ def __init__( error: Optional["ErrorResponseCommon"] = None, **kwargs ): + """ + :keyword id: The operation Id. + :paramtype id: str + :keyword name: The operation name. + :paramtype name: str + :keyword start_time: Start time of the job in standard ISO8601 format. + :paramtype start_time: ~datetime.datetime + :keyword end_time: End time of the job in standard ISO8601 format. + :paramtype end_time: ~datetime.datetime + :keyword status: The status of the operation. + :paramtype status: str + :keyword error: The error detail of the operation if any. + :paramtype error: ~$(python-base-namespace).v2019_10_17.models.ErrorResponseCommon + """ super(OperationStatus, self).__init__(**kwargs) self.id = id self.name = name @@ -322,6 +370,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProxyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -339,11 +389,11 @@ class PrivateEndpointConnection(ProxyResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param private_endpoint: Private endpoint which the connection belongs to. - :type private_endpoint: ~$(python-base-namespace).v2019_10_17.models.PrivateEndpointProperty - :param private_link_service_connection_state: Connection state of the private endpoint + :ivar private_endpoint: Private endpoint which the connection belongs to. + :vartype private_endpoint: ~$(python-base-namespace).v2019_10_17.models.PrivateEndpointProperty + :ivar private_link_service_connection_state: Connection state of the private endpoint connection. - :type private_link_service_connection_state: + :vartype private_link_service_connection_state: ~$(python-base-namespace).v2019_10_17.models.PrivateLinkServiceConnectionStateProperty :ivar provisioning_state: State of the private endpoint connection. :vartype provisioning_state: str @@ -372,6 +422,15 @@ def __init__( private_link_service_connection_state: Optional["PrivateLinkServiceConnectionStateProperty"] = None, **kwargs ): + """ + :keyword private_endpoint: Private endpoint which the connection belongs to. + :paramtype private_endpoint: + ~$(python-base-namespace).v2019_10_17.models.PrivateEndpointProperty + :keyword private_link_service_connection_state: Connection state of the private endpoint + connection. + :paramtype private_link_service_connection_state: + ~$(python-base-namespace).v2019_10_17.models.PrivateLinkServiceConnectionStateProperty + """ super(PrivateEndpointConnection, self).__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state @@ -403,6 +462,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -411,8 +472,8 @@ def __init__( class PrivateEndpointProperty(msrest.serialization.Model): """Private endpoint which the connection belongs to. - :param id: Resource id of the private endpoint. - :type id: str + :ivar id: Resource id of the private endpoint. + :vartype id: str """ _attribute_map = { @@ -425,6 +486,10 @@ def __init__( id: Optional[str] = None, **kwargs ): + """ + :keyword id: Resource id of the private endpoint. + :paramtype id: str + """ super(PrivateEndpointProperty, self).__init__(**kwargs) self.id = id @@ -466,6 +531,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateLinkResource, self).__init__(**kwargs) self.group_id = None self.required_members = None @@ -496,6 +563,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateLinkResourceListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -508,10 +577,10 @@ class PrivateLinkServiceConnectionStateProperty(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param status: Required. The private link service connection status. - :type status: str - :param description: Required. The private link service connection description. - :type description: str + :ivar status: Required. The private link service connection status. + :vartype status: str + :ivar description: Required. The private link service connection description. + :vartype description: str :ivar actions_required: The actions required for private link service connection. :vartype actions_required: str """ @@ -535,6 +604,12 @@ def __init__( description: str, **kwargs ): + """ + :keyword status: Required. The private link service connection status. + :paramtype status: str + :keyword description: Required. The private link service connection description. + :paramtype description: str + """ super(PrivateLinkServiceConnectionStateProperty, self).__init__(**kwargs) self.status = status self.description = description @@ -552,8 +627,8 @@ class ScopedResource(ProxyResource): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param linked_resource_id: The resource id of the scoped Azure monitor resource. - :type linked_resource_id: str + :ivar linked_resource_id: The resource id of the scoped Azure monitor resource. + :vartype linked_resource_id: str :ivar provisioning_state: State of the private endpoint connection. :vartype provisioning_state: str """ @@ -579,6 +654,10 @@ def __init__( linked_resource_id: Optional[str] = None, **kwargs ): + """ + :keyword linked_resource_id: The resource id of the scoped Azure monitor resource. + :paramtype linked_resource_id: str + """ super(ScopedResource, self).__init__(**kwargs) self.linked_resource_id = linked_resource_id self.provisioning_state = None @@ -609,6 +688,8 @@ def __init__( self, **kwargs ): + """ + """ super(ScopedResourceListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -617,8 +698,8 @@ def __init__( class TagsResource(msrest.serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on a PrivateLinkScope instance. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -631,5 +712,9 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TagsResource, self).__init__(**kwargs) self.tags = tags diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_endpoint_connections_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_endpoint_connections_operations.py index 0b05c290c9f09..2f5d9a6d8623f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_endpoint_connections_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_endpoint_connections_operations.py @@ -5,26 +5,182 @@ # 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 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.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + scope_name, # type: str + private_endpoint_connection_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_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_initial( + subscription_id, # type: str + resource_group_name, # type: str + scope_name, # type: str + private_endpoint_connection_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_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, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id, # type: str + resource_group_name, # type: str + scope_name, # type: str + private_endpoint_connection_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-17-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_private_link_scope_request( + subscription_id, # type: str + resource_group_name, # type: str + scope_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_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 + ) + +# fmt: on class PrivateEndpointConnectionsOperations(object): """PrivateEndpointConnectionsOperations operations. @@ -47,6 +203,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_group_name, # type: str @@ -57,7 +214,7 @@ def get( # type: (...) -> "_models.PrivateEndpointConnection" """Gets a private endpoint connection. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str @@ -73,28 +230,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - 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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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 = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self.get.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 @@ -108,8 +255,10 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + def _create_or_update_initial( self, resource_group_name, # type: str @@ -124,33 +273,23 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'PrivateEndpointConnection') - 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 @@ -166,8 +305,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -179,7 +321,7 @@ def begin_create_or_update( # type: (...) -> LROPoller["_models.PrivateEndpointConnection"] """Approve or reject a private endpoint connection with a given name. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str @@ -189,15 +331,20 @@ def begin_create_or_update( :type parameters: ~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -210,28 +357,21 @@ def begin_create_or_update( scope_name=scope_name, private_endpoint_connection_name=private_endpoint_connection_name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - 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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -243,6 +383,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore def _delete_initial( @@ -258,26 +399,18 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - - # Construct URL - url = self._delete_initial.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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_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] + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -290,6 +423,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -300,7 +435,7 @@ def begin_delete( # type: (...) -> LROPoller[None] """Deletes a private endpoint connection with a given name. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str @@ -308,15 +443,17 @@ def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -331,22 +468,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - 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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -358,8 +487,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + @distributed_trace def list_by_private_link_scope( self, resource_group_name, # type: str @@ -369,13 +500,15 @@ def list_by_private_link_scope( # type: (...) -> Iterable["_models.PrivateEndpointConnectionListResult"] """Gets all private endpoint connections on a private link scope. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnectionListResult] + :return: An iterator like instance of either PrivateEndpointConnectionListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateEndpointConnectionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionListResult"] @@ -383,36 +516,33 @@ def list_by_private_link_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-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_private_link_scope.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'), - 'scopeName': self._serialize.url("scope_name", scope_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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_private_link_scope_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + template_url=self.list_by_private_link_scope.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_list_by_private_link_scope_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_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('PrivateEndpointConnectionListResult', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -430,6 +560,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_resources_operations.py index 669f69362ef80..74c9330488780 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_resources_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_resources_operations.py @@ -5,24 +5,106 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_private_link_scope_request( + subscription_id, # type: str + resource_group_name, # type: str + scope_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_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_request( + subscription_id, # type: str + resource_group_name, # type: str + scope_name, # type: str + group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), + "groupName": _SERIALIZER.url("group_name", 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 + ) + +# fmt: on class PrivateLinkResourcesOperations(object): """PrivateLinkResourcesOperations operations. @@ -45,6 +127,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_private_link_scope( self, resource_group_name, # type: str @@ -54,13 +137,15 @@ def list_by_private_link_scope( # type: (...) -> Iterable["_models.PrivateLinkResourceListResult"] """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateLinkResourceListResult] + :return: An iterator like instance of either PrivateLinkResourceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.PrivateLinkResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceListResult"] @@ -68,36 +153,33 @@ def list_by_private_link_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-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_private_link_scope.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'), - 'scopeName': self._serialize.url("scope_name", scope_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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_private_link_scope_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + template_url=self.list_by_private_link_scope.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_list_by_private_link_scope_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_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('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,11 +197,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_private_link_scope.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -130,7 +214,7 @@ def get( # type: (...) -> "_models.PrivateLinkResource" """Gets the private link resources that need to be created for a Azure Monitor PrivateLinkScope. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str @@ -146,28 +230,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - 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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'groupName': self._serialize.url("group_name", 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + group_name=group_name, + template_url=self.get.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 @@ -181,4 +255,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/privateLinkResources/{groupName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scope_operation_status_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scope_operation_status_operations.py index e2af92cf65293..a80dea6170fa0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scope_operation_status_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scope_operation_status_operations.py @@ -5,23 +5,67 @@ # 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 TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + async_operation_id, # type: str + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}') + path_format_arguments = { + "asyncOperationId": _SERIALIZER.url("async_operation_id", async_operation_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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 + ) + +# fmt: on class PrivateLinkScopeOperationStatusOperations(object): """PrivateLinkScopeOperationStatusOperations operations. @@ -44,6 +88,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, async_operation_id, # type: str @@ -56,7 +101,7 @@ def get( :param async_operation_id: The operation Id. :type async_operation_id: str - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationStatus, or the result of cls(response) @@ -68,27 +113,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'asyncOperationId': self._serialize.url("async_operation_id", async_operation_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + async_operation_id=async_operation_id, + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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 @@ -102,4 +137,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopeOperationStatuses/{asyncOperationId}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scoped_resources_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scoped_resources_operations.py index 1766c14357ae2..276fcae43182c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scoped_resources_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scoped_resources_operations.py @@ -5,26 +5,182 @@ # 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 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.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + scope_name, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), + "name": _SERIALIZER.url("name", 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_initial( + subscription_id, # type: str + resource_group_name, # type: str + scope_name, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), + "name": _SERIALIZER.url("name", 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, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id, # type: str + resource_group_name, # type: str + scope_name, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-17-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_name, 'str'), + "name": _SERIALIZER.url("name", 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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_list_by_private_link_scope_request( + subscription_id, # type: str + resource_group_name, # type: str + scope_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_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 + ) + +# fmt: on class PrivateLinkScopedResourcesOperations(object): """PrivateLinkScopedResourcesOperations operations. @@ -47,6 +203,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_group_name, # type: str @@ -57,7 +214,7 @@ def get( # type: (...) -> "_models.ScopedResource" """Gets a scoped resource in a private link scope. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str @@ -73,28 +230,18 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - 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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'name': self._serialize.url("name", 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 = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + name=name, + template_url=self.get.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 @@ -108,8 +255,10 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}'} # type: ignore + def _create_or_update_initial( self, resource_group_name, # type: str @@ -124,33 +273,23 @@ def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'name': self._serialize.url("name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'ScopedResource') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + name=name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScopedResource') - 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 @@ -169,8 +308,11 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, resource_group_name, # type: str @@ -182,7 +324,7 @@ def begin_create_or_update( # type: (...) -> LROPoller["_models.ScopedResource"] """Approve or reject a private endpoint connection with a given name. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str @@ -192,15 +334,20 @@ def begin_create_or_update( :type parameters: ~$(python-base-namespace).v2019_10_17.models.ScopedResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either ScopedResource or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~$(python-base-namespace).v2019_10_17.models.ScopedResource] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ScopedResource or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2019_10_17.models.ScopedResource] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopedResource"] lro_delay = kwargs.pop( 'polling_interval', @@ -213,28 +360,21 @@ def begin_create_or_update( scope_name=scope_name, name=name, parameters=parameters, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('ScopedResource', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - 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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -246,6 +386,7 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}'} # type: ignore def _delete_initial( @@ -261,26 +402,18 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - - # Construct URL - url = self._delete_initial.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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'name': self._serialize.url("name", 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] + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + name=name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -293,6 +426,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -303,7 +438,7 @@ def begin_delete( # type: (...) -> LROPoller[None] """Deletes a private endpoint connection with a given name. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str @@ -311,15 +446,17 @@ def begin_delete( :type name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -334,22 +471,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - 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'), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -361,8 +490,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/privateLinkScopes/{scopeName}/scopedResources/{name}'} # type: ignore + @distributed_trace def list_by_private_link_scope( self, resource_group_name, # type: str @@ -372,13 +503,15 @@ def list_by_private_link_scope( # type: (...) -> Iterable["_models.ScopedResourceListResult"] """Gets all private endpoint connections on a private link scope. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ScopedResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.ScopedResourceListResult] + :return: An iterator like instance of either ScopedResourceListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.ScopedResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ScopedResourceListResult"] @@ -386,36 +519,33 @@ def list_by_private_link_scope( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-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_private_link_scope.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'), - 'scopeName': self._serialize.url("scope_name", scope_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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_private_link_scope_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_name, + template_url=self.list_by_private_link_scope.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_list_by_private_link_scope_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + scope_name=scope_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('ScopedResourceListResult', pipeline_response) + deserialized = self._deserialize("ScopedResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -433,6 +563,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scopes_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scopes_operations.py index 814a9efd71832..3c56eb6d78b6b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scopes_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_10_17/operations/_private_link_scopes_operations.py @@ -5,26 +5,246 @@ # 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 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.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes') + 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( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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_delete_request_initial( + resource_group_name, # type: str + subscription_id, # type: str + scope_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-17-preview" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_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') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + subscription_id, # type: str + scope_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_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( + resource_group_name, # type: str + subscription_id, # type: str + scope_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_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, + **kwargs + ) + + +def build_update_tags_request( + resource_group_name, # type: str + subscription_id, # type: str + scope_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-10-17-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "scopeName": _SERIALIZER.url("scope_name", scope_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, + **kwargs + ) + +# fmt: on class PrivateLinkScopesOperations(object): """PrivateLinkScopesOperations operations. @@ -47,6 +267,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -55,8 +276,10 @@ def list( """Gets a list of all Azure Monitor PrivateLinkScopes within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureMonitorPrivateLinkScopeListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScopeListResult] + :return: An iterator like instance of either AzureMonitorPrivateLinkScopeListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureMonitorPrivateLinkScopeListResult"] @@ -64,34 +287,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-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 - 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_list_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('AzureMonitorPrivateLinkScopeListResult', pipeline_response) + deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -109,11 +327,13 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/microsoft.insights/privateLinkScopes'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -122,11 +342,13 @@ def list_by_resource_group( # type: (...) -> Iterable["_models.AzureMonitorPrivateLinkScopeListResult"] """Gets a list of Azure Monitor PrivateLinkScopes within a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 AzureMonitorPrivateLinkScopeListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScopeListResult] + :return: An iterator like instance of either AzureMonitorPrivateLinkScopeListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScopeListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureMonitorPrivateLinkScopeListResult"] @@ -134,35 +356,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('AzureMonitorPrivateLinkScopeListResult', pipeline_response) + deserialized = self._deserialize("AzureMonitorPrivateLinkScopeListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -180,6 +398,7 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged( get_next, extract_data ) @@ -197,25 +416,17 @@ def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'scopeName': self._serialize.url("scope_name", scope_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] + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + scope_name=scope_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -228,6 +439,8 @@ def _delete_initial( _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}'} # type: ignore + + @distributed_trace def begin_delete( self, resource_group_name, # type: str @@ -237,21 +450,23 @@ def begin_delete( # type: (...) -> LROPoller[None] """Deletes a Azure Monitor PrivateLinkScope. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -265,21 +480,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'scopeName': self._serialize.url("scope_name", scope_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -291,8 +499,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -302,7 +512,7 @@ def get( # type: (...) -> "_models.AzureMonitorPrivateLinkScope" """Returns a Azure Monitor PrivateLinkScope. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str @@ -316,27 +526,17 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'scopeName': self._serialize.url("scope_name", scope_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 = build_get_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + scope_name=scope_name, + template_url=self.get.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 @@ -350,8 +550,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -363,13 +566,14 @@ def create_or_update( """Creates (or updates) a Azure Monitor PrivateLinkScope. Note: You cannot specify a different value for InstrumentationKey nor AppId in the Put operation. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str :param azure_monitor_private_link_scope_payload: Properties that need to be specified to create or update a Azure Monitor PrivateLinkScope. - :type azure_monitor_private_link_scope_payload: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope + :type azure_monitor_private_link_scope_payload: + ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope :keyword callable cls: A custom type or function that will be passed the direct response :return: AzureMonitorPrivateLinkScope, or the result of cls(response) :rtype: ~$(python-base-namespace).v2019_10_17.models.AzureMonitorPrivateLinkScope @@ -380,32 +584,22 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'scopeName': self._serialize.url("scope_name", scope_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(azure_monitor_private_link_scope_payload, 'AzureMonitorPrivateLinkScope') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + scope_name=scope_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(azure_monitor_private_link_scope_payload, 'AzureMonitorPrivateLinkScope') - 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 @@ -423,8 +617,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}'} # type: ignore + + @distributed_trace def update_tags( self, resource_group_name, # type: str @@ -436,7 +633,7 @@ def update_tags( """Updates an existing PrivateLinkScope's tags. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param scope_name: The name of the Azure Monitor PrivateLinkScope resource. :type scope_name: str @@ -453,32 +650,22 @@ def update_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-10-17-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'scopeName': self._serialize.url("scope_name", scope_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(private_link_scope_tags, 'TagsResource') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + scope_name=scope_name, + content_type=content_type, + json=_json, + template_url=self.update_tags.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(private_link_scope_tags, 'TagsResource') - 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 @@ -492,4 +679,6 @@ def update_tags( return cls(pipeline_response, deserialized, {}) return deserialized + update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/microsoft.insights/privateLinkScopes/{scopeName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_configuration.py index 17ffb143fc7e7..977c106c2f049 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_metadata.json index 2948f6d358e5d..34885a43497c6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "data_collection_rule_associations": "DataCollectionRuleAssociationsOperations", diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_monitor_management_client.py index 4cdf02aa7cac0..feacd782f3232 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_monitor_management_client.py @@ -6,78 +6,85 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import DataCollectionRuleAssociationsOperations, DataCollectionRulesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import DataCollectionRuleAssociationsOperations -from .operations import DataCollectionRulesOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. :ivar data_collection_rule_associations: DataCollectionRuleAssociationsOperations operations - :vartype data_collection_rule_associations: $(python-base-namespace).v2019_11_01_preview.operations.DataCollectionRuleAssociationsOperations + :vartype data_collection_rule_associations: + $(python-base-namespace).v2019_11_01_preview.operations.DataCollectionRuleAssociationsOperations :ivar data_collection_rules: DataCollectionRulesOperations operations - :vartype data_collection_rules: $(python-base-namespace).v2019_11_01_preview.operations.DataCollectionRulesOperations + :vartype data_collection_rules: + $(python-base-namespace).v2019_11_01_preview.operations.DataCollectionRulesOperations :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_collection_rules = DataCollectionRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.data_collection_rules = DataCollectionRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_configuration.py index 77e781a7e2199..2dc886a8a1f4f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_monitor_management_client.py index 25ca1c442b6d0..ea9134b6ffef9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_monitor_management_client.py @@ -6,74 +6,81 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import DataCollectionRuleAssociationsOperations, DataCollectionRulesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MonitorManagementClientConfiguration -from .operations import DataCollectionRuleAssociationsOperations -from .operations import DataCollectionRulesOperations -from .. import models - - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar data_collection_rule_associations: DataCollectionRuleAssociationsOperations operations - :vartype data_collection_rule_associations: $(python-base-namespace).v2019_11_01_preview.aio.operations.DataCollectionRuleAssociationsOperations + :vartype data_collection_rule_associations: + $(python-base-namespace).v2019_11_01_preview.aio.operations.DataCollectionRuleAssociationsOperations :ivar data_collection_rules: DataCollectionRulesOperations operations - :vartype data_collection_rules: $(python-base-namespace).v2019_11_01_preview.aio.operations.DataCollectionRulesOperations + :vartype data_collection_rules: + $(python-base-namespace).v2019_11_01_preview.aio.operations.DataCollectionRulesOperations :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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_collection_rules = DataCollectionRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.data_collection_rules = DataCollectionRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rule_associations_operations.py index 9cbf0246fd812..d7bca3542c6d7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rule_associations_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rule_associations_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._data_collection_rule_associations_operations import build_create_request, build_delete_request, build_get_request, build_list_by_resource_request, build_list_by_rule_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 list_by_resource( self, resource_uri: str, @@ -53,8 +59,10 @@ def list_by_resource( :param resource_uri: The identifier of the resource. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + :return: An iterator like instance of either + DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] @@ -62,34 +70,29 @@ def list_by_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-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.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True, 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_request( + resource_uri=resource_uri, + template_url=self.list_by_resource.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_list_by_resource_request( + resource_uri=resource_uri, + 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('DataCollectionRuleAssociationProxyOnlyResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,17 +105,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations'} # type: ignore + @distributed_trace def list_by_rule( self, resource_group_name: str, @@ -129,8 +134,10 @@ def list_by_rule( insensitive. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + :return: An iterator like instance of either + DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] @@ -138,36 +145,33 @@ def list_by_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-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_rule.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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_rule_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_name, + template_url=self.list_by_rule.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_list_by_rule_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_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('DataCollectionRuleAssociationProxyOnlyResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -180,17 +184,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations'} # type: ignore + @distributed_trace_async async def get( self, resource_uri: str, @@ -207,7 +213,8 @@ async def get( :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + :rtype: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] @@ -215,32 +222,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - 'associationName': self._serialize.url("association_name", association_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 = build_get_request( + resource_uri=resource_uri, + association_name=association_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) @@ -249,8 +246,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + + @distributed_trace_async async def create( self, resource_uri: str, @@ -267,10 +267,12 @@ async def create( :param association_name: The name of the association. The name is case insensitive. :type association_name: str :param body: The payload. - :type body: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + :type body: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + :rtype: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] @@ -278,40 +280,30 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - 'associationName': self._serialize.url("association_name", association_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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] if body is not None: - body_content = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') + _json = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request( + resource_uri=resource_uri, + association_name=association_name, + content_type=content_type, + json=_json, + template_url=self.create.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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -324,8 +316,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_uri: str, @@ -350,35 +345,26 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - 'associationName': self._serialize.url("association_name", association_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 = build_delete_request( + resource_uri=resource_uri, + association_name=association_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rules_operations.py index 29bce722e8890..c080414315049 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/aio/operations/_data_collection_rules_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._data_collection_rules_operations import build_create_request, build_delete_request, build_get_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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -53,8 +59,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :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 DataCollectionRuleResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResourceListResult] + :return: An iterator like instance of either DataCollectionRuleResourceListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] @@ -62,35 +70,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-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', max_length=90, 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') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('DataCollectionRuleResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,17 +107,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Insights/dataCollectionRules'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -123,8 +129,10 @@ def list_by_subscription( Lists all data collection rules in the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResourceListResult] + :return: An iterator like instance of either DataCollectionRuleResourceListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] @@ -132,34 +140,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('DataCollectionRuleResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -172,17 +175,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Insights/dataCollectionRules'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -208,33 +213,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - 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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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 = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) @@ -243,8 +238,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}'} # type: ignore + + @distributed_trace_async async def create( self, resource_group_name: str, @@ -273,41 +271,31 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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] if body is not None: - body_content = self._serialize.body(body, 'DataCollectionRuleResource') + _json = self._serialize.body(body, 'DataCollectionRuleResource') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_name, + content_type=content_type, + json=_json, + template_url=self.create.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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -320,8 +308,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -350,41 +341,31 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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] if body is not None: - body_content = self._serialize.body(body, 'ResourceForUpdate') + _json = self._serialize.body(body, 'ResourceForUpdate') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) @@ -393,8 +374,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -420,36 +404,27 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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 = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_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.Insights/dataCollectionRules/{dataCollectionRuleName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models.py index e5edb02c607cc..2ddeaeebf25d4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models.py @@ -13,10 +13,10 @@ class AzureMonitorMetricsDestination(msrest.serialization.Model): """Azure Monitor Metrics destination. - :param name: A friendly name for the destination. + :ivar name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -27,6 +27,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: A friendly name for the destination. + This name should be unique across all destinations (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(AzureMonitorMetricsDestination, self).__init__(**kwargs) self.name = kwargs.get('name', None) @@ -36,20 +42,20 @@ class DataCollectionRule(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the data collection rule. - :type description: str + :ivar description: Description of the data collection rule. + :vartype description: str :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. :vartype immutable_id: str - :param data_sources: The specification of data sources. + :ivar data_sources: The specification of data sources. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :type data_sources: + :vartype data_sources: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDataSources - :param destinations: The specification of destinations. - :type destinations: + :ivar destinations: The specification of destinations. + :vartype destinations: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDestinations - :param data_flows: The specification of data flows. - :type data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] + :ivar data_flows: The specification of data flows. + :vartype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -74,6 +80,20 @@ def __init__( self, **kwargs ): + """ + :keyword description: Description of the data collection rule. + :paramtype description: str + :keyword data_sources: The specification of data sources. + This property is optional and can be omitted if the rule is meant to be used via direct calls + to the provisioned endpoint. + :paramtype data_sources: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDataSources + :keyword destinations: The specification of destinations. + :paramtype destinations: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDestinations + :keyword data_flows: The specification of data flows. + :paramtype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] + """ super(DataCollectionRule, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.immutable_id = None @@ -88,11 +108,11 @@ class DataCollectionRuleAssociation(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the association. - :type description: str - :param data_collection_rule_id: The resource ID of the data collection rule that is to be + :ivar description: Description of the association. + :vartype description: str + :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be associated. - :type data_collection_rule_id: str + :vartype data_collection_rule_id: str :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -113,6 +133,13 @@ def __init__( self, **kwargs ): + """ + :keyword description: Description of the association. + :paramtype description: str + :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be + associated. + :paramtype data_collection_rule_id: str + """ super(DataCollectionRuleAssociation, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.data_collection_rule_id = kwargs.get('data_collection_rule_id', None) @@ -132,11 +159,11 @@ class DataCollectionRuleAssociationProxyOnlyResource(msrest.serialization.Model) :vartype type: str :ivar etag: Resource entity tag (ETag). :vartype etag: str - :param description: Description of the association. - :type description: str - :param data_collection_rule_id: The resource ID of the data collection rule that is to be + :ivar description: Description of the association. + :vartype description: str + :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be associated. - :type data_collection_rule_id: str + :vartype data_collection_rule_id: str :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -165,6 +192,13 @@ def __init__( self, **kwargs ): + """ + :keyword description: Description of the association. + :paramtype description: str + :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be + associated. + :paramtype data_collection_rule_id: str + """ super(DataCollectionRuleAssociationProxyOnlyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -180,11 +214,11 @@ class DataCollectionRuleAssociationProxyOnlyResourceListResult(msrest.serializat All required parameters must be populated in order to send to Azure. - :param value: Required. A list of resources. - :type value: + :ivar value: Required. A list of resources. + :vartype value: list[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -200,6 +234,13 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. A list of resources. + :paramtype value: + list[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(DataCollectionRuleAssociationProxyOnlyResourceListResult, self).__init__(**kwargs) self.value = kwargs['value'] self.next_link = kwargs.get('next_link', None) @@ -210,11 +251,11 @@ class DataCollectionRuleAssociationProxyOnlyResourceProperties(DataCollectionRul Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the association. - :type description: str - :param data_collection_rule_id: The resource ID of the data collection rule that is to be + :ivar description: Description of the association. + :vartype description: str + :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be associated. - :type data_collection_rule_id: str + :vartype data_collection_rule_id: str :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -235,22 +276,29 @@ def __init__( self, **kwargs ): + """ + :keyword description: Description of the association. + :paramtype description: str + :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be + associated. + :paramtype data_collection_rule_id: str + """ super(DataCollectionRuleAssociationProxyOnlyResourceProperties, self).__init__(**kwargs) class DataSourcesSpec(msrest.serialization.Model): """Specification of data sources that will be collected. - :param performance_counters: The list of performance counter data source configurations. - :type performance_counters: + :ivar performance_counters: The list of performance counter data source configurations. + :vartype performance_counters: list[~$(python-base-namespace).v2019_11_01_preview.models.PerfCounterDataSource] - :param windows_event_logs: The list of Windows Event Log data source configurations. - :type windows_event_logs: + :ivar windows_event_logs: The list of Windows Event Log data source configurations. + :vartype windows_event_logs: list[~$(python-base-namespace).v2019_11_01_preview.models.WindowsEventLogDataSource] - :param syslog: The list of Syslog data source configurations. - :type syslog: list[~$(python-base-namespace).v2019_11_01_preview.models.SyslogDataSource] - :param extensions: The list of Azure VM extension data source configurations. - :type extensions: + :ivar syslog: The list of Syslog data source configurations. + :vartype syslog: list[~$(python-base-namespace).v2019_11_01_preview.models.SyslogDataSource] + :ivar extensions: The list of Azure VM extension data source configurations. + :vartype extensions: list[~$(python-base-namespace).v2019_11_01_preview.models.ExtensionDataSource] """ @@ -265,6 +313,19 @@ def __init__( self, **kwargs ): + """ + :keyword performance_counters: The list of performance counter data source configurations. + :paramtype performance_counters: + list[~$(python-base-namespace).v2019_11_01_preview.models.PerfCounterDataSource] + :keyword windows_event_logs: The list of Windows Event Log data source configurations. + :paramtype windows_event_logs: + list[~$(python-base-namespace).v2019_11_01_preview.models.WindowsEventLogDataSource] + :keyword syslog: The list of Syslog data source configurations. + :paramtype syslog: list[~$(python-base-namespace).v2019_11_01_preview.models.SyslogDataSource] + :keyword extensions: The list of Azure VM extension data source configurations. + :paramtype extensions: + list[~$(python-base-namespace).v2019_11_01_preview.models.ExtensionDataSource] + """ super(DataSourcesSpec, self).__init__(**kwargs) self.performance_counters = kwargs.get('performance_counters', None) self.windows_event_logs = kwargs.get('windows_event_logs', None) @@ -276,16 +337,16 @@ class DataCollectionRuleDataSources(DataSourcesSpec): """The specification of data sources. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :param performance_counters: The list of performance counter data source configurations. - :type performance_counters: + :ivar performance_counters: The list of performance counter data source configurations. + :vartype performance_counters: list[~$(python-base-namespace).v2019_11_01_preview.models.PerfCounterDataSource] - :param windows_event_logs: The list of Windows Event Log data source configurations. - :type windows_event_logs: + :ivar windows_event_logs: The list of Windows Event Log data source configurations. + :vartype windows_event_logs: list[~$(python-base-namespace).v2019_11_01_preview.models.WindowsEventLogDataSource] - :param syslog: The list of Syslog data source configurations. - :type syslog: list[~$(python-base-namespace).v2019_11_01_preview.models.SyslogDataSource] - :param extensions: The list of Azure VM extension data source configurations. - :type extensions: + :ivar syslog: The list of Syslog data source configurations. + :vartype syslog: list[~$(python-base-namespace).v2019_11_01_preview.models.SyslogDataSource] + :ivar extensions: The list of Azure VM extension data source configurations. + :vartype extensions: list[~$(python-base-namespace).v2019_11_01_preview.models.ExtensionDataSource] """ @@ -300,17 +361,30 @@ def __init__( self, **kwargs ): + """ + :keyword performance_counters: The list of performance counter data source configurations. + :paramtype performance_counters: + list[~$(python-base-namespace).v2019_11_01_preview.models.PerfCounterDataSource] + :keyword windows_event_logs: The list of Windows Event Log data source configurations. + :paramtype windows_event_logs: + list[~$(python-base-namespace).v2019_11_01_preview.models.WindowsEventLogDataSource] + :keyword syslog: The list of Syslog data source configurations. + :paramtype syslog: list[~$(python-base-namespace).v2019_11_01_preview.models.SyslogDataSource] + :keyword extensions: The list of Azure VM extension data source configurations. + :paramtype extensions: + list[~$(python-base-namespace).v2019_11_01_preview.models.ExtensionDataSource] + """ super(DataCollectionRuleDataSources, self).__init__(**kwargs) class DestinationsSpec(msrest.serialization.Model): """Specification of destinations that can be used in data flows. - :param log_analytics: List of Log Analytics destinations. - :type log_analytics: + :ivar log_analytics: List of Log Analytics destinations. + :vartype log_analytics: list[~$(python-base-namespace).v2019_11_01_preview.models.LogAnalyticsDestination] - :param azure_monitor_metrics: Azure Monitor Metrics destination. - :type azure_monitor_metrics: + :ivar azure_monitor_metrics: Azure Monitor Metrics destination. + :vartype azure_monitor_metrics: ~$(python-base-namespace).v2019_11_01_preview.models.DestinationsSpecAzureMonitorMetrics """ @@ -323,6 +397,14 @@ def __init__( self, **kwargs ): + """ + :keyword log_analytics: List of Log Analytics destinations. + :paramtype log_analytics: + list[~$(python-base-namespace).v2019_11_01_preview.models.LogAnalyticsDestination] + :keyword azure_monitor_metrics: Azure Monitor Metrics destination. + :paramtype azure_monitor_metrics: + ~$(python-base-namespace).v2019_11_01_preview.models.DestinationsSpecAzureMonitorMetrics + """ super(DestinationsSpec, self).__init__(**kwargs) self.log_analytics = kwargs.get('log_analytics', None) self.azure_monitor_metrics = kwargs.get('azure_monitor_metrics', None) @@ -331,11 +413,11 @@ def __init__( class DataCollectionRuleDestinations(DestinationsSpec): """The specification of destinations. - :param log_analytics: List of Log Analytics destinations. - :type log_analytics: + :ivar log_analytics: List of Log Analytics destinations. + :vartype log_analytics: list[~$(python-base-namespace).v2019_11_01_preview.models.LogAnalyticsDestination] - :param azure_monitor_metrics: Azure Monitor Metrics destination. - :type azure_monitor_metrics: + :ivar azure_monitor_metrics: Azure Monitor Metrics destination. + :vartype azure_monitor_metrics: ~$(python-base-namespace).v2019_11_01_preview.models.DestinationsSpecAzureMonitorMetrics """ @@ -348,6 +430,14 @@ def __init__( self, **kwargs ): + """ + :keyword log_analytics: List of Log Analytics destinations. + :paramtype log_analytics: + list[~$(python-base-namespace).v2019_11_01_preview.models.LogAnalyticsDestination] + :keyword azure_monitor_metrics: Azure Monitor Metrics destination. + :paramtype azure_monitor_metrics: + ~$(python-base-namespace).v2019_11_01_preview.models.DestinationsSpecAzureMonitorMetrics + """ super(DataCollectionRuleDestinations, self).__init__(**kwargs) @@ -358,12 +448,12 @@ class DataCollectionRuleResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: The kind of the resource. Possible values include: "Linux", "Windows". - :type kind: str or + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: The kind of the resource. Possible values include: "Linux", "Windows". + :vartype kind: str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleResourceKind :ivar id: Fully qualified ID of the resource. :vartype id: str @@ -373,20 +463,20 @@ class DataCollectionRuleResource(msrest.serialization.Model): :vartype type: str :ivar etag: Resource entity tag (ETag). :vartype etag: str - :param description: Description of the data collection rule. - :type description: str + :ivar description: Description of the data collection rule. + :vartype description: str :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. :vartype immutable_id: str - :param data_sources: The specification of data sources. + :ivar data_sources: The specification of data sources. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :type data_sources: + :vartype data_sources: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDataSources - :param destinations: The specification of destinations. - :type destinations: + :ivar destinations: The specification of destinations. + :vartype destinations: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDestinations - :param data_flows: The specification of data flows. - :type data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] + :ivar data_flows: The specification of data flows. + :vartype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -423,6 +513,27 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: The kind of the resource. Possible values include: "Linux", "Windows". + :paramtype kind: str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleResourceKind + :keyword description: Description of the data collection rule. + :paramtype description: str + :keyword data_sources: The specification of data sources. + This property is optional and can be omitted if the rule is meant to be used via direct calls + to the provisioned endpoint. + :paramtype data_sources: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDataSources + :keyword destinations: The specification of destinations. + :paramtype destinations: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDestinations + :keyword data_flows: The specification of data flows. + :paramtype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] + """ super(DataCollectionRuleResource, self).__init__(**kwargs) self.location = kwargs['location'] self.tags = kwargs.get('tags', None) @@ -444,11 +555,11 @@ class DataCollectionRuleResourceListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. A list of resources. - :type value: + :ivar value: Required. A list of resources. + :vartype value: list[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -464,6 +575,13 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. A list of resources. + :paramtype value: + list[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(DataCollectionRuleResourceListResult, self).__init__(**kwargs) self.value = kwargs['value'] self.next_link = kwargs.get('next_link', None) @@ -474,20 +592,20 @@ class DataCollectionRuleResourceProperties(DataCollectionRule): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the data collection rule. - :type description: str + :ivar description: Description of the data collection rule. + :vartype description: str :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. :vartype immutable_id: str - :param data_sources: The specification of data sources. + :ivar data_sources: The specification of data sources. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :type data_sources: + :vartype data_sources: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDataSources - :param destinations: The specification of destinations. - :type destinations: + :ivar destinations: The specification of destinations. + :vartype destinations: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDestinations - :param data_flows: The specification of data flows. - :type data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] + :ivar data_flows: The specification of data flows. + :vartype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -512,17 +630,31 @@ def __init__( self, **kwargs ): + """ + :keyword description: Description of the data collection rule. + :paramtype description: str + :keyword data_sources: The specification of data sources. + This property is optional and can be omitted if the rule is meant to be used via direct calls + to the provisioned endpoint. + :paramtype data_sources: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDataSources + :keyword destinations: The specification of destinations. + :paramtype destinations: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDestinations + :keyword data_flows: The specification of data flows. + :paramtype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] + """ super(DataCollectionRuleResourceProperties, self).__init__(**kwargs) class DataFlow(msrest.serialization.Model): """Definition of which streams are sent to which destinations. - :param streams: List of streams for this data flow. - :type streams: list[str or + :ivar streams: List of streams for this data flow. + :vartype streams: list[str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataFlowStreams] - :param destinations: List of destinations for this data flow. - :type destinations: list[str] + :ivar destinations: List of destinations for this data flow. + :vartype destinations: list[str] """ _attribute_map = { @@ -534,6 +666,13 @@ def __init__( self, **kwargs ): + """ + :keyword streams: List of streams for this data flow. + :paramtype streams: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataFlowStreams] + :keyword destinations: List of destinations for this data flow. + :paramtype destinations: list[str] + """ super(DataFlow, self).__init__(**kwargs) self.streams = kwargs.get('streams', None) self.destinations = kwargs.get('destinations', None) @@ -542,10 +681,10 @@ def __init__( class DestinationsSpecAzureMonitorMetrics(AzureMonitorMetricsDestination): """Azure Monitor Metrics destination. - :param name: A friendly name for the destination. + :ivar name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -556,6 +695,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: A friendly name for the destination. + This name should be unique across all destinations (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(DestinationsSpecAzureMonitorMetrics, self).__init__(**kwargs) @@ -584,6 +729,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -627,6 +774,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -638,8 +787,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~$(python-base-namespace).v2019_11_01_preview.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~$(python-base-namespace).v2019_11_01_preview.models.ErrorDetail """ _attribute_map = { @@ -650,6 +799,10 @@ def __init__( self, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~$(python-base-namespace).v2019_11_01_preview.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = kwargs.get('error', None) @@ -660,22 +813,22 @@ class ExtensionDataSource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param streams: List of streams that this data source will be sent to. + :ivar streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. - :type streams: list[str or + :vartype streams: list[str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownExtensionDataSourceStreams] - :param extension_name: Required. The name of the VM extension. - :type extension_name: str - :param extension_settings: The extension settings. The format is specific for particular + :ivar extension_name: Required. The name of the VM extension. + :vartype extension_name: str + :ivar extension_settings: The extension settings. The format is specific for particular extension. - :type extension_settings: any - :param input_data_sources: The list of data sources this extension needs data from. - :type input_data_sources: list[str] - :param name: A friendly name for the data source. + :vartype extension_settings: any + :ivar input_data_sources: The list of data sources this extension needs data from. + :vartype input_data_sources: list[str] + :ivar name: A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _validation = { @@ -694,6 +847,24 @@ def __init__( self, **kwargs ): + """ + :keyword streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :paramtype streams: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownExtensionDataSourceStreams] + :keyword extension_name: Required. The name of the VM extension. + :paramtype extension_name: str + :keyword extension_settings: The extension settings. The format is specific for particular + extension. + :paramtype extension_settings: any + :keyword input_data_sources: The list of data sources this extension needs data from. + :paramtype input_data_sources: list[str] + :keyword name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(ExtensionDataSource, self).__init__(**kwargs) self.streams = kwargs.get('streams', None) self.extension_name = kwargs['extension_name'] @@ -707,14 +878,14 @@ class LogAnalyticsDestination(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param workspace_resource_id: The resource ID of the Log Analytics workspace. - :type workspace_resource_id: str + :ivar workspace_resource_id: The resource ID of the Log Analytics workspace. + :vartype workspace_resource_id: str :ivar workspace_id: The Customer ID of the Log Analytics workspace. :vartype workspace_id: str - :param name: A friendly name for the destination. + :ivar name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _validation = { @@ -731,6 +902,14 @@ def __init__( self, **kwargs ): + """ + :keyword workspace_resource_id: The resource ID of the Log Analytics workspace. + :paramtype workspace_resource_id: str + :keyword name: A friendly name for the destination. + This name should be unique across all destinations (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(LogAnalyticsDestination, self).__init__(**kwargs) self.workspace_resource_id = kwargs.get('workspace_resource_id', None) self.workspace_id = None @@ -741,23 +920,23 @@ class PerfCounterDataSource(msrest.serialization.Model): """Definition of which performance counters will be collected and how they will be collected by this data collection rule. Collected from both Windows and Linux machines where the counter is present. - :param streams: List of streams that this data source will be sent to. + :ivar streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. - :type streams: list[str or + :vartype streams: list[str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownPerfCounterDataSourceStreams] - :param sampling_frequency_in_seconds: The number of seconds between consecutive counter + :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter measurements (samples). - :type sampling_frequency_in_seconds: int - :param counter_specifiers: A list of specifier names of the performance counters you want to + :vartype sampling_frequency_in_seconds: int + :ivar counter_specifiers: A list of specifier names of the performance counters you want to collect. Use a wildcard (*) to collect a counter for all instances. To get a list of performance counters on Windows, run the command 'typeperf'. - :type counter_specifiers: list[str] - :param name: A friendly name for the data source. + :vartype counter_specifiers: list[str] + :ivar name: A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -771,6 +950,25 @@ def __init__( self, **kwargs ): + """ + :keyword streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :paramtype streams: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownPerfCounterDataSourceStreams] + :keyword sampling_frequency_in_seconds: The number of seconds between consecutive counter + measurements (samples). + :paramtype sampling_frequency_in_seconds: int + :keyword counter_specifiers: A list of specifier names of the performance counters you want to + collect. + Use a wildcard (*) to collect a counter for all instances. + To get a list of performance counters on Windows, run the command 'typeperf'. + :paramtype counter_specifiers: list[str] + :keyword name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(PerfCounterDataSource, self).__init__(**kwargs) self.streams = kwargs.get('streams', None) self.sampling_frequency_in_seconds = kwargs.get('sampling_frequency_in_seconds', None) @@ -781,8 +979,8 @@ def __init__( class ResourceForUpdate(msrest.serialization.Model): """Definition of ARM tracked top level resource properties for update operation. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -793,6 +991,10 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(ResourceForUpdate, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) @@ -801,21 +1003,21 @@ class SyslogDataSource(msrest.serialization.Model): """Definition of which syslog data will be collected and how it will be collected. Only collected from Linux machines. - :param streams: List of streams that this data source will be sent to. + :ivar streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. - :type streams: list[str or + :vartype streams: list[str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceStreams] - :param facility_names: The list of facility names. - :type facility_names: list[str or + :ivar facility_names: The list of facility names. + :vartype facility_names: list[str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceFacilityNames] - :param log_levels: The log levels to collect. - :type log_levels: list[str or + :ivar log_levels: The log levels to collect. + :vartype log_levels: list[str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceLogLevels] - :param name: A friendly name for the data source. + :ivar name: A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -829,6 +1031,23 @@ def __init__( self, **kwargs ): + """ + :keyword streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :paramtype streams: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceStreams] + :keyword facility_names: The list of facility names. + :paramtype facility_names: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceFacilityNames] + :keyword log_levels: The log levels to collect. + :paramtype log_levels: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceLogLevels] + :keyword name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(SyslogDataSource, self).__init__(**kwargs) self.streams = kwargs.get('streams', None) self.facility_names = kwargs.get('facility_names', None) @@ -840,17 +1059,17 @@ class WindowsEventLogDataSource(msrest.serialization.Model): """Definition of which Windows Event Log events will be collected and how they will be collected. Only collected from Windows machines. - :param streams: List of streams that this data source will be sent to. + :ivar streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. - :type streams: list[str or + :vartype streams: list[str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownWindowsEventLogDataSourceStreams] - :param x_path_queries: A list of Windows Event Log queries in XPATH format. - :type x_path_queries: list[str] - :param name: A friendly name for the data source. + :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. + :vartype x_path_queries: list[str] + :ivar name: A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -863,6 +1082,19 @@ def __init__( self, **kwargs ): + """ + :keyword streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :paramtype streams: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownWindowsEventLogDataSourceStreams] + :keyword x_path_queries: A list of Windows Event Log queries in XPATH format. + :paramtype x_path_queries: list[str] + :keyword name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(WindowsEventLogDataSource, self).__init__(**kwargs) self.streams = kwargs.get('streams', None) self.x_path_queries = kwargs.get('x_path_queries', None) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models_py3.py index 44aff14895f6d..7a0a0f36f511e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_models_py3.py @@ -17,10 +17,10 @@ class AzureMonitorMetricsDestination(msrest.serialization.Model): """Azure Monitor Metrics destination. - :param name: A friendly name for the destination. + :ivar name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -33,6 +33,12 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: A friendly name for the destination. + This name should be unique across all destinations (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(AzureMonitorMetricsDestination, self).__init__(**kwargs) self.name = name @@ -42,20 +48,20 @@ class DataCollectionRule(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the data collection rule. - :type description: str + :ivar description: Description of the data collection rule. + :vartype description: str :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. :vartype immutable_id: str - :param data_sources: The specification of data sources. + :ivar data_sources: The specification of data sources. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :type data_sources: + :vartype data_sources: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDataSources - :param destinations: The specification of destinations. - :type destinations: + :ivar destinations: The specification of destinations. + :vartype destinations: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDestinations - :param data_flows: The specification of data flows. - :type data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] + :ivar data_flows: The specification of data flows. + :vartype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -85,6 +91,20 @@ def __init__( data_flows: Optional[List["DataFlow"]] = None, **kwargs ): + """ + :keyword description: Description of the data collection rule. + :paramtype description: str + :keyword data_sources: The specification of data sources. + This property is optional and can be omitted if the rule is meant to be used via direct calls + to the provisioned endpoint. + :paramtype data_sources: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDataSources + :keyword destinations: The specification of destinations. + :paramtype destinations: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDestinations + :keyword data_flows: The specification of data flows. + :paramtype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] + """ super(DataCollectionRule, self).__init__(**kwargs) self.description = description self.immutable_id = None @@ -99,11 +119,11 @@ class DataCollectionRuleAssociation(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the association. - :type description: str - :param data_collection_rule_id: The resource ID of the data collection rule that is to be + :ivar description: Description of the association. + :vartype description: str + :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be associated. - :type data_collection_rule_id: str + :vartype data_collection_rule_id: str :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -127,6 +147,13 @@ def __init__( data_collection_rule_id: Optional[str] = None, **kwargs ): + """ + :keyword description: Description of the association. + :paramtype description: str + :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be + associated. + :paramtype data_collection_rule_id: str + """ super(DataCollectionRuleAssociation, self).__init__(**kwargs) self.description = description self.data_collection_rule_id = data_collection_rule_id @@ -146,11 +173,11 @@ class DataCollectionRuleAssociationProxyOnlyResource(msrest.serialization.Model) :vartype type: str :ivar etag: Resource entity tag (ETag). :vartype etag: str - :param description: Description of the association. - :type description: str - :param data_collection_rule_id: The resource ID of the data collection rule that is to be + :ivar description: Description of the association. + :vartype description: str + :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be associated. - :type data_collection_rule_id: str + :vartype data_collection_rule_id: str :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -182,6 +209,13 @@ def __init__( data_collection_rule_id: Optional[str] = None, **kwargs ): + """ + :keyword description: Description of the association. + :paramtype description: str + :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be + associated. + :paramtype data_collection_rule_id: str + """ super(DataCollectionRuleAssociationProxyOnlyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -197,11 +231,11 @@ class DataCollectionRuleAssociationProxyOnlyResourceListResult(msrest.serializat All required parameters must be populated in order to send to Azure. - :param value: Required. A list of resources. - :type value: + :ivar value: Required. A list of resources. + :vartype value: list[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -220,6 +254,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. A list of resources. + :paramtype value: + list[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(DataCollectionRuleAssociationProxyOnlyResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -230,11 +271,11 @@ class DataCollectionRuleAssociationProxyOnlyResourceProperties(DataCollectionRul Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the association. - :type description: str - :param data_collection_rule_id: The resource ID of the data collection rule that is to be + :ivar description: Description of the association. + :vartype description: str + :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be associated. - :type data_collection_rule_id: str + :vartype data_collection_rule_id: str :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -258,22 +299,29 @@ def __init__( data_collection_rule_id: Optional[str] = None, **kwargs ): + """ + :keyword description: Description of the association. + :paramtype description: str + :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be + associated. + :paramtype data_collection_rule_id: str + """ super(DataCollectionRuleAssociationProxyOnlyResourceProperties, self).__init__(description=description, data_collection_rule_id=data_collection_rule_id, **kwargs) class DataSourcesSpec(msrest.serialization.Model): """Specification of data sources that will be collected. - :param performance_counters: The list of performance counter data source configurations. - :type performance_counters: + :ivar performance_counters: The list of performance counter data source configurations. + :vartype performance_counters: list[~$(python-base-namespace).v2019_11_01_preview.models.PerfCounterDataSource] - :param windows_event_logs: The list of Windows Event Log data source configurations. - :type windows_event_logs: + :ivar windows_event_logs: The list of Windows Event Log data source configurations. + :vartype windows_event_logs: list[~$(python-base-namespace).v2019_11_01_preview.models.WindowsEventLogDataSource] - :param syslog: The list of Syslog data source configurations. - :type syslog: list[~$(python-base-namespace).v2019_11_01_preview.models.SyslogDataSource] - :param extensions: The list of Azure VM extension data source configurations. - :type extensions: + :ivar syslog: The list of Syslog data source configurations. + :vartype syslog: list[~$(python-base-namespace).v2019_11_01_preview.models.SyslogDataSource] + :ivar extensions: The list of Azure VM extension data source configurations. + :vartype extensions: list[~$(python-base-namespace).v2019_11_01_preview.models.ExtensionDataSource] """ @@ -293,6 +341,19 @@ def __init__( extensions: Optional[List["ExtensionDataSource"]] = None, **kwargs ): + """ + :keyword performance_counters: The list of performance counter data source configurations. + :paramtype performance_counters: + list[~$(python-base-namespace).v2019_11_01_preview.models.PerfCounterDataSource] + :keyword windows_event_logs: The list of Windows Event Log data source configurations. + :paramtype windows_event_logs: + list[~$(python-base-namespace).v2019_11_01_preview.models.WindowsEventLogDataSource] + :keyword syslog: The list of Syslog data source configurations. + :paramtype syslog: list[~$(python-base-namespace).v2019_11_01_preview.models.SyslogDataSource] + :keyword extensions: The list of Azure VM extension data source configurations. + :paramtype extensions: + list[~$(python-base-namespace).v2019_11_01_preview.models.ExtensionDataSource] + """ super(DataSourcesSpec, self).__init__(**kwargs) self.performance_counters = performance_counters self.windows_event_logs = windows_event_logs @@ -304,16 +365,16 @@ class DataCollectionRuleDataSources(DataSourcesSpec): """The specification of data sources. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :param performance_counters: The list of performance counter data source configurations. - :type performance_counters: + :ivar performance_counters: The list of performance counter data source configurations. + :vartype performance_counters: list[~$(python-base-namespace).v2019_11_01_preview.models.PerfCounterDataSource] - :param windows_event_logs: The list of Windows Event Log data source configurations. - :type windows_event_logs: + :ivar windows_event_logs: The list of Windows Event Log data source configurations. + :vartype windows_event_logs: list[~$(python-base-namespace).v2019_11_01_preview.models.WindowsEventLogDataSource] - :param syslog: The list of Syslog data source configurations. - :type syslog: list[~$(python-base-namespace).v2019_11_01_preview.models.SyslogDataSource] - :param extensions: The list of Azure VM extension data source configurations. - :type extensions: + :ivar syslog: The list of Syslog data source configurations. + :vartype syslog: list[~$(python-base-namespace).v2019_11_01_preview.models.SyslogDataSource] + :ivar extensions: The list of Azure VM extension data source configurations. + :vartype extensions: list[~$(python-base-namespace).v2019_11_01_preview.models.ExtensionDataSource] """ @@ -333,17 +394,30 @@ def __init__( extensions: Optional[List["ExtensionDataSource"]] = None, **kwargs ): + """ + :keyword performance_counters: The list of performance counter data source configurations. + :paramtype performance_counters: + list[~$(python-base-namespace).v2019_11_01_preview.models.PerfCounterDataSource] + :keyword windows_event_logs: The list of Windows Event Log data source configurations. + :paramtype windows_event_logs: + list[~$(python-base-namespace).v2019_11_01_preview.models.WindowsEventLogDataSource] + :keyword syslog: The list of Syslog data source configurations. + :paramtype syslog: list[~$(python-base-namespace).v2019_11_01_preview.models.SyslogDataSource] + :keyword extensions: The list of Azure VM extension data source configurations. + :paramtype extensions: + list[~$(python-base-namespace).v2019_11_01_preview.models.ExtensionDataSource] + """ super(DataCollectionRuleDataSources, self).__init__(performance_counters=performance_counters, windows_event_logs=windows_event_logs, syslog=syslog, extensions=extensions, **kwargs) class DestinationsSpec(msrest.serialization.Model): """Specification of destinations that can be used in data flows. - :param log_analytics: List of Log Analytics destinations. - :type log_analytics: + :ivar log_analytics: List of Log Analytics destinations. + :vartype log_analytics: list[~$(python-base-namespace).v2019_11_01_preview.models.LogAnalyticsDestination] - :param azure_monitor_metrics: Azure Monitor Metrics destination. - :type azure_monitor_metrics: + :ivar azure_monitor_metrics: Azure Monitor Metrics destination. + :vartype azure_monitor_metrics: ~$(python-base-namespace).v2019_11_01_preview.models.DestinationsSpecAzureMonitorMetrics """ @@ -359,6 +433,14 @@ def __init__( azure_monitor_metrics: Optional["DestinationsSpecAzureMonitorMetrics"] = None, **kwargs ): + """ + :keyword log_analytics: List of Log Analytics destinations. + :paramtype log_analytics: + list[~$(python-base-namespace).v2019_11_01_preview.models.LogAnalyticsDestination] + :keyword azure_monitor_metrics: Azure Monitor Metrics destination. + :paramtype azure_monitor_metrics: + ~$(python-base-namespace).v2019_11_01_preview.models.DestinationsSpecAzureMonitorMetrics + """ super(DestinationsSpec, self).__init__(**kwargs) self.log_analytics = log_analytics self.azure_monitor_metrics = azure_monitor_metrics @@ -367,11 +449,11 @@ def __init__( class DataCollectionRuleDestinations(DestinationsSpec): """The specification of destinations. - :param log_analytics: List of Log Analytics destinations. - :type log_analytics: + :ivar log_analytics: List of Log Analytics destinations. + :vartype log_analytics: list[~$(python-base-namespace).v2019_11_01_preview.models.LogAnalyticsDestination] - :param azure_monitor_metrics: Azure Monitor Metrics destination. - :type azure_monitor_metrics: + :ivar azure_monitor_metrics: Azure Monitor Metrics destination. + :vartype azure_monitor_metrics: ~$(python-base-namespace).v2019_11_01_preview.models.DestinationsSpecAzureMonitorMetrics """ @@ -387,6 +469,14 @@ def __init__( azure_monitor_metrics: Optional["DestinationsSpecAzureMonitorMetrics"] = None, **kwargs ): + """ + :keyword log_analytics: List of Log Analytics destinations. + :paramtype log_analytics: + list[~$(python-base-namespace).v2019_11_01_preview.models.LogAnalyticsDestination] + :keyword azure_monitor_metrics: Azure Monitor Metrics destination. + :paramtype azure_monitor_metrics: + ~$(python-base-namespace).v2019_11_01_preview.models.DestinationsSpecAzureMonitorMetrics + """ super(DataCollectionRuleDestinations, self).__init__(log_analytics=log_analytics, azure_monitor_metrics=azure_monitor_metrics, **kwargs) @@ -397,12 +487,12 @@ class DataCollectionRuleResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: The kind of the resource. Possible values include: "Linux", "Windows". - :type kind: str or + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: The kind of the resource. Possible values include: "Linux", "Windows". + :vartype kind: str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleResourceKind :ivar id: Fully qualified ID of the resource. :vartype id: str @@ -412,20 +502,20 @@ class DataCollectionRuleResource(msrest.serialization.Model): :vartype type: str :ivar etag: Resource entity tag (ETag). :vartype etag: str - :param description: Description of the data collection rule. - :type description: str + :ivar description: Description of the data collection rule. + :vartype description: str :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. :vartype immutable_id: str - :param data_sources: The specification of data sources. + :ivar data_sources: The specification of data sources. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :type data_sources: + :vartype data_sources: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDataSources - :param destinations: The specification of destinations. - :type destinations: + :ivar destinations: The specification of destinations. + :vartype destinations: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDestinations - :param data_flows: The specification of data flows. - :type data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] + :ivar data_flows: The specification of data flows. + :vartype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -470,6 +560,27 @@ def __init__( data_flows: Optional[List["DataFlow"]] = None, **kwargs ): + """ + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: The kind of the resource. Possible values include: "Linux", "Windows". + :paramtype kind: str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataCollectionRuleResourceKind + :keyword description: Description of the data collection rule. + :paramtype description: str + :keyword data_sources: The specification of data sources. + This property is optional and can be omitted if the rule is meant to be used via direct calls + to the provisioned endpoint. + :paramtype data_sources: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDataSources + :keyword destinations: The specification of destinations. + :paramtype destinations: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDestinations + :keyword data_flows: The specification of data flows. + :paramtype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] + """ super(DataCollectionRuleResource, self).__init__(**kwargs) self.location = location self.tags = tags @@ -491,11 +602,11 @@ class DataCollectionRuleResourceListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. A list of resources. - :type value: + :ivar value: Required. A list of resources. + :vartype value: list[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -514,6 +625,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. A list of resources. + :paramtype value: + list[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResource] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(DataCollectionRuleResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -524,20 +642,20 @@ class DataCollectionRuleResourceProperties(DataCollectionRule): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the data collection rule. - :type description: str + :ivar description: Description of the data collection rule. + :vartype description: str :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. :vartype immutable_id: str - :param data_sources: The specification of data sources. + :ivar data_sources: The specification of data sources. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :type data_sources: + :vartype data_sources: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDataSources - :param destinations: The specification of destinations. - :type destinations: + :ivar destinations: The specification of destinations. + :vartype destinations: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDestinations - :param data_flows: The specification of data flows. - :type data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] + :ivar data_flows: The specification of data flows. + :vartype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -567,17 +685,31 @@ def __init__( data_flows: Optional[List["DataFlow"]] = None, **kwargs ): + """ + :keyword description: Description of the data collection rule. + :paramtype description: str + :keyword data_sources: The specification of data sources. + This property is optional and can be omitted if the rule is meant to be used via direct calls + to the provisioned endpoint. + :paramtype data_sources: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDataSources + :keyword destinations: The specification of destinations. + :paramtype destinations: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleDestinations + :keyword data_flows: The specification of data flows. + :paramtype data_flows: list[~$(python-base-namespace).v2019_11_01_preview.models.DataFlow] + """ super(DataCollectionRuleResourceProperties, self).__init__(description=description, data_sources=data_sources, destinations=destinations, data_flows=data_flows, **kwargs) class DataFlow(msrest.serialization.Model): """Definition of which streams are sent to which destinations. - :param streams: List of streams for this data flow. - :type streams: list[str or + :ivar streams: List of streams for this data flow. + :vartype streams: list[str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataFlowStreams] - :param destinations: List of destinations for this data flow. - :type destinations: list[str] + :ivar destinations: List of destinations for this data flow. + :vartype destinations: list[str] """ _attribute_map = { @@ -592,6 +724,13 @@ def __init__( destinations: Optional[List[str]] = None, **kwargs ): + """ + :keyword streams: List of streams for this data flow. + :paramtype streams: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownDataFlowStreams] + :keyword destinations: List of destinations for this data flow. + :paramtype destinations: list[str] + """ super(DataFlow, self).__init__(**kwargs) self.streams = streams self.destinations = destinations @@ -600,10 +739,10 @@ def __init__( class DestinationsSpecAzureMonitorMetrics(AzureMonitorMetricsDestination): """Azure Monitor Metrics destination. - :param name: A friendly name for the destination. + :ivar name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -616,6 +755,12 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: A friendly name for the destination. + This name should be unique across all destinations (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(DestinationsSpecAzureMonitorMetrics, self).__init__(name=name, **kwargs) @@ -644,6 +789,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -687,6 +834,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -698,8 +847,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~$(python-base-namespace).v2019_11_01_preview.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~$(python-base-namespace).v2019_11_01_preview.models.ErrorDetail """ _attribute_map = { @@ -712,6 +861,10 @@ def __init__( error: Optional["ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~$(python-base-namespace).v2019_11_01_preview.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -722,22 +875,22 @@ class ExtensionDataSource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param streams: List of streams that this data source will be sent to. + :ivar streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. - :type streams: list[str or + :vartype streams: list[str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownExtensionDataSourceStreams] - :param extension_name: Required. The name of the VM extension. - :type extension_name: str - :param extension_settings: The extension settings. The format is specific for particular + :ivar extension_name: Required. The name of the VM extension. + :vartype extension_name: str + :ivar extension_settings: The extension settings. The format is specific for particular extension. - :type extension_settings: any - :param input_data_sources: The list of data sources this extension needs data from. - :type input_data_sources: list[str] - :param name: A friendly name for the data source. + :vartype extension_settings: any + :ivar input_data_sources: The list of data sources this extension needs data from. + :vartype input_data_sources: list[str] + :ivar name: A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _validation = { @@ -762,6 +915,24 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :paramtype streams: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownExtensionDataSourceStreams] + :keyword extension_name: Required. The name of the VM extension. + :paramtype extension_name: str + :keyword extension_settings: The extension settings. The format is specific for particular + extension. + :paramtype extension_settings: any + :keyword input_data_sources: The list of data sources this extension needs data from. + :paramtype input_data_sources: list[str] + :keyword name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(ExtensionDataSource, self).__init__(**kwargs) self.streams = streams self.extension_name = extension_name @@ -775,14 +946,14 @@ class LogAnalyticsDestination(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param workspace_resource_id: The resource ID of the Log Analytics workspace. - :type workspace_resource_id: str + :ivar workspace_resource_id: The resource ID of the Log Analytics workspace. + :vartype workspace_resource_id: str :ivar workspace_id: The Customer ID of the Log Analytics workspace. :vartype workspace_id: str - :param name: A friendly name for the destination. + :ivar name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _validation = { @@ -802,6 +973,14 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword workspace_resource_id: The resource ID of the Log Analytics workspace. + :paramtype workspace_resource_id: str + :keyword name: A friendly name for the destination. + This name should be unique across all destinations (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(LogAnalyticsDestination, self).__init__(**kwargs) self.workspace_resource_id = workspace_resource_id self.workspace_id = None @@ -812,23 +991,23 @@ class PerfCounterDataSource(msrest.serialization.Model): """Definition of which performance counters will be collected and how they will be collected by this data collection rule. Collected from both Windows and Linux machines where the counter is present. - :param streams: List of streams that this data source will be sent to. + :ivar streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. - :type streams: list[str or + :vartype streams: list[str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownPerfCounterDataSourceStreams] - :param sampling_frequency_in_seconds: The number of seconds between consecutive counter + :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter measurements (samples). - :type sampling_frequency_in_seconds: int - :param counter_specifiers: A list of specifier names of the performance counters you want to + :vartype sampling_frequency_in_seconds: int + :ivar counter_specifiers: A list of specifier names of the performance counters you want to collect. Use a wildcard (*) to collect a counter for all instances. To get a list of performance counters on Windows, run the command 'typeperf'. - :type counter_specifiers: list[str] - :param name: A friendly name for the data source. + :vartype counter_specifiers: list[str] + :ivar name: A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -847,6 +1026,25 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :paramtype streams: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownPerfCounterDataSourceStreams] + :keyword sampling_frequency_in_seconds: The number of seconds between consecutive counter + measurements (samples). + :paramtype sampling_frequency_in_seconds: int + :keyword counter_specifiers: A list of specifier names of the performance counters you want to + collect. + Use a wildcard (*) to collect a counter for all instances. + To get a list of performance counters on Windows, run the command 'typeperf'. + :paramtype counter_specifiers: list[str] + :keyword name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(PerfCounterDataSource, self).__init__(**kwargs) self.streams = streams self.sampling_frequency_in_seconds = sampling_frequency_in_seconds @@ -857,8 +1055,8 @@ def __init__( class ResourceForUpdate(msrest.serialization.Model): """Definition of ARM tracked top level resource properties for update operation. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -871,6 +1069,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(ResourceForUpdate, self).__init__(**kwargs) self.tags = tags @@ -879,21 +1081,21 @@ class SyslogDataSource(msrest.serialization.Model): """Definition of which syslog data will be collected and how it will be collected. Only collected from Linux machines. - :param streams: List of streams that this data source will be sent to. + :ivar streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. - :type streams: list[str or + :vartype streams: list[str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceStreams] - :param facility_names: The list of facility names. - :type facility_names: list[str or + :ivar facility_names: The list of facility names. + :vartype facility_names: list[str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceFacilityNames] - :param log_levels: The log levels to collect. - :type log_levels: list[str or + :ivar log_levels: The log levels to collect. + :vartype log_levels: list[str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceLogLevels] - :param name: A friendly name for the data source. + :ivar name: A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -912,6 +1114,23 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :paramtype streams: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceStreams] + :keyword facility_names: The list of facility names. + :paramtype facility_names: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceFacilityNames] + :keyword log_levels: The log levels to collect. + :paramtype log_levels: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownSyslogDataSourceLogLevels] + :keyword name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(SyslogDataSource, self).__init__(**kwargs) self.streams = streams self.facility_names = facility_names @@ -923,17 +1142,17 @@ class WindowsEventLogDataSource(msrest.serialization.Model): """Definition of which Windows Event Log events will be collected and how they will be collected. Only collected from Windows machines. - :param streams: List of streams that this data source will be sent to. + :ivar streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. - :type streams: list[str or + :vartype streams: list[str or ~$(python-base-namespace).v2019_11_01_preview.models.KnownWindowsEventLogDataSourceStreams] - :param x_path_queries: A list of Windows Event Log queries in XPATH format. - :type x_path_queries: list[str] - :param name: A friendly name for the data source. + :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. + :vartype x_path_queries: list[str] + :ivar name: A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -950,6 +1169,19 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :paramtype streams: list[str or + ~$(python-base-namespace).v2019_11_01_preview.models.KnownWindowsEventLogDataSourceStreams] + :keyword x_path_queries: A list of Windows Event Log queries in XPATH format. + :paramtype x_path_queries: list[str] + :keyword name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(WindowsEventLogDataSource, self).__init__(**kwargs) self.streams = streams self.x_path_queries = x_path_queries diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_monitor_management_client_enums.py index 251ddeea0a23b..fe34d7947fb3d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/models/_monitor_management_client_enums.py @@ -6,27 +6,12 @@ # 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 KnownDataCollectionRuleAssociationProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionRuleAssociationProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The resource provisioning state. """ @@ -36,7 +21,7 @@ class KnownDataCollectionRuleAssociationProvisioningState(with_metaclass(_CaseIn SUCCEEDED = "Succeeded" FAILED = "Failed" -class KnownDataCollectionRuleProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionRuleProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The resource provisioning state. """ @@ -46,14 +31,14 @@ class KnownDataCollectionRuleProvisioningState(with_metaclass(_CaseInsensitiveEn SUCCEEDED = "Succeeded" FAILED = "Failed" -class KnownDataCollectionRuleResourceKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionRuleResourceKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The kind of the resource. """ LINUX = "Linux" WINDOWS = "Windows" -class KnownDataFlowStreams(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataFlowStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_EVENT = "Microsoft-Event" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" @@ -61,7 +46,7 @@ class KnownDataFlowStreams(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_SYSLOG = "Microsoft-Syslog" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" -class KnownExtensionDataSourceStreams(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownExtensionDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_EVENT = "Microsoft-Event" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" @@ -69,12 +54,12 @@ class KnownExtensionDataSourceStreams(with_metaclass(_CaseInsensitiveEnumMeta, s MICROSOFT_SYSLOG = "Microsoft-Syslog" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" -class KnownPerfCounterDataSourceStreams(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownPerfCounterDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_PERF = "Microsoft-Perf" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" -class KnownSyslogDataSourceFacilityNames(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownSyslogDataSourceFacilityNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTH = "auth" AUTHPRIV = "authpriv" @@ -98,7 +83,7 @@ class KnownSyslogDataSourceFacilityNames(with_metaclass(_CaseInsensitiveEnumMeta LOCAL7 = "local7" ASTERISK = "*" -class KnownSyslogDataSourceLogLevels(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownSyslogDataSourceLogLevels(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEBUG = "Debug" INFO = "Info" @@ -110,11 +95,11 @@ class KnownSyslogDataSourceLogLevels(with_metaclass(_CaseInsensitiveEnumMeta, st EMERGENCY = "Emergency" ASTERISK = "*" -class KnownSyslogDataSourceStreams(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownSyslogDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_SYSLOG = "Microsoft-Syslog" -class KnownWindowsEventLogDataSourceStreams(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownWindowsEventLogDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" MICROSOFT_EVENT = "Microsoft-Event" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rule_associations_operations.py index f7feadebaa83d..84888860ee91e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rule_associations_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rule_associations_operations.py @@ -5,24 +5,206 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, 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_rule_request( + subscription_id, # type: str + resource_group_name, # type: str + data_collection_rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_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_get_request( + resource_uri, # type: str + association_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), + "associationName": _SERIALIZER.url("association_name", association_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_request( + resource_uri, # type: str + association_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), + "associationName": _SERIALIZER.url("association_name", association_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, + **kwargs + ) + + +def build_delete_request( + resource_uri, # type: str + association_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), + "associationName": _SERIALIZER.url("association_name", association_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 + ) + +# fmt: on class DataCollectionRuleAssociationsOperations(object): """DataCollectionRuleAssociationsOperations operations. @@ -45,6 +227,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource( self, resource_uri, # type: str @@ -58,8 +241,10 @@ def list_by_resource( :param resource_uri: The identifier of the resource. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + :return: An iterator like instance of either + DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] @@ -67,34 +252,29 @@ def list_by_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-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.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True, 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_request( + resource_uri=resource_uri, + template_url=self.list_by_resource.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_list_by_resource_request( + resource_uri=resource_uri, + 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('DataCollectionRuleAssociationProxyOnlyResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -107,17 +287,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations'} # type: ignore + @distributed_trace def list_by_rule( self, resource_group_name, # type: str @@ -135,8 +317,10 @@ def list_by_rule( insensitive. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + :return: An iterator like instance of either + DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] @@ -144,36 +328,33 @@ def list_by_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-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_rule.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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_rule_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_name, + template_url=self.list_by_rule.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_list_by_rule_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_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('DataCollectionRuleAssociationProxyOnlyResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -186,17 +367,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations'} # type: ignore + @distributed_trace def get( self, resource_uri, # type: str @@ -214,7 +397,8 @@ def get( :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + :rtype: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] @@ -222,32 +406,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - 'associationName': self._serialize.url("association_name", association_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 = build_get_request( + resource_uri=resource_uri, + association_name=association_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) @@ -256,8 +430,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + + @distributed_trace def create( self, resource_uri, # type: str @@ -275,10 +452,12 @@ def create( :param association_name: The name of the association. The name is case insensitive. :type association_name: str :param body: The payload. - :type body: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + :type body: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource + :rtype: + ~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] @@ -286,40 +465,30 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - 'associationName': self._serialize.url("association_name", association_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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] if body is not None: - body_content = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') + _json = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request( + resource_uri=resource_uri, + association_name=association_name, + content_type=content_type, + json=_json, + template_url=self.create.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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -332,8 +501,11 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + + @distributed_trace def delete( self, resource_uri, # type: str @@ -359,35 +531,26 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - 'associationName': self._serialize.url("association_name", association_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 = build_delete_request( + resource_uri=resource_uri, + association_name=association_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rules_operations.py index c7a2fca7f84dd..30eb07d7fe482 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2019_11_01_preview/operations/_data_collection_rules_operations.py @@ -5,24 +5,250 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_group_request( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, 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_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules') + 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_get_request( + subscription_id, # type: str + resource_group_name, # type: str + data_collection_rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_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_request( + subscription_id, # type: str + resource_group_name, # type: str + data_collection_rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_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, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + data_collection_rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_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, + **kwargs + ) + + +def build_delete_request( + subscription_id, # type: str + resource_group_name, # type: str + data_collection_rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2019-11-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_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 + ) + +# fmt: on class DataCollectionRulesOperations(object): """DataCollectionRulesOperations operations. @@ -45,6 +271,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -58,8 +285,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :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 DataCollectionRuleResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResourceListResult] + :return: An iterator like instance of either DataCollectionRuleResourceListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] @@ -67,35 +296,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-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', max_length=90, 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') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('DataCollectionRuleResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,17 +333,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Insights/dataCollectionRules'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs # type: Any @@ -129,8 +356,10 @@ def list_by_subscription( Lists all data collection rules in the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResourceListResult] + :return: An iterator like instance of either DataCollectionRuleResourceListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2019_11_01_preview.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] @@ -138,34 +367,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('DataCollectionRuleResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -178,17 +402,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Insights/dataCollectionRules'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -215,33 +441,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - 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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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 = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) @@ -250,8 +466,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}'} # type: ignore + + @distributed_trace def create( self, resource_group_name, # type: str @@ -281,41 +500,31 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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] if body is not None: - body_content = self._serialize.body(body, 'DataCollectionRuleResource') + _json = self._serialize.body(body, 'DataCollectionRuleResource') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_name, + content_type=content_type, + json=_json, + template_url=self.create.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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -328,8 +537,11 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -359,41 +571,31 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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] if body is not None: - body_content = self._serialize.body(body, 'ResourceForUpdate') + _json = self._serialize.body(body, 'ResourceForUpdate') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) @@ -402,8 +604,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -430,36 +635,27 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-01-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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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 = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_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.Insights/dataCollectionRules/{dataCollectionRuleName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_configuration.py index 0c4c839c67519..d5c9ac3b61762 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -37,9 +37,9 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2020-01-01-preview" @@ -62,4 +62,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_metadata.json index 724484160644d..378468ef8a93e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -42,7 +42,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -62,7 +62,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -79,11 +79,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "management_group_diagnostic_settings": "ManagementGroupDiagnosticSettingsOperations" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_monitor_management_client.py index 35801d7fac263..df4782da9c404 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_monitor_management_client.py @@ -6,67 +6,79 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ManagementGroupDiagnosticSettingsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import ManagementGroupDiagnosticSettingsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. - :ivar management_group_diagnostic_settings: ManagementGroupDiagnosticSettingsOperations operations - :vartype management_group_diagnostic_settings: $(python-base-namespace).v2020_01_01_preview.operations.ManagementGroupDiagnosticSettingsOperations + :ivar management_group_diagnostic_settings: ManagementGroupDiagnosticSettingsOperations + operations + :vartype management_group_diagnostic_settings: + $(python-base-namespace).v2020_01_01_preview.operations.ManagementGroupDiagnosticSettingsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :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" - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, **kwargs) + self._config = MonitorManagementClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_configuration.py index 91dce6198f597..cdef221ece0b6 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/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 @@ -34,9 +34,9 @@ def __init__( credential: "AsyncTokenCredential", **kwargs: Any ) -> None: + super(MonitorManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") - super(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.api_version = "2020-01-01-preview" @@ -58,4 +58,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_monitor_management_client.py index 1b9308541bdfa..8c3c52b5455bb 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_monitor_management_client.py @@ -6,63 +6,75 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import MonitorManagementClientConfiguration from .operations import ManagementGroupDiagnosticSettingsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. - :ivar management_group_diagnostic_settings: ManagementGroupDiagnosticSettingsOperations operations - :vartype management_group_diagnostic_settings: $(python-base-namespace).v2020_01_01_preview.aio.operations.ManagementGroupDiagnosticSettingsOperations + :ivar management_group_diagnostic_settings: ManagementGroupDiagnosticSettingsOperations + operations + :vartype management_group_diagnostic_settings: + $(python-base-namespace).v2020_01_01_preview.aio.operations.ManagementGroupDiagnosticSettingsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :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", - 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 = MonitorManagementClientConfiguration(credential, **kwargs) + self._config = MonitorManagementClientConfiguration(credential=credential, **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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) - self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - http_request.url = self._client.format_url(http_request.url) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py index 2ff71bcf89fb9..921396e02fe26 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/aio/operations/_management_group_diagnostic_settings_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._management_group_diagnostic_settings_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_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_async async def get( self, management_group_id: str, @@ -55,7 +61,8 @@ async def get( :type name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementGroupDiagnosticSettingsResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource + :rtype: + ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResource"] @@ -63,32 +70,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_get_request( + management_group_id=management_group_id, + name=name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementGroupDiagnosticSettingsResource', pipeline_response) @@ -97,8 +94,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, management_group_id: str, @@ -113,10 +113,12 @@ async def create_or_update( :param name: The name of the diagnostic setting. :type name: str :param parameters: Parameters supplied to the operation. - :type parameters: ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource + :type parameters: + ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementGroupDiagnosticSettingsResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource + :rtype: + ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResource"] @@ -124,37 +126,27 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01-preview" - 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 = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'ManagementGroupDiagnosticSettingsResource') + + request = build_create_or_update_request( + management_group_id=management_group_id, + name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementGroupDiagnosticSettingsResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementGroupDiagnosticSettingsResource', pipeline_response) @@ -163,8 +155,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace_async async def delete( self, management_group_id: str, @@ -187,32 +182,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_delete_request( + management_group_id=management_group_id, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -220,6 +205,8 @@ async def delete( delete.metadata = {'url': '/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def list( self, management_group_id: str, @@ -230,8 +217,10 @@ def list( :param management_group_id: The management group id. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementGroupDiagnosticSettingsResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResourceCollection] + :return: An iterator like instance of either + ManagementGroupDiagnosticSettingsResourceCollection or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResourceCollection"] @@ -239,34 +228,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01-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 - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True), - } - 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + management_group_id=management_group_id, + template_url=self.list.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_list_request( + management_group_id=management_group_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('ManagementGroupDiagnosticSettingsResourceCollection', pipeline_response) + deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -279,12 +263,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models.py index 5715644ceb01e..d89716b38ead8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models.py @@ -13,10 +13,10 @@ class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -28,6 +28,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -44,8 +50,8 @@ class ManagementGroupProxyOnlyResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Location of the resource. - :type location: str + :ivar location: Location of the resource. + :vartype location: str """ _validation = { @@ -65,6 +71,10 @@ def __init__( self, **kwargs ): + """ + :keyword location: Location of the resource. + :paramtype location: str + """ super(ManagementGroupProxyOnlyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -83,26 +93,26 @@ class ManagementGroupDiagnosticSettingsResource(ManagementGroupProxyOnlyResource :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Location of the resource. - :type location: str - :param storage_account_id: The resource ID of the storage account to which you would like to + :ivar location: Location of the resource. + :vartype location: str + :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. - :type service_bus_rule_id: str - :param event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :type event_hub_authorization_rule_id: str - :param event_hub_name: The name of the event hub. If none is specified, the default event hub + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :vartype event_hub_authorization_rule_id: str + :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub will be selected. - :type event_hub_name: str - :param logs: The list of logs settings. - :type logs: + :vartype event_hub_name: str + :ivar logs: The list of logs settings. + :vartype logs: list[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupLogSettings] - :param workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would + :ivar workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str + :vartype workspace_id: str """ _validation = { @@ -128,6 +138,28 @@ def __init__( self, **kwargs ): + """ + :keyword location: Location of the resource. + :paramtype location: str + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here + to maintain backwards compatibility. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub + will be selected. + :paramtype event_hub_name: str + :keyword logs: The list of logs settings. + :paramtype logs: + list[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupLogSettings] + :keyword workspace_id: The full ARM resource ID of the Log Analytics workspace to which you + would like to send Diagnostic Logs. Example: + /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + :paramtype workspace_id: str + """ super(ManagementGroupDiagnosticSettingsResource, self).__init__(**kwargs) self.storage_account_id = kwargs.get('storage_account_id', None) self.service_bus_rule_id = kwargs.get('service_bus_rule_id', None) @@ -140,8 +172,8 @@ def __init__( class ManagementGroupDiagnosticSettingsResourceCollection(msrest.serialization.Model): """Represents a collection of management group diagnostic settings resources. - :param value: The collection of management group diagnostic settings resources. - :type value: + :ivar value: The collection of management group diagnostic settings resources. + :vartype value: list[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource] """ @@ -153,6 +185,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: The collection of management group diagnostic settings resources. + :paramtype value: + list[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource] + """ super(ManagementGroupDiagnosticSettingsResourceCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -162,11 +199,11 @@ class ManagementGroupLogSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param category: Required. Name of a Management Group Diagnostic Log category for a resource + :ivar category: Required. Name of a Management Group Diagnostic Log category for a resource type this setting is applied to. - :type category: str - :param enabled: Required. a value indicating whether this log is enabled. - :type enabled: bool + :vartype category: str + :ivar enabled: Required. a value indicating whether this log is enabled. + :vartype enabled: bool """ _validation = { @@ -183,6 +220,13 @@ def __init__( self, **kwargs ): + """ + :keyword category: Required. Name of a Management Group Diagnostic Log category for a resource + type this setting is applied to. + :paramtype category: str + :keyword enabled: Required. a value indicating whether this log is enabled. + :paramtype enabled: bool + """ super(ManagementGroupLogSettings, self).__init__(**kwargs) self.category = kwargs['category'] self.enabled = kwargs['enabled'] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models_py3.py index 64fb6dadc29aa..e53b3a61d86c2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/models/_models_py3.py @@ -15,10 +15,10 @@ class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -33,6 +33,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -49,8 +55,8 @@ class ManagementGroupProxyOnlyResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Location of the resource. - :type location: str + :ivar location: Location of the resource. + :vartype location: str """ _validation = { @@ -72,6 +78,10 @@ def __init__( location: Optional[str] = None, **kwargs ): + """ + :keyword location: Location of the resource. + :paramtype location: str + """ super(ManagementGroupProxyOnlyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -90,26 +100,26 @@ class ManagementGroupDiagnosticSettingsResource(ManagementGroupProxyOnlyResource :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Location of the resource. - :type location: str - :param storage_account_id: The resource ID of the storage account to which you would like to + :ivar location: Location of the resource. + :vartype location: str + :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. - :type service_bus_rule_id: str - :param event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :type event_hub_authorization_rule_id: str - :param event_hub_name: The name of the event hub. If none is specified, the default event hub + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :vartype event_hub_authorization_rule_id: str + :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub will be selected. - :type event_hub_name: str - :param logs: The list of logs settings. - :type logs: + :vartype event_hub_name: str + :ivar logs: The list of logs settings. + :vartype logs: list[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupLogSettings] - :param workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would + :ivar workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str + :vartype workspace_id: str """ _validation = { @@ -143,6 +153,28 @@ def __init__( workspace_id: Optional[str] = None, **kwargs ): + """ + :keyword location: Location of the resource. + :paramtype location: str + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here + to maintain backwards compatibility. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub + will be selected. + :paramtype event_hub_name: str + :keyword logs: The list of logs settings. + :paramtype logs: + list[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupLogSettings] + :keyword workspace_id: The full ARM resource ID of the Log Analytics workspace to which you + would like to send Diagnostic Logs. Example: + /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + :paramtype workspace_id: str + """ super(ManagementGroupDiagnosticSettingsResource, self).__init__(location=location, **kwargs) self.storage_account_id = storage_account_id self.service_bus_rule_id = service_bus_rule_id @@ -155,8 +187,8 @@ def __init__( class ManagementGroupDiagnosticSettingsResourceCollection(msrest.serialization.Model): """Represents a collection of management group diagnostic settings resources. - :param value: The collection of management group diagnostic settings resources. - :type value: + :ivar value: The collection of management group diagnostic settings resources. + :vartype value: list[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource] """ @@ -170,6 +202,11 @@ def __init__( value: Optional[List["ManagementGroupDiagnosticSettingsResource"]] = None, **kwargs ): + """ + :keyword value: The collection of management group diagnostic settings resources. + :paramtype value: + list[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource] + """ super(ManagementGroupDiagnosticSettingsResourceCollection, self).__init__(**kwargs) self.value = value @@ -179,11 +216,11 @@ class ManagementGroupLogSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param category: Required. Name of a Management Group Diagnostic Log category for a resource + :ivar category: Required. Name of a Management Group Diagnostic Log category for a resource type this setting is applied to. - :type category: str - :param enabled: Required. a value indicating whether this log is enabled. - :type enabled: bool + :vartype category: str + :ivar enabled: Required. a value indicating whether this log is enabled. + :vartype enabled: bool """ _validation = { @@ -203,6 +240,13 @@ def __init__( enabled: bool, **kwargs ): + """ + :keyword category: Required. Name of a Management Group Diagnostic Log category for a resource + type this setting is applied to. + :paramtype category: str + :keyword enabled: Required. a value indicating whether this log is enabled. + :paramtype enabled: bool + """ super(ManagementGroupLogSettings, self).__init__(**kwargs) self.category = category self.enabled = enabled diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_management_group_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_management_group_diagnostic_settings_operations.py index d15bed8025606..4ea85580a0f8a 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_management_group_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_01_01_preview/operations/_management_group_diagnostic_settings_operations.py @@ -5,24 +5,170 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + management_group_id, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), + "name": _SERIALIZER.url("name", 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( + management_group_id, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), + "name": _SERIALIZER.url("name", 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, + **kwargs + ) + + +def build_delete_request( + management_group_id, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), + "name": _SERIALIZER.url("name", 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_list_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-01-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), + } + + 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 + ) + +# fmt: on class ManagementGroupDiagnosticSettingsOperations(object): """ManagementGroupDiagnosticSettingsOperations operations. @@ -45,6 +191,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, management_group_id, # type: str @@ -60,7 +207,8 @@ def get( :type name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementGroupDiagnosticSettingsResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource + :rtype: + ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResource"] @@ -68,32 +216,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_get_request( + management_group_id=management_group_id, + name=name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementGroupDiagnosticSettingsResource', pipeline_response) @@ -102,8 +240,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def create_or_update( self, management_group_id, # type: str @@ -119,10 +260,12 @@ def create_or_update( :param name: The name of the diagnostic setting. :type name: str :param parameters: Parameters supplied to the operation. - :type parameters: ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource + :type parameters: + ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementGroupDiagnosticSettingsResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource + :rtype: + ~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResource"] @@ -130,37 +273,27 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01-preview" - 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 = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'ManagementGroupDiagnosticSettingsResource') + + request = build_create_or_update_request( + management_group_id=management_group_id, + name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementGroupDiagnosticSettingsResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementGroupDiagnosticSettingsResource', pipeline_response) @@ -169,8 +302,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def delete( self, management_group_id, # type: str @@ -194,32 +330,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_delete_request( + management_group_id=management_group_id, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -227,6 +353,8 @@ def delete( delete.metadata = {'url': '/providers/microsoft.management/managementGroups/{managementGroupId}/providers/microsoft.insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def list( self, management_group_id, # type: str @@ -238,8 +366,10 @@ def list( :param management_group_id: The management group id. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementGroupDiagnosticSettingsResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResourceCollection] + :return: An iterator like instance of either + ManagementGroupDiagnosticSettingsResourceCollection or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_01_01_preview.models.ManagementGroupDiagnosticSettingsResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResourceCollection"] @@ -247,34 +377,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-01-01-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 - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True), - } - 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + management_group_id=management_group_id, + template_url=self.list.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_list_request( + management_group_id=management_group_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('ManagementGroupDiagnosticSettingsResourceCollection', pipeline_response) + deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -287,12 +412,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_configuration.py index 1f601e6a83062..ff5232d682373 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_metadata.json index a556e8b454f65..0518924e3fa38 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "scheduled_query_rules": "ScheduledQueryRulesOperations" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_monitor_management_client.py index f16bbdb9ca83c..98aee76e0bebf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_monitor_management_client.py @@ -6,73 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ScheduledQueryRulesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import ScheduledQueryRulesOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. :ivar scheduled_query_rules: ScheduledQueryRulesOperations operations - :vartype scheduled_query_rules: $(python-base-namespace).v2020_05_01_preview.operations.ScheduledQueryRulesOperations + :vartype scheduled_query_rules: + $(python-base-namespace).v2020_05_01_preview.operations.ScheduledQueryRulesOperations :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.scheduled_query_rules = ScheduledQueryRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.scheduled_query_rules = ScheduledQueryRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_configuration.py index b4b6605c0d04e..9542d1ff846f5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_monitor_management_client.py index bac9461982547..62e082f8affdb 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_monitor_management_client.py @@ -6,69 +6,77 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import MonitorManagementClientConfiguration from .operations import ScheduledQueryRulesOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar scheduled_query_rules: ScheduledQueryRulesOperations operations - :vartype scheduled_query_rules: $(python-base-namespace).v2020_05_01_preview.aio.operations.ScheduledQueryRulesOperations + :vartype scheduled_query_rules: + $(python-base-namespace).v2020_05_01_preview.aio.operations.ScheduledQueryRulesOperations :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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.scheduled_query_rules = ScheduledQueryRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.scheduled_query_rules = ScheduledQueryRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_scheduled_query_rules_operations.py index 77eccbaf2c5d1..8e128c253a04e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_scheduled_query_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/aio/operations/_scheduled_query_rules_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._scheduled_query_rules_operations import build_create_or_update_request, build_delete_request, build_get_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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -48,8 +54,10 @@ def list_by_subscription( """Retrieve a scheduled query rule definitions 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 ScheduledQueryRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourceCollection] + :return: An iterator like instance of either ScheduledQueryRuleResourceCollection or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ScheduledQueryRuleResourceCollection"] @@ -57,34 +65,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('ScheduledQueryRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("ScheduledQueryRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,17 +100,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, 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.Insights/scheduledQueryRules'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -115,11 +120,13 @@ def list_by_resource_group( ) -> AsyncIterable["_models.ScheduledQueryRuleResourceCollection"]: """Retrieve scheduled query rule definitions in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 ScheduledQueryRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourceCollection] + :return: An iterator like instance of either ScheduledQueryRuleResourceCollection or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ScheduledQueryRuleResourceCollection"] @@ -127,35 +134,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('ScheduledQueryRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("ScheduledQueryRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -168,17 +171,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, 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.Insights/scheduledQueryRules'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -187,7 +192,7 @@ async def get( ) -> "_models.ScheduledQueryRuleResource": """Retrieve an scheduled query rule definition. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -201,33 +206,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - 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'), - 'ruleName': self._serialize.url("rule_name", 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 = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=rule_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorContract, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ScheduledQueryRuleResource', pipeline_response) @@ -236,8 +231,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -247,12 +245,13 @@ async def create_or_update( ) -> "_models.ScheduledQueryRuleResource": """Creates or updates a scheduled query rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str :param parameters: The parameters of the rule to create or update. - :type parameters: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource + :type parameters: + ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource :keyword callable cls: A custom type or function that will be passed the direct response :return: ScheduledQueryRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource @@ -263,38 +262,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - 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'), - 'ruleName': self._serialize.url("rule_name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScheduledQueryRuleResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScheduledQueryRuleResource') - 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.failsafe_deserialize(_models.ErrorContract, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -307,8 +296,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -318,12 +310,13 @@ async def update( ) -> "_models.ScheduledQueryRuleResource": """Update a scheduled query rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str :param parameters: The parameters of the rule to update. - :type parameters: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourcePatch + :type parameters: + ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourcePatch :keyword callable cls: A custom type or function that will be passed the direct response :return: ScheduledQueryRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource @@ -334,38 +327,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-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'), - 'ruleName': self._serialize.url("rule_name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScheduledQueryRuleResourcePatch') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScheduledQueryRuleResourcePatch') - 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.failsafe_deserialize(_models.ErrorContract, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ScheduledQueryRuleResource', pipeline_response) @@ -374,8 +357,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -384,7 +370,7 @@ async def delete( ) -> None: """Deletes a scheduled query rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -398,36 +384,27 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-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'), - 'ruleName': self._serialize.url("rule_name", 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 = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=rule_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorContract, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_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.Insights/scheduledQueryRules/{ruleName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models.py index bc0dc2510e615..29e166722c1b1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models.py @@ -13,10 +13,10 @@ class Action(msrest.serialization.Model): """Actions to invoke when the alert fires. - :param action_group_id: Action Group resource Id to invoke when the alert fires. - :type action_group_id: str - :param web_hook_properties: The properties of a webhook object. - :type web_hook_properties: dict[str, str] + :ivar action_group_id: Action Group resource Id to invoke when the alert fires. + :vartype action_group_id: str + :ivar web_hook_properties: The properties of a webhook object. + :vartype web_hook_properties: dict[str, str] """ _attribute_map = { @@ -28,6 +28,12 @@ def __init__( self, **kwargs ): + """ + :keyword action_group_id: Action Group resource Id to invoke when the alert fires. + :paramtype action_group_id: str + :keyword web_hook_properties: The properties of a webhook object. + :paramtype web_hook_properties: dict[str, str] + """ super(Action, self).__init__(**kwargs) self.action_group_id = kwargs.get('action_group_id', None) self.web_hook_properties = kwargs.get('web_hook_properties', None) @@ -38,27 +44,28 @@ class Condition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param query: Log query alert. - :type query: str - :param time_aggregation: Required. Aggregation type. Possible values include: "Count", + :ivar query: Log query alert. + :vartype query: str + :ivar time_aggregation: Required. Aggregation type. Possible values include: "Count", "Average", "Minimum", "Maximum", "Total". - :type time_aggregation: str or + :vartype time_aggregation: str or ~$(python-base-namespace).v2020_05_01_preview.models.TimeAggregation - :param metric_measure_column: The column containing the metric measure number. - :type metric_measure_column: str - :param resource_id_column: The column containing the resource id. The content of the column - must be a uri formatted as resource id. - :type resource_id_column: str - :param dimensions: List of Dimensions conditions. - :type dimensions: list[~$(python-base-namespace).v2020_05_01_preview.models.Dimension] - :param operator: Required. The criteria operator. Possible values include: "Equals", + :ivar metric_measure_column: The column containing the metric measure number. + :vartype metric_measure_column: str + :ivar resource_id_column: The column containing the resource id. The content of the column must + be a uri formatted as resource id. + :vartype resource_id_column: str + :ivar dimensions: List of Dimensions conditions. + :vartype dimensions: list[~$(python-base-namespace).v2020_05_01_preview.models.Dimension] + :ivar operator: Required. The criteria operator. Possible values include: "Equals", "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or ~$(python-base-namespace).v2020_05_01_preview.models.ConditionOperator - :param threshold: Required. the criteria threshold value that activates the alert. - :type threshold: float - :param failing_periods: The minimum number of violations required within the selected lookback + :vartype operator: str or + ~$(python-base-namespace).v2020_05_01_preview.models.ConditionOperator + :ivar threshold: Required. the criteria threshold value that activates the alert. + :vartype threshold: float + :ivar failing_periods: The minimum number of violations required within the selected lookback time window required to raise an alert. - :type failing_periods: + :vartype failing_periods: ~$(python-base-namespace).v2020_05_01_preview.models.ConditionFailingPeriods """ @@ -83,6 +90,31 @@ def __init__( self, **kwargs ): + """ + :keyword query: Log query alert. + :paramtype query: str + :keyword time_aggregation: Required. Aggregation type. Possible values include: "Count", + "Average", "Minimum", "Maximum", "Total". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2020_05_01_preview.models.TimeAggregation + :keyword metric_measure_column: The column containing the metric measure number. + :paramtype metric_measure_column: str + :keyword resource_id_column: The column containing the resource id. The content of the column + must be a uri formatted as resource id. + :paramtype resource_id_column: str + :keyword dimensions: List of Dimensions conditions. + :paramtype dimensions: list[~$(python-base-namespace).v2020_05_01_preview.models.Dimension] + :keyword operator: Required. The criteria operator. Possible values include: "Equals", + "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :paramtype operator: str or + ~$(python-base-namespace).v2020_05_01_preview.models.ConditionOperator + :keyword threshold: Required. the criteria threshold value that activates the alert. + :paramtype threshold: float + :keyword failing_periods: The minimum number of violations required within the selected + lookback time window required to raise an alert. + :paramtype failing_periods: + ~$(python-base-namespace).v2020_05_01_preview.models.ConditionFailingPeriods + """ super(Condition, self).__init__(**kwargs) self.query = kwargs.get('query', None) self.time_aggregation = kwargs['time_aggregation'] @@ -97,13 +129,13 @@ def __init__( class ConditionFailingPeriods(msrest.serialization.Model): """The minimum number of violations required within the selected lookback time window required to raise an alert. - :param number_of_evaluation_periods: The number of aggregated lookback points. The lookback - time window is calculated based on the aggregation granularity (windowSize) and the selected - number of aggregated points. Default value is 1. - :type number_of_evaluation_periods: long - :param min_failing_periods_to_alert: The number of violations to trigger an alert. Should be + :ivar number_of_evaluation_periods: The number of aggregated lookback points. The lookback time + window is calculated based on the aggregation granularity (windowSize) and the selected number + of aggregated points. Default value is 1. + :vartype number_of_evaluation_periods: long + :ivar min_failing_periods_to_alert: The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. Default value is 1. - :type min_failing_periods_to_alert: long + :vartype min_failing_periods_to_alert: long """ _attribute_map = { @@ -115,6 +147,15 @@ def __init__( self, **kwargs ): + """ + :keyword number_of_evaluation_periods: The number of aggregated lookback points. The lookback + time window is calculated based on the aggregation granularity (windowSize) and the selected + number of aggregated points. Default value is 1. + :paramtype number_of_evaluation_periods: long + :keyword min_failing_periods_to_alert: The number of violations to trigger an alert. Should be + smaller or equal to numberOfEvaluationPeriods. Default value is 1. + :paramtype min_failing_periods_to_alert: long + """ super(ConditionFailingPeriods, self).__init__(**kwargs) self.number_of_evaluation_periods = kwargs.get('number_of_evaluation_periods', 1) self.min_failing_periods_to_alert = kwargs.get('min_failing_periods_to_alert', 1) @@ -125,13 +166,14 @@ class Dimension(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the dimension. - :type name: str - :param operator: Required. Operator for dimension values. Possible values include: "Include", + :ivar name: Required. Name of the dimension. + :vartype name: str + :ivar operator: Required. Operator for dimension values. Possible values include: "Include", "Exclude". - :type operator: str or ~$(python-base-namespace).v2020_05_01_preview.models.DimensionOperator - :param values: Required. List of dimension values. - :type values: list[str] + :vartype operator: str or + ~$(python-base-namespace).v2020_05_01_preview.models.DimensionOperator + :ivar values: Required. List of dimension values. + :vartype values: list[str] """ _validation = { @@ -150,6 +192,16 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. Name of the dimension. + :paramtype name: str + :keyword operator: Required. Operator for dimension values. Possible values include: "Include", + "Exclude". + :paramtype operator: str or + ~$(python-base-namespace).v2020_05_01_preview.models.DimensionOperator + :keyword values: Required. List of dimension values. + :paramtype values: list[str] + """ super(Dimension, self).__init__(**kwargs) self.name = kwargs['name'] self.operator = kwargs['operator'] @@ -181,6 +233,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -189,8 +243,8 @@ def __init__( class ErrorContract(msrest.serialization.Model): """Describes the format of Error response. - :param error: The error details. - :type error: ~$(python-base-namespace).v2020_05_01_preview.models.ErrorResponse + :ivar error: The error details. + :vartype error: ~$(python-base-namespace).v2020_05_01_preview.models.ErrorResponse """ _attribute_map = { @@ -201,6 +255,10 @@ def __init__( self, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~$(python-base-namespace).v2020_05_01_preview.models.ErrorResponse + """ super(ErrorContract, self).__init__(**kwargs) self.error = kwargs.get('error', None) @@ -243,6 +301,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -282,6 +342,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -291,8 +353,8 @@ def __init__( class ScheduledQueryRuleCriteria(msrest.serialization.Model): """The rule criteria that defines the conditions of the scheduled query rule. - :param all_of: A list of conditions to evaluate against the specified scopes. - :type all_of: list[~$(python-base-namespace).v2020_05_01_preview.models.Condition] + :ivar all_of: A list of conditions to evaluate against the specified scopes. + :vartype all_of: list[~$(python-base-namespace).v2020_05_01_preview.models.Condition] """ _attribute_map = { @@ -303,6 +365,10 @@ def __init__( self, **kwargs ): + """ + :keyword all_of: A list of conditions to evaluate against the specified scopes. + :paramtype all_of: list[~$(python-base-namespace).v2020_05_01_preview.models.Condition] + """ super(ScheduledQueryRuleCriteria, self).__init__(**kwargs) self.all_of = kwargs.get('all_of', None) @@ -322,10 +388,10 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str """ _validation = { @@ -347,6 +413,12 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ super(TrackedResource, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.location = kwargs['location'] @@ -367,10 +439,10 @@ class ScheduledQueryRuleResource(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. @@ -385,39 +457,40 @@ class ScheduledQueryRuleResource(TrackedResource): :vartype created_with_api_version: str :ivar is_legacy_log_analytics_rule: True if alert rule is legacy Log Analytic rule. :vartype is_legacy_log_analytics_rule: bool - :param description: The description of the scheduled query rule. - :type description: str - :param display_name: The display name of the alert rule. - :type display_name: str - :param severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is + :ivar description: The description of the scheduled query rule. + :vartype description: str + :ivar display_name: The display name of the alert rule. + :vartype display_name: str + :ivar severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. Possible values include: 0, 1, 2, 3, 4. - :type severity: str or ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity - :param enabled: The flag which indicates whether this scheduled query rule is enabled. Value + :vartype severity: float or ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity + :ivar enabled: The flag which indicates whether this scheduled query rule is enabled. Value should be true or false. - :type enabled: bool - :param scopes: The list of resource id's that this scheduled query rule is scoped to. - :type scopes: list[str] - :param evaluation_frequency: How often the scheduled query rule is evaluated represented in ISO + :vartype enabled: bool + :ivar scopes: The list of resource id's that this scheduled query rule is scoped to. + :vartype scopes: list[str] + :ivar evaluation_frequency: How often the scheduled query rule is evaluated represented in ISO 8601 duration format. - :type evaluation_frequency: ~datetime.timedelta - :param window_size: The period of time (in ISO 8601 duration format) on which the Alert query + :vartype evaluation_frequency: ~datetime.timedelta + :ivar window_size: The period of time (in ISO 8601 duration format) on which the Alert query will be executed (bin size). - :type window_size: ~datetime.timedelta - :param override_query_time_range: If specified then overrides the query time range (default is + :vartype window_size: ~datetime.timedelta + :ivar override_query_time_range: If specified then overrides the query time range (default is WindowSize*NumberOfEvaluationPeriods). - :type override_query_time_range: ~datetime.timedelta - :param target_resource_types: List of resource type of the target resource(s) on which the - alert is created/updated. For example if the scope is a resource group and targetResourceTypes - is Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual + :vartype override_query_time_range: ~datetime.timedelta + :ivar target_resource_types: List of resource type of the target resource(s) on which the alert + is created/updated. For example if the scope is a resource group and targetResourceTypes is + Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource group which meet the alert criteria. - :type target_resource_types: list[str] - :param criteria: The rule criteria that defines the conditions of the scheduled query rule. - :type criteria: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleCriteria - :param mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 duration + :vartype target_resource_types: list[str] + :ivar criteria: The rule criteria that defines the conditions of the scheduled query rule. + :vartype criteria: + ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleCriteria + :ivar mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 duration format) after the alert is fired. - :type mute_actions_duration: ~datetime.timedelta - :param actions: - :type actions: list[~$(python-base-namespace).v2020_05_01_preview.models.Action] + :vartype mute_actions_duration: ~datetime.timedelta + :ivar actions: + :vartype actions: list[~$(python-base-namespace).v2020_05_01_preview.models.Action] """ _validation = { @@ -459,6 +532,47 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword description: The description of the scheduled query rule. + :paramtype description: str + :keyword display_name: The display name of the alert rule. + :paramtype display_name: str + :keyword severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is + severest. Possible values include: 0, 1, 2, 3, 4. + :paramtype severity: float or + ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity + :keyword enabled: The flag which indicates whether this scheduled query rule is enabled. Value + should be true or false. + :paramtype enabled: bool + :keyword scopes: The list of resource id's that this scheduled query rule is scoped to. + :paramtype scopes: list[str] + :keyword evaluation_frequency: How often the scheduled query rule is evaluated represented in + ISO 8601 duration format. + :paramtype evaluation_frequency: ~datetime.timedelta + :keyword window_size: The period of time (in ISO 8601 duration format) on which the Alert query + will be executed (bin size). + :paramtype window_size: ~datetime.timedelta + :keyword override_query_time_range: If specified then overrides the query time range (default + is WindowSize*NumberOfEvaluationPeriods). + :paramtype override_query_time_range: ~datetime.timedelta + :keyword target_resource_types: List of resource type of the target resource(s) on which the + alert is created/updated. For example if the scope is a resource group and targetResourceTypes + is Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual + machine in the resource group which meet the alert criteria. + :paramtype target_resource_types: list[str] + :keyword criteria: The rule criteria that defines the conditions of the scheduled query rule. + :paramtype criteria: + ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleCriteria + :keyword mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 + duration format) after the alert is fired. + :paramtype mute_actions_duration: ~datetime.timedelta + :keyword actions: + :paramtype actions: list[~$(python-base-namespace).v2020_05_01_preview.models.Action] + """ super(ScheduledQueryRuleResource, self).__init__(**kwargs) self.kind = None self.etag = None @@ -481,8 +595,8 @@ def __init__( class ScheduledQueryRuleResourceCollection(msrest.serialization.Model): """Represents a collection of scheduled query rule resources. - :param value: The values for the scheduled query rule resources. - :type value: + :ivar value: The values for the scheduled query rule resources. + :vartype value: list[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource] """ @@ -494,6 +608,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: The values for the scheduled query rule resources. + :paramtype value: + list[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource] + """ super(ScheduledQueryRuleResourceCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -503,45 +622,46 @@ class ScheduledQueryRuleResourcePatch(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] :ivar created_with_api_version: The api-version used when creating this alert rule. :vartype created_with_api_version: str :ivar is_legacy_log_analytics_rule: True if alert rule is legacy Log Analytic rule. :vartype is_legacy_log_analytics_rule: bool - :param description: The description of the scheduled query rule. - :type description: str - :param display_name: The display name of the alert rule. - :type display_name: str - :param severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is + :ivar description: The description of the scheduled query rule. + :vartype description: str + :ivar display_name: The display name of the alert rule. + :vartype display_name: str + :ivar severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. Possible values include: 0, 1, 2, 3, 4. - :type severity: str or ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity - :param enabled: The flag which indicates whether this scheduled query rule is enabled. Value + :vartype severity: float or ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity + :ivar enabled: The flag which indicates whether this scheduled query rule is enabled. Value should be true or false. - :type enabled: bool - :param scopes: The list of resource id's that this scheduled query rule is scoped to. - :type scopes: list[str] - :param evaluation_frequency: How often the scheduled query rule is evaluated represented in ISO + :vartype enabled: bool + :ivar scopes: The list of resource id's that this scheduled query rule is scoped to. + :vartype scopes: list[str] + :ivar evaluation_frequency: How often the scheduled query rule is evaluated represented in ISO 8601 duration format. - :type evaluation_frequency: ~datetime.timedelta - :param window_size: The period of time (in ISO 8601 duration format) on which the Alert query + :vartype evaluation_frequency: ~datetime.timedelta + :ivar window_size: The period of time (in ISO 8601 duration format) on which the Alert query will be executed (bin size). - :type window_size: ~datetime.timedelta - :param override_query_time_range: If specified then overrides the query time range (default is + :vartype window_size: ~datetime.timedelta + :ivar override_query_time_range: If specified then overrides the query time range (default is WindowSize*NumberOfEvaluationPeriods). - :type override_query_time_range: ~datetime.timedelta - :param target_resource_types: List of resource type of the target resource(s) on which the - alert is created/updated. For example if the scope is a resource group and targetResourceTypes - is Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual + :vartype override_query_time_range: ~datetime.timedelta + :ivar target_resource_types: List of resource type of the target resource(s) on which the alert + is created/updated. For example if the scope is a resource group and targetResourceTypes is + Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource group which meet the alert criteria. - :type target_resource_types: list[str] - :param criteria: The rule criteria that defines the conditions of the scheduled query rule. - :type criteria: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleCriteria - :param mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 duration + :vartype target_resource_types: list[str] + :ivar criteria: The rule criteria that defines the conditions of the scheduled query rule. + :vartype criteria: + ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleCriteria + :ivar mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 duration format) after the alert is fired. - :type mute_actions_duration: ~datetime.timedelta - :param actions: - :type actions: list[~$(python-base-namespace).v2020_05_01_preview.models.Action] + :vartype mute_actions_duration: ~datetime.timedelta + :ivar actions: + :vartype actions: list[~$(python-base-namespace).v2020_05_01_preview.models.Action] """ _validation = { @@ -571,6 +691,45 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword description: The description of the scheduled query rule. + :paramtype description: str + :keyword display_name: The display name of the alert rule. + :paramtype display_name: str + :keyword severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is + severest. Possible values include: 0, 1, 2, 3, 4. + :paramtype severity: float or + ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity + :keyword enabled: The flag which indicates whether this scheduled query rule is enabled. Value + should be true or false. + :paramtype enabled: bool + :keyword scopes: The list of resource id's that this scheduled query rule is scoped to. + :paramtype scopes: list[str] + :keyword evaluation_frequency: How often the scheduled query rule is evaluated represented in + ISO 8601 duration format. + :paramtype evaluation_frequency: ~datetime.timedelta + :keyword window_size: The period of time (in ISO 8601 duration format) on which the Alert query + will be executed (bin size). + :paramtype window_size: ~datetime.timedelta + :keyword override_query_time_range: If specified then overrides the query time range (default + is WindowSize*NumberOfEvaluationPeriods). + :paramtype override_query_time_range: ~datetime.timedelta + :keyword target_resource_types: List of resource type of the target resource(s) on which the + alert is created/updated. For example if the scope is a resource group and targetResourceTypes + is Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual + machine in the resource group which meet the alert criteria. + :paramtype target_resource_types: list[str] + :keyword criteria: The rule criteria that defines the conditions of the scheduled query rule. + :paramtype criteria: + ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleCriteria + :keyword mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 + duration format) after the alert is fired. + :paramtype mute_actions_duration: ~datetime.timedelta + :keyword actions: + :paramtype actions: list[~$(python-base-namespace).v2020_05_01_preview.models.Action] + """ super(ScheduledQueryRuleResourcePatch, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.created_with_api_version = None diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models_py3.py index 1525426b24eaf..76b08a05a895c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_models_py3.py @@ -18,10 +18,10 @@ class Action(msrest.serialization.Model): """Actions to invoke when the alert fires. - :param action_group_id: Action Group resource Id to invoke when the alert fires. - :type action_group_id: str - :param web_hook_properties: The properties of a webhook object. - :type web_hook_properties: dict[str, str] + :ivar action_group_id: Action Group resource Id to invoke when the alert fires. + :vartype action_group_id: str + :ivar web_hook_properties: The properties of a webhook object. + :vartype web_hook_properties: dict[str, str] """ _attribute_map = { @@ -36,6 +36,12 @@ def __init__( web_hook_properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword action_group_id: Action Group resource Id to invoke when the alert fires. + :paramtype action_group_id: str + :keyword web_hook_properties: The properties of a webhook object. + :paramtype web_hook_properties: dict[str, str] + """ super(Action, self).__init__(**kwargs) self.action_group_id = action_group_id self.web_hook_properties = web_hook_properties @@ -46,27 +52,28 @@ class Condition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param query: Log query alert. - :type query: str - :param time_aggregation: Required. Aggregation type. Possible values include: "Count", + :ivar query: Log query alert. + :vartype query: str + :ivar time_aggregation: Required. Aggregation type. Possible values include: "Count", "Average", "Minimum", "Maximum", "Total". - :type time_aggregation: str or + :vartype time_aggregation: str or ~$(python-base-namespace).v2020_05_01_preview.models.TimeAggregation - :param metric_measure_column: The column containing the metric measure number. - :type metric_measure_column: str - :param resource_id_column: The column containing the resource id. The content of the column - must be a uri formatted as resource id. - :type resource_id_column: str - :param dimensions: List of Dimensions conditions. - :type dimensions: list[~$(python-base-namespace).v2020_05_01_preview.models.Dimension] - :param operator: Required. The criteria operator. Possible values include: "Equals", + :ivar metric_measure_column: The column containing the metric measure number. + :vartype metric_measure_column: str + :ivar resource_id_column: The column containing the resource id. The content of the column must + be a uri formatted as resource id. + :vartype resource_id_column: str + :ivar dimensions: List of Dimensions conditions. + :vartype dimensions: list[~$(python-base-namespace).v2020_05_01_preview.models.Dimension] + :ivar operator: Required. The criteria operator. Possible values include: "Equals", "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or ~$(python-base-namespace).v2020_05_01_preview.models.ConditionOperator - :param threshold: Required. the criteria threshold value that activates the alert. - :type threshold: float - :param failing_periods: The minimum number of violations required within the selected lookback + :vartype operator: str or + ~$(python-base-namespace).v2020_05_01_preview.models.ConditionOperator + :ivar threshold: Required. the criteria threshold value that activates the alert. + :vartype threshold: float + :ivar failing_periods: The minimum number of violations required within the selected lookback time window required to raise an alert. - :type failing_periods: + :vartype failing_periods: ~$(python-base-namespace).v2020_05_01_preview.models.ConditionFailingPeriods """ @@ -100,6 +107,31 @@ def __init__( failing_periods: Optional["ConditionFailingPeriods"] = None, **kwargs ): + """ + :keyword query: Log query alert. + :paramtype query: str + :keyword time_aggregation: Required. Aggregation type. Possible values include: "Count", + "Average", "Minimum", "Maximum", "Total". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2020_05_01_preview.models.TimeAggregation + :keyword metric_measure_column: The column containing the metric measure number. + :paramtype metric_measure_column: str + :keyword resource_id_column: The column containing the resource id. The content of the column + must be a uri formatted as resource id. + :paramtype resource_id_column: str + :keyword dimensions: List of Dimensions conditions. + :paramtype dimensions: list[~$(python-base-namespace).v2020_05_01_preview.models.Dimension] + :keyword operator: Required. The criteria operator. Possible values include: "Equals", + "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". + :paramtype operator: str or + ~$(python-base-namespace).v2020_05_01_preview.models.ConditionOperator + :keyword threshold: Required. the criteria threshold value that activates the alert. + :paramtype threshold: float + :keyword failing_periods: The minimum number of violations required within the selected + lookback time window required to raise an alert. + :paramtype failing_periods: + ~$(python-base-namespace).v2020_05_01_preview.models.ConditionFailingPeriods + """ super(Condition, self).__init__(**kwargs) self.query = query self.time_aggregation = time_aggregation @@ -114,13 +146,13 @@ def __init__( class ConditionFailingPeriods(msrest.serialization.Model): """The minimum number of violations required within the selected lookback time window required to raise an alert. - :param number_of_evaluation_periods: The number of aggregated lookback points. The lookback - time window is calculated based on the aggregation granularity (windowSize) and the selected - number of aggregated points. Default value is 1. - :type number_of_evaluation_periods: long - :param min_failing_periods_to_alert: The number of violations to trigger an alert. Should be + :ivar number_of_evaluation_periods: The number of aggregated lookback points. The lookback time + window is calculated based on the aggregation granularity (windowSize) and the selected number + of aggregated points. Default value is 1. + :vartype number_of_evaluation_periods: long + :ivar min_failing_periods_to_alert: The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. Default value is 1. - :type min_failing_periods_to_alert: long + :vartype min_failing_periods_to_alert: long """ _attribute_map = { @@ -135,6 +167,15 @@ def __init__( min_failing_periods_to_alert: Optional[int] = 1, **kwargs ): + """ + :keyword number_of_evaluation_periods: The number of aggregated lookback points. The lookback + time window is calculated based on the aggregation granularity (windowSize) and the selected + number of aggregated points. Default value is 1. + :paramtype number_of_evaluation_periods: long + :keyword min_failing_periods_to_alert: The number of violations to trigger an alert. Should be + smaller or equal to numberOfEvaluationPeriods. Default value is 1. + :paramtype min_failing_periods_to_alert: long + """ super(ConditionFailingPeriods, self).__init__(**kwargs) self.number_of_evaluation_periods = number_of_evaluation_periods self.min_failing_periods_to_alert = min_failing_periods_to_alert @@ -145,13 +186,14 @@ class Dimension(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. Name of the dimension. - :type name: str - :param operator: Required. Operator for dimension values. Possible values include: "Include", + :ivar name: Required. Name of the dimension. + :vartype name: str + :ivar operator: Required. Operator for dimension values. Possible values include: "Include", "Exclude". - :type operator: str or ~$(python-base-namespace).v2020_05_01_preview.models.DimensionOperator - :param values: Required. List of dimension values. - :type values: list[str] + :vartype operator: str or + ~$(python-base-namespace).v2020_05_01_preview.models.DimensionOperator + :ivar values: Required. List of dimension values. + :vartype values: list[str] """ _validation = { @@ -174,6 +216,16 @@ def __init__( values: List[str], **kwargs ): + """ + :keyword name: Required. Name of the dimension. + :paramtype name: str + :keyword operator: Required. Operator for dimension values. Possible values include: "Include", + "Exclude". + :paramtype operator: str or + ~$(python-base-namespace).v2020_05_01_preview.models.DimensionOperator + :keyword values: Required. List of dimension values. + :paramtype values: list[str] + """ super(Dimension, self).__init__(**kwargs) self.name = name self.operator = operator @@ -205,6 +257,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -213,8 +267,8 @@ def __init__( class ErrorContract(msrest.serialization.Model): """Describes the format of Error response. - :param error: The error details. - :type error: ~$(python-base-namespace).v2020_05_01_preview.models.ErrorResponse + :ivar error: The error details. + :vartype error: ~$(python-base-namespace).v2020_05_01_preview.models.ErrorResponse """ _attribute_map = { @@ -227,6 +281,10 @@ def __init__( error: Optional["ErrorResponse"] = None, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~$(python-base-namespace).v2020_05_01_preview.models.ErrorResponse + """ super(ErrorContract, self).__init__(**kwargs) self.error = error @@ -269,6 +327,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -308,6 +368,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -317,8 +379,8 @@ def __init__( class ScheduledQueryRuleCriteria(msrest.serialization.Model): """The rule criteria that defines the conditions of the scheduled query rule. - :param all_of: A list of conditions to evaluate against the specified scopes. - :type all_of: list[~$(python-base-namespace).v2020_05_01_preview.models.Condition] + :ivar all_of: A list of conditions to evaluate against the specified scopes. + :vartype all_of: list[~$(python-base-namespace).v2020_05_01_preview.models.Condition] """ _attribute_map = { @@ -331,6 +393,10 @@ def __init__( all_of: Optional[List["Condition"]] = None, **kwargs ): + """ + :keyword all_of: A list of conditions to evaluate against the specified scopes. + :paramtype all_of: list[~$(python-base-namespace).v2020_05_01_preview.models.Condition] + """ super(ScheduledQueryRuleCriteria, self).__init__(**kwargs) self.all_of = all_of @@ -350,10 +416,10 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str """ _validation = { @@ -378,6 +444,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ super(TrackedResource, self).__init__(**kwargs) self.tags = tags self.location = location @@ -398,10 +470,10 @@ class ScheduledQueryRuleResource(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str :ivar kind: Metadata used by portal/tooling/etc to render different UX experiences for resources of the same type; e.g. ApiApps are a kind of Microsoft.Web/sites type. If supported, the resource provider must validate and persist this value. @@ -416,39 +488,40 @@ class ScheduledQueryRuleResource(TrackedResource): :vartype created_with_api_version: str :ivar is_legacy_log_analytics_rule: True if alert rule is legacy Log Analytic rule. :vartype is_legacy_log_analytics_rule: bool - :param description: The description of the scheduled query rule. - :type description: str - :param display_name: The display name of the alert rule. - :type display_name: str - :param severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is + :ivar description: The description of the scheduled query rule. + :vartype description: str + :ivar display_name: The display name of the alert rule. + :vartype display_name: str + :ivar severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. Possible values include: 0, 1, 2, 3, 4. - :type severity: str or ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity - :param enabled: The flag which indicates whether this scheduled query rule is enabled. Value + :vartype severity: float or ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity + :ivar enabled: The flag which indicates whether this scheduled query rule is enabled. Value should be true or false. - :type enabled: bool - :param scopes: The list of resource id's that this scheduled query rule is scoped to. - :type scopes: list[str] - :param evaluation_frequency: How often the scheduled query rule is evaluated represented in ISO + :vartype enabled: bool + :ivar scopes: The list of resource id's that this scheduled query rule is scoped to. + :vartype scopes: list[str] + :ivar evaluation_frequency: How often the scheduled query rule is evaluated represented in ISO 8601 duration format. - :type evaluation_frequency: ~datetime.timedelta - :param window_size: The period of time (in ISO 8601 duration format) on which the Alert query + :vartype evaluation_frequency: ~datetime.timedelta + :ivar window_size: The period of time (in ISO 8601 duration format) on which the Alert query will be executed (bin size). - :type window_size: ~datetime.timedelta - :param override_query_time_range: If specified then overrides the query time range (default is + :vartype window_size: ~datetime.timedelta + :ivar override_query_time_range: If specified then overrides the query time range (default is WindowSize*NumberOfEvaluationPeriods). - :type override_query_time_range: ~datetime.timedelta - :param target_resource_types: List of resource type of the target resource(s) on which the - alert is created/updated. For example if the scope is a resource group and targetResourceTypes - is Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual + :vartype override_query_time_range: ~datetime.timedelta + :ivar target_resource_types: List of resource type of the target resource(s) on which the alert + is created/updated. For example if the scope is a resource group and targetResourceTypes is + Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource group which meet the alert criteria. - :type target_resource_types: list[str] - :param criteria: The rule criteria that defines the conditions of the scheduled query rule. - :type criteria: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleCriteria - :param mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 duration + :vartype target_resource_types: list[str] + :ivar criteria: The rule criteria that defines the conditions of the scheduled query rule. + :vartype criteria: + ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleCriteria + :ivar mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 duration format) after the alert is fired. - :type mute_actions_duration: ~datetime.timedelta - :param actions: - :type actions: list[~$(python-base-namespace).v2020_05_01_preview.models.Action] + :vartype mute_actions_duration: ~datetime.timedelta + :ivar actions: + :vartype actions: list[~$(python-base-namespace).v2020_05_01_preview.models.Action] """ _validation = { @@ -505,6 +578,47 @@ def __init__( actions: Optional[List["Action"]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword description: The description of the scheduled query rule. + :paramtype description: str + :keyword display_name: The display name of the alert rule. + :paramtype display_name: str + :keyword severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is + severest. Possible values include: 0, 1, 2, 3, 4. + :paramtype severity: float or + ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity + :keyword enabled: The flag which indicates whether this scheduled query rule is enabled. Value + should be true or false. + :paramtype enabled: bool + :keyword scopes: The list of resource id's that this scheduled query rule is scoped to. + :paramtype scopes: list[str] + :keyword evaluation_frequency: How often the scheduled query rule is evaluated represented in + ISO 8601 duration format. + :paramtype evaluation_frequency: ~datetime.timedelta + :keyword window_size: The period of time (in ISO 8601 duration format) on which the Alert query + will be executed (bin size). + :paramtype window_size: ~datetime.timedelta + :keyword override_query_time_range: If specified then overrides the query time range (default + is WindowSize*NumberOfEvaluationPeriods). + :paramtype override_query_time_range: ~datetime.timedelta + :keyword target_resource_types: List of resource type of the target resource(s) on which the + alert is created/updated. For example if the scope is a resource group and targetResourceTypes + is Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual + machine in the resource group which meet the alert criteria. + :paramtype target_resource_types: list[str] + :keyword criteria: The rule criteria that defines the conditions of the scheduled query rule. + :paramtype criteria: + ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleCriteria + :keyword mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 + duration format) after the alert is fired. + :paramtype mute_actions_duration: ~datetime.timedelta + :keyword actions: + :paramtype actions: list[~$(python-base-namespace).v2020_05_01_preview.models.Action] + """ super(ScheduledQueryRuleResource, self).__init__(tags=tags, location=location, **kwargs) self.kind = None self.etag = None @@ -527,8 +641,8 @@ def __init__( class ScheduledQueryRuleResourceCollection(msrest.serialization.Model): """Represents a collection of scheduled query rule resources. - :param value: The values for the scheduled query rule resources. - :type value: + :ivar value: The values for the scheduled query rule resources. + :vartype value: list[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource] """ @@ -542,6 +656,11 @@ def __init__( value: Optional[List["ScheduledQueryRuleResource"]] = None, **kwargs ): + """ + :keyword value: The values for the scheduled query rule resources. + :paramtype value: + list[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource] + """ super(ScheduledQueryRuleResourceCollection, self).__init__(**kwargs) self.value = value @@ -551,45 +670,46 @@ class ScheduledQueryRuleResourcePatch(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] :ivar created_with_api_version: The api-version used when creating this alert rule. :vartype created_with_api_version: str :ivar is_legacy_log_analytics_rule: True if alert rule is legacy Log Analytic rule. :vartype is_legacy_log_analytics_rule: bool - :param description: The description of the scheduled query rule. - :type description: str - :param display_name: The display name of the alert rule. - :type display_name: str - :param severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is + :ivar description: The description of the scheduled query rule. + :vartype description: str + :ivar display_name: The display name of the alert rule. + :vartype display_name: str + :ivar severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest. Possible values include: 0, 1, 2, 3, 4. - :type severity: str or ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity - :param enabled: The flag which indicates whether this scheduled query rule is enabled. Value + :vartype severity: float or ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity + :ivar enabled: The flag which indicates whether this scheduled query rule is enabled. Value should be true or false. - :type enabled: bool - :param scopes: The list of resource id's that this scheduled query rule is scoped to. - :type scopes: list[str] - :param evaluation_frequency: How often the scheduled query rule is evaluated represented in ISO + :vartype enabled: bool + :ivar scopes: The list of resource id's that this scheduled query rule is scoped to. + :vartype scopes: list[str] + :ivar evaluation_frequency: How often the scheduled query rule is evaluated represented in ISO 8601 duration format. - :type evaluation_frequency: ~datetime.timedelta - :param window_size: The period of time (in ISO 8601 duration format) on which the Alert query + :vartype evaluation_frequency: ~datetime.timedelta + :ivar window_size: The period of time (in ISO 8601 duration format) on which the Alert query will be executed (bin size). - :type window_size: ~datetime.timedelta - :param override_query_time_range: If specified then overrides the query time range (default is + :vartype window_size: ~datetime.timedelta + :ivar override_query_time_range: If specified then overrides the query time range (default is WindowSize*NumberOfEvaluationPeriods). - :type override_query_time_range: ~datetime.timedelta - :param target_resource_types: List of resource type of the target resource(s) on which the - alert is created/updated. For example if the scope is a resource group and targetResourceTypes - is Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual + :vartype override_query_time_range: ~datetime.timedelta + :ivar target_resource_types: List of resource type of the target resource(s) on which the alert + is created/updated. For example if the scope is a resource group and targetResourceTypes is + Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual machine in the resource group which meet the alert criteria. - :type target_resource_types: list[str] - :param criteria: The rule criteria that defines the conditions of the scheduled query rule. - :type criteria: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleCriteria - :param mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 duration + :vartype target_resource_types: list[str] + :ivar criteria: The rule criteria that defines the conditions of the scheduled query rule. + :vartype criteria: + ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleCriteria + :ivar mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 duration format) after the alert is fired. - :type mute_actions_duration: ~datetime.timedelta - :param actions: - :type actions: list[~$(python-base-namespace).v2020_05_01_preview.models.Action] + :vartype mute_actions_duration: ~datetime.timedelta + :ivar actions: + :vartype actions: list[~$(python-base-namespace).v2020_05_01_preview.models.Action] """ _validation = { @@ -633,6 +753,45 @@ def __init__( actions: Optional[List["Action"]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword description: The description of the scheduled query rule. + :paramtype description: str + :keyword display_name: The display name of the alert rule. + :paramtype display_name: str + :keyword severity: Severity of the alert. Should be an integer between [0-4]. Value of 0 is + severest. Possible values include: 0, 1, 2, 3, 4. + :paramtype severity: float or + ~$(python-base-namespace).v2020_05_01_preview.models.AlertSeverity + :keyword enabled: The flag which indicates whether this scheduled query rule is enabled. Value + should be true or false. + :paramtype enabled: bool + :keyword scopes: The list of resource id's that this scheduled query rule is scoped to. + :paramtype scopes: list[str] + :keyword evaluation_frequency: How often the scheduled query rule is evaluated represented in + ISO 8601 duration format. + :paramtype evaluation_frequency: ~datetime.timedelta + :keyword window_size: The period of time (in ISO 8601 duration format) on which the Alert query + will be executed (bin size). + :paramtype window_size: ~datetime.timedelta + :keyword override_query_time_range: If specified then overrides the query time range (default + is WindowSize*NumberOfEvaluationPeriods). + :paramtype override_query_time_range: ~datetime.timedelta + :keyword target_resource_types: List of resource type of the target resource(s) on which the + alert is created/updated. For example if the scope is a resource group and targetResourceTypes + is Microsoft.Compute/virtualMachines, then a different alert will be fired for each virtual + machine in the resource group which meet the alert criteria. + :paramtype target_resource_types: list[str] + :keyword criteria: The rule criteria that defines the conditions of the scheduled query rule. + :paramtype criteria: + ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleCriteria + :keyword mute_actions_duration: Mute actions for the chosen period of time (in ISO 8601 + duration format) after the alert is fired. + :paramtype mute_actions_duration: ~datetime.timedelta + :keyword actions: + :paramtype actions: list[~$(python-base-namespace).v2020_05_01_preview.models.Action] + """ super(ScheduledQueryRuleResourcePatch, self).__init__(**kwargs) self.tags = tags self.created_with_api_version = None diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_monitor_management_client_enums.py index 824ade35f9c68..da2f1e015f96c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/models/_monitor_management_client_enums.py @@ -6,27 +6,12 @@ # 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 AlertSeverity(with_metaclass(_CaseInsensitiveEnumMeta, float, Enum)): +class AlertSeverity(with_metaclass(CaseInsensitiveEnumMeta, float, Enum)): """Severity of the alert. Should be an integer between [0-4]. Value of 0 is severest """ @@ -36,7 +21,7 @@ class AlertSeverity(with_metaclass(_CaseInsensitiveEnumMeta, float, Enum)): THREE = 3 FOUR = 4 -class ConditionOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ConditionOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The criteria operator. """ @@ -46,14 +31,14 @@ class ConditionOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" -class DimensionOperator(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DimensionOperator(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Operator for dimension values """ INCLUDE = "Include" EXCLUDE = "Exclude" -class TimeAggregation(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TimeAggregation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Aggregation type """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_scheduled_query_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_scheduled_query_rules_operations.py index 155ebb7421760..4f73e7b19daa2 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_scheduled_query_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_05_01_preview/operations/_scheduled_query_rules_operations.py @@ -5,24 +5,250 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/scheduledQueryRules') + 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, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, 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_get_request( + subscription_id, # type: str + resource_group_name, # type: str + rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", 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, # type: str + resource_group_name, # type: str + rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", 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, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", 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, + **kwargs + ) + + +def build_delete_request( + subscription_id, # type: str + resource_group_name, # type: str + rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "ruleName": _SERIALIZER.url("rule_name", 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 + ) + +# fmt: on class ScheduledQueryRulesOperations(object): """ScheduledQueryRulesOperations operations. @@ -45,6 +271,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, **kwargs # type: Any @@ -53,8 +280,10 @@ def list_by_subscription( """Retrieve a scheduled query rule definitions 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 ScheduledQueryRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourceCollection] + :return: An iterator like instance of either ScheduledQueryRuleResourceCollection or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ScheduledQueryRuleResourceCollection"] @@ -62,34 +291,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('ScheduledQueryRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("ScheduledQueryRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,17 +326,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, 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.Insights/scheduledQueryRules'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -121,11 +347,13 @@ def list_by_resource_group( # type: (...) -> Iterable["_models.ScheduledQueryRuleResourceCollection"] """Retrieve scheduled query rule definitions in a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 ScheduledQueryRuleResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourceCollection] + :return: An iterator like instance of either ScheduledQueryRuleResourceCollection or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ScheduledQueryRuleResourceCollection"] @@ -133,35 +361,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('ScheduledQueryRuleResourceCollection', pipeline_response) + deserialized = self._deserialize("ScheduledQueryRuleResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -174,17 +398,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorContract, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, 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.Insights/scheduledQueryRules'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -194,7 +420,7 @@ def get( # type: (...) -> "_models.ScheduledQueryRuleResource" """Retrieve an scheduled query rule definition. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -208,33 +434,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - 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'), - 'ruleName': self._serialize.url("rule_name", 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 = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=rule_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorContract, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ScheduledQueryRuleResource', pipeline_response) @@ -243,8 +459,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -255,12 +474,13 @@ def create_or_update( # type: (...) -> "_models.ScheduledQueryRuleResource" """Creates or updates a scheduled query rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str :param parameters: The parameters of the rule to create or update. - :type parameters: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource + :type parameters: + ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource :keyword callable cls: A custom type or function that will be passed the direct response :return: ScheduledQueryRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource @@ -271,38 +491,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-preview" - 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'), - 'ruleName': self._serialize.url("rule_name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScheduledQueryRuleResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScheduledQueryRuleResource') - 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.failsafe_deserialize(_models.ErrorContract, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -315,8 +525,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -327,12 +540,13 @@ def update( # type: (...) -> "_models.ScheduledQueryRuleResource" """Update a scheduled query rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str :param parameters: The parameters of the rule to update. - :type parameters: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourcePatch + :type parameters: + ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResourcePatch :keyword callable cls: A custom type or function that will be passed the direct response :return: ScheduledQueryRuleResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_05_01_preview.models.ScheduledQueryRuleResource @@ -343,38 +557,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-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'), - 'ruleName': self._serialize.url("rule_name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ScheduledQueryRuleResourcePatch') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ScheduledQueryRuleResourcePatch') - 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.failsafe_deserialize(_models.ErrorContract, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ScheduledQueryRuleResource', pipeline_response) @@ -383,8 +587,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/scheduledQueryRules/{ruleName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -394,7 +601,7 @@ def delete( # type: (...) -> None """Deletes a scheduled query rule. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param rule_name: The name of the rule. :type rule_name: str @@ -408,36 +615,27 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-05-01-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'), - 'ruleName': self._serialize.url("rule_name", 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 = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + rule_name=rule_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorContract, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorContract, pipeline_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.Insights/scheduledQueryRules/{ruleName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py index 28d48e6791d02..2156b8b8dbd04 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_configuration.py @@ -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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_metadata.json index 29a3b208a9663..f1fae9dab9581 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "activity_log_alerts": "ActivityLogAlertsOperations" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py index b1daa9d88de56..60c0d15f84601 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_monitor_management_client.py @@ -6,73 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ActivityLogAlertsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActivityLogAlertsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. :ivar activity_log_alerts: ActivityLogAlertsOperations operations - :vartype activity_log_alerts: $(python-base-namespace).v2020_10_01.operations.ActivityLogAlertsOperations + :vartype activity_log_alerts: + $(python-base-namespace).v2020_10_01.operations.ActivityLogAlertsOperations :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.activity_log_alerts = ActivityLogAlertsOperations(self._client, self._config, self._serialize, self._deserialize) - self.activity_log_alerts = ActivityLogAlertsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_configuration.py index 968ee446dd680..d463a021089f0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_monitor_management_client.py index ec3d4d50df64f..6f8d6651909b9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_monitor_management_client.py @@ -6,69 +6,77 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import MonitorManagementClientConfiguration from .operations import ActivityLogAlertsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar activity_log_alerts: ActivityLogAlertsOperations operations - :vartype activity_log_alerts: $(python-base-namespace).v2020_10_01.aio.operations.ActivityLogAlertsOperations + :vartype activity_log_alerts: + $(python-base-namespace).v2020_10_01.aio.operations.ActivityLogAlertsOperations :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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.activity_log_alerts = ActivityLogAlertsOperations(self._client, self._config, self._serialize, self._deserialize) - self.activity_log_alerts = ActivityLogAlertsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_activity_log_alerts_operations.py index ecb6e1f12579d..08ed28f3b920d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_activity_log_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/aio/operations/_activity_log_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._activity_log_alerts_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_update_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_async async def create_or_update( self, resource_group_name: str, @@ -55,7 +61,8 @@ async def create_or_update( :param activity_log_alert_name: The name of the Activity Log Alert rule. :type activity_log_alert_name: str :param activity_log_alert_rule: The Activity Log Alert rule to create or use for the update. - :type activity_log_alert_rule: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource + :type activity_log_alert_rule: + ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource :keyword callable cls: A custom type or function that will be passed the direct response :return: ActivityLogAlertResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource @@ -66,38 +73,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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', max_length=90, min_length=1), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(activity_log_alert_rule, 'ActivityLogAlertResource') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(activity_log_alert_rule, 'ActivityLogAlertResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -110,8 +107,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -134,33 +134,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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', max_length=90, min_length=1), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # 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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) @@ -169,8 +159,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -193,33 +186,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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', max_length=90, min_length=1), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # 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_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -227,6 +210,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -243,7 +228,8 @@ async def update( :param activity_log_alert_name: The name of the Activity Log Alert rule. :type activity_log_alert_name: str :param activity_log_alert_rule_patch: Parameters supplied to the operation. - :type activity_log_alert_rule_patch: ~$(python-base-namespace).v2020_10_01.models.AlertRulePatchObject + :type activity_log_alert_rule_patch: + ~$(python-base-namespace).v2020_10_01.models.AlertRulePatchObject :keyword callable cls: A custom type or function that will be passed the direct response :return: ActivityLogAlertResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource @@ -254,38 +240,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - 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', max_length=90, min_length=1), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(activity_log_alert_rule_patch, 'AlertRulePatchObject') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(activity_log_alert_rule_patch, '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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) @@ -294,8 +270,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace def list_by_subscription_id( self, **kwargs: Any @@ -304,7 +283,8 @@ def list_by_subscription_id( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertRuleList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_10_01.models.AlertRuleList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_10_01.models.AlertRuleList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleList"] @@ -312,34 +292,29 @@ def list_by_subscription_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_subscription_id.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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription_id.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_list_by_subscription_id_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('AlertRuleList', pipeline_response) + deserialized = self._deserialize("AlertRuleList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -352,17 +327,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -374,7 +351,8 @@ def list_by_resource_group( :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 AlertRuleList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_10_01.models.AlertRuleList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2020_10_01.models.AlertRuleList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleList"] @@ -382,35 +360,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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', max_length=90, 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') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('AlertRuleList', pipeline_response) + deserialized = self._deserialize("AlertRuleList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -423,12 +397,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models.py index 419f5583f36f5..6d57041dde0c9 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models.py @@ -15,12 +15,12 @@ class ActionGroup(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param action_group_id: Required. The resource ID of the Action Group. This cannot be null or + :ivar action_group_id: Required. The resource ID of the Action Group. This cannot be null or empty. - :type action_group_id: str - :param webhook_properties: the dictionary of custom properties to include with the post + :vartype action_group_id: str + :ivar webhook_properties: the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. - :type webhook_properties: dict[str, str] + :vartype webhook_properties: dict[str, str] """ _validation = { @@ -36,6 +36,14 @@ def __init__( self, **kwargs ): + """ + :keyword action_group_id: Required. The resource ID of the Action Group. This cannot be null or + empty. + :paramtype action_group_id: str + :keyword webhook_properties: the dictionary of custom properties to include with the post + operation. These data are appended to the webhook payload. + :paramtype webhook_properties: dict[str, str] + """ super(ActionGroup, self).__init__(**kwargs) self.action_group_id = kwargs['action_group_id'] self.webhook_properties = kwargs.get('webhook_properties', None) @@ -44,8 +52,8 @@ def __init__( class ActionList(msrest.serialization.Model): """A list of Activity Log Alert rule actions. - :param action_groups: The list of the Action Groups. - :type action_groups: list[~$(python-base-namespace).v2020_10_01.models.ActionGroup] + :ivar action_groups: The list of the Action Groups. + :vartype action_groups: list[~$(python-base-namespace).v2020_10_01.models.ActionGroup] """ _attribute_map = { @@ -56,6 +64,10 @@ def __init__( self, **kwargs ): + """ + :keyword action_groups: The list of the Action Groups. + :paramtype action_groups: list[~$(python-base-namespace).v2020_10_01.models.ActionGroup] + """ super(ActionList, self).__init__(**kwargs) self.action_groups = kwargs.get('action_groups', None) @@ -71,11 +83,11 @@ class AzureResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. Since Azure Activity Log Alerts is a global + :ivar location: The location of the resource. Since Azure Activity Log Alerts is a global service, the location of the rules should always be 'global'. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _validation = { @@ -96,6 +108,13 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location of the resource. Since Azure Activity Log Alerts is a global + service, the location of the rules should always be 'global'. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(AzureResource, self).__init__(**kwargs) self.id = None self.name = None @@ -115,24 +134,24 @@ class ActivityLogAlertResource(AzureResource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. Since Azure Activity Log Alerts is a global + :ivar location: The location of the resource. Since Azure Activity Log Alerts is a global service, the location of the rules should always be 'global'. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param scopes: A list of resource IDs that will be used as prefixes. The alert will only apply + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar scopes: A list of resource IDs that will be used as prefixes. The alert will only apply to Activity Log events with resource IDs that fall under one of these prefixes. This list must include at least one item. - :type scopes: list[str] - :param condition: The condition that will cause this alert to activate. - :type condition: ~$(python-base-namespace).v2020_10_01.models.AlertRuleAllOfCondition - :param actions: The actions that will activate when the condition is met. - :type actions: ~$(python-base-namespace).v2020_10_01.models.ActionList - :param enabled: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log + :vartype scopes: list[str] + :ivar condition: The condition that will cause this alert to activate. + :vartype condition: ~$(python-base-namespace).v2020_10_01.models.AlertRuleAllOfCondition + :ivar actions: The actions that will activate when the condition is met. + :vartype actions: ~$(python-base-namespace).v2020_10_01.models.ActionList + :ivar enabled: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log Alert rule is not enabled, then none of its actions will be activated. - :type enabled: bool - :param description: A description of this Activity Log Alert rule. - :type description: str + :vartype enabled: bool + :ivar description: A description of this Activity Log Alert rule. + :vartype description: str """ _validation = { @@ -158,6 +177,26 @@ def __init__( self, **kwargs ): + """ + :keyword location: The location of the resource. Since Azure Activity Log Alerts is a global + service, the location of the rules should always be 'global'. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword scopes: A list of resource IDs that will be used as prefixes. The alert will only + apply to Activity Log events with resource IDs that fall under one of these prefixes. This list + must include at least one item. + :paramtype scopes: list[str] + :keyword condition: The condition that will cause this alert to activate. + :paramtype condition: ~$(python-base-namespace).v2020_10_01.models.AlertRuleAllOfCondition + :keyword actions: The actions that will activate when the condition is met. + :paramtype actions: ~$(python-base-namespace).v2020_10_01.models.ActionList + :keyword enabled: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log + Alert rule is not enabled, then none of its actions will be activated. + :paramtype enabled: bool + :keyword description: A description of this Activity Log Alert rule. + :paramtype description: str + """ super(ActivityLogAlertResource, self).__init__(**kwargs) self.scopes = kwargs.get('scopes', None) self.condition = kwargs.get('condition', None) @@ -171,8 +210,9 @@ class AlertRuleAllOfCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param all_of: Required. The list of Activity Log Alert rule conditions. - :type all_of: list[~$(python-base-namespace).v2020_10_01.models.AlertRuleAnyOfOrLeafCondition] + :ivar all_of: Required. The list of Activity Log Alert rule conditions. + :vartype all_of: + list[~$(python-base-namespace).v2020_10_01.models.AlertRuleAnyOfOrLeafCondition] """ _validation = { @@ -187,6 +227,11 @@ def __init__( self, **kwargs ): + """ + :keyword all_of: Required. The list of Activity Log Alert rule conditions. + :paramtype all_of: + list[~$(python-base-namespace).v2020_10_01.models.AlertRuleAnyOfOrLeafCondition] + """ super(AlertRuleAllOfCondition, self).__init__(**kwargs) self.all_of = kwargs['all_of'] @@ -195,17 +240,17 @@ class AlertRuleLeafCondition(msrest.serialization.Model): """An Activity Log Alert rule condition that is met by comparing the field and value of an Activity Log event. This condition must contain 'field' and either 'equals' or 'containsAny'. - :param field: The name of the Activity Log event's field that this condition will examine. + :ivar field: The name of the Activity Log event's field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties'. - :type field: str - :param equals: The value of the event's field will be compared to this value (case-insensitive) + :vartype field: str + :ivar equals: The value of the event's field will be compared to this value (case-insensitive) to determine if the condition is met. - :type equals: str - :param contains_any: The value of the event's field will be compared to the values in this - array (case-insensitive) to determine if the condition is met. - :type contains_any: list[str] + :vartype equals: str + :ivar contains_any: The value of the event's field will be compared to the values in this array + (case-insensitive) to determine if the condition is met. + :vartype contains_any: list[str] """ _attribute_map = { @@ -218,6 +263,19 @@ def __init__( self, **kwargs ): + """ + :keyword field: The name of the Activity Log event's field that this condition will examine. + The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', + 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', + 'resourceType', or anything beginning with 'properties'. + :paramtype field: str + :keyword equals: The value of the event's field will be compared to this value + (case-insensitive) to determine if the condition is met. + :paramtype equals: str + :keyword contains_any: The value of the event's field will be compared to the values in this + array (case-insensitive) to determine if the condition is met. + :paramtype contains_any: list[str] + """ super(AlertRuleLeafCondition, self).__init__(**kwargs) self.field = kwargs.get('field', None) self.equals = kwargs.get('equals', None) @@ -236,20 +294,20 @@ class AlertRuleAnyOfOrLeafCondition(AlertRuleLeafCondition): * **AnyOf Condition -** must contain **only** 'anyOf' (which is an array of Leaf Conditions). *Please note, 'field', 'equals' and 'containsAny' should **not** be set in an AnyOf Condition.*. - :param field: The name of the Activity Log event's field that this condition will examine. + :ivar field: The name of the Activity Log event's field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties'. - :type field: str - :param equals: The value of the event's field will be compared to this value (case-insensitive) + :vartype field: str + :ivar equals: The value of the event's field will be compared to this value (case-insensitive) to determine if the condition is met. - :type equals: str - :param contains_any: The value of the event's field will be compared to the values in this - array (case-insensitive) to determine if the condition is met. - :type contains_any: list[str] - :param any_of: An Activity Log Alert rule condition that is met when at least one of its member + :vartype equals: str + :ivar contains_any: The value of the event's field will be compared to the values in this array + (case-insensitive) to determine if the condition is met. + :vartype contains_any: list[str] + :ivar any_of: An Activity Log Alert rule condition that is met when at least one of its member leaf conditions are met. - :type any_of: list[~$(python-base-namespace).v2020_10_01.models.AlertRuleLeafCondition] + :vartype any_of: list[~$(python-base-namespace).v2020_10_01.models.AlertRuleLeafCondition] """ _attribute_map = { @@ -263,6 +321,22 @@ def __init__( self, **kwargs ): + """ + :keyword field: The name of the Activity Log event's field that this condition will examine. + The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', + 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', + 'resourceType', or anything beginning with 'properties'. + :paramtype field: str + :keyword equals: The value of the event's field will be compared to this value + (case-insensitive) to determine if the condition is met. + :paramtype equals: str + :keyword contains_any: The value of the event's field will be compared to the values in this + array (case-insensitive) to determine if the condition is met. + :paramtype contains_any: list[str] + :keyword any_of: An Activity Log Alert rule condition that is met when at least one of its + member leaf conditions are met. + :paramtype any_of: list[~$(python-base-namespace).v2020_10_01.models.AlertRuleLeafCondition] + """ super(AlertRuleAnyOfOrLeafCondition, self).__init__(**kwargs) self.any_of = kwargs.get('any_of', None) @@ -270,10 +344,10 @@ def __init__( class AlertRuleList(msrest.serialization.Model): """A list of Activity Log Alert rules. - :param value: The list of Activity Log Alert rules. - :type value: list[~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar value: The list of Activity Log Alert rules. + :vartype value: list[~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -285,6 +359,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of Activity Log Alert rules. + :paramtype value: list[~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(AlertRuleList, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -293,11 +373,11 @@ def __init__( class AlertRulePatchObject(msrest.serialization.Model): """An Activity Log Alert rule object for the body of patch operations. - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param enabled: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log Alert rule is not enabled, then none of its actions will be activated. - :type enabled: bool + :vartype enabled: bool """ _attribute_map = { @@ -309,6 +389,13 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log + Alert rule is not enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ super(AlertRulePatchObject, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.enabled = kwargs.get('enabled', True) @@ -339,6 +426,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models_py3.py index f6a14450917fb..f1101062bcca7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/models/_models_py3.py @@ -17,12 +17,12 @@ class ActionGroup(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param action_group_id: Required. The resource ID of the Action Group. This cannot be null or + :ivar action_group_id: Required. The resource ID of the Action Group. This cannot be null or empty. - :type action_group_id: str - :param webhook_properties: the dictionary of custom properties to include with the post + :vartype action_group_id: str + :ivar webhook_properties: the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload. - :type webhook_properties: dict[str, str] + :vartype webhook_properties: dict[str, str] """ _validation = { @@ -41,6 +41,14 @@ def __init__( webhook_properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword action_group_id: Required. The resource ID of the Action Group. This cannot be null or + empty. + :paramtype action_group_id: str + :keyword webhook_properties: the dictionary of custom properties to include with the post + operation. These data are appended to the webhook payload. + :paramtype webhook_properties: dict[str, str] + """ super(ActionGroup, self).__init__(**kwargs) self.action_group_id = action_group_id self.webhook_properties = webhook_properties @@ -49,8 +57,8 @@ def __init__( class ActionList(msrest.serialization.Model): """A list of Activity Log Alert rule actions. - :param action_groups: The list of the Action Groups. - :type action_groups: list[~$(python-base-namespace).v2020_10_01.models.ActionGroup] + :ivar action_groups: The list of the Action Groups. + :vartype action_groups: list[~$(python-base-namespace).v2020_10_01.models.ActionGroup] """ _attribute_map = { @@ -63,6 +71,10 @@ def __init__( action_groups: Optional[List["ActionGroup"]] = None, **kwargs ): + """ + :keyword action_groups: The list of the Action Groups. + :paramtype action_groups: list[~$(python-base-namespace).v2020_10_01.models.ActionGroup] + """ super(ActionList, self).__init__(**kwargs) self.action_groups = action_groups @@ -78,11 +90,11 @@ class AzureResource(msrest.serialization.Model): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. Since Azure Activity Log Alerts is a global + :ivar location: The location of the resource. Since Azure Activity Log Alerts is a global service, the location of the rules should always be 'global'. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] """ _validation = { @@ -106,6 +118,13 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: The location of the resource. Since Azure Activity Log Alerts is a global + service, the location of the rules should always be 'global'. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + """ super(AzureResource, self).__init__(**kwargs) self.id = None self.name = None @@ -125,24 +144,24 @@ class ActivityLogAlertResource(AzureResource): :vartype name: str :ivar type: The type of the resource. :vartype type: str - :param location: The location of the resource. Since Azure Activity Log Alerts is a global + :ivar location: The location of the resource. Since Azure Activity Log Alerts is a global service, the location of the rules should always be 'global'. - :type location: str - :param tags: A set of tags. The tags of the resource. - :type tags: dict[str, str] - :param scopes: A list of resource IDs that will be used as prefixes. The alert will only apply + :vartype location: str + :ivar tags: A set of tags. The tags of the resource. + :vartype tags: dict[str, str] + :ivar scopes: A list of resource IDs that will be used as prefixes. The alert will only apply to Activity Log events with resource IDs that fall under one of these prefixes. This list must include at least one item. - :type scopes: list[str] - :param condition: The condition that will cause this alert to activate. - :type condition: ~$(python-base-namespace).v2020_10_01.models.AlertRuleAllOfCondition - :param actions: The actions that will activate when the condition is met. - :type actions: ~$(python-base-namespace).v2020_10_01.models.ActionList - :param enabled: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log + :vartype scopes: list[str] + :ivar condition: The condition that will cause this alert to activate. + :vartype condition: ~$(python-base-namespace).v2020_10_01.models.AlertRuleAllOfCondition + :ivar actions: The actions that will activate when the condition is met. + :vartype actions: ~$(python-base-namespace).v2020_10_01.models.ActionList + :ivar enabled: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log Alert rule is not enabled, then none of its actions will be activated. - :type enabled: bool - :param description: A description of this Activity Log Alert rule. - :type description: str + :vartype enabled: bool + :ivar description: A description of this Activity Log Alert rule. + :vartype description: str """ _validation = { @@ -176,6 +195,26 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword location: The location of the resource. Since Azure Activity Log Alerts is a global + service, the location of the rules should always be 'global'. + :paramtype location: str + :keyword tags: A set of tags. The tags of the resource. + :paramtype tags: dict[str, str] + :keyword scopes: A list of resource IDs that will be used as prefixes. The alert will only + apply to Activity Log events with resource IDs that fall under one of these prefixes. This list + must include at least one item. + :paramtype scopes: list[str] + :keyword condition: The condition that will cause this alert to activate. + :paramtype condition: ~$(python-base-namespace).v2020_10_01.models.AlertRuleAllOfCondition + :keyword actions: The actions that will activate when the condition is met. + :paramtype actions: ~$(python-base-namespace).v2020_10_01.models.ActionList + :keyword enabled: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log + Alert rule is not enabled, then none of its actions will be activated. + :paramtype enabled: bool + :keyword description: A description of this Activity Log Alert rule. + :paramtype description: str + """ super(ActivityLogAlertResource, self).__init__(location=location, tags=tags, **kwargs) self.scopes = scopes self.condition = condition @@ -189,8 +228,9 @@ class AlertRuleAllOfCondition(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param all_of: Required. The list of Activity Log Alert rule conditions. - :type all_of: list[~$(python-base-namespace).v2020_10_01.models.AlertRuleAnyOfOrLeafCondition] + :ivar all_of: Required. The list of Activity Log Alert rule conditions. + :vartype all_of: + list[~$(python-base-namespace).v2020_10_01.models.AlertRuleAnyOfOrLeafCondition] """ _validation = { @@ -207,6 +247,11 @@ def __init__( all_of: List["AlertRuleAnyOfOrLeafCondition"], **kwargs ): + """ + :keyword all_of: Required. The list of Activity Log Alert rule conditions. + :paramtype all_of: + list[~$(python-base-namespace).v2020_10_01.models.AlertRuleAnyOfOrLeafCondition] + """ super(AlertRuleAllOfCondition, self).__init__(**kwargs) self.all_of = all_of @@ -215,17 +260,17 @@ class AlertRuleLeafCondition(msrest.serialization.Model): """An Activity Log Alert rule condition that is met by comparing the field and value of an Activity Log event. This condition must contain 'field' and either 'equals' or 'containsAny'. - :param field: The name of the Activity Log event's field that this condition will examine. + :ivar field: The name of the Activity Log event's field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties'. - :type field: str - :param equals: The value of the event's field will be compared to this value (case-insensitive) + :vartype field: str + :ivar equals: The value of the event's field will be compared to this value (case-insensitive) to determine if the condition is met. - :type equals: str - :param contains_any: The value of the event's field will be compared to the values in this - array (case-insensitive) to determine if the condition is met. - :type contains_any: list[str] + :vartype equals: str + :ivar contains_any: The value of the event's field will be compared to the values in this array + (case-insensitive) to determine if the condition is met. + :vartype contains_any: list[str] """ _attribute_map = { @@ -242,6 +287,19 @@ def __init__( contains_any: Optional[List[str]] = None, **kwargs ): + """ + :keyword field: The name of the Activity Log event's field that this condition will examine. + The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', + 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', + 'resourceType', or anything beginning with 'properties'. + :paramtype field: str + :keyword equals: The value of the event's field will be compared to this value + (case-insensitive) to determine if the condition is met. + :paramtype equals: str + :keyword contains_any: The value of the event's field will be compared to the values in this + array (case-insensitive) to determine if the condition is met. + :paramtype contains_any: list[str] + """ super(AlertRuleLeafCondition, self).__init__(**kwargs) self.field = field self.equals = equals @@ -260,20 +318,20 @@ class AlertRuleAnyOfOrLeafCondition(AlertRuleLeafCondition): * **AnyOf Condition -** must contain **only** 'anyOf' (which is an array of Leaf Conditions). *Please note, 'field', 'equals' and 'containsAny' should **not** be set in an AnyOf Condition.*. - :param field: The name of the Activity Log event's field that this condition will examine. + :ivar field: The name of the Activity Log event's field that this condition will examine. The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', 'resourceType', or anything beginning with 'properties'. - :type field: str - :param equals: The value of the event's field will be compared to this value (case-insensitive) + :vartype field: str + :ivar equals: The value of the event's field will be compared to this value (case-insensitive) to determine if the condition is met. - :type equals: str - :param contains_any: The value of the event's field will be compared to the values in this - array (case-insensitive) to determine if the condition is met. - :type contains_any: list[str] - :param any_of: An Activity Log Alert rule condition that is met when at least one of its member + :vartype equals: str + :ivar contains_any: The value of the event's field will be compared to the values in this array + (case-insensitive) to determine if the condition is met. + :vartype contains_any: list[str] + :ivar any_of: An Activity Log Alert rule condition that is met when at least one of its member leaf conditions are met. - :type any_of: list[~$(python-base-namespace).v2020_10_01.models.AlertRuleLeafCondition] + :vartype any_of: list[~$(python-base-namespace).v2020_10_01.models.AlertRuleLeafCondition] """ _attribute_map = { @@ -292,6 +350,22 @@ def __init__( any_of: Optional[List["AlertRuleLeafCondition"]] = None, **kwargs ): + """ + :keyword field: The name of the Activity Log event's field that this condition will examine. + The possible values for this field are (case-insensitive): 'resourceId', 'category', 'caller', + 'level', 'operationName', 'resourceGroup', 'resourceProvider', 'status', 'subStatus', + 'resourceType', or anything beginning with 'properties'. + :paramtype field: str + :keyword equals: The value of the event's field will be compared to this value + (case-insensitive) to determine if the condition is met. + :paramtype equals: str + :keyword contains_any: The value of the event's field will be compared to the values in this + array (case-insensitive) to determine if the condition is met. + :paramtype contains_any: list[str] + :keyword any_of: An Activity Log Alert rule condition that is met when at least one of its + member leaf conditions are met. + :paramtype any_of: list[~$(python-base-namespace).v2020_10_01.models.AlertRuleLeafCondition] + """ super(AlertRuleAnyOfOrLeafCondition, self).__init__(field=field, equals=equals, contains_any=contains_any, **kwargs) self.any_of = any_of @@ -299,10 +373,10 @@ def __init__( class AlertRuleList(msrest.serialization.Model): """A list of Activity Log Alert rules. - :param value: The list of Activity Log Alert rules. - :type value: list[~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar value: The list of Activity Log Alert rules. + :vartype value: list[~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -317,6 +391,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of Activity Log Alert rules. + :paramtype value: list[~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(AlertRuleList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -325,11 +405,11 @@ def __init__( class AlertRulePatchObject(msrest.serialization.Model): """An Activity Log Alert rule object for the body of patch operations. - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param enabled: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log Alert rule is not enabled, then none of its actions will be activated. - :type enabled: bool + :vartype enabled: bool """ _attribute_map = { @@ -344,6 +424,13 @@ def __init__( enabled: Optional[bool] = True, **kwargs ): + """ + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this Activity Log Alert rule is enabled. If an Activity Log + Alert rule is not enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ super(AlertRulePatchObject, self).__init__(**kwargs) self.tags = tags self.enabled = enabled @@ -374,6 +461,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py index 19e1ae46f59c2..f4bf1c659a037 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2020_10_01/operations/_activity_log_alerts_operations.py @@ -5,24 +5,250 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + subscription_id, # type: str + resource_group_name, # type: str + activity_log_alert_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_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, + **kwargs + ) + + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + activity_log_alert_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_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_delete_request( + subscription_id, # type: str + resource_group_name, # type: str + activity_log_alert_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_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, # type: str + resource_group_name, # type: str + activity_log_alert_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "activityLogAlertName": _SERIALIZER.url("activity_log_alert_name", activity_log_alert_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, + **kwargs + ) + + +def build_list_by_subscription_id_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts') + 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, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2020-10-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, 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 + ) + +# fmt: on class ActivityLogAlertsOperations(object): """ActivityLogAlertsOperations operations. @@ -45,6 +271,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -60,7 +287,8 @@ def create_or_update( :param activity_log_alert_name: The name of the Activity Log Alert rule. :type activity_log_alert_name: str :param activity_log_alert_rule: The Activity Log Alert rule to create or use for the update. - :type activity_log_alert_rule: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource + :type activity_log_alert_rule: + ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource :keyword callable cls: A custom type or function that will be passed the direct response :return: ActivityLogAlertResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource @@ -71,38 +299,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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', max_length=90, min_length=1), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(activity_log_alert_rule, 'ActivityLogAlertResource') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(activity_log_alert_rule, 'ActivityLogAlertResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -115,8 +333,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -140,33 +361,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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', max_length=90, min_length=1), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # 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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) @@ -175,8 +386,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -200,33 +414,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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', max_length=90, min_length=1), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # 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_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -234,6 +438,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -251,7 +457,8 @@ def update( :param activity_log_alert_name: The name of the Activity Log Alert rule. :type activity_log_alert_name: str :param activity_log_alert_rule_patch: Parameters supplied to the operation. - :type activity_log_alert_rule_patch: ~$(python-base-namespace).v2020_10_01.models.AlertRulePatchObject + :type activity_log_alert_rule_patch: + ~$(python-base-namespace).v2020_10_01.models.AlertRulePatchObject :keyword callable cls: A custom type or function that will be passed the direct response :return: ActivityLogAlertResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2020_10_01.models.ActivityLogAlertResource @@ -262,38 +469,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-01" - 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', max_length=90, min_length=1), - 'activityLogAlertName': self._serialize.url("activity_log_alert_name", activity_log_alert_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(activity_log_alert_rule_patch, 'AlertRulePatchObject') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + activity_log_alert_name=activity_log_alert_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(activity_log_alert_rule_patch, '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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActivityLogAlertResource', pipeline_response) @@ -302,8 +499,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}'} # type: ignore + + @distributed_trace def list_by_subscription_id( self, **kwargs # type: Any @@ -313,7 +513,8 @@ def list_by_subscription_id( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AlertRuleList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_10_01.models.AlertRuleList] + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_10_01.models.AlertRuleList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleList"] @@ -321,34 +522,29 @@ def list_by_subscription_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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_subscription_id.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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription_id.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_list_by_subscription_id_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('AlertRuleList', pipeline_response) + deserialized = self._deserialize("AlertRuleList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -361,17 +557,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/activityLogAlerts'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -384,7 +582,8 @@ def list_by_resource_group( :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 AlertRuleList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_10_01.models.AlertRuleList] + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2020_10_01.models.AlertRuleList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AlertRuleList"] @@ -392,35 +591,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-10-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', max_length=90, 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') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('AlertRuleList', pipeline_response) + deserialized = self._deserialize("AlertRuleList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -433,12 +628,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_configuration.py index 6c2b6a6fe818e..6a29f727d5f3f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_metadata.json index 257eaf0e018bb..b089e37d50b56 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "data_collection_endpoints": "DataCollectionEndpointsOperations", diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_monitor_management_client.py index c28a4128d4c60..32688b862d406 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_monitor_management_client.py @@ -6,83 +6,89 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import DataCollectionEndpointsOperations, DataCollectionRuleAssociationsOperations, DataCollectionRulesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import DataCollectionEndpointsOperations -from .operations import DataCollectionRuleAssociationsOperations -from .operations import DataCollectionRulesOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. :ivar data_collection_endpoints: DataCollectionEndpointsOperations operations - :vartype data_collection_endpoints: $(python-base-namespace).v2021_04_01.operations.DataCollectionEndpointsOperations + :vartype data_collection_endpoints: + $(python-base-namespace).v2021_04_01.operations.DataCollectionEndpointsOperations :ivar data_collection_rule_associations: DataCollectionRuleAssociationsOperations operations - :vartype data_collection_rule_associations: $(python-base-namespace).v2021_04_01.operations.DataCollectionRuleAssociationsOperations + :vartype data_collection_rule_associations: + $(python-base-namespace).v2021_04_01.operations.DataCollectionRuleAssociationsOperations :ivar data_collection_rules: DataCollectionRulesOperations operations - :vartype data_collection_rules: $(python-base-namespace).v2021_04_01.operations.DataCollectionRulesOperations + :vartype data_collection_rules: + $(python-base-namespace).v2021_04_01.operations.DataCollectionRulesOperations :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.data_collection_endpoints = DataCollectionEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_collection_rules = DataCollectionRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_collection_endpoints = DataCollectionEndpointsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.data_collection_rules = DataCollectionRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_configuration.py index cb6cdeab6de82..457603f1e0013 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_monitor_management_client.py index a18ea946eba9f..cc25115a9967c 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_monitor_management_client.py @@ -6,79 +6,85 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import DataCollectionEndpointsOperations, DataCollectionRuleAssociationsOperations, DataCollectionRulesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MonitorManagementClientConfiguration -from .operations import DataCollectionEndpointsOperations -from .operations import DataCollectionRuleAssociationsOperations -from .operations import DataCollectionRulesOperations -from .. import models - - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar data_collection_endpoints: DataCollectionEndpointsOperations operations - :vartype data_collection_endpoints: $(python-base-namespace).v2021_04_01.aio.operations.DataCollectionEndpointsOperations + :vartype data_collection_endpoints: + $(python-base-namespace).v2021_04_01.aio.operations.DataCollectionEndpointsOperations :ivar data_collection_rule_associations: DataCollectionRuleAssociationsOperations operations - :vartype data_collection_rule_associations: $(python-base-namespace).v2021_04_01.aio.operations.DataCollectionRuleAssociationsOperations + :vartype data_collection_rule_associations: + $(python-base-namespace).v2021_04_01.aio.operations.DataCollectionRuleAssociationsOperations :ivar data_collection_rules: DataCollectionRulesOperations operations - :vartype data_collection_rules: $(python-base-namespace).v2021_04_01.aio.operations.DataCollectionRulesOperations + :vartype data_collection_rules: + $(python-base-namespace).v2021_04_01.aio.operations.DataCollectionRulesOperations :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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.data_collection_endpoints = DataCollectionEndpointsOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.data_collection_rules = DataCollectionRulesOperations(self._client, self._config, self._serialize, self._deserialize) - self.data_collection_endpoints = DataCollectionEndpointsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.data_collection_rule_associations = DataCollectionRuleAssociationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.data_collection_rules = DataCollectionRulesOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_endpoints_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_endpoints_operations.py index 40fd39f48a974..dc284b81446b4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_endpoints_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_endpoints_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._data_collection_endpoints_operations import build_create_request, build_delete_request, build_get_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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -53,8 +59,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :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 DataCollectionEndpointResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResourceListResult] + :return: An iterator like instance of either DataCollectionEndpointResourceListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResourceListResult"] @@ -62,35 +70,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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', max_length=90, 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') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('DataCollectionEndpointResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,17 +107,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, 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.Insights/dataCollectionEndpoints'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -123,8 +129,10 @@ def list_by_subscription( Lists all data collection endpoints in the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionEndpointResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResourceListResult] + :return: An iterator like instance of either DataCollectionEndpointResourceListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResourceListResult"] @@ -132,34 +140,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('DataCollectionEndpointResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -172,17 +175,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, 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.Insights/dataCollectionEndpoints'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -208,33 +213,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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', max_length=90, min_length=1), - 'dataCollectionEndpointName': self._serialize.url("data_collection_endpoint_name", data_collection_endpoint_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 = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_endpoint_name=data_collection_endpoint_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) @@ -243,8 +238,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}'} # type: ignore + + @distributed_trace_async async def create( self, resource_group_name: str, @@ -273,41 +271,31 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.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', max_length=90, min_length=1), - 'dataCollectionEndpointName': self._serialize.url("data_collection_endpoint_name", data_collection_endpoint_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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] if body is not None: - body_content = self._serialize.body(body, 'DataCollectionEndpointResource') + _json = self._serialize.body(body, 'DataCollectionEndpointResource') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_endpoint_name=data_collection_endpoint_name, + content_type=content_type, + json=_json, + template_url=self.create.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.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -320,8 +308,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -350,41 +341,31 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - 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', max_length=90, min_length=1), - 'dataCollectionEndpointName': self._serialize.url("data_collection_endpoint_name", data_collection_endpoint_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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] if body is not None: - body_content = self._serialize.body(body, 'ResourceForUpdate') + _json = self._serialize.body(body, 'ResourceForUpdate') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_endpoint_name=data_collection_endpoint_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.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) @@ -393,8 +374,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -420,36 +404,27 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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', max_length=90, min_length=1), - 'dataCollectionEndpointName': self._serialize.url("data_collection_endpoint_name", data_collection_endpoint_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 = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_endpoint_name=data_collection_endpoint_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_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.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rule_associations_operations.py index 8cf71334c09ee..3492b8a74d5d8 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rule_associations_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rule_associations_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._data_collection_rule_associations_operations import build_create_request, build_delete_request, build_get_request, build_list_by_resource_request, build_list_by_rule_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 list_by_resource( self, resource_uri: str, @@ -53,8 +59,10 @@ def list_by_resource( :param resource_uri: The identifier of the resource. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + :return: An iterator like instance of either + DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] @@ -62,34 +70,29 @@ def list_by_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True, 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_request( + resource_uri=resource_uri, + template_url=self.list_by_resource.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_list_by_resource_request( + resource_uri=resource_uri, + 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('DataCollectionRuleAssociationProxyOnlyResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,17 +105,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations'} # type: ignore + @distributed_trace def list_by_rule( self, resource_group_name: str, @@ -129,8 +134,10 @@ def list_by_rule( insensitive. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + :return: An iterator like instance of either + DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] @@ -138,36 +145,33 @@ def list_by_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_rule.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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_rule_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_name, + template_url=self.list_by_rule.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_list_by_rule_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_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('DataCollectionRuleAssociationProxyOnlyResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -180,17 +184,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations'} # type: ignore + @distributed_trace_async async def get( self, resource_uri: str, @@ -207,7 +213,8 @@ async def get( :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource + :rtype: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] @@ -215,32 +222,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - 'associationName': self._serialize.url("association_name", association_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 = build_get_request( + resource_uri=resource_uri, + association_name=association_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) @@ -249,8 +246,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + + @distributed_trace_async async def create( self, resource_uri: str, @@ -267,10 +267,12 @@ async def create( :param association_name: The name of the association. The name is case insensitive. :type association_name: str :param body: The payload. - :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource + :type body: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource + :rtype: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] @@ -278,40 +280,30 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - 'associationName': self._serialize.url("association_name", association_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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] if body is not None: - body_content = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') + _json = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request( + resource_uri=resource_uri, + association_name=association_name, + content_type=content_type, + json=_json, + template_url=self.create.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.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -324,8 +316,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_uri: str, @@ -350,35 +345,26 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - 'associationName': self._serialize.url("association_name", association_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 = build_delete_request( + resource_uri=resource_uri, + association_name=association_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rules_operations.py index 9affad029e760..f888346fcd12b 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/aio/operations/_data_collection_rules_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._data_collection_rules_operations import build_create_request, build_delete_request, build_get_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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -53,8 +59,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :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 DataCollectionRuleResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResourceListResult] + :return: An iterator like instance of either DataCollectionRuleResourceListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] @@ -62,35 +70,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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', max_length=90, 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') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('DataCollectionRuleResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,17 +107,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, 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.Insights/dataCollectionRules'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -123,8 +129,10 @@ def list_by_subscription( Lists all data collection rules in the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResourceListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResourceListResult] + :return: An iterator like instance of either DataCollectionRuleResourceListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] @@ -132,34 +140,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('DataCollectionRuleResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -172,17 +175,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, 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.Insights/dataCollectionRules'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -208,33 +213,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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 = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) @@ -243,8 +238,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}'} # type: ignore + + @distributed_trace_async async def create( self, resource_group_name: str, @@ -273,41 +271,31 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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] if body is not None: - body_content = self._serialize.body(body, 'DataCollectionRuleResource') + _json = self._serialize.body(body, 'DataCollectionRuleResource') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_name, + content_type=content_type, + json=_json, + template_url=self.create.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.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -320,8 +308,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -350,41 +341,31 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - 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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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] if body is not None: - body_content = self._serialize.body(body, 'ResourceForUpdate') + _json = self._serialize.body(body, 'ResourceForUpdate') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_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.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) @@ -393,8 +374,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -420,36 +404,27 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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 = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_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.Insights/dataCollectionRules/{dataCollectionRuleName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models.py index ebdaea5727624..57b34be9c870d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models.py @@ -13,10 +13,10 @@ class AzureMonitorMetricsDestination(msrest.serialization.Model): """Azure Monitor Metrics destination. - :param name: A friendly name for the destination. + :ivar name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -27,6 +27,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: A friendly name for the destination. + This name should be unique across all destinations (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(AzureMonitorMetricsDestination, self).__init__(**kwargs) self.name = kwargs.get('name', None) @@ -52,6 +58,8 @@ def __init__( self, **kwargs ): + """ + """ super(ConfigurationAccessEndpointSpec, self).__init__(**kwargs) self.endpoint = None @@ -61,19 +69,19 @@ class DataCollectionEndpoint(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the data collection endpoint. - :type description: str - :param immutable_id: The immutable ID of this data collection endpoint resource. This property + :ivar description: Description of the data collection endpoint. + :vartype description: str + :ivar immutable_id: The immutable ID of this data collection endpoint resource. This property is READ-ONLY. - :type immutable_id: str - :param configuration_access: The endpoint used by agents to access their configuration. - :type configuration_access: + :vartype immutable_id: str + :ivar configuration_access: The endpoint used by agents to access their configuration. + :vartype configuration_access: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointConfigurationAccess - :param logs_ingestion: The endpoint used by clients to ingest logs. - :type logs_ingestion: + :ivar logs_ingestion: The endpoint used by clients to ingest logs. + :vartype logs_ingestion: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointLogsIngestion - :param network_acls: Network access control rules for the endpoints. - :type network_acls: + :ivar network_acls: Network access control rules for the endpoints. + :vartype network_acls: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". @@ -98,6 +106,22 @@ def __init__( self, **kwargs ): + """ + :keyword description: Description of the data collection endpoint. + :paramtype description: str + :keyword immutable_id: The immutable ID of this data collection endpoint resource. This + property is READ-ONLY. + :paramtype immutable_id: str + :keyword configuration_access: The endpoint used by agents to access their configuration. + :paramtype configuration_access: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointConfigurationAccess + :keyword logs_ingestion: The endpoint used by clients to ingest logs. + :paramtype logs_ingestion: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointLogsIngestion + :keyword network_acls: Network access control rules for the endpoints. + :paramtype network_acls: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls + """ super(DataCollectionEndpoint, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.immutable_id = kwargs.get('immutable_id', None) @@ -128,6 +152,8 @@ def __init__( self, **kwargs ): + """ + """ super(DataCollectionEndpointConfigurationAccess, self).__init__(**kwargs) @@ -152,6 +178,8 @@ def __init__( self, **kwargs ): + """ + """ super(LogsIngestionEndpointSpec, self).__init__(**kwargs) self.endpoint = None @@ -177,15 +205,17 @@ def __init__( self, **kwargs ): + """ + """ super(DataCollectionEndpointLogsIngestion, self).__init__(**kwargs) class NetworkRuleSet(msrest.serialization.Model): """Definition of the network rules. - :param public_network_access: The configuration to set whether network access from public + :ivar public_network_access: The configuration to set whether network access from public internet to the endpoints are allowed. Possible values include: "Enabled", "Disabled". - :type public_network_access: str or + :vartype public_network_access: str or ~$(python-base-namespace).v2021_04_01.models.KnownPublicNetworkAccessOptions """ @@ -197,6 +227,12 @@ def __init__( self, **kwargs ): + """ + :keyword public_network_access: The configuration to set whether network access from public + internet to the endpoints are allowed. Possible values include: "Enabled", "Disabled". + :paramtype public_network_access: str or + ~$(python-base-namespace).v2021_04_01.models.KnownPublicNetworkAccessOptions + """ super(NetworkRuleSet, self).__init__(**kwargs) self.public_network_access = kwargs.get('public_network_access', None) @@ -204,9 +240,9 @@ def __init__( class DataCollectionEndpointNetworkAcls(NetworkRuleSet): """Network access control rules for the endpoints. - :param public_network_access: The configuration to set whether network access from public + :ivar public_network_access: The configuration to set whether network access from public internet to the endpoints are allowed. Possible values include: "Enabled", "Disabled". - :type public_network_access: str or + :vartype public_network_access: str or ~$(python-base-namespace).v2021_04_01.models.KnownPublicNetworkAccessOptions """ @@ -218,6 +254,12 @@ def __init__( self, **kwargs ): + """ + :keyword public_network_access: The configuration to set whether network access from public + internet to the endpoints are allowed. Possible values include: "Enabled", "Disabled". + :paramtype public_network_access: str or + ~$(python-base-namespace).v2021_04_01.models.KnownPublicNetworkAccessOptions + """ super(DataCollectionEndpointNetworkAcls, self).__init__(**kwargs) @@ -228,12 +270,12 @@ class DataCollectionEndpointResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: The kind of the resource. Possible values include: "Linux", "Windows". - :type kind: str or + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: The kind of the resource. Possible values include: "Linux", "Windows". + :vartype kind: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionEndpointResourceKind :ivar id: Fully qualified ID of the resource. :vartype id: str @@ -246,19 +288,19 @@ class DataCollectionEndpointResource(msrest.serialization.Model): :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResourceSystemData - :param description: Description of the data collection endpoint. - :type description: str - :param immutable_id: The immutable ID of this data collection endpoint resource. This property + :ivar description: Description of the data collection endpoint. + :vartype description: str + :ivar immutable_id: The immutable ID of this data collection endpoint resource. This property is READ-ONLY. - :type immutable_id: str - :param configuration_access: The endpoint used by agents to access their configuration. - :type configuration_access: + :vartype immutable_id: str + :ivar configuration_access: The endpoint used by agents to access their configuration. + :vartype configuration_access: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointConfigurationAccess - :param logs_ingestion: The endpoint used by clients to ingest logs. - :type logs_ingestion: + :ivar logs_ingestion: The endpoint used by clients to ingest logs. + :vartype logs_ingestion: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointLogsIngestion - :param network_acls: Network access control rules for the endpoints. - :type network_acls: + :ivar network_acls: Network access control rules for the endpoints. + :vartype network_acls: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". @@ -297,6 +339,29 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: The kind of the resource. Possible values include: "Linux", "Windows". + :paramtype kind: str or + ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionEndpointResourceKind + :keyword description: Description of the data collection endpoint. + :paramtype description: str + :keyword immutable_id: The immutable ID of this data collection endpoint resource. This + property is READ-ONLY. + :paramtype immutable_id: str + :keyword configuration_access: The endpoint used by agents to access their configuration. + :paramtype configuration_access: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointConfigurationAccess + :keyword logs_ingestion: The endpoint used by clients to ingest logs. + :paramtype logs_ingestion: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointLogsIngestion + :keyword network_acls: Network access control rules for the endpoints. + :paramtype network_acls: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls + """ super(DataCollectionEndpointResource, self).__init__(**kwargs) self.location = kwargs['location'] self.tags = kwargs.get('tags', None) @@ -319,10 +384,11 @@ class DataCollectionEndpointResourceListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. A list of resources. - :type value: list[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: Required. A list of resources. + :vartype value: + list[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -338,6 +404,13 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. A list of resources. + :paramtype value: + list[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(DataCollectionEndpointResourceListResult, self).__init__(**kwargs) self.value = kwargs['value'] self.next_link = kwargs.get('next_link', None) @@ -348,19 +421,19 @@ class DataCollectionEndpointResourceProperties(DataCollectionEndpoint): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the data collection endpoint. - :type description: str - :param immutable_id: The immutable ID of this data collection endpoint resource. This property + :ivar description: Description of the data collection endpoint. + :vartype description: str + :ivar immutable_id: The immutable ID of this data collection endpoint resource. This property is READ-ONLY. - :type immutable_id: str - :param configuration_access: The endpoint used by agents to access their configuration. - :type configuration_access: + :vartype immutable_id: str + :ivar configuration_access: The endpoint used by agents to access their configuration. + :vartype configuration_access: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointConfigurationAccess - :param logs_ingestion: The endpoint used by clients to ingest logs. - :type logs_ingestion: + :ivar logs_ingestion: The endpoint used by clients to ingest logs. + :vartype logs_ingestion: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointLogsIngestion - :param network_acls: Network access control rules for the endpoints. - :type network_acls: + :ivar network_acls: Network access control rules for the endpoints. + :vartype network_acls: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". @@ -385,26 +458,43 @@ def __init__( self, **kwargs ): + """ + :keyword description: Description of the data collection endpoint. + :paramtype description: str + :keyword immutable_id: The immutable ID of this data collection endpoint resource. This + property is READ-ONLY. + :paramtype immutable_id: str + :keyword configuration_access: The endpoint used by agents to access their configuration. + :paramtype configuration_access: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointConfigurationAccess + :keyword logs_ingestion: The endpoint used by clients to ingest logs. + :paramtype logs_ingestion: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointLogsIngestion + :keyword network_acls: Network access control rules for the endpoints. + :paramtype network_acls: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls + """ super(DataCollectionEndpointResourceProperties, self).__init__(**kwargs) class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :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 ~$(python-base-namespace).v2021_04_01.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 + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :vartype last_modified_by_type: str or + ~$(python-base-namespace).v2021_04_01.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -420,6 +510,23 @@ def __init__( self, **kwargs ): + """ + :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 ~$(python-base-namespace).v2021_04_01.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 + ~$(python-base-namespace).v2021_04_01.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 = kwargs.get('created_by', None) self.created_by_type = kwargs.get('created_by_type', None) @@ -432,20 +539,21 @@ def __init__( class DataCollectionEndpointResourceSystemData(SystemData): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :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 ~$(python-base-namespace).v2021_04_01.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 + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :vartype last_modified_by_type: str or + ~$(python-base-namespace).v2021_04_01.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -461,6 +569,23 @@ def __init__( self, **kwargs ): + """ + :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 ~$(python-base-namespace).v2021_04_01.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 + ~$(python-base-namespace).v2021_04_01.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(DataCollectionEndpointResourceSystemData, self).__init__(**kwargs) @@ -469,18 +594,20 @@ class DataCollectionRule(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the data collection rule. - :type description: str + :ivar description: Description of the data collection rule. + :vartype description: str :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. :vartype immutable_id: str - :param data_sources: The specification of data sources. + :ivar data_sources: The specification of data sources. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :type data_sources: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDataSources - :param destinations: The specification of destinations. - :type destinations: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations - :param data_flows: The specification of data flows. - :type data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] + :vartype data_sources: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDataSources + :ivar destinations: The specification of destinations. + :vartype destinations: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations + :ivar data_flows: The specification of data flows. + :vartype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -505,6 +632,20 @@ def __init__( self, **kwargs ): + """ + :keyword description: Description of the data collection rule. + :paramtype description: str + :keyword data_sources: The specification of data sources. + This property is optional and can be omitted if the rule is meant to be used via direct calls + to the provisioned endpoint. + :paramtype data_sources: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDataSources + :keyword destinations: The specification of destinations. + :paramtype destinations: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations + :keyword data_flows: The specification of data flows. + :paramtype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] + """ super(DataCollectionRule, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.immutable_id = None @@ -519,14 +660,14 @@ class DataCollectionRuleAssociation(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the association. - :type description: str - :param data_collection_rule_id: The resource ID of the data collection rule that is to be + :ivar description: Description of the association. + :vartype description: str + :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be associated. - :type data_collection_rule_id: str - :param data_collection_endpoint_id: The resource ID of the data collection endpoint that is to + :vartype data_collection_rule_id: str + :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to be associated. - :type data_collection_endpoint_id: str + :vartype data_collection_endpoint_id: str :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -548,6 +689,16 @@ def __init__( self, **kwargs ): + """ + :keyword description: Description of the association. + :paramtype description: str + :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be + associated. + :paramtype data_collection_rule_id: str + :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that is + to be associated. + :paramtype data_collection_endpoint_id: str + """ super(DataCollectionRuleAssociation, self).__init__(**kwargs) self.description = kwargs.get('description', None) self.data_collection_rule_id = kwargs.get('data_collection_rule_id', None) @@ -571,14 +722,14 @@ class DataCollectionRuleAssociationProxyOnlyResource(msrest.serialization.Model) :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceSystemData - :param description: Description of the association. - :type description: str - :param data_collection_rule_id: The resource ID of the data collection rule that is to be + :ivar description: Description of the association. + :vartype description: str + :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be associated. - :type data_collection_rule_id: str - :param data_collection_endpoint_id: The resource ID of the data collection endpoint that is to + :vartype data_collection_rule_id: str + :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to be associated. - :type data_collection_endpoint_id: str + :vartype data_collection_endpoint_id: str :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -610,6 +761,16 @@ def __init__( self, **kwargs ): + """ + :keyword description: Description of the association. + :paramtype description: str + :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be + associated. + :paramtype data_collection_rule_id: str + :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that is + to be associated. + :paramtype data_collection_endpoint_id: str + """ super(DataCollectionRuleAssociationProxyOnlyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -627,11 +788,11 @@ class DataCollectionRuleAssociationProxyOnlyResourceListResult(msrest.serializat All required parameters must be populated in order to send to Azure. - :param value: Required. A list of resources. - :type value: + :ivar value: Required. A list of resources. + :vartype value: list[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -647,6 +808,13 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. A list of resources. + :paramtype value: + list[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(DataCollectionRuleAssociationProxyOnlyResourceListResult, self).__init__(**kwargs) self.value = kwargs['value'] self.next_link = kwargs.get('next_link', None) @@ -657,14 +825,14 @@ class DataCollectionRuleAssociationProxyOnlyResourceProperties(DataCollectionRul Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the association. - :type description: str - :param data_collection_rule_id: The resource ID of the data collection rule that is to be + :ivar description: Description of the association. + :vartype description: str + :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be associated. - :type data_collection_rule_id: str - :param data_collection_endpoint_id: The resource ID of the data collection endpoint that is to + :vartype data_collection_rule_id: str + :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to be associated. - :type data_collection_endpoint_id: str + :vartype data_collection_endpoint_id: str :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -686,26 +854,37 @@ def __init__( self, **kwargs ): + """ + :keyword description: Description of the association. + :paramtype description: str + :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be + associated. + :paramtype data_collection_rule_id: str + :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that is + to be associated. + :paramtype data_collection_endpoint_id: str + """ super(DataCollectionRuleAssociationProxyOnlyResourceProperties, self).__init__(**kwargs) class DataCollectionRuleAssociationProxyOnlyResourceSystemData(SystemData): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :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 ~$(python-base-namespace).v2021_04_01.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 + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :vartype last_modified_by_type: str or + ~$(python-base-namespace).v2021_04_01.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -721,22 +900,39 @@ def __init__( self, **kwargs ): + """ + :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 ~$(python-base-namespace).v2021_04_01.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 + ~$(python-base-namespace).v2021_04_01.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(DataCollectionRuleAssociationProxyOnlyResourceSystemData, self).__init__(**kwargs) class DataSourcesSpec(msrest.serialization.Model): """Specification of data sources that will be collected. - :param performance_counters: The list of performance counter data source configurations. - :type performance_counters: + :ivar performance_counters: The list of performance counter data source configurations. + :vartype performance_counters: list[~$(python-base-namespace).v2021_04_01.models.PerfCounterDataSource] - :param windows_event_logs: The list of Windows Event Log data source configurations. - :type windows_event_logs: + :ivar windows_event_logs: The list of Windows Event Log data source configurations. + :vartype windows_event_logs: list[~$(python-base-namespace).v2021_04_01.models.WindowsEventLogDataSource] - :param syslog: The list of Syslog data source configurations. - :type syslog: list[~$(python-base-namespace).v2021_04_01.models.SyslogDataSource] - :param extensions: The list of Azure VM extension data source configurations. - :type extensions: list[~$(python-base-namespace).v2021_04_01.models.ExtensionDataSource] + :ivar syslog: The list of Syslog data source configurations. + :vartype syslog: list[~$(python-base-namespace).v2021_04_01.models.SyslogDataSource] + :ivar extensions: The list of Azure VM extension data source configurations. + :vartype extensions: list[~$(python-base-namespace).v2021_04_01.models.ExtensionDataSource] """ _attribute_map = { @@ -750,6 +946,18 @@ def __init__( self, **kwargs ): + """ + :keyword performance_counters: The list of performance counter data source configurations. + :paramtype performance_counters: + list[~$(python-base-namespace).v2021_04_01.models.PerfCounterDataSource] + :keyword windows_event_logs: The list of Windows Event Log data source configurations. + :paramtype windows_event_logs: + list[~$(python-base-namespace).v2021_04_01.models.WindowsEventLogDataSource] + :keyword syslog: The list of Syslog data source configurations. + :paramtype syslog: list[~$(python-base-namespace).v2021_04_01.models.SyslogDataSource] + :keyword extensions: The list of Azure VM extension data source configurations. + :paramtype extensions: list[~$(python-base-namespace).v2021_04_01.models.ExtensionDataSource] + """ super(DataSourcesSpec, self).__init__(**kwargs) self.performance_counters = kwargs.get('performance_counters', None) self.windows_event_logs = kwargs.get('windows_event_logs', None) @@ -761,16 +969,16 @@ class DataCollectionRuleDataSources(DataSourcesSpec): """The specification of data sources. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :param performance_counters: The list of performance counter data source configurations. - :type performance_counters: + :ivar performance_counters: The list of performance counter data source configurations. + :vartype performance_counters: list[~$(python-base-namespace).v2021_04_01.models.PerfCounterDataSource] - :param windows_event_logs: The list of Windows Event Log data source configurations. - :type windows_event_logs: + :ivar windows_event_logs: The list of Windows Event Log data source configurations. + :vartype windows_event_logs: list[~$(python-base-namespace).v2021_04_01.models.WindowsEventLogDataSource] - :param syslog: The list of Syslog data source configurations. - :type syslog: list[~$(python-base-namespace).v2021_04_01.models.SyslogDataSource] - :param extensions: The list of Azure VM extension data source configurations. - :type extensions: list[~$(python-base-namespace).v2021_04_01.models.ExtensionDataSource] + :ivar syslog: The list of Syslog data source configurations. + :vartype syslog: list[~$(python-base-namespace).v2021_04_01.models.SyslogDataSource] + :ivar extensions: The list of Azure VM extension data source configurations. + :vartype extensions: list[~$(python-base-namespace).v2021_04_01.models.ExtensionDataSource] """ _attribute_map = { @@ -784,16 +992,29 @@ def __init__( self, **kwargs ): + """ + :keyword performance_counters: The list of performance counter data source configurations. + :paramtype performance_counters: + list[~$(python-base-namespace).v2021_04_01.models.PerfCounterDataSource] + :keyword windows_event_logs: The list of Windows Event Log data source configurations. + :paramtype windows_event_logs: + list[~$(python-base-namespace).v2021_04_01.models.WindowsEventLogDataSource] + :keyword syslog: The list of Syslog data source configurations. + :paramtype syslog: list[~$(python-base-namespace).v2021_04_01.models.SyslogDataSource] + :keyword extensions: The list of Azure VM extension data source configurations. + :paramtype extensions: list[~$(python-base-namespace).v2021_04_01.models.ExtensionDataSource] + """ super(DataCollectionRuleDataSources, self).__init__(**kwargs) class DestinationsSpec(msrest.serialization.Model): """Specification of destinations that can be used in data flows. - :param log_analytics: List of Log Analytics destinations. - :type log_analytics: list[~$(python-base-namespace).v2021_04_01.models.LogAnalyticsDestination] - :param azure_monitor_metrics: Azure Monitor Metrics destination. - :type azure_monitor_metrics: + :ivar log_analytics: List of Log Analytics destinations. + :vartype log_analytics: + list[~$(python-base-namespace).v2021_04_01.models.LogAnalyticsDestination] + :ivar azure_monitor_metrics: Azure Monitor Metrics destination. + :vartype azure_monitor_metrics: ~$(python-base-namespace).v2021_04_01.models.DestinationsSpecAzureMonitorMetrics """ @@ -806,6 +1027,14 @@ def __init__( self, **kwargs ): + """ + :keyword log_analytics: List of Log Analytics destinations. + :paramtype log_analytics: + list[~$(python-base-namespace).v2021_04_01.models.LogAnalyticsDestination] + :keyword azure_monitor_metrics: Azure Monitor Metrics destination. + :paramtype azure_monitor_metrics: + ~$(python-base-namespace).v2021_04_01.models.DestinationsSpecAzureMonitorMetrics + """ super(DestinationsSpec, self).__init__(**kwargs) self.log_analytics = kwargs.get('log_analytics', None) self.azure_monitor_metrics = kwargs.get('azure_monitor_metrics', None) @@ -814,10 +1043,11 @@ def __init__( class DataCollectionRuleDestinations(DestinationsSpec): """The specification of destinations. - :param log_analytics: List of Log Analytics destinations. - :type log_analytics: list[~$(python-base-namespace).v2021_04_01.models.LogAnalyticsDestination] - :param azure_monitor_metrics: Azure Monitor Metrics destination. - :type azure_monitor_metrics: + :ivar log_analytics: List of Log Analytics destinations. + :vartype log_analytics: + list[~$(python-base-namespace).v2021_04_01.models.LogAnalyticsDestination] + :ivar azure_monitor_metrics: Azure Monitor Metrics destination. + :vartype azure_monitor_metrics: ~$(python-base-namespace).v2021_04_01.models.DestinationsSpecAzureMonitorMetrics """ @@ -830,6 +1060,14 @@ def __init__( self, **kwargs ): + """ + :keyword log_analytics: List of Log Analytics destinations. + :paramtype log_analytics: + list[~$(python-base-namespace).v2021_04_01.models.LogAnalyticsDestination] + :keyword azure_monitor_metrics: Azure Monitor Metrics destination. + :paramtype azure_monitor_metrics: + ~$(python-base-namespace).v2021_04_01.models.DestinationsSpecAzureMonitorMetrics + """ super(DataCollectionRuleDestinations, self).__init__(**kwargs) @@ -840,12 +1078,12 @@ class DataCollectionRuleResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: The kind of the resource. Possible values include: "Linux", "Windows". - :type kind: str or + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: The kind of the resource. Possible values include: "Linux", "Windows". + :vartype kind: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleResourceKind :ivar id: Fully qualified ID of the resource. :vartype id: str @@ -858,18 +1096,20 @@ class DataCollectionRuleResource(msrest.serialization.Model): :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResourceSystemData - :param description: Description of the data collection rule. - :type description: str + :ivar description: Description of the data collection rule. + :vartype description: str :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. :vartype immutable_id: str - :param data_sources: The specification of data sources. + :ivar data_sources: The specification of data sources. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :type data_sources: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDataSources - :param destinations: The specification of destinations. - :type destinations: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations - :param data_flows: The specification of data flows. - :type data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] + :vartype data_sources: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDataSources + :ivar destinations: The specification of destinations. + :vartype destinations: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations + :ivar data_flows: The specification of data flows. + :vartype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -908,6 +1148,27 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: The kind of the resource. Possible values include: "Linux", "Windows". + :paramtype kind: str or + ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleResourceKind + :keyword description: Description of the data collection rule. + :paramtype description: str + :keyword data_sources: The specification of data sources. + This property is optional and can be omitted if the rule is meant to be used via direct calls + to the provisioned endpoint. + :paramtype data_sources: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDataSources + :keyword destinations: The specification of destinations. + :paramtype destinations: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations + :keyword data_flows: The specification of data flows. + :paramtype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] + """ super(DataCollectionRuleResource, self).__init__(**kwargs) self.location = kwargs['location'] self.tags = kwargs.get('tags', None) @@ -930,10 +1191,10 @@ class DataCollectionRuleResourceListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. A list of resources. - :type value: list[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: Required. A list of resources. + :vartype value: list[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -949,6 +1210,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. A list of resources. + :paramtype value: list[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(DataCollectionRuleResourceListResult, self).__init__(**kwargs) self.value = kwargs['value'] self.next_link = kwargs.get('next_link', None) @@ -959,18 +1226,20 @@ class DataCollectionRuleResourceProperties(DataCollectionRule): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the data collection rule. - :type description: str + :ivar description: Description of the data collection rule. + :vartype description: str :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. :vartype immutable_id: str - :param data_sources: The specification of data sources. + :ivar data_sources: The specification of data sources. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :type data_sources: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDataSources - :param destinations: The specification of destinations. - :type destinations: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations - :param data_flows: The specification of data flows. - :type data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] + :vartype data_sources: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDataSources + :ivar destinations: The specification of destinations. + :vartype destinations: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations + :ivar data_flows: The specification of data flows. + :vartype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -995,26 +1264,41 @@ def __init__( self, **kwargs ): + """ + :keyword description: Description of the data collection rule. + :paramtype description: str + :keyword data_sources: The specification of data sources. + This property is optional and can be omitted if the rule is meant to be used via direct calls + to the provisioned endpoint. + :paramtype data_sources: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDataSources + :keyword destinations: The specification of destinations. + :paramtype destinations: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations + :keyword data_flows: The specification of data flows. + :paramtype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] + """ super(DataCollectionRuleResourceProperties, self).__init__(**kwargs) class DataCollectionRuleResourceSystemData(SystemData): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :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 ~$(python-base-namespace).v2021_04_01.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 + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :vartype last_modified_by_type: str or + ~$(python-base-namespace).v2021_04_01.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -1030,16 +1314,34 @@ def __init__( self, **kwargs ): + """ + :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 ~$(python-base-namespace).v2021_04_01.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 + ~$(python-base-namespace).v2021_04_01.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(DataCollectionRuleResourceSystemData, self).__init__(**kwargs) class DataFlow(msrest.serialization.Model): """Definition of which streams are sent to which destinations. - :param streams: List of streams for this data flow. - :type streams: list[str or ~$(python-base-namespace).v2021_04_01.models.KnownDataFlowStreams] - :param destinations: List of destinations for this data flow. - :type destinations: list[str] + :ivar streams: List of streams for this data flow. + :vartype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownDataFlowStreams] + :ivar destinations: List of destinations for this data flow. + :vartype destinations: list[str] """ _attribute_map = { @@ -1051,6 +1353,13 @@ def __init__( self, **kwargs ): + """ + :keyword streams: List of streams for this data flow. + :paramtype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownDataFlowStreams] + :keyword destinations: List of destinations for this data flow. + :paramtype destinations: list[str] + """ super(DataFlow, self).__init__(**kwargs) self.streams = kwargs.get('streams', None) self.destinations = kwargs.get('destinations', None) @@ -1059,10 +1368,10 @@ def __init__( class DestinationsSpecAzureMonitorMetrics(AzureMonitorMetricsDestination): """Azure Monitor Metrics destination. - :param name: A friendly name for the destination. + :ivar name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -1073,6 +1382,12 @@ def __init__( self, **kwargs ): + """ + :keyword name: A friendly name for the destination. + This name should be unique across all destinations (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(DestinationsSpecAzureMonitorMetrics, self).__init__(**kwargs) @@ -1101,6 +1416,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -1144,6 +1461,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -1155,8 +1474,8 @@ def __init__( class ErrorResponseCommonV2(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~$(python-base-namespace).v2021_04_01.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~$(python-base-namespace).v2021_04_01.models.ErrorDetail """ _attribute_map = { @@ -1167,6 +1486,10 @@ def __init__( self, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~$(python-base-namespace).v2021_04_01.models.ErrorDetail + """ super(ErrorResponseCommonV2, self).__init__(**kwargs) self.error = kwargs.get('error', None) @@ -1177,22 +1500,22 @@ class ExtensionDataSource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param streams: List of streams that this data source will be sent to. + :ivar streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. - :type streams: list[str or + :vartype streams: list[str or ~$(python-base-namespace).v2021_04_01.models.KnownExtensionDataSourceStreams] - :param extension_name: Required. The name of the VM extension. - :type extension_name: str - :param extension_settings: The extension settings. The format is specific for particular + :ivar extension_name: Required. The name of the VM extension. + :vartype extension_name: str + :ivar extension_settings: The extension settings. The format is specific for particular extension. - :type extension_settings: any - :param input_data_sources: The list of data sources this extension needs data from. - :type input_data_sources: list[str] - :param name: A friendly name for the data source. + :vartype extension_settings: any + :ivar input_data_sources: The list of data sources this extension needs data from. + :vartype input_data_sources: list[str] + :ivar name: A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _validation = { @@ -1211,6 +1534,24 @@ def __init__( self, **kwargs ): + """ + :keyword streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :paramtype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownExtensionDataSourceStreams] + :keyword extension_name: Required. The name of the VM extension. + :paramtype extension_name: str + :keyword extension_settings: The extension settings. The format is specific for particular + extension. + :paramtype extension_settings: any + :keyword input_data_sources: The list of data sources this extension needs data from. + :paramtype input_data_sources: list[str] + :keyword name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(ExtensionDataSource, self).__init__(**kwargs) self.streams = kwargs.get('streams', None) self.extension_name = kwargs['extension_name'] @@ -1224,14 +1565,14 @@ class LogAnalyticsDestination(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param workspace_resource_id: The resource ID of the Log Analytics workspace. - :type workspace_resource_id: str + :ivar workspace_resource_id: The resource ID of the Log Analytics workspace. + :vartype workspace_resource_id: str :ivar workspace_id: The Customer ID of the Log Analytics workspace. :vartype workspace_id: str - :param name: A friendly name for the destination. + :ivar name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _validation = { @@ -1248,6 +1589,14 @@ def __init__( self, **kwargs ): + """ + :keyword workspace_resource_id: The resource ID of the Log Analytics workspace. + :paramtype workspace_resource_id: str + :keyword name: A friendly name for the destination. + This name should be unique across all destinations (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(LogAnalyticsDestination, self).__init__(**kwargs) self.workspace_resource_id = kwargs.get('workspace_resource_id', None) self.workspace_id = None @@ -1258,23 +1607,23 @@ class PerfCounterDataSource(msrest.serialization.Model): """Definition of which performance counters will be collected and how they will be collected by this data collection rule. Collected from both Windows and Linux machines where the counter is present. - :param streams: List of streams that this data source will be sent to. + :ivar streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. - :type streams: list[str or + :vartype streams: list[str or ~$(python-base-namespace).v2021_04_01.models.KnownPerfCounterDataSourceStreams] - :param sampling_frequency_in_seconds: The number of seconds between consecutive counter + :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter measurements (samples). - :type sampling_frequency_in_seconds: int - :param counter_specifiers: A list of specifier names of the performance counters you want to + :vartype sampling_frequency_in_seconds: int + :ivar counter_specifiers: A list of specifier names of the performance counters you want to collect. Use a wildcard (*) to collect a counter for all instances. To get a list of performance counters on Windows, run the command 'typeperf'. - :type counter_specifiers: list[str] - :param name: A friendly name for the data source. + :vartype counter_specifiers: list[str] + :ivar name: A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -1288,6 +1637,25 @@ def __init__( self, **kwargs ): + """ + :keyword streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :paramtype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownPerfCounterDataSourceStreams] + :keyword sampling_frequency_in_seconds: The number of seconds between consecutive counter + measurements (samples). + :paramtype sampling_frequency_in_seconds: int + :keyword counter_specifiers: A list of specifier names of the performance counters you want to + collect. + Use a wildcard (*) to collect a counter for all instances. + To get a list of performance counters on Windows, run the command 'typeperf'. + :paramtype counter_specifiers: list[str] + :keyword name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(PerfCounterDataSource, self).__init__(**kwargs) self.streams = kwargs.get('streams', None) self.sampling_frequency_in_seconds = kwargs.get('sampling_frequency_in_seconds', None) @@ -1298,8 +1666,8 @@ def __init__( class ResourceForUpdate(msrest.serialization.Model): """Definition of ARM tracked top level resource properties for update operation. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1310,6 +1678,10 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(ResourceForUpdate, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) @@ -1318,21 +1690,21 @@ class SyslogDataSource(msrest.serialization.Model): """Definition of which syslog data will be collected and how it will be collected. Only collected from Linux machines. - :param streams: List of streams that this data source will be sent to. + :ivar streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. - :type streams: list[str or + :vartype streams: list[str or ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceStreams] - :param facility_names: The list of facility names. - :type facility_names: list[str or + :ivar facility_names: The list of facility names. + :vartype facility_names: list[str or ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceFacilityNames] - :param log_levels: The log levels to collect. - :type log_levels: list[str or + :ivar log_levels: The log levels to collect. + :vartype log_levels: list[str or ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceLogLevels] - :param name: A friendly name for the data source. + :ivar name: A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -1346,6 +1718,23 @@ def __init__( self, **kwargs ): + """ + :keyword streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :paramtype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceStreams] + :keyword facility_names: The list of facility names. + :paramtype facility_names: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceFacilityNames] + :keyword log_levels: The log levels to collect. + :paramtype log_levels: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceLogLevels] + :keyword name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(SyslogDataSource, self).__init__(**kwargs) self.streams = kwargs.get('streams', None) self.facility_names = kwargs.get('facility_names', None) @@ -1357,17 +1746,17 @@ class WindowsEventLogDataSource(msrest.serialization.Model): """Definition of which Windows Event Log events will be collected and how they will be collected. Only collected from Windows machines. - :param streams: List of streams that this data source will be sent to. + :ivar streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. - :type streams: list[str or + :vartype streams: list[str or ~$(python-base-namespace).v2021_04_01.models.KnownWindowsEventLogDataSourceStreams] - :param x_path_queries: A list of Windows Event Log queries in XPATH format. - :type x_path_queries: list[str] - :param name: A friendly name for the data source. + :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. + :vartype x_path_queries: list[str] + :ivar name: A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -1380,6 +1769,19 @@ def __init__( self, **kwargs ): + """ + :keyword streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :paramtype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownWindowsEventLogDataSourceStreams] + :keyword x_path_queries: A list of Windows Event Log queries in XPATH format. + :paramtype x_path_queries: list[str] + :keyword name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(WindowsEventLogDataSource, self).__init__(**kwargs) self.streams = kwargs.get('streams', None) self.x_path_queries = kwargs.get('x_path_queries', None) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models_py3.py index b0edf7f37ce69..5fbd1e5708995 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_models_py3.py @@ -18,10 +18,10 @@ class AzureMonitorMetricsDestination(msrest.serialization.Model): """Azure Monitor Metrics destination. - :param name: A friendly name for the destination. + :ivar name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -34,6 +34,12 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: A friendly name for the destination. + This name should be unique across all destinations (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(AzureMonitorMetricsDestination, self).__init__(**kwargs) self.name = name @@ -59,6 +65,8 @@ def __init__( self, **kwargs ): + """ + """ super(ConfigurationAccessEndpointSpec, self).__init__(**kwargs) self.endpoint = None @@ -68,19 +76,19 @@ class DataCollectionEndpoint(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the data collection endpoint. - :type description: str - :param immutable_id: The immutable ID of this data collection endpoint resource. This property + :ivar description: Description of the data collection endpoint. + :vartype description: str + :ivar immutable_id: The immutable ID of this data collection endpoint resource. This property is READ-ONLY. - :type immutable_id: str - :param configuration_access: The endpoint used by agents to access their configuration. - :type configuration_access: + :vartype immutable_id: str + :ivar configuration_access: The endpoint used by agents to access their configuration. + :vartype configuration_access: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointConfigurationAccess - :param logs_ingestion: The endpoint used by clients to ingest logs. - :type logs_ingestion: + :ivar logs_ingestion: The endpoint used by clients to ingest logs. + :vartype logs_ingestion: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointLogsIngestion - :param network_acls: Network access control rules for the endpoints. - :type network_acls: + :ivar network_acls: Network access control rules for the endpoints. + :vartype network_acls: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". @@ -111,6 +119,22 @@ def __init__( network_acls: Optional["DataCollectionEndpointNetworkAcls"] = None, **kwargs ): + """ + :keyword description: Description of the data collection endpoint. + :paramtype description: str + :keyword immutable_id: The immutable ID of this data collection endpoint resource. This + property is READ-ONLY. + :paramtype immutable_id: str + :keyword configuration_access: The endpoint used by agents to access their configuration. + :paramtype configuration_access: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointConfigurationAccess + :keyword logs_ingestion: The endpoint used by clients to ingest logs. + :paramtype logs_ingestion: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointLogsIngestion + :keyword network_acls: Network access control rules for the endpoints. + :paramtype network_acls: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls + """ super(DataCollectionEndpoint, self).__init__(**kwargs) self.description = description self.immutable_id = immutable_id @@ -141,6 +165,8 @@ def __init__( self, **kwargs ): + """ + """ super(DataCollectionEndpointConfigurationAccess, self).__init__(**kwargs) @@ -165,6 +191,8 @@ def __init__( self, **kwargs ): + """ + """ super(LogsIngestionEndpointSpec, self).__init__(**kwargs) self.endpoint = None @@ -190,15 +218,17 @@ def __init__( self, **kwargs ): + """ + """ super(DataCollectionEndpointLogsIngestion, self).__init__(**kwargs) class NetworkRuleSet(msrest.serialization.Model): """Definition of the network rules. - :param public_network_access: The configuration to set whether network access from public + :ivar public_network_access: The configuration to set whether network access from public internet to the endpoints are allowed. Possible values include: "Enabled", "Disabled". - :type public_network_access: str or + :vartype public_network_access: str or ~$(python-base-namespace).v2021_04_01.models.KnownPublicNetworkAccessOptions """ @@ -212,6 +242,12 @@ def __init__( public_network_access: Optional[Union[str, "KnownPublicNetworkAccessOptions"]] = None, **kwargs ): + """ + :keyword public_network_access: The configuration to set whether network access from public + internet to the endpoints are allowed. Possible values include: "Enabled", "Disabled". + :paramtype public_network_access: str or + ~$(python-base-namespace).v2021_04_01.models.KnownPublicNetworkAccessOptions + """ super(NetworkRuleSet, self).__init__(**kwargs) self.public_network_access = public_network_access @@ -219,9 +255,9 @@ def __init__( class DataCollectionEndpointNetworkAcls(NetworkRuleSet): """Network access control rules for the endpoints. - :param public_network_access: The configuration to set whether network access from public + :ivar public_network_access: The configuration to set whether network access from public internet to the endpoints are allowed. Possible values include: "Enabled", "Disabled". - :type public_network_access: str or + :vartype public_network_access: str or ~$(python-base-namespace).v2021_04_01.models.KnownPublicNetworkAccessOptions """ @@ -235,6 +271,12 @@ def __init__( public_network_access: Optional[Union[str, "KnownPublicNetworkAccessOptions"]] = None, **kwargs ): + """ + :keyword public_network_access: The configuration to set whether network access from public + internet to the endpoints are allowed. Possible values include: "Enabled", "Disabled". + :paramtype public_network_access: str or + ~$(python-base-namespace).v2021_04_01.models.KnownPublicNetworkAccessOptions + """ super(DataCollectionEndpointNetworkAcls, self).__init__(public_network_access=public_network_access, **kwargs) @@ -245,12 +287,12 @@ class DataCollectionEndpointResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: The kind of the resource. Possible values include: "Linux", "Windows". - :type kind: str or + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: The kind of the resource. Possible values include: "Linux", "Windows". + :vartype kind: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionEndpointResourceKind :ivar id: Fully qualified ID of the resource. :vartype id: str @@ -263,19 +305,19 @@ class DataCollectionEndpointResource(msrest.serialization.Model): :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResourceSystemData - :param description: Description of the data collection endpoint. - :type description: str - :param immutable_id: The immutable ID of this data collection endpoint resource. This property + :ivar description: Description of the data collection endpoint. + :vartype description: str + :ivar immutable_id: The immutable ID of this data collection endpoint resource. This property is READ-ONLY. - :type immutable_id: str - :param configuration_access: The endpoint used by agents to access their configuration. - :type configuration_access: + :vartype immutable_id: str + :ivar configuration_access: The endpoint used by agents to access their configuration. + :vartype configuration_access: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointConfigurationAccess - :param logs_ingestion: The endpoint used by clients to ingest logs. - :type logs_ingestion: + :ivar logs_ingestion: The endpoint used by clients to ingest logs. + :vartype logs_ingestion: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointLogsIngestion - :param network_acls: Network access control rules for the endpoints. - :type network_acls: + :ivar network_acls: Network access control rules for the endpoints. + :vartype network_acls: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". @@ -323,6 +365,29 @@ def __init__( network_acls: Optional["DataCollectionEndpointNetworkAcls"] = None, **kwargs ): + """ + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: The kind of the resource. Possible values include: "Linux", "Windows". + :paramtype kind: str or + ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionEndpointResourceKind + :keyword description: Description of the data collection endpoint. + :paramtype description: str + :keyword immutable_id: The immutable ID of this data collection endpoint resource. This + property is READ-ONLY. + :paramtype immutable_id: str + :keyword configuration_access: The endpoint used by agents to access their configuration. + :paramtype configuration_access: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointConfigurationAccess + :keyword logs_ingestion: The endpoint used by clients to ingest logs. + :paramtype logs_ingestion: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointLogsIngestion + :keyword network_acls: Network access control rules for the endpoints. + :paramtype network_acls: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls + """ super(DataCollectionEndpointResource, self).__init__(**kwargs) self.location = location self.tags = tags @@ -345,10 +410,11 @@ class DataCollectionEndpointResourceListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. A list of resources. - :type value: list[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: Required. A list of resources. + :vartype value: + list[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -367,6 +433,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. A list of resources. + :paramtype value: + list[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResource] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(DataCollectionEndpointResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -377,19 +450,19 @@ class DataCollectionEndpointResourceProperties(DataCollectionEndpoint): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the data collection endpoint. - :type description: str - :param immutable_id: The immutable ID of this data collection endpoint resource. This property + :ivar description: Description of the data collection endpoint. + :vartype description: str + :ivar immutable_id: The immutable ID of this data collection endpoint resource. This property is READ-ONLY. - :type immutable_id: str - :param configuration_access: The endpoint used by agents to access their configuration. - :type configuration_access: + :vartype immutable_id: str + :ivar configuration_access: The endpoint used by agents to access their configuration. + :vartype configuration_access: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointConfigurationAccess - :param logs_ingestion: The endpoint used by clients to ingest logs. - :type logs_ingestion: + :ivar logs_ingestion: The endpoint used by clients to ingest logs. + :vartype logs_ingestion: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointLogsIngestion - :param network_acls: Network access control rules for the endpoints. - :type network_acls: + :ivar network_acls: Network access control rules for the endpoints. + :vartype network_acls: ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls :ivar provisioning_state: The resource provisioning state. This property is READ-ONLY. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". @@ -420,26 +493,43 @@ def __init__( network_acls: Optional["DataCollectionEndpointNetworkAcls"] = None, **kwargs ): + """ + :keyword description: Description of the data collection endpoint. + :paramtype description: str + :keyword immutable_id: The immutable ID of this data collection endpoint resource. This + property is READ-ONLY. + :paramtype immutable_id: str + :keyword configuration_access: The endpoint used by agents to access their configuration. + :paramtype configuration_access: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointConfigurationAccess + :keyword logs_ingestion: The endpoint used by clients to ingest logs. + :paramtype logs_ingestion: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointLogsIngestion + :keyword network_acls: Network access control rules for the endpoints. + :paramtype network_acls: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointNetworkAcls + """ super(DataCollectionEndpointResourceProperties, self).__init__(description=description, immutable_id=immutable_id, configuration_access=configuration_access, logs_ingestion=logs_ingestion, network_acls=network_acls, **kwargs) class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :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 ~$(python-base-namespace).v2021_04_01.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 + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :vartype last_modified_by_type: str or + ~$(python-base-namespace).v2021_04_01.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -462,6 +552,23 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :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 ~$(python-base-namespace).v2021_04_01.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 + ~$(python-base-namespace).v2021_04_01.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 @@ -474,20 +581,21 @@ def __init__( class DataCollectionEndpointResourceSystemData(SystemData): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :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 ~$(python-base-namespace).v2021_04_01.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 + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :vartype last_modified_by_type: str or + ~$(python-base-namespace).v2021_04_01.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -510,6 +618,23 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :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 ~$(python-base-namespace).v2021_04_01.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 + ~$(python-base-namespace).v2021_04_01.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(DataCollectionEndpointResourceSystemData, self).__init__(created_by=created_by, created_by_type=created_by_type, created_at=created_at, last_modified_by=last_modified_by, last_modified_by_type=last_modified_by_type, last_modified_at=last_modified_at, **kwargs) @@ -518,18 +643,20 @@ class DataCollectionRule(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the data collection rule. - :type description: str + :ivar description: Description of the data collection rule. + :vartype description: str :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. :vartype immutable_id: str - :param data_sources: The specification of data sources. + :ivar data_sources: The specification of data sources. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :type data_sources: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDataSources - :param destinations: The specification of destinations. - :type destinations: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations - :param data_flows: The specification of data flows. - :type data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] + :vartype data_sources: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDataSources + :ivar destinations: The specification of destinations. + :vartype destinations: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations + :ivar data_flows: The specification of data flows. + :vartype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -559,6 +686,20 @@ def __init__( data_flows: Optional[List["DataFlow"]] = None, **kwargs ): + """ + :keyword description: Description of the data collection rule. + :paramtype description: str + :keyword data_sources: The specification of data sources. + This property is optional and can be omitted if the rule is meant to be used via direct calls + to the provisioned endpoint. + :paramtype data_sources: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDataSources + :keyword destinations: The specification of destinations. + :paramtype destinations: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations + :keyword data_flows: The specification of data flows. + :paramtype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] + """ super(DataCollectionRule, self).__init__(**kwargs) self.description = description self.immutable_id = None @@ -573,14 +714,14 @@ class DataCollectionRuleAssociation(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the association. - :type description: str - :param data_collection_rule_id: The resource ID of the data collection rule that is to be + :ivar description: Description of the association. + :vartype description: str + :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be associated. - :type data_collection_rule_id: str - :param data_collection_endpoint_id: The resource ID of the data collection endpoint that is to + :vartype data_collection_rule_id: str + :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to be associated. - :type data_collection_endpoint_id: str + :vartype data_collection_endpoint_id: str :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -606,6 +747,16 @@ def __init__( data_collection_endpoint_id: Optional[str] = None, **kwargs ): + """ + :keyword description: Description of the association. + :paramtype description: str + :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be + associated. + :paramtype data_collection_rule_id: str + :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that is + to be associated. + :paramtype data_collection_endpoint_id: str + """ super(DataCollectionRuleAssociation, self).__init__(**kwargs) self.description = description self.data_collection_rule_id = data_collection_rule_id @@ -629,14 +780,14 @@ class DataCollectionRuleAssociationProxyOnlyResource(msrest.serialization.Model) :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceSystemData - :param description: Description of the association. - :type description: str - :param data_collection_rule_id: The resource ID of the data collection rule that is to be + :ivar description: Description of the association. + :vartype description: str + :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be associated. - :type data_collection_rule_id: str - :param data_collection_endpoint_id: The resource ID of the data collection endpoint that is to + :vartype data_collection_rule_id: str + :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to be associated. - :type data_collection_endpoint_id: str + :vartype data_collection_endpoint_id: str :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -672,6 +823,16 @@ def __init__( data_collection_endpoint_id: Optional[str] = None, **kwargs ): + """ + :keyword description: Description of the association. + :paramtype description: str + :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be + associated. + :paramtype data_collection_rule_id: str + :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that is + to be associated. + :paramtype data_collection_endpoint_id: str + """ super(DataCollectionRuleAssociationProxyOnlyResource, self).__init__(**kwargs) self.id = None self.name = None @@ -689,11 +850,11 @@ class DataCollectionRuleAssociationProxyOnlyResourceListResult(msrest.serializat All required parameters must be populated in order to send to Azure. - :param value: Required. A list of resources. - :type value: + :ivar value: Required. A list of resources. + :vartype value: list[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -712,6 +873,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. A list of resources. + :paramtype value: + list[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(DataCollectionRuleAssociationProxyOnlyResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -722,14 +890,14 @@ class DataCollectionRuleAssociationProxyOnlyResourceProperties(DataCollectionRul Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the association. - :type description: str - :param data_collection_rule_id: The resource ID of the data collection rule that is to be + :ivar description: Description of the association. + :vartype description: str + :ivar data_collection_rule_id: The resource ID of the data collection rule that is to be associated. - :type data_collection_rule_id: str - :param data_collection_endpoint_id: The resource ID of the data collection endpoint that is to + :vartype data_collection_rule_id: str + :ivar data_collection_endpoint_id: The resource ID of the data collection endpoint that is to be associated. - :type data_collection_endpoint_id: str + :vartype data_collection_endpoint_id: str :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -755,26 +923,37 @@ def __init__( data_collection_endpoint_id: Optional[str] = None, **kwargs ): + """ + :keyword description: Description of the association. + :paramtype description: str + :keyword data_collection_rule_id: The resource ID of the data collection rule that is to be + associated. + :paramtype data_collection_rule_id: str + :keyword data_collection_endpoint_id: The resource ID of the data collection endpoint that is + to be associated. + :paramtype data_collection_endpoint_id: str + """ super(DataCollectionRuleAssociationProxyOnlyResourceProperties, self).__init__(description=description, data_collection_rule_id=data_collection_rule_id, data_collection_endpoint_id=data_collection_endpoint_id, **kwargs) class DataCollectionRuleAssociationProxyOnlyResourceSystemData(SystemData): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :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 ~$(python-base-namespace).v2021_04_01.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 + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :vartype last_modified_by_type: str or + ~$(python-base-namespace).v2021_04_01.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -797,22 +976,39 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :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 ~$(python-base-namespace).v2021_04_01.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 + ~$(python-base-namespace).v2021_04_01.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(DataCollectionRuleAssociationProxyOnlyResourceSystemData, self).__init__(created_by=created_by, created_by_type=created_by_type, created_at=created_at, last_modified_by=last_modified_by, last_modified_by_type=last_modified_by_type, last_modified_at=last_modified_at, **kwargs) class DataSourcesSpec(msrest.serialization.Model): """Specification of data sources that will be collected. - :param performance_counters: The list of performance counter data source configurations. - :type performance_counters: + :ivar performance_counters: The list of performance counter data source configurations. + :vartype performance_counters: list[~$(python-base-namespace).v2021_04_01.models.PerfCounterDataSource] - :param windows_event_logs: The list of Windows Event Log data source configurations. - :type windows_event_logs: + :ivar windows_event_logs: The list of Windows Event Log data source configurations. + :vartype windows_event_logs: list[~$(python-base-namespace).v2021_04_01.models.WindowsEventLogDataSource] - :param syslog: The list of Syslog data source configurations. - :type syslog: list[~$(python-base-namespace).v2021_04_01.models.SyslogDataSource] - :param extensions: The list of Azure VM extension data source configurations. - :type extensions: list[~$(python-base-namespace).v2021_04_01.models.ExtensionDataSource] + :ivar syslog: The list of Syslog data source configurations. + :vartype syslog: list[~$(python-base-namespace).v2021_04_01.models.SyslogDataSource] + :ivar extensions: The list of Azure VM extension data source configurations. + :vartype extensions: list[~$(python-base-namespace).v2021_04_01.models.ExtensionDataSource] """ _attribute_map = { @@ -831,6 +1027,18 @@ def __init__( extensions: Optional[List["ExtensionDataSource"]] = None, **kwargs ): + """ + :keyword performance_counters: The list of performance counter data source configurations. + :paramtype performance_counters: + list[~$(python-base-namespace).v2021_04_01.models.PerfCounterDataSource] + :keyword windows_event_logs: The list of Windows Event Log data source configurations. + :paramtype windows_event_logs: + list[~$(python-base-namespace).v2021_04_01.models.WindowsEventLogDataSource] + :keyword syslog: The list of Syslog data source configurations. + :paramtype syslog: list[~$(python-base-namespace).v2021_04_01.models.SyslogDataSource] + :keyword extensions: The list of Azure VM extension data source configurations. + :paramtype extensions: list[~$(python-base-namespace).v2021_04_01.models.ExtensionDataSource] + """ super(DataSourcesSpec, self).__init__(**kwargs) self.performance_counters = performance_counters self.windows_event_logs = windows_event_logs @@ -842,16 +1050,16 @@ class DataCollectionRuleDataSources(DataSourcesSpec): """The specification of data sources. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :param performance_counters: The list of performance counter data source configurations. - :type performance_counters: + :ivar performance_counters: The list of performance counter data source configurations. + :vartype performance_counters: list[~$(python-base-namespace).v2021_04_01.models.PerfCounterDataSource] - :param windows_event_logs: The list of Windows Event Log data source configurations. - :type windows_event_logs: + :ivar windows_event_logs: The list of Windows Event Log data source configurations. + :vartype windows_event_logs: list[~$(python-base-namespace).v2021_04_01.models.WindowsEventLogDataSource] - :param syslog: The list of Syslog data source configurations. - :type syslog: list[~$(python-base-namespace).v2021_04_01.models.SyslogDataSource] - :param extensions: The list of Azure VM extension data source configurations. - :type extensions: list[~$(python-base-namespace).v2021_04_01.models.ExtensionDataSource] + :ivar syslog: The list of Syslog data source configurations. + :vartype syslog: list[~$(python-base-namespace).v2021_04_01.models.SyslogDataSource] + :ivar extensions: The list of Azure VM extension data source configurations. + :vartype extensions: list[~$(python-base-namespace).v2021_04_01.models.ExtensionDataSource] """ _attribute_map = { @@ -870,16 +1078,29 @@ def __init__( extensions: Optional[List["ExtensionDataSource"]] = None, **kwargs ): + """ + :keyword performance_counters: The list of performance counter data source configurations. + :paramtype performance_counters: + list[~$(python-base-namespace).v2021_04_01.models.PerfCounterDataSource] + :keyword windows_event_logs: The list of Windows Event Log data source configurations. + :paramtype windows_event_logs: + list[~$(python-base-namespace).v2021_04_01.models.WindowsEventLogDataSource] + :keyword syslog: The list of Syslog data source configurations. + :paramtype syslog: list[~$(python-base-namespace).v2021_04_01.models.SyslogDataSource] + :keyword extensions: The list of Azure VM extension data source configurations. + :paramtype extensions: list[~$(python-base-namespace).v2021_04_01.models.ExtensionDataSource] + """ super(DataCollectionRuleDataSources, self).__init__(performance_counters=performance_counters, windows_event_logs=windows_event_logs, syslog=syslog, extensions=extensions, **kwargs) class DestinationsSpec(msrest.serialization.Model): """Specification of destinations that can be used in data flows. - :param log_analytics: List of Log Analytics destinations. - :type log_analytics: list[~$(python-base-namespace).v2021_04_01.models.LogAnalyticsDestination] - :param azure_monitor_metrics: Azure Monitor Metrics destination. - :type azure_monitor_metrics: + :ivar log_analytics: List of Log Analytics destinations. + :vartype log_analytics: + list[~$(python-base-namespace).v2021_04_01.models.LogAnalyticsDestination] + :ivar azure_monitor_metrics: Azure Monitor Metrics destination. + :vartype azure_monitor_metrics: ~$(python-base-namespace).v2021_04_01.models.DestinationsSpecAzureMonitorMetrics """ @@ -895,6 +1116,14 @@ def __init__( azure_monitor_metrics: Optional["DestinationsSpecAzureMonitorMetrics"] = None, **kwargs ): + """ + :keyword log_analytics: List of Log Analytics destinations. + :paramtype log_analytics: + list[~$(python-base-namespace).v2021_04_01.models.LogAnalyticsDestination] + :keyword azure_monitor_metrics: Azure Monitor Metrics destination. + :paramtype azure_monitor_metrics: + ~$(python-base-namespace).v2021_04_01.models.DestinationsSpecAzureMonitorMetrics + """ super(DestinationsSpec, self).__init__(**kwargs) self.log_analytics = log_analytics self.azure_monitor_metrics = azure_monitor_metrics @@ -903,10 +1132,11 @@ def __init__( class DataCollectionRuleDestinations(DestinationsSpec): """The specification of destinations. - :param log_analytics: List of Log Analytics destinations. - :type log_analytics: list[~$(python-base-namespace).v2021_04_01.models.LogAnalyticsDestination] - :param azure_monitor_metrics: Azure Monitor Metrics destination. - :type azure_monitor_metrics: + :ivar log_analytics: List of Log Analytics destinations. + :vartype log_analytics: + list[~$(python-base-namespace).v2021_04_01.models.LogAnalyticsDestination] + :ivar azure_monitor_metrics: Azure Monitor Metrics destination. + :vartype azure_monitor_metrics: ~$(python-base-namespace).v2021_04_01.models.DestinationsSpecAzureMonitorMetrics """ @@ -922,6 +1152,14 @@ def __init__( azure_monitor_metrics: Optional["DestinationsSpecAzureMonitorMetrics"] = None, **kwargs ): + """ + :keyword log_analytics: List of Log Analytics destinations. + :paramtype log_analytics: + list[~$(python-base-namespace).v2021_04_01.models.LogAnalyticsDestination] + :keyword azure_monitor_metrics: Azure Monitor Metrics destination. + :paramtype azure_monitor_metrics: + ~$(python-base-namespace).v2021_04_01.models.DestinationsSpecAzureMonitorMetrics + """ super(DataCollectionRuleDestinations, self).__init__(log_analytics=log_analytics, azure_monitor_metrics=azure_monitor_metrics, **kwargs) @@ -932,12 +1170,12 @@ class DataCollectionRuleResource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param location: Required. The geo-location where the resource lives. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param kind: The kind of the resource. Possible values include: "Linux", "Windows". - :type kind: str or + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar kind: The kind of the resource. Possible values include: "Linux", "Windows". + :vartype kind: str or ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleResourceKind :ivar id: Fully qualified ID of the resource. :vartype id: str @@ -950,18 +1188,20 @@ class DataCollectionRuleResource(msrest.serialization.Model): :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResourceSystemData - :param description: Description of the data collection rule. - :type description: str + :ivar description: Description of the data collection rule. + :vartype description: str :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. :vartype immutable_id: str - :param data_sources: The specification of data sources. + :ivar data_sources: The specification of data sources. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :type data_sources: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDataSources - :param destinations: The specification of destinations. - :type destinations: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations - :param data_flows: The specification of data flows. - :type data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] + :vartype data_sources: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDataSources + :ivar destinations: The specification of destinations. + :vartype destinations: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations + :ivar data_flows: The specification of data flows. + :vartype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -1008,6 +1248,27 @@ def __init__( data_flows: Optional[List["DataFlow"]] = None, **kwargs ): + """ + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword kind: The kind of the resource. Possible values include: "Linux", "Windows". + :paramtype kind: str or + ~$(python-base-namespace).v2021_04_01.models.KnownDataCollectionRuleResourceKind + :keyword description: Description of the data collection rule. + :paramtype description: str + :keyword data_sources: The specification of data sources. + This property is optional and can be omitted if the rule is meant to be used via direct calls + to the provisioned endpoint. + :paramtype data_sources: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDataSources + :keyword destinations: The specification of destinations. + :paramtype destinations: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations + :keyword data_flows: The specification of data flows. + :paramtype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] + """ super(DataCollectionRuleResource, self).__init__(**kwargs) self.location = location self.tags = tags @@ -1030,10 +1291,10 @@ class DataCollectionRuleResourceListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. A list of resources. - :type value: list[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource] - :param next_link: The URL to use for getting the next set of results. - :type next_link: str + :ivar value: Required. A list of resources. + :vartype value: list[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource] + :ivar next_link: The URL to use for getting the next set of results. + :vartype next_link: str """ _validation = { @@ -1052,6 +1313,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. A list of resources. + :paramtype value: list[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResource] + :keyword next_link: The URL to use for getting the next set of results. + :paramtype next_link: str + """ super(DataCollectionRuleResourceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -1062,18 +1329,20 @@ class DataCollectionRuleResourceProperties(DataCollectionRule): Variables are only populated by the server, and will be ignored when sending a request. - :param description: Description of the data collection rule. - :type description: str + :ivar description: Description of the data collection rule. + :vartype description: str :ivar immutable_id: The immutable ID of this data collection rule. This property is READ-ONLY. :vartype immutable_id: str - :param data_sources: The specification of data sources. + :ivar data_sources: The specification of data sources. This property is optional and can be omitted if the rule is meant to be used via direct calls to the provisioned endpoint. - :type data_sources: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDataSources - :param destinations: The specification of destinations. - :type destinations: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations - :param data_flows: The specification of data flows. - :type data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] + :vartype data_sources: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDataSources + :ivar destinations: The specification of destinations. + :vartype destinations: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations + :ivar data_flows: The specification of data flows. + :vartype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] :ivar provisioning_state: The resource provisioning state. Possible values include: "Creating", "Updating", "Deleting", "Succeeded", "Failed". :vartype provisioning_state: str or @@ -1103,26 +1372,41 @@ def __init__( data_flows: Optional[List["DataFlow"]] = None, **kwargs ): + """ + :keyword description: Description of the data collection rule. + :paramtype description: str + :keyword data_sources: The specification of data sources. + This property is optional and can be omitted if the rule is meant to be used via direct calls + to the provisioned endpoint. + :paramtype data_sources: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDataSources + :keyword destinations: The specification of destinations. + :paramtype destinations: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleDestinations + :keyword data_flows: The specification of data flows. + :paramtype data_flows: list[~$(python-base-namespace).v2021_04_01.models.DataFlow] + """ super(DataCollectionRuleResourceProperties, self).__init__(description=description, data_sources=data_sources, destinations=destinations, data_flows=data_flows, **kwargs) class DataCollectionRuleResourceSystemData(SystemData): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :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 ~$(python-base-namespace).v2021_04_01.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 + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~$(python-base-namespace).v2021_04_01.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :vartype last_modified_by_type: str or + ~$(python-base-namespace).v2021_04_01.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -1145,16 +1429,34 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :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 ~$(python-base-namespace).v2021_04_01.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 + ~$(python-base-namespace).v2021_04_01.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(DataCollectionRuleResourceSystemData, self).__init__(created_by=created_by, created_by_type=created_by_type, created_at=created_at, last_modified_by=last_modified_by, last_modified_by_type=last_modified_by_type, last_modified_at=last_modified_at, **kwargs) class DataFlow(msrest.serialization.Model): """Definition of which streams are sent to which destinations. - :param streams: List of streams for this data flow. - :type streams: list[str or ~$(python-base-namespace).v2021_04_01.models.KnownDataFlowStreams] - :param destinations: List of destinations for this data flow. - :type destinations: list[str] + :ivar streams: List of streams for this data flow. + :vartype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownDataFlowStreams] + :ivar destinations: List of destinations for this data flow. + :vartype destinations: list[str] """ _attribute_map = { @@ -1169,6 +1471,13 @@ def __init__( destinations: Optional[List[str]] = None, **kwargs ): + """ + :keyword streams: List of streams for this data flow. + :paramtype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownDataFlowStreams] + :keyword destinations: List of destinations for this data flow. + :paramtype destinations: list[str] + """ super(DataFlow, self).__init__(**kwargs) self.streams = streams self.destinations = destinations @@ -1177,10 +1486,10 @@ def __init__( class DestinationsSpecAzureMonitorMetrics(AzureMonitorMetricsDestination): """Azure Monitor Metrics destination. - :param name: A friendly name for the destination. + :ivar name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -1193,6 +1502,12 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: A friendly name for the destination. + This name should be unique across all destinations (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(DestinationsSpecAzureMonitorMetrics, self).__init__(name=name, **kwargs) @@ -1221,6 +1536,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -1264,6 +1581,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -1275,8 +1594,8 @@ def __init__( class ErrorResponseCommonV2(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~$(python-base-namespace).v2021_04_01.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~$(python-base-namespace).v2021_04_01.models.ErrorDetail """ _attribute_map = { @@ -1289,6 +1608,10 @@ def __init__( error: Optional["ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~$(python-base-namespace).v2021_04_01.models.ErrorDetail + """ super(ErrorResponseCommonV2, self).__init__(**kwargs) self.error = error @@ -1299,22 +1622,22 @@ class ExtensionDataSource(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param streams: List of streams that this data source will be sent to. + :ivar streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. - :type streams: list[str or + :vartype streams: list[str or ~$(python-base-namespace).v2021_04_01.models.KnownExtensionDataSourceStreams] - :param extension_name: Required. The name of the VM extension. - :type extension_name: str - :param extension_settings: The extension settings. The format is specific for particular + :ivar extension_name: Required. The name of the VM extension. + :vartype extension_name: str + :ivar extension_settings: The extension settings. The format is specific for particular extension. - :type extension_settings: any - :param input_data_sources: The list of data sources this extension needs data from. - :type input_data_sources: list[str] - :param name: A friendly name for the data source. + :vartype extension_settings: any + :ivar input_data_sources: The list of data sources this extension needs data from. + :vartype input_data_sources: list[str] + :ivar name: A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _validation = { @@ -1339,6 +1662,24 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :paramtype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownExtensionDataSourceStreams] + :keyword extension_name: Required. The name of the VM extension. + :paramtype extension_name: str + :keyword extension_settings: The extension settings. The format is specific for particular + extension. + :paramtype extension_settings: any + :keyword input_data_sources: The list of data sources this extension needs data from. + :paramtype input_data_sources: list[str] + :keyword name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(ExtensionDataSource, self).__init__(**kwargs) self.streams = streams self.extension_name = extension_name @@ -1352,14 +1693,14 @@ class LogAnalyticsDestination(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param workspace_resource_id: The resource ID of the Log Analytics workspace. - :type workspace_resource_id: str + :ivar workspace_resource_id: The resource ID of the Log Analytics workspace. + :vartype workspace_resource_id: str :ivar workspace_id: The Customer ID of the Log Analytics workspace. :vartype workspace_id: str - :param name: A friendly name for the destination. + :ivar name: A friendly name for the destination. This name should be unique across all destinations (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _validation = { @@ -1379,6 +1720,14 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword workspace_resource_id: The resource ID of the Log Analytics workspace. + :paramtype workspace_resource_id: str + :keyword name: A friendly name for the destination. + This name should be unique across all destinations (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(LogAnalyticsDestination, self).__init__(**kwargs) self.workspace_resource_id = workspace_resource_id self.workspace_id = None @@ -1389,23 +1738,23 @@ class PerfCounterDataSource(msrest.serialization.Model): """Definition of which performance counters will be collected and how they will be collected by this data collection rule. Collected from both Windows and Linux machines where the counter is present. - :param streams: List of streams that this data source will be sent to. + :ivar streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. - :type streams: list[str or + :vartype streams: list[str or ~$(python-base-namespace).v2021_04_01.models.KnownPerfCounterDataSourceStreams] - :param sampling_frequency_in_seconds: The number of seconds between consecutive counter + :ivar sampling_frequency_in_seconds: The number of seconds between consecutive counter measurements (samples). - :type sampling_frequency_in_seconds: int - :param counter_specifiers: A list of specifier names of the performance counters you want to + :vartype sampling_frequency_in_seconds: int + :ivar counter_specifiers: A list of specifier names of the performance counters you want to collect. Use a wildcard (*) to collect a counter for all instances. To get a list of performance counters on Windows, run the command 'typeperf'. - :type counter_specifiers: list[str] - :param name: A friendly name for the data source. + :vartype counter_specifiers: list[str] + :ivar name: A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -1424,6 +1773,25 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :paramtype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownPerfCounterDataSourceStreams] + :keyword sampling_frequency_in_seconds: The number of seconds between consecutive counter + measurements (samples). + :paramtype sampling_frequency_in_seconds: int + :keyword counter_specifiers: A list of specifier names of the performance counters you want to + collect. + Use a wildcard (*) to collect a counter for all instances. + To get a list of performance counters on Windows, run the command 'typeperf'. + :paramtype counter_specifiers: list[str] + :keyword name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(PerfCounterDataSource, self).__init__(**kwargs) self.streams = streams self.sampling_frequency_in_seconds = sampling_frequency_in_seconds @@ -1434,8 +1802,8 @@ def __init__( class ResourceForUpdate(msrest.serialization.Model): """Definition of ARM tracked top level resource properties for update operation. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -1448,6 +1816,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(ResourceForUpdate, self).__init__(**kwargs) self.tags = tags @@ -1456,21 +1828,21 @@ class SyslogDataSource(msrest.serialization.Model): """Definition of which syslog data will be collected and how it will be collected. Only collected from Linux machines. - :param streams: List of streams that this data source will be sent to. + :ivar streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. - :type streams: list[str or + :vartype streams: list[str or ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceStreams] - :param facility_names: The list of facility names. - :type facility_names: list[str or + :ivar facility_names: The list of facility names. + :vartype facility_names: list[str or ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceFacilityNames] - :param log_levels: The log levels to collect. - :type log_levels: list[str or + :ivar log_levels: The log levels to collect. + :vartype log_levels: list[str or ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceLogLevels] - :param name: A friendly name for the data source. + :ivar name: A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -1489,6 +1861,23 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :paramtype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceStreams] + :keyword facility_names: The list of facility names. + :paramtype facility_names: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceFacilityNames] + :keyword log_levels: The log levels to collect. + :paramtype log_levels: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownSyslogDataSourceLogLevels] + :keyword name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(SyslogDataSource, self).__init__(**kwargs) self.streams = streams self.facility_names = facility_names @@ -1500,17 +1889,17 @@ class WindowsEventLogDataSource(msrest.serialization.Model): """Definition of which Windows Event Log events will be collected and how they will be collected. Only collected from Windows machines. - :param streams: List of streams that this data source will be sent to. + :ivar streams: List of streams that this data source will be sent to. A stream indicates what schema will be used for this data and usually what table in Log Analytics the data will be sent to. - :type streams: list[str or + :vartype streams: list[str or ~$(python-base-namespace).v2021_04_01.models.KnownWindowsEventLogDataSourceStreams] - :param x_path_queries: A list of Windows Event Log queries in XPATH format. - :type x_path_queries: list[str] - :param name: A friendly name for the data source. + :ivar x_path_queries: A list of Windows Event Log queries in XPATH format. + :vartype x_path_queries: list[str] + :ivar name: A friendly name for the data source. This name should be unique across all data sources (regardless of type) within the data collection rule. - :type name: str + :vartype name: str """ _attribute_map = { @@ -1527,6 +1916,19 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword streams: List of streams that this data source will be sent to. + A stream indicates what schema will be used for this data and usually what table in Log + Analytics the data will be sent to. + :paramtype streams: list[str or + ~$(python-base-namespace).v2021_04_01.models.KnownWindowsEventLogDataSourceStreams] + :keyword x_path_queries: A list of Windows Event Log queries in XPATH format. + :paramtype x_path_queries: list[str] + :keyword name: A friendly name for the data source. + This name should be unique across all data sources (regardless of type) within the data + collection rule. + :paramtype name: str + """ super(WindowsEventLogDataSource, self).__init__(**kwargs) self.streams = streams self.x_path_queries = x_path_queries diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_monitor_management_client_enums.py index 9617f5f9e1e38..297a4c1f0059f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/models/_monitor_management_client_enums.py @@ -6,27 +6,12 @@ # 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 CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -35,7 +20,7 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class KnownDataCollectionEndpointProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionEndpointProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The resource provisioning state. This property is READ-ONLY. """ @@ -45,14 +30,14 @@ class KnownDataCollectionEndpointProvisioningState(with_metaclass(_CaseInsensiti SUCCEEDED = "Succeeded" FAILED = "Failed" -class KnownDataCollectionEndpointResourceKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionEndpointResourceKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The kind of the resource. """ LINUX = "Linux" WINDOWS = "Windows" -class KnownDataCollectionRuleAssociationProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionRuleAssociationProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The resource provisioning state. """ @@ -62,7 +47,7 @@ class KnownDataCollectionRuleAssociationProvisioningState(with_metaclass(_CaseIn SUCCEEDED = "Succeeded" FAILED = "Failed" -class KnownDataCollectionRuleProvisioningState(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionRuleProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The resource provisioning state. """ @@ -72,14 +57,14 @@ class KnownDataCollectionRuleProvisioningState(with_metaclass(_CaseInsensitiveEn SUCCEEDED = "Succeeded" FAILED = "Failed" -class KnownDataCollectionRuleResourceKind(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataCollectionRuleResourceKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The kind of the resource. """ LINUX = "Linux" WINDOWS = "Windows" -class KnownDataFlowStreams(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownDataFlowStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_EVENT = "Microsoft-Event" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" @@ -87,7 +72,7 @@ class KnownDataFlowStreams(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_SYSLOG = "Microsoft-Syslog" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" -class KnownExtensionDataSourceStreams(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownExtensionDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_EVENT = "Microsoft-Event" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" @@ -95,12 +80,12 @@ class KnownExtensionDataSourceStreams(with_metaclass(_CaseInsensitiveEnumMeta, s MICROSOFT_SYSLOG = "Microsoft-Syslog" MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" -class KnownPerfCounterDataSourceStreams(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownPerfCounterDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_PERF = "Microsoft-Perf" MICROSOFT_INSIGHTS_METRICS = "Microsoft-InsightsMetrics" -class KnownPublicNetworkAccessOptions(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownPublicNetworkAccessOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The configuration to set whether network access from public internet to the endpoints are allowed. """ @@ -108,7 +93,7 @@ class KnownPublicNetworkAccessOptions(with_metaclass(_CaseInsensitiveEnumMeta, s ENABLED = "Enabled" DISABLED = "Disabled" -class KnownSyslogDataSourceFacilityNames(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownSyslogDataSourceFacilityNames(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): AUTH = "auth" AUTHPRIV = "authpriv" @@ -132,7 +117,7 @@ class KnownSyslogDataSourceFacilityNames(with_metaclass(_CaseInsensitiveEnumMeta LOCAL7 = "local7" ASTERISK = "*" -class KnownSyslogDataSourceLogLevels(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownSyslogDataSourceLogLevels(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DEBUG = "Debug" INFO = "Info" @@ -144,11 +129,11 @@ class KnownSyslogDataSourceLogLevels(with_metaclass(_CaseInsensitiveEnumMeta, st EMERGENCY = "Emergency" ASTERISK = "*" -class KnownSyslogDataSourceStreams(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownSyslogDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_SYSLOG = "Microsoft-Syslog" -class KnownWindowsEventLogDataSourceStreams(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class KnownWindowsEventLogDataSourceStreams(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): MICROSOFT_WINDOWS_EVENT = "Microsoft-WindowsEvent" MICROSOFT_EVENT = "Microsoft-Event" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_endpoints_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_endpoints_operations.py index 623b4484c48f0..c7a3eba1b68b5 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_endpoints_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_endpoints_operations.py @@ -5,24 +5,250 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_group_request( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, 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_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionEndpoints') + 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_get_request( + subscription_id, # type: str + resource_group_name, # type: str + data_collection_endpoint_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_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_request( + subscription_id, # type: str + resource_group_name, # type: str + data_collection_endpoint_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_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, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + data_collection_endpoint_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_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, + **kwargs + ) + + +def build_delete_request( + subscription_id, # type: str + resource_group_name, # type: str + data_collection_endpoint_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "dataCollectionEndpointName": _SERIALIZER.url("data_collection_endpoint_name", data_collection_endpoint_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 + ) + +# fmt: on class DataCollectionEndpointsOperations(object): """DataCollectionEndpointsOperations operations. @@ -45,6 +271,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -58,8 +285,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :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 DataCollectionEndpointResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResourceListResult] + :return: An iterator like instance of either DataCollectionEndpointResourceListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResourceListResult"] @@ -67,35 +296,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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', max_length=90, 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') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('DataCollectionEndpointResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,17 +333,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, 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.Insights/dataCollectionEndpoints'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs # type: Any @@ -129,8 +356,10 @@ def list_by_subscription( Lists all data collection endpoints in the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionEndpointResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResourceListResult] + :return: An iterator like instance of either DataCollectionEndpointResourceListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionEndpointResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionEndpointResourceListResult"] @@ -138,34 +367,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('DataCollectionEndpointResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionEndpointResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -178,17 +402,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, 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.Insights/dataCollectionEndpoints'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -215,33 +441,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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', max_length=90, min_length=1), - 'dataCollectionEndpointName': self._serialize.url("data_collection_endpoint_name", data_collection_endpoint_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 = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_endpoint_name=data_collection_endpoint_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) @@ -250,8 +466,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}'} # type: ignore + + @distributed_trace def create( self, resource_group_name, # type: str @@ -281,41 +500,31 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.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', max_length=90, min_length=1), - 'dataCollectionEndpointName': self._serialize.url("data_collection_endpoint_name", data_collection_endpoint_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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] if body is not None: - body_content = self._serialize.body(body, 'DataCollectionEndpointResource') + _json = self._serialize.body(body, 'DataCollectionEndpointResource') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_endpoint_name=data_collection_endpoint_name, + content_type=content_type, + json=_json, + template_url=self.create.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.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -328,8 +537,11 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -359,41 +571,31 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - 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', max_length=90, min_length=1), - 'dataCollectionEndpointName': self._serialize.url("data_collection_endpoint_name", data_collection_endpoint_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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] if body is not None: - body_content = self._serialize.body(body, 'ResourceForUpdate') + _json = self._serialize.body(body, 'ResourceForUpdate') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_endpoint_name=data_collection_endpoint_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.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DataCollectionEndpointResource', pipeline_response) @@ -402,8 +604,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -430,36 +635,27 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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', max_length=90, min_length=1), - 'dataCollectionEndpointName': self._serialize.url("data_collection_endpoint_name", data_collection_endpoint_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 = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_endpoint_name=data_collection_endpoint_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_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.Insights/dataCollectionEndpoints/{dataCollectionEndpointName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rule_associations_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rule_associations_operations.py index 9f6b43e857d19..33d3a103a78ab 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rule_associations_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rule_associations_operations.py @@ -5,24 +5,206 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, 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_rule_request( + subscription_id, # type: str + resource_group_name, # type: str + data_collection_rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_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_get_request( + resource_uri, # type: str + association_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), + "associationName": _SERIALIZER.url("association_name", association_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_request( + resource_uri, # type: str + association_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), + "associationName": _SERIALIZER.url("association_name", association_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, + **kwargs + ) + + +def build_delete_request( + resource_uri, # type: str + association_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), + "associationName": _SERIALIZER.url("association_name", association_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 + ) + +# fmt: on class DataCollectionRuleAssociationsOperations(object): """DataCollectionRuleAssociationsOperations operations. @@ -45,6 +227,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource( self, resource_uri, # type: str @@ -58,8 +241,10 @@ def list_by_resource( :param resource_uri: The identifier of the resource. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + :return: An iterator like instance of either + DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] @@ -67,34 +252,29 @@ def list_by_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True, 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_request( + resource_uri=resource_uri, + template_url=self.list_by_resource.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_list_by_resource_request( + resource_uri=resource_uri, + 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('DataCollectionRuleAssociationProxyOnlyResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -107,17 +287,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations'} # type: ignore + @distributed_trace def list_by_rule( self, resource_group_name, # type: str @@ -135,8 +317,10 @@ def list_by_rule( insensitive. :type data_collection_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] + :return: An iterator like instance of either + DataCollectionRuleAssociationProxyOnlyResourceListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResourceListResult"] @@ -144,36 +328,33 @@ def list_by_rule( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_rule.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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_rule_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_name, + template_url=self.list_by_rule.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_list_by_rule_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_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('DataCollectionRuleAssociationProxyOnlyResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleAssociationProxyOnlyResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -186,17 +367,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_rule.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}/associations'} # type: ignore + @distributed_trace def get( self, resource_uri, # type: str @@ -214,7 +397,8 @@ def get( :type association_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource + :rtype: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] @@ -222,32 +406,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - 'associationName': self._serialize.url("association_name", association_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 = build_get_request( + resource_uri=resource_uri, + association_name=association_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DataCollectionRuleAssociationProxyOnlyResource', pipeline_response) @@ -256,8 +430,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + + @distributed_trace def create( self, resource_uri, # type: str @@ -275,10 +452,12 @@ def create( :param association_name: The name of the association. The name is case insensitive. :type association_name: str :param body: The payload. - :type body: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource + :type body: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource :keyword callable cls: A custom type or function that will be passed the direct response :return: DataCollectionRuleAssociationProxyOnlyResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource + :rtype: + ~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleAssociationProxyOnlyResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleAssociationProxyOnlyResource"] @@ -286,40 +465,30 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - 'associationName': self._serialize.url("association_name", association_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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] if body is not None: - body_content = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') + _json = self._serialize.body(body, 'DataCollectionRuleAssociationProxyOnlyResource') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request( + resource_uri=resource_uri, + association_name=association_name, + content_type=content_type, + json=_json, + template_url=self.create.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.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -332,8 +501,11 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + + @distributed_trace def delete( self, resource_uri, # type: str @@ -359,35 +531,26 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True, min_length=1), - 'associationName': self._serialize.url("association_name", association_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 = build_delete_request( + resource_uri=resource_uri, + association_name=association_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) delete.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/dataCollectionRuleAssociations/{associationName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rules_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rules_operations.py index 287d2a2318343..1b3b0bb75c556 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rules_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_04_01/operations/_data_collection_rules_operations.py @@ -5,24 +5,250 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_group_request( + subscription_id, # type: str + resource_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, 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_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/dataCollectionRules') + 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_get_request( + subscription_id, # type: str + resource_group_name, # type: str + data_collection_rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_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_request( + subscription_id, # type: str + resource_group_name, # type: str + data_collection_rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_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, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + data_collection_rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_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, + **kwargs + ) + + +def build_delete_request( + subscription_id, # type: str + resource_group_name, # type: str + data_collection_rule_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "dataCollectionRuleName": _SERIALIZER.url("data_collection_rule_name", data_collection_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 + ) + +# fmt: on class DataCollectionRulesOperations(object): """DataCollectionRulesOperations operations. @@ -45,6 +271,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -58,8 +285,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :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 DataCollectionRuleResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResourceListResult] + :return: An iterator like instance of either DataCollectionRuleResourceListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] @@ -67,35 +296,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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', max_length=90, 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') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('DataCollectionRuleResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,17 +333,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, 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.Insights/dataCollectionRules'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs # type: Any @@ -129,8 +356,10 @@ def list_by_subscription( Lists all data collection rules in the specified subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DataCollectionRuleResourceListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResourceListResult] + :return: An iterator like instance of either DataCollectionRuleResourceListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_04_01.models.DataCollectionRuleResourceListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DataCollectionRuleResourceListResult"] @@ -138,34 +367,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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_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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('DataCollectionRuleResourceListResult', pipeline_response) + deserialized = self._deserialize("DataCollectionRuleResourceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -178,17 +402,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, 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.Insights/dataCollectionRules'} # type: ignore + @distributed_trace def get( self, resource_group_name, # type: str @@ -215,33 +441,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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 = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) @@ -250,8 +466,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}'} # type: ignore + + @distributed_trace def create( self, resource_group_name, # type: str @@ -281,41 +500,31 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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] if body is not None: - body_content = self._serialize.body(body, 'DataCollectionRuleResource') + _json = self._serialize.body(body, 'DataCollectionRuleResource') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_name, + content_type=content_type, + json=_json, + template_url=self.create.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.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -328,8 +537,11 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -359,41 +571,31 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-01" - 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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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] if body is not None: - body_content = self._serialize.body(body, 'ResourceForUpdate') + _json = self._serialize.body(body, 'ResourceForUpdate') else: - body_content = None - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + _json = None + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_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.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DataCollectionRuleResource', pipeline_response) @@ -402,8 +604,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -430,36 +635,27 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-04-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', max_length=90, min_length=1), - 'dataCollectionRuleName': self._serialize.url("data_collection_rule_name", data_collection_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 = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + data_collection_rule_name=data_collection_rule_name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponseCommonV2, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponseCommonV2, pipeline_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.Insights/dataCollectionRules/{dataCollectionRuleName}'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_configuration.py index 8c42b54730121..41eff219590f1 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_metadata.json index 2b64e6cd360c5..3feeaec00b538 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "autoscale_settings": "AutoscaleSettingsOperations", diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_monitor_management_client.py index f8a24f027f319..07b9e4b9dbb62 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_monitor_management_client.py @@ -6,98 +6,102 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import AutoscaleSettingsOperations, DiagnosticSettingsCategoryOperations, DiagnosticSettingsOperations, ManagementGroupDiagnosticSettingsOperations, PredictiveMetricOperations, SubscriptionDiagnosticSettingsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import AutoscaleSettingsOperations -from .operations import PredictiveMetricOperations -from .operations import DiagnosticSettingsOperations -from .operations import DiagnosticSettingsCategoryOperations -from .operations import ManagementGroupDiagnosticSettingsOperations -from .operations import SubscriptionDiagnosticSettingsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. :ivar autoscale_settings: AutoscaleSettingsOperations operations - :vartype autoscale_settings: $(python-base-namespace).v2021_05_01_preview.operations.AutoscaleSettingsOperations + :vartype autoscale_settings: + $(python-base-namespace).v2021_05_01_preview.operations.AutoscaleSettingsOperations :ivar predictive_metric: PredictiveMetricOperations operations - :vartype predictive_metric: $(python-base-namespace).v2021_05_01_preview.operations.PredictiveMetricOperations + :vartype predictive_metric: + $(python-base-namespace).v2021_05_01_preview.operations.PredictiveMetricOperations :ivar diagnostic_settings: DiagnosticSettingsOperations operations - :vartype diagnostic_settings: $(python-base-namespace).v2021_05_01_preview.operations.DiagnosticSettingsOperations + :vartype diagnostic_settings: + $(python-base-namespace).v2021_05_01_preview.operations.DiagnosticSettingsOperations :ivar diagnostic_settings_category: DiagnosticSettingsCategoryOperations operations - :vartype diagnostic_settings_category: $(python-base-namespace).v2021_05_01_preview.operations.DiagnosticSettingsCategoryOperations - :ivar management_group_diagnostic_settings: ManagementGroupDiagnosticSettingsOperations operations - :vartype management_group_diagnostic_settings: $(python-base-namespace).v2021_05_01_preview.operations.ManagementGroupDiagnosticSettingsOperations + :vartype diagnostic_settings_category: + $(python-base-namespace).v2021_05_01_preview.operations.DiagnosticSettingsCategoryOperations + :ivar management_group_diagnostic_settings: ManagementGroupDiagnosticSettingsOperations + operations + :vartype management_group_diagnostic_settings: + $(python-base-namespace).v2021_05_01_preview.operations.ManagementGroupDiagnosticSettingsOperations :ivar subscription_diagnostic_settings: SubscriptionDiagnosticSettingsOperations operations - :vartype subscription_diagnostic_settings: $(python-base-namespace).v2021_05_01_preview.operations.SubscriptionDiagnosticSettingsOperations + :vartype subscription_diagnostic_settings: + $(python-base-namespace).v2021_05_01_preview.operations.SubscriptionDiagnosticSettingsOperations :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] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.autoscale_settings = AutoscaleSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.predictive_metric = PredictiveMetricOperations(self._client, self._config, self._serialize, self._deserialize) + self.diagnostic_settings = DiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations(self._client, self._config, self._serialize, self._deserialize) + self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.autoscale_settings = AutoscaleSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.predictive_metric = PredictiveMetricOperations( - self._client, self._config, self._serialize, self._deserialize) - self.diagnostic_settings = DiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations( - self._client, self._config, self._serialize, self._deserialize) - self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_configuration.py index af72dcd13a9f8..7da2da7519122 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_monitor_management_client.py index 44fb006c737e4..1024edbc3147e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_monitor_management_client.py @@ -6,94 +6,98 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import AutoscaleSettingsOperations, DiagnosticSettingsCategoryOperations, DiagnosticSettingsOperations, ManagementGroupDiagnosticSettingsOperations, PredictiveMetricOperations, SubscriptionDiagnosticSettingsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MonitorManagementClientConfiguration -from .operations import AutoscaleSettingsOperations -from .operations import PredictiveMetricOperations -from .operations import DiagnosticSettingsOperations -from .operations import DiagnosticSettingsCategoryOperations -from .operations import ManagementGroupDiagnosticSettingsOperations -from .operations import SubscriptionDiagnosticSettingsOperations -from .. import models - - -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar autoscale_settings: AutoscaleSettingsOperations operations - :vartype autoscale_settings: $(python-base-namespace).v2021_05_01_preview.aio.operations.AutoscaleSettingsOperations + :vartype autoscale_settings: + $(python-base-namespace).v2021_05_01_preview.aio.operations.AutoscaleSettingsOperations :ivar predictive_metric: PredictiveMetricOperations operations - :vartype predictive_metric: $(python-base-namespace).v2021_05_01_preview.aio.operations.PredictiveMetricOperations + :vartype predictive_metric: + $(python-base-namespace).v2021_05_01_preview.aio.operations.PredictiveMetricOperations :ivar diagnostic_settings: DiagnosticSettingsOperations operations - :vartype diagnostic_settings: $(python-base-namespace).v2021_05_01_preview.aio.operations.DiagnosticSettingsOperations + :vartype diagnostic_settings: + $(python-base-namespace).v2021_05_01_preview.aio.operations.DiagnosticSettingsOperations :ivar diagnostic_settings_category: DiagnosticSettingsCategoryOperations operations - :vartype diagnostic_settings_category: $(python-base-namespace).v2021_05_01_preview.aio.operations.DiagnosticSettingsCategoryOperations - :ivar management_group_diagnostic_settings: ManagementGroupDiagnosticSettingsOperations operations - :vartype management_group_diagnostic_settings: $(python-base-namespace).v2021_05_01_preview.aio.operations.ManagementGroupDiagnosticSettingsOperations + :vartype diagnostic_settings_category: + $(python-base-namespace).v2021_05_01_preview.aio.operations.DiagnosticSettingsCategoryOperations + :ivar management_group_diagnostic_settings: ManagementGroupDiagnosticSettingsOperations + operations + :vartype management_group_diagnostic_settings: + $(python-base-namespace).v2021_05_01_preview.aio.operations.ManagementGroupDiagnosticSettingsOperations :ivar subscription_diagnostic_settings: SubscriptionDiagnosticSettingsOperations operations - :vartype subscription_diagnostic_settings: $(python-base-namespace).v2021_05_01_preview.aio.operations.SubscriptionDiagnosticSettingsOperations + :vartype subscription_diagnostic_settings: + $(python-base-namespace).v2021_05_01_preview.aio.operations.SubscriptionDiagnosticSettingsOperations :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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.autoscale_settings = AutoscaleSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.predictive_metric = PredictiveMetricOperations(self._client, self._config, self._serialize, self._deserialize) + self.diagnostic_settings = DiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations(self._client, self._config, self._serialize, self._deserialize) + self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations(self._client, self._config, self._serialize, self._deserialize) + - self.autoscale_settings = AutoscaleSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.predictive_metric = PredictiveMetricOperations( - self._client, self._config, self._serialize, self._deserialize) - self.diagnostic_settings = DiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.diagnostic_settings_category = DiagnosticSettingsCategoryOperations( - self._client, self._config, self._serialize, self._deserialize) - self.management_group_diagnostic_settings = ManagementGroupDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.subscription_diagnostic_settings = SubscriptionDiagnosticSettingsOperations( - self._client, self._config, self._serialize, self._deserialize) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_autoscale_settings_operations.py index 18416b0517d64..7aa783a2f7138 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_autoscale_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_autoscale_settings_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._autoscale_settings_operations import build_create_or_update_request, build_delete_request, build_get_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]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -48,11 +54,13 @@ def list_by_resource_group( ) -> AsyncIterable["_models.AutoscaleSettingResourceCollection"]: """Lists the autoscale settings for a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 AutoscaleSettingResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourceCollection] + :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResourceCollection"] @@ -60,35 +68,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('AutoscaleSettingResourceCollection', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,17 +105,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, 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.Insights/autoscalesettings'} # type: ignore + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -121,7 +127,7 @@ async def create_or_update( ) -> "_models.AutoscaleSettingResource": """Creates or updates an autoscale setting. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str @@ -137,38 +143,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'autoscaleSettingName': self._serialize.url("autoscale_setting_name", autoscale_setting_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AutoscaleSettingResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AutoscaleSettingResource') - 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.failsafe_deserialize(_models.AutoscaleErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -181,8 +177,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -191,7 +190,7 @@ async def delete( ) -> None: """Deletes and autoscale setting. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str @@ -205,33 +204,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'autoscaleSettingName': self._serialize.url("autoscale_setting_name", autoscale_setting_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.AutoscaleErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -239,6 +228,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -247,7 +238,7 @@ async def get( ) -> "_models.AutoscaleSettingResource": """Gets an autoscale setting. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str @@ -261,33 +252,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'autoscaleSettingName': self._serialize.url("autoscale_setting_name", autoscale_setting_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.AutoscaleErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) @@ -296,8 +277,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -308,12 +292,13 @@ async def update( """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str :param autoscale_setting_resource: Parameters supplied to the operation. - :type autoscale_setting_resource: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourcePatch + :type autoscale_setting_resource: + ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourcePatch :keyword callable cls: A custom type or function that will be passed the direct response :return: AutoscaleSettingResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource @@ -324,38 +309,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-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'), - 'autoscaleSettingName': self._serialize.url("autoscale_setting_name", autoscale_setting_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(autoscale_setting_resource, 'AutoscaleSettingResourcePatch') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(autoscale_setting_resource, 'AutoscaleSettingResourcePatch') - 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.failsafe_deserialize(_models.AutoscaleErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) @@ -364,8 +339,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -373,8 +351,10 @@ def list_by_subscription( """Lists the autoscale settings for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourceCollection] + :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResourceCollection"] @@ -382,34 +362,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('AutoscaleSettingResourceCollection', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -422,12 +397,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py index aa9858884eae9..2caa5d0120dd0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_category_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_category_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._diagnostic_settings_category_operations import build_get_request, build_list_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_async async def get( self, resource_uri: str, @@ -63,32 +69,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_get_request( + resource_uri=resource_uri, + name=name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DiagnosticSettingsCategoryResource', pipeline_response) @@ -97,8 +93,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}'} # type: ignore + + @distributed_trace def list( self, resource_uri: str, @@ -109,8 +108,10 @@ def list( :param resource_uri: The identifier of the resource. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiagnosticSettingsCategoryResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResourceCollection] + :return: An iterator like instance of either DiagnosticSettingsCategoryResourceCollection or + the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsCategoryResourceCollection"] @@ -118,34 +119,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-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 - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + template_url=self.list.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_list_request( + resource_uri=resource_uri, + 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('DiagnosticSettingsCategoryResourceCollection', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsCategoryResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -158,12 +154,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_operations.py index 1c0867bbab312..3d65ad45bfed4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_diagnostic_settings_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._diagnostic_settings_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_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_async async def get( self, resource_uri: str, @@ -63,32 +69,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_get_request( + resource_uri=resource_uri, + name=name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DiagnosticSettingsResource', pipeline_response) @@ -97,8 +93,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_uri: str, @@ -113,7 +112,8 @@ async def create_or_update( :param name: The name of the diagnostic setting. :type name: str :param parameters: Parameters supplied to the operation. - :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource + :type parameters: + ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticSettingsResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource @@ -124,37 +124,27 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - 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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'DiagnosticSettingsResource') + + request = build_create_or_update_request( + resource_uri=resource_uri, + name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DiagnosticSettingsResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DiagnosticSettingsResource', pipeline_response) @@ -163,8 +153,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_uri: str, @@ -187,32 +180,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_delete_request( + resource_uri=resource_uri, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -220,6 +203,8 @@ async def delete( delete.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def list( self, resource_uri: str, @@ -230,8 +215,10 @@ def list( :param resource_uri: The identifier of the resource. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiagnosticSettingsResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResourceCollection] + :return: An iterator like instance of either DiagnosticSettingsResourceCollection or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsResourceCollection"] @@ -239,34 +226,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-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 - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + template_url=self.list.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_list_request( + resource_uri=resource_uri, + 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('DiagnosticSettingsResourceCollection', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -279,12 +261,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py index 0d3a2f487cb7a..bcbdf01076582 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_management_group_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_management_group_diagnostic_settings_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._management_group_diagnostic_settings_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_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_async async def get( self, management_group_id: str, @@ -55,7 +61,8 @@ async def get( :type name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementGroupDiagnosticSettingsResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource + :rtype: + ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResource"] @@ -63,32 +70,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_get_request( + management_group_id=management_group_id, + name=name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementGroupDiagnosticSettingsResource', pipeline_response) @@ -97,8 +94,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, management_group_id: str, @@ -113,10 +113,12 @@ async def create_or_update( :param name: The name of the diagnostic setting. :type name: str :param parameters: Parameters supplied to the operation. - :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource + :type parameters: + ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementGroupDiagnosticSettingsResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource + :rtype: + ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResource"] @@ -124,37 +126,27 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - 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 = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'ManagementGroupDiagnosticSettingsResource') + + request = build_create_or_update_request( + management_group_id=management_group_id, + name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementGroupDiagnosticSettingsResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementGroupDiagnosticSettingsResource', pipeline_response) @@ -163,8 +155,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace_async async def delete( self, management_group_id: str, @@ -187,32 +182,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_delete_request( + management_group_id=management_group_id, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -220,6 +205,8 @@ async def delete( delete.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def list( self, management_group_id: str, @@ -230,8 +217,10 @@ def list( :param management_group_id: The management group id. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementGroupDiagnosticSettingsResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResourceCollection] + :return: An iterator like instance of either + ManagementGroupDiagnosticSettingsResourceCollection or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResourceCollection"] @@ -239,34 +228,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-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 - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True), - } - 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + management_group_id=management_group_id, + template_url=self.list.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_list_request( + management_group_id=management_group_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('ManagementGroupDiagnosticSettingsResourceCollection', pipeline_response) + deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -279,12 +263,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_predictive_metric_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_predictive_metric_operations.py index 55732a9aee1c8..a3ad60180b574 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_predictive_metric_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_predictive_metric_operations.py @@ -6,16 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings 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_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._predictive_metric_operations import build_get_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -54,7 +59,7 @@ async def get( ) -> "_models.PredictiveResponse": """get predictive autoscale metric future data. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str @@ -81,38 +86,28 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - 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'), - 'autoscaleSettingName': self._serialize.url("autoscale_setting_name", autoscale_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['timespan'] = self._serialize.query("timespan", timespan, 'str') - query_parameters['interval'] = self._serialize.query("interval", interval, 'duration') - query_parameters['metricNamespace'] = self._serialize.query("metric_namespace", metric_namespace, 'str') - query_parameters['metricName'] = self._serialize.query("metric_name", metric_name, 'str') - query_parameters['aggregation'] = self._serialize.query("aggregation", aggregation, '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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + timespan=timespan, + interval=interval, + metric_namespace=metric_namespace, + metric_name=metric_name, + aggregation=aggregation, + template_url=self.get.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.AutoscaleErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PredictiveResponse', pipeline_response) @@ -121,4 +116,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py index 303455c75d844..8dff60bc58a4d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_subscription_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/aio/operations/_subscription_diagnostic_settings_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._subscription_diagnostic_settings_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_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_async async def get( self, name: str, @@ -52,7 +58,8 @@ async def get( :type name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionDiagnosticSettingsResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :rtype: + ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResource"] @@ -60,32 +67,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - 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), - 'name': self._serialize.url("name", 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 = build_get_request( + subscription_id=self._config.subscription_id, + name=name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SubscriptionDiagnosticSettingsResource', pipeline_response) @@ -94,8 +91,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, name: str, @@ -107,10 +107,12 @@ async def create_or_update( :param name: The name of the diagnostic setting. :type name: str :param parameters: Parameters supplied to the operation. - :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :type parameters: + ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionDiagnosticSettingsResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :rtype: + ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResource"] @@ -118,37 +120,27 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - 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), - 'name': self._serialize.url("name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'SubscriptionDiagnosticSettingsResource') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SubscriptionDiagnosticSettingsResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SubscriptionDiagnosticSettingsResource', pipeline_response) @@ -157,8 +149,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace_async async def delete( self, name: str, @@ -178,32 +173,22 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-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), - 'name': self._serialize.url("name", 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 = build_delete_request( + subscription_id=self._config.subscription_id, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -211,6 +196,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -218,8 +205,10 @@ def list( """Gets the active subscription diagnostic settings list for the specified subscriptionId. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionDiagnosticSettingsResourceCollection or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResourceCollection] + :return: An iterator like instance of either SubscriptionDiagnosticSettingsResourceCollection + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResourceCollection"] @@ -227,34 +216,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-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 - 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_list_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('SubscriptionDiagnosticSettingsResourceCollection', pipeline_response) + deserialized = self._deserialize("SubscriptionDiagnosticSettingsResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -267,12 +251,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models.py index 080976daeeffa..557b001723749 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models.py @@ -15,8 +15,9 @@ class AutoscaleErrorResponse(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param error: The error object. - :type error: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleErrorResponseError + :ivar error: The error object. + :vartype error: + ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleErrorResponseError :ivar system_data: The system metadata related to the response. :vartype system_data: ~$(python-base-namespace).v2021_05_01_preview.models.SystemData """ @@ -34,6 +35,11 @@ def __init__( self, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: + ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleErrorResponseError + """ super(AutoscaleErrorResponse, self).__init__(**kwargs) self.error = kwargs.get('error', None) self.system_data = None @@ -42,14 +48,14 @@ def __init__( class AutoscaleErrorResponseError(msrest.serialization.Model): """The error object. - :param code: One of a server-defined set of error codes. - :type code: str - :param message: A human-readable representation of the error. - :type message: str - :param target: The target of the particular error. - :type target: str - :param details: A human-readable representation of the error's details. - :type details: str + :ivar code: One of a server-defined set of error codes. + :vartype code: str + :ivar message: A human-readable representation of the error. + :vartype message: str + :ivar target: The target of the particular error. + :vartype target: str + :ivar details: A human-readable representation of the error's details. + :vartype details: str """ _attribute_map = { @@ -63,6 +69,16 @@ def __init__( self, **kwargs ): + """ + :keyword code: One of a server-defined set of error codes. + :paramtype code: str + :keyword message: A human-readable representation of the error. + :paramtype message: str + :keyword target: The target of the particular error. + :paramtype target: str + :keyword details: A human-readable representation of the error's details. + :paramtype details: str + """ super(AutoscaleErrorResponseError, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -80,10 +96,11 @@ class AutoscaleNotification(msrest.serialization.Model): :ivar operation: the operation associated with the notification and its value must be "scale". Has constant value: "Scale". :vartype operation: str - :param email: the email notification. - :type email: ~$(python-base-namespace).v2021_05_01_preview.models.EmailNotification - :param webhooks: the collection of webhook notifications. - :type webhooks: list[~$(python-base-namespace).v2021_05_01_preview.models.WebhookNotification] + :ivar email: the email notification. + :vartype email: ~$(python-base-namespace).v2021_05_01_preview.models.EmailNotification + :ivar webhooks: the collection of webhook notifications. + :vartype webhooks: + list[~$(python-base-namespace).v2021_05_01_preview.models.WebhookNotification] """ _validation = { @@ -102,6 +119,13 @@ def __init__( self, **kwargs ): + """ + :keyword email: the email notification. + :paramtype email: ~$(python-base-namespace).v2021_05_01_preview.models.EmailNotification + :keyword webhooks: the collection of webhook notifications. + :paramtype webhooks: + list[~$(python-base-namespace).v2021_05_01_preview.models.WebhookNotification] + """ super(AutoscaleNotification, self).__init__(**kwargs) self.email = kwargs.get('email', None) self.webhooks = kwargs.get('webhooks', None) @@ -112,19 +136,19 @@ class AutoscaleProfile(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. the name of the profile. - :type name: str - :param capacity: Required. the number of instances that can be used during this profile. - :type capacity: ~$(python-base-namespace).v2021_05_01_preview.models.ScaleCapacity - :param rules: Required. the collection of rules that provide the triggers and parameters for - the scaling action. A maximum of 10 rules can be specified. - :type rules: list[~$(python-base-namespace).v2021_05_01_preview.models.ScaleRule] - :param fixed_date: the specific date-time for the profile. This element is not used if the + :ivar name: Required. the name of the profile. + :vartype name: str + :ivar capacity: Required. the number of instances that can be used during this profile. + :vartype capacity: ~$(python-base-namespace).v2021_05_01_preview.models.ScaleCapacity + :ivar rules: Required. the collection of rules that provide the triggers and parameters for the + scaling action. A maximum of 10 rules can be specified. + :vartype rules: list[~$(python-base-namespace).v2021_05_01_preview.models.ScaleRule] + :ivar fixed_date: the specific date-time for the profile. This element is not used if the Recurrence element is used. - :type fixed_date: ~$(python-base-namespace).v2021_05_01_preview.models.TimeWindow - :param recurrence: the repeating times at which this profile begins. This element is not used - if the FixedDate element is used. - :type recurrence: ~$(python-base-namespace).v2021_05_01_preview.models.Recurrence + :vartype fixed_date: ~$(python-base-namespace).v2021_05_01_preview.models.TimeWindow + :ivar recurrence: the repeating times at which this profile begins. This element is not used if + the FixedDate element is used. + :vartype recurrence: ~$(python-base-namespace).v2021_05_01_preview.models.Recurrence """ _validation = { @@ -145,6 +169,21 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. the name of the profile. + :paramtype name: str + :keyword capacity: Required. the number of instances that can be used during this profile. + :paramtype capacity: ~$(python-base-namespace).v2021_05_01_preview.models.ScaleCapacity + :keyword rules: Required. the collection of rules that provide the triggers and parameters for + the scaling action. A maximum of 10 rules can be specified. + :paramtype rules: list[~$(python-base-namespace).v2021_05_01_preview.models.ScaleRule] + :keyword fixed_date: the specific date-time for the profile. This element is not used if the + Recurrence element is used. + :paramtype fixed_date: ~$(python-base-namespace).v2021_05_01_preview.models.TimeWindow + :keyword recurrence: the repeating times at which this profile begins. This element is not used + if the FixedDate element is used. + :paramtype recurrence: ~$(python-base-namespace).v2021_05_01_preview.models.Recurrence + """ super(AutoscaleProfile, self).__init__(**kwargs) self.name = kwargs['name'] self.capacity = kwargs['capacity'] @@ -166,35 +205,35 @@ class AutoscaleSettingResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in length than 128 characters and a value no greater in length than 256 characters. - :type tags: dict[str, str] + :vartype tags: dict[str, str] :ivar system_data: The system metadata related to the response. :vartype system_data: ~$(python-base-namespace).v2021_05_01_preview.models.SystemData - :param profiles: Required. the collection of automatic scaling profiles that specify different + :ivar profiles: Required. the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. - :type profiles: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleProfile] - :param notifications: the collection of notifications. - :type notifications: + :vartype profiles: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleProfile] + :ivar notifications: the collection of notifications. + :vartype notifications: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleNotification] - :param enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the resource. The default value is 'true'. - :type enabled: bool - :param predictive_autoscale_policy: the predictive autoscale policy mode. - :type predictive_autoscale_policy: + :vartype enabled: bool + :ivar predictive_autoscale_policy: the predictive autoscale policy mode. + :vartype predictive_autoscale_policy: ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveAutoscalePolicy - :param name_properties_name: the name of the autoscale setting. - :type name_properties_name: str - :param target_resource_uri: the resource identifier of the resource that the autoscale setting + :ivar name_properties_name: the name of the autoscale setting. + :vartype name_properties_name: str + :ivar target_resource_uri: the resource identifier of the resource that the autoscale setting should be added to. - :type target_resource_uri: str - :param target_resource_location: the location of the resource that the autoscale setting should + :vartype target_resource_uri: str + :ivar target_resource_location: the location of the resource that the autoscale setting should be added to. - :type target_resource_location: str + :vartype target_resource_location: str """ _validation = { @@ -226,6 +265,37 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the + resource. These tags can be used in viewing and grouping this resource (across resource + groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no + greater in length than 128 characters and a value no greater in length than 256 characters. + :paramtype tags: dict[str, str] + :keyword profiles: Required. the collection of automatic scaling profiles that specify + different scaling parameters for different time periods. A maximum of 20 profiles can be + specified. + :paramtype profiles: + list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleProfile] + :keyword notifications: the collection of notifications. + :paramtype notifications: + list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleNotification] + :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + resource. The default value is 'true'. + :paramtype enabled: bool + :keyword predictive_autoscale_policy: the predictive autoscale policy mode. + :paramtype predictive_autoscale_policy: + ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveAutoscalePolicy + :keyword name_properties_name: the name of the autoscale setting. + :paramtype name_properties_name: str + :keyword target_resource_uri: the resource identifier of the resource that the autoscale + setting should be added to. + :paramtype target_resource_uri: str + :keyword target_resource_location: the location of the resource that the autoscale setting + should be added to. + :paramtype target_resource_location: str + """ super(AutoscaleSettingResource, self).__init__(**kwargs) self.id = None self.name = None @@ -247,11 +317,11 @@ class AutoscaleSettingResourceCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the values for the autoscale setting resources. - :type value: + :ivar value: Required. the values for the autoscale setting resources. + :vartype value: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource] - :param next_link: URL to get the next set of results. - :type next_link: str + :ivar next_link: URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -267,6 +337,13 @@ def __init__( self, **kwargs ): + """ + :keyword value: Required. the values for the autoscale setting resources. + :paramtype value: + list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource] + :keyword next_link: URL to get the next set of results. + :paramtype next_link: str + """ super(AutoscaleSettingResourceCollection, self).__init__(**kwargs) self.value = kwargs['value'] self.next_link = kwargs.get('next_link', None) @@ -275,28 +352,28 @@ def __init__( class AutoscaleSettingResourcePatch(msrest.serialization.Model): """The autoscale setting object for patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param profiles: the collection of automatic scaling profiles that specify different scaling + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar profiles: the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. - :type profiles: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleProfile] - :param notifications: the collection of notifications. - :type notifications: + :vartype profiles: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleProfile] + :ivar notifications: the collection of notifications. + :vartype notifications: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleNotification] - :param enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the resource. The default value is 'true'. - :type enabled: bool - :param predictive_autoscale_policy: the predictive autoscale policy mode. - :type predictive_autoscale_policy: + :vartype enabled: bool + :ivar predictive_autoscale_policy: the predictive autoscale policy mode. + :vartype predictive_autoscale_policy: ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveAutoscalePolicy - :param name: the name of the autoscale setting. - :type name: str - :param target_resource_uri: the resource identifier of the resource that the autoscale setting + :ivar name: the name of the autoscale setting. + :vartype name: str + :ivar target_resource_uri: the resource identifier of the resource that the autoscale setting should be added to. - :type target_resource_uri: str - :param target_resource_location: the location of the resource that the autoscale setting should + :vartype target_resource_uri: str + :ivar target_resource_location: the location of the resource that the autoscale setting should be added to. - :type target_resource_location: str + :vartype target_resource_location: str """ _validation = { @@ -318,6 +395,31 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword profiles: the collection of automatic scaling profiles that specify different scaling + parameters for different time periods. A maximum of 20 profiles can be specified. + :paramtype profiles: + list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleProfile] + :keyword notifications: the collection of notifications. + :paramtype notifications: + list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleNotification] + :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + resource. The default value is 'true'. + :paramtype enabled: bool + :keyword predictive_autoscale_policy: the predictive autoscale policy mode. + :paramtype predictive_autoscale_policy: + ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveAutoscalePolicy + :keyword name: the name of the autoscale setting. + :paramtype name: str + :keyword target_resource_uri: the resource identifier of the resource that the autoscale + setting should be added to. + :paramtype target_resource_uri: str + :keyword target_resource_location: the location of the resource that the autoscale setting + should be added to. + :paramtype target_resource_location: str + """ super(AutoscaleSettingResourcePatch, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.profiles = kwargs.get('profiles', None) @@ -360,6 +462,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -381,11 +485,12 @@ class DiagnosticSettingsCategoryResource(Resource): :vartype type: str :ivar system_data: The system metadata related to this resource. :vartype system_data: ~$(python-base-namespace).v2021_05_01_preview.models.SystemData - :param category_type: The type of the diagnostic settings category. Possible values include: + :ivar category_type: The type of the diagnostic settings category. Possible values include: "Metrics", "Logs". - :type category_type: str or ~$(python-base-namespace).v2021_05_01_preview.models.CategoryType - :param category_groups: the collection of what category groups are supported. - :type category_groups: list[str] + :vartype category_type: str or + ~$(python-base-namespace).v2021_05_01_preview.models.CategoryType + :ivar category_groups: the collection of what category groups are supported. + :vartype category_groups: list[str] """ _validation = { @@ -408,6 +513,14 @@ def __init__( self, **kwargs ): + """ + :keyword category_type: The type of the diagnostic settings category. Possible values include: + "Metrics", "Logs". + :paramtype category_type: str or + ~$(python-base-namespace).v2021_05_01_preview.models.CategoryType + :keyword category_groups: the collection of what category groups are supported. + :paramtype category_groups: list[str] + """ super(DiagnosticSettingsCategoryResource, self).__init__(**kwargs) self.system_data = None self.category_type = kwargs.get('category_type', None) @@ -417,8 +530,8 @@ def __init__( class DiagnosticSettingsCategoryResourceCollection(msrest.serialization.Model): """Represents a collection of diagnostic setting category resources. - :param value: The collection of diagnostic settings category resources. - :type value: + :ivar value: The collection of diagnostic settings category resources. + :vartype value: list[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResource] """ @@ -430,6 +543,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: The collection of diagnostic settings category resources. + :paramtype value: + list[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResource] + """ super(DiagnosticSettingsCategoryResourceCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -449,33 +567,33 @@ class DiagnosticSettingsResource(Resource): :vartype type: str :ivar system_data: The system metadata related to this resource. :vartype system_data: ~$(python-base-namespace).v2021_05_01_preview.models.SystemData - :param storage_account_id: The resource ID of the storage account to which you would like to + :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. - :type service_bus_rule_id: str - :param event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :type event_hub_authorization_rule_id: str - :param event_hub_name: The name of the event hub. If none is specified, the default event hub + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :vartype event_hub_authorization_rule_id: str + :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub will be selected. - :type event_hub_name: str - :param metrics: The list of metric settings. - :type metrics: list[~$(python-base-namespace).v2021_05_01_preview.models.MetricSettings] - :param logs: The list of logs settings. - :type logs: list[~$(python-base-namespace).v2021_05_01_preview.models.LogSettings] - :param workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would + :vartype event_hub_name: str + :ivar metrics: The list of metric settings. + :vartype metrics: list[~$(python-base-namespace).v2021_05_01_preview.models.MetricSettings] + :ivar logs: The list of logs settings. + :vartype logs: list[~$(python-base-namespace).v2021_05_01_preview.models.LogSettings] + :ivar workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str - :param marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which - you would like to send Diagnostic Logs. - :type marketplace_partner_id: str - :param log_analytics_destination_type: A string indicating whether the export to Log Analytics + :vartype workspace_id: str + :ivar marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which you + would like to send Diagnostic Logs. + :vartype marketplace_partner_id: str + :ivar log_analytics_destination_type: A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type constructed as follows: :code:``_:code:``. Possible values are: Dedicated and null (null is default.). - :type log_analytics_destination_type: str + :vartype log_analytics_destination_type: str """ _validation = { @@ -505,6 +623,35 @@ def __init__( self, **kwargs ): + """ + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here + to maintain backwards compatibility. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub + will be selected. + :paramtype event_hub_name: str + :keyword metrics: The list of metric settings. + :paramtype metrics: list[~$(python-base-namespace).v2021_05_01_preview.models.MetricSettings] + :keyword logs: The list of logs settings. + :paramtype logs: list[~$(python-base-namespace).v2021_05_01_preview.models.LogSettings] + :keyword workspace_id: The full ARM resource ID of the Log Analytics workspace to which you + would like to send Diagnostic Logs. Example: + /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + :paramtype workspace_id: str + :keyword marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which + you would like to send Diagnostic Logs. + :paramtype marketplace_partner_id: str + :keyword log_analytics_destination_type: A string indicating whether the export to Log + Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination + type constructed as follows: :code:``_:code:``. Possible values are: Dedicated and null (null is default.). + :paramtype log_analytics_destination_type: str + """ super(DiagnosticSettingsResource, self).__init__(**kwargs) self.system_data = None self.storage_account_id = kwargs.get('storage_account_id', None) @@ -521,8 +668,8 @@ def __init__( class DiagnosticSettingsResourceCollection(msrest.serialization.Model): """Represents a collection of alert rule resources. - :param value: The collection of diagnostic settings resources;. - :type value: + :ivar value: The collection of diagnostic settings resources;. + :vartype value: list[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource] """ @@ -534,6 +681,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: The collection of diagnostic settings resources;. + :paramtype value: + list[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource] + """ super(DiagnosticSettingsResourceCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -541,15 +693,15 @@ def __init__( class EmailNotification(msrest.serialization.Model): """Email notification of an autoscale event. - :param send_to_subscription_administrator: a value indicating whether to send email to + :ivar send_to_subscription_administrator: a value indicating whether to send email to subscription administrator. - :type send_to_subscription_administrator: bool - :param send_to_subscription_co_administrators: a value indicating whether to send email to + :vartype send_to_subscription_administrator: bool + :ivar send_to_subscription_co_administrators: a value indicating whether to send email to subscription co-administrators. - :type send_to_subscription_co_administrators: bool - :param custom_emails: the custom e-mails list. This value can be null or empty, in which case + :vartype send_to_subscription_co_administrators: bool + :ivar custom_emails: the custom e-mails list. This value can be null or empty, in which case this attribute will be ignored. - :type custom_emails: list[str] + :vartype custom_emails: list[str] """ _attribute_map = { @@ -562,6 +714,17 @@ def __init__( self, **kwargs ): + """ + :keyword send_to_subscription_administrator: a value indicating whether to send email to + subscription administrator. + :paramtype send_to_subscription_administrator: bool + :keyword send_to_subscription_co_administrators: a value indicating whether to send email to + subscription co-administrators. + :paramtype send_to_subscription_co_administrators: bool + :keyword custom_emails: the custom e-mails list. This value can be null or empty, in which case + this attribute will be ignored. + :paramtype custom_emails: list[str] + """ super(EmailNotification, self).__init__(**kwargs) self.send_to_subscription_administrator = kwargs.get('send_to_subscription_administrator', False) self.send_to_subscription_co_administrators = kwargs.get('send_to_subscription_co_administrators', False) @@ -571,10 +734,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -586,6 +749,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -596,18 +765,18 @@ class LogSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param category: Name of a Diagnostic Log category for a resource type this setting is applied + :ivar category: Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. - :type category: str - :param category_group: Name of a Diagnostic Log category group for a resource type this setting + :vartype category: str + :ivar category_group: Name of a Diagnostic Log category group for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. - :type category_group: str - :param enabled: Required. a value indicating whether this log is enabled. - :type enabled: bool - :param retention_policy: the retention policy for this log. - :type retention_policy: ~$(python-base-namespace).v2021_05_01_preview.models.RetentionPolicy + :vartype category_group: str + :ivar enabled: Required. a value indicating whether this log is enabled. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this log. + :vartype retention_policy: ~$(python-base-namespace).v2021_05_01_preview.models.RetentionPolicy """ _validation = { @@ -625,6 +794,21 @@ def __init__( self, **kwargs ): + """ + :keyword category: Name of a Diagnostic Log category for a resource type this setting is + applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET + diagnostic settings operation. + :paramtype category: str + :keyword category_group: Name of a Diagnostic Log category group for a resource type this + setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first + perform a GET diagnostic settings operation. + :paramtype category_group: str + :keyword enabled: Required. a value indicating whether this log is enabled. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this log. + :paramtype retention_policy: + ~$(python-base-namespace).v2021_05_01_preview.models.RetentionPolicy + """ super(LogSettings, self).__init__(**kwargs) self.category = kwargs.get('category', None) self.category_group = kwargs.get('category_group', None) @@ -647,27 +831,27 @@ class ManagementGroupDiagnosticSettingsResource(Resource): :vartype type: str :ivar system_data: The system metadata related to this resource. :vartype system_data: ~$(python-base-namespace).v2021_05_01_preview.models.SystemData - :param storage_account_id: The resource ID of the storage account to which you would like to + :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. - :type service_bus_rule_id: str - :param event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :type event_hub_authorization_rule_id: str - :param event_hub_name: The name of the event hub. If none is specified, the default event hub + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :vartype event_hub_authorization_rule_id: str + :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub will be selected. - :type event_hub_name: str - :param logs: The list of logs settings. - :type logs: + :vartype event_hub_name: str + :ivar logs: The list of logs settings. + :vartype logs: list[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupLogSettings] - :param workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would + :ivar workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str - :param marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which - you would like to send Diagnostic Logs. - :type marketplace_partner_id: str + :vartype workspace_id: str + :ivar marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which you + would like to send Diagnostic Logs. + :vartype marketplace_partner_id: str """ _validation = { @@ -695,6 +879,29 @@ def __init__( self, **kwargs ): + """ + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here + to maintain backwards compatibility. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub + will be selected. + :paramtype event_hub_name: str + :keyword logs: The list of logs settings. + :paramtype logs: + list[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupLogSettings] + :keyword workspace_id: The full ARM resource ID of the Log Analytics workspace to which you + would like to send Diagnostic Logs. Example: + /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + :paramtype workspace_id: str + :keyword marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which + you would like to send Diagnostic Logs. + :paramtype marketplace_partner_id: str + """ super(ManagementGroupDiagnosticSettingsResource, self).__init__(**kwargs) self.system_data = None self.storage_account_id = kwargs.get('storage_account_id', None) @@ -709,8 +916,8 @@ def __init__( class ManagementGroupDiagnosticSettingsResourceCollection(msrest.serialization.Model): """Represents a collection of management group diagnostic settings resources. - :param value: The collection of management group diagnostic settings resources. - :type value: + :ivar value: The collection of management group diagnostic settings resources. + :vartype value: list[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource] """ @@ -722,6 +929,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: The collection of management group diagnostic settings resources. + :paramtype value: + list[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource] + """ super(ManagementGroupDiagnosticSettingsResourceCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -731,14 +943,14 @@ class ManagementGroupLogSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param category: Name of a Management Group Diagnostic Log category for a resource type this + :ivar category: Name of a Management Group Diagnostic Log category for a resource type this setting is applied to. - :type category: str - :param category_group: Name of a Management Group Diagnostic Log category group for a resource + :vartype category: str + :ivar category_group: Name of a Management Group Diagnostic Log category group for a resource type this setting is applied to. - :type category_group: str - :param enabled: Required. a value indicating whether this log is enabled. - :type enabled: bool + :vartype category_group: str + :ivar enabled: Required. a value indicating whether this log is enabled. + :vartype enabled: bool """ _validation = { @@ -755,6 +967,16 @@ def __init__( self, **kwargs ): + """ + :keyword category: Name of a Management Group Diagnostic Log category for a resource type this + setting is applied to. + :paramtype category: str + :keyword category_group: Name of a Management Group Diagnostic Log category group for a + resource type this setting is applied to. + :paramtype category_group: str + :keyword enabled: Required. a value indicating whether this log is enabled. + :paramtype enabled: bool + """ super(ManagementGroupLogSettings, self).__init__(**kwargs) self.category = kwargs.get('category', None) self.category_group = kwargs.get('category_group', None) @@ -766,16 +988,16 @@ class MetricSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_grain: the timegrain of the metric in ISO8601 format. - :type time_grain: ~datetime.timedelta - :param category: Name of a Diagnostic Metric category for a resource type this setting is + :ivar time_grain: the timegrain of the metric in ISO8601 format. + :vartype time_grain: ~datetime.timedelta + :ivar category: Name of a Diagnostic Metric category for a resource type this setting is applied to. To obtain the list of Diagnostic metric categories for a resource, first perform a GET diagnostic settings operation. - :type category: str - :param enabled: Required. a value indicating whether this category is enabled. - :type enabled: bool - :param retention_policy: the retention policy for this category. - :type retention_policy: ~$(python-base-namespace).v2021_05_01_preview.models.RetentionPolicy + :vartype category: str + :ivar enabled: Required. a value indicating whether this category is enabled. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this category. + :vartype retention_policy: ~$(python-base-namespace).v2021_05_01_preview.models.RetentionPolicy """ _validation = { @@ -793,6 +1015,19 @@ def __init__( self, **kwargs ): + """ + :keyword time_grain: the timegrain of the metric in ISO8601 format. + :paramtype time_grain: ~datetime.timedelta + :keyword category: Name of a Diagnostic Metric category for a resource type this setting is + applied to. To obtain the list of Diagnostic metric categories for a resource, first perform a + GET diagnostic settings operation. + :paramtype category: str + :keyword enabled: Required. a value indicating whether this category is enabled. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this category. + :paramtype retention_policy: + ~$(python-base-namespace).v2021_05_01_preview.models.RetentionPolicy + """ super(MetricSettings, self).__init__(**kwargs) self.time_grain = kwargs.get('time_grain', None) self.category = kwargs.get('category', None) @@ -805,45 +1040,44 @@ class MetricTrigger(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param metric_name: Required. the name of the metric that defines what the rule monitors. - :type metric_name: str - :param metric_namespace: the namespace of the metric that defines what the rule monitors. - :type metric_namespace: str - :param metric_resource_uri: Required. the resource identifier of the resource the rule - monitors. - :type metric_resource_uri: str - :param metric_resource_location: the location of the resource the rule monitors. - :type metric_resource_location: str - :param time_grain: Required. the granularity of metrics the rule monitors. Must be one of the + :ivar metric_name: Required. the name of the metric that defines what the rule monitors. + :vartype metric_name: str + :ivar metric_namespace: the namespace of the metric that defines what the rule monitors. + :vartype metric_namespace: str + :ivar metric_resource_uri: Required. the resource identifier of the resource the rule monitors. + :vartype metric_resource_uri: str + :ivar metric_resource_location: the location of the resource the rule monitors. + :vartype metric_resource_location: str + :ivar time_grain: Required. the granularity of metrics the rule monitors. Must be one of the predefined values returned from metric definitions for the metric. Must be between 12 hours and 1 minute. - :type time_grain: ~datetime.timedelta - :param statistic: Required. the metric statistic type. How the metrics from multiple instances + :vartype time_grain: ~datetime.timedelta + :ivar statistic: Required. the metric statistic type. How the metrics from multiple instances are combined. Possible values include: "Average", "Min", "Max", "Sum", "Count". - :type statistic: str or + :vartype statistic: str or ~$(python-base-namespace).v2021_05_01_preview.models.MetricStatisticType - :param time_window: Required. the range of time in which instance data is collected. This value + :ivar time_window: Required. the range of time in which instance data is collected. This value must be greater than the delay in metric collection, which can vary from resource-to-resource. Must be between 12 hours and 5 minutes. - :type time_window: ~datetime.timedelta - :param time_aggregation: Required. time aggregation type. How the data that is collected should + :vartype time_window: ~datetime.timedelta + :ivar time_aggregation: Required. time aggregation type. How the data that is collected should be combined over time. The default value is Average. Possible values include: "Average", "Minimum", "Maximum", "Total", "Count", "Last". - :type time_aggregation: str or + :vartype time_aggregation: str or ~$(python-base-namespace).v2021_05_01_preview.models.TimeAggregationType - :param operator: Required. the operator that is used to compare the metric data and the + :ivar operator: Required. the operator that is used to compare the metric data and the threshold. Possible values include: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or + :vartype operator: str or ~$(python-base-namespace).v2021_05_01_preview.models.ComparisonOperationType - :param threshold: Required. the threshold of the metric that triggers the scale action. - :type threshold: float - :param dimensions: List of dimension conditions. For example: + :ivar threshold: Required. the threshold of the metric that triggers the scale action. + :vartype threshold: float + :ivar dimensions: List of dimension conditions. For example: [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. - :type dimensions: + :vartype dimensions: list[~$(python-base-namespace).v2021_05_01_preview.models.ScaleRuleMetricDimension] - :param divide_per_instance: a value indicating whether metric should divide per instance. - :type divide_per_instance: bool + :ivar divide_per_instance: a value indicating whether metric should divide per instance. + :vartype divide_per_instance: bool """ _validation = { @@ -876,6 +1110,47 @@ def __init__( self, **kwargs ): + """ + :keyword metric_name: Required. the name of the metric that defines what the rule monitors. + :paramtype metric_name: str + :keyword metric_namespace: the namespace of the metric that defines what the rule monitors. + :paramtype metric_namespace: str + :keyword metric_resource_uri: Required. the resource identifier of the resource the rule + monitors. + :paramtype metric_resource_uri: str + :keyword metric_resource_location: the location of the resource the rule monitors. + :paramtype metric_resource_location: str + :keyword time_grain: Required. the granularity of metrics the rule monitors. Must be one of the + predefined values returned from metric definitions for the metric. Must be between 12 hours and + 1 minute. + :paramtype time_grain: ~datetime.timedelta + :keyword statistic: Required. the metric statistic type. How the metrics from multiple + instances are combined. Possible values include: "Average", "Min", "Max", "Sum", "Count". + :paramtype statistic: str or + ~$(python-base-namespace).v2021_05_01_preview.models.MetricStatisticType + :keyword time_window: Required. the range of time in which instance data is collected. This + value must be greater than the delay in metric collection, which can vary from + resource-to-resource. Must be between 12 hours and 5 minutes. + :paramtype time_window: ~datetime.timedelta + :keyword time_aggregation: Required. time aggregation type. How the data that is collected + should be combined over time. The default value is Average. Possible values include: "Average", + "Minimum", "Maximum", "Total", "Count", "Last". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2021_05_01_preview.models.TimeAggregationType + :keyword operator: Required. the operator that is used to compare the metric data and the + threshold. Possible values include: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", + "LessThan", "LessThanOrEqual". + :paramtype operator: str or + ~$(python-base-namespace).v2021_05_01_preview.models.ComparisonOperationType + :keyword threshold: Required. the threshold of the metric that triggers the scale action. + :paramtype threshold: float + :keyword dimensions: List of dimension conditions. For example: + [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. + :paramtype dimensions: + list[~$(python-base-namespace).v2021_05_01_preview.models.ScaleRuleMetricDimension] + :keyword divide_per_instance: a value indicating whether metric should divide per instance. + :paramtype divide_per_instance: bool + """ super(MetricTrigger, self).__init__(**kwargs) self.metric_name = kwargs['metric_name'] self.metric_namespace = kwargs.get('metric_namespace', None) @@ -896,13 +1171,13 @@ class PredictiveAutoscalePolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param scale_mode: Required. the predictive autoscale mode. Possible values include: - "Disabled", "ForecastOnly", "Enabled". - :type scale_mode: str or + :ivar scale_mode: Required. the predictive autoscale mode. Possible values include: "Disabled", + "ForecastOnly", "Enabled". + :vartype scale_mode: str or ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveAutoscalePolicyScaleMode - :param scale_look_ahead_time: the amount of time to specify by which instances are launched in + :ivar scale_look_ahead_time: the amount of time to specify by which instances are launched in advance. It must be between 1 minute and 60 minutes in ISO 8601 format. - :type scale_look_ahead_time: ~datetime.timedelta + :vartype scale_look_ahead_time: ~datetime.timedelta """ _validation = { @@ -918,6 +1193,15 @@ def __init__( self, **kwargs ): + """ + :keyword scale_mode: Required. the predictive autoscale mode. Possible values include: + "Disabled", "ForecastOnly", "Enabled". + :paramtype scale_mode: str or + ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveAutoscalePolicyScaleMode + :keyword scale_look_ahead_time: the amount of time to specify by which instances are launched + in advance. It must be between 1 minute and 60 minutes in ISO 8601 format. + :paramtype scale_look_ahead_time: ~datetime.timedelta + """ super(PredictiveAutoscalePolicy, self).__init__(**kwargs) self.scale_mode = kwargs['scale_mode'] self.scale_look_ahead_time = kwargs.get('scale_look_ahead_time', None) @@ -926,20 +1210,20 @@ def __init__( class PredictiveResponse(msrest.serialization.Model): """The response to a metrics query. - :param timespan: The timespan for which the data was retrieved. Its value consists of two + :ivar timespan: The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. - :type timespan: str - :param interval: The interval (window size) for which the metric data was returned in. This - may be adjusted in the future and returned back from what was originally requested. This is - not present if a metadata request was made. - :type interval: ~datetime.timedelta - :param metric_name: The metrics being queried. - :type metric_name: str - :param target_resource_id: resource of the predictive metric. - :type target_resource_id: str - :param data: the value of the collection. - :type data: list[~$(python-base-namespace).v2021_05_01_preview.models.PredictiveValue] + :vartype timespan: str + :ivar interval: The interval (window size) for which the metric data was returned in. This may + be adjusted in the future and returned back from what was originally requested. This is not + present if a metadata request was made. + :vartype interval: ~datetime.timedelta + :ivar metric_name: The metrics being queried. + :vartype metric_name: str + :ivar target_resource_id: resource of the predictive metric. + :vartype target_resource_id: str + :ivar data: the value of the collection. + :vartype data: list[~$(python-base-namespace).v2021_05_01_preview.models.PredictiveValue] """ _attribute_map = { @@ -954,6 +1238,22 @@ def __init__( self, **kwargs ): + """ + :keyword timespan: The timespan for which the data was retrieved. Its value consists of two + datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back + from what was originally requested. + :paramtype timespan: str + :keyword interval: The interval (window size) for which the metric data was returned in. This + may be adjusted in the future and returned back from what was originally requested. This is + not present if a metadata request was made. + :paramtype interval: ~datetime.timedelta + :keyword metric_name: The metrics being queried. + :paramtype metric_name: str + :keyword target_resource_id: resource of the predictive metric. + :paramtype target_resource_id: str + :keyword data: the value of the collection. + :paramtype data: list[~$(python-base-namespace).v2021_05_01_preview.models.PredictiveValue] + """ super(PredictiveResponse, self).__init__(**kwargs) self.timespan = kwargs.get('timespan', None) self.interval = kwargs.get('interval', None) @@ -967,10 +1267,10 @@ class PredictiveValue(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_stamp: Required. the timestamp for the metric value in ISO 8601 format. - :type time_stamp: ~datetime.datetime - :param value: Required. Predictive value in this time bucket. - :type value: float + :ivar time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :vartype time_stamp: ~datetime.datetime + :ivar value: Required. Predictive value in this time bucket. + :vartype value: float """ _validation = { @@ -987,6 +1287,12 @@ def __init__( self, **kwargs ): + """ + :keyword time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :paramtype time_stamp: ~datetime.datetime + :keyword value: Required. Predictive value in this time bucket. + :paramtype value: float + """ super(PredictiveValue, self).__init__(**kwargs) self.time_stamp = kwargs['time_stamp'] self.value = kwargs['value'] @@ -997,15 +1303,15 @@ class Recurrence(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param frequency: Required. the recurrence frequency. How often the schedule profile should - take effect. This value must be Week, meaning each week will have the same set of profiles. For + :ivar frequency: Required. the recurrence frequency. How often the schedule profile should take + effect. This value must be Week, meaning each week will have the same set of profiles. For example, to set a daily schedule, set **schedule** to every day of the week. The frequency property specifies that the schedule is repeated weekly. Possible values include: "None", "Second", "Minute", "Hour", "Day", "Week", "Month", "Year". - :type frequency: str or + :vartype frequency: str or ~$(python-base-namespace).v2021_05_01_preview.models.RecurrenceFrequency - :param schedule: Required. the scheduling constraints for when the profile begins. - :type schedule: ~$(python-base-namespace).v2021_05_01_preview.models.RecurrentSchedule + :ivar schedule: Required. the scheduling constraints for when the profile begins. + :vartype schedule: ~$(python-base-namespace).v2021_05_01_preview.models.RecurrentSchedule """ _validation = { @@ -1022,6 +1328,17 @@ def __init__( self, **kwargs ): + """ + :keyword frequency: Required. the recurrence frequency. How often the schedule profile should + take effect. This value must be Week, meaning each week will have the same set of profiles. For + example, to set a daily schedule, set **schedule** to every day of the week. The frequency + property specifies that the schedule is repeated weekly. Possible values include: "None", + "Second", "Minute", "Hour", "Day", "Week", "Month", "Year". + :paramtype frequency: str or + ~$(python-base-namespace).v2021_05_01_preview.models.RecurrenceFrequency + :keyword schedule: Required. the scheduling constraints for when the profile begins. + :paramtype schedule: ~$(python-base-namespace).v2021_05_01_preview.models.RecurrentSchedule + """ super(Recurrence, self).__init__(**kwargs) self.frequency = kwargs['frequency'] self.schedule = kwargs['schedule'] @@ -1032,7 +1349,7 @@ class RecurrentSchedule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_zone: Required. the timezone for the hours of the profile. Some examples of valid + :ivar time_zone: Required. the timezone for the hours of the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard @@ -1062,15 +1379,15 @@ class RecurrentSchedule(msrest.serialization.Model): Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time. - :type time_zone: str - :param days: Required. the collection of days that the profile takes effect on. Possible values + :vartype time_zone: str + :ivar days: Required. the collection of days that the profile takes effect on. Possible values are Sunday through Saturday. - :type days: list[str] - :param hours: Required. A collection of hours that the profile takes effect on. Values - supported are 0 to 23 on the 24-hour clock (AM/PM times are not supported). - :type hours: list[int] - :param minutes: Required. A collection of minutes at which the profile takes effect at. - :type minutes: list[int] + :vartype days: list[str] + :ivar hours: Required. A collection of hours that the profile takes effect on. Values supported + are 0 to 23 on the 24-hour clock (AM/PM times are not supported). + :vartype hours: list[int] + :ivar minutes: Required. A collection of minutes at which the profile takes effect at. + :vartype minutes: list[int] """ _validation = { @@ -1091,6 +1408,47 @@ def __init__( self, **kwargs ): + """ + :keyword time_zone: Required. the timezone for the hours of the profile. Some examples of valid + time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, + Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain + Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard + Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, + Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard + Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, + Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina + Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, + Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde + Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. + Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central European + Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, + GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. + Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, + Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, + Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran + Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius + Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West + Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, + Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard + Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia + Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. + Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, + Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard + Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, + Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, + Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji + Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands + Standard Time. + :paramtype time_zone: str + :keyword days: Required. the collection of days that the profile takes effect on. Possible + values are Sunday through Saturday. + :paramtype days: list[str] + :keyword hours: Required. A collection of hours that the profile takes effect on. Values + supported are 0 to 23 on the 24-hour clock (AM/PM times are not supported). + :paramtype hours: list[int] + :keyword minutes: Required. A collection of minutes at which the profile takes effect at. + :paramtype minutes: list[int] + """ super(RecurrentSchedule, self).__init__(**kwargs) self.time_zone = kwargs['time_zone'] self.days = kwargs['days'] @@ -1103,11 +1461,11 @@ class RetentionPolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param enabled: Required. a value indicating whether the retention policy is enabled. - :type enabled: bool - :param days: Required. the number of days for the retention in days. A value of 0 will retain + :ivar enabled: Required. a value indicating whether the retention policy is enabled. + :vartype enabled: bool + :ivar days: Required. the number of days for the retention in days. A value of 0 will retain the events indefinitely. - :type days: int + :vartype days: int """ _validation = { @@ -1124,6 +1482,13 @@ def __init__( self, **kwargs ): + """ + :keyword enabled: Required. a value indicating whether the retention policy is enabled. + :paramtype enabled: bool + :keyword days: Required. the number of days for the retention in days. A value of 0 will retain + the events indefinitely. + :paramtype days: int + """ super(RetentionPolicy, self).__init__(**kwargs) self.enabled = kwargs['enabled'] self.days = kwargs['days'] @@ -1134,18 +1499,18 @@ class ScaleAction(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param direction: Required. the scale direction. Whether the scaling action increases or + :ivar direction: Required. the scale direction. Whether the scaling action increases or decreases the number of instances. Possible values include: "None", "Increase", "Decrease". - :type direction: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleDirection - :param type: Required. the type of action that should occur when the scale rule fires. Possible + :vartype direction: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleDirection + :ivar type: Required. the type of action that should occur when the scale rule fires. Possible values include: "ChangeCount", "PercentChangeCount", "ExactCount", "ServiceAllowedNextValue". - :type type: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleType - :param value: the number of instances that are involved in the scaling action. This value must + :vartype type: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleType + :ivar value: the number of instances that are involved in the scaling action. This value must be 1 or greater. The default value is 1. - :type value: str - :param cooldown: Required. the amount of time to wait since the last scaling action before this + :vartype value: str + :ivar cooldown: Required. the amount of time to wait since the last scaling action before this action occurs. It must be between 1 week and 1 minute in ISO 8601 format. - :type cooldown: ~datetime.timedelta + :vartype cooldown: ~datetime.timedelta """ _validation = { @@ -1165,6 +1530,22 @@ def __init__( self, **kwargs ): + """ + :keyword direction: Required. the scale direction. Whether the scaling action increases or + decreases the number of instances. Possible values include: "None", "Increase", "Decrease". + :paramtype direction: str or + ~$(python-base-namespace).v2021_05_01_preview.models.ScaleDirection + :keyword type: Required. the type of action that should occur when the scale rule fires. + Possible values include: "ChangeCount", "PercentChangeCount", "ExactCount", + "ServiceAllowedNextValue". + :paramtype type: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleType + :keyword value: the number of instances that are involved in the scaling action. This value + must be 1 or greater. The default value is 1. + :paramtype value: str + :keyword cooldown: Required. the amount of time to wait since the last scaling action before + this action occurs. It must be between 1 week and 1 minute in ISO 8601 format. + :paramtype cooldown: ~datetime.timedelta + """ super(ScaleAction, self).__init__(**kwargs) self.direction = kwargs['direction'] self.type = kwargs['type'] @@ -1177,15 +1558,15 @@ class ScaleCapacity(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param minimum: Required. the minimum number of instances for the resource. - :type minimum: str - :param maximum: Required. the maximum number of instances for the resource. The actual maximum + :ivar minimum: Required. the minimum number of instances for the resource. + :vartype minimum: str + :ivar maximum: Required. the maximum number of instances for the resource. The actual maximum number of instances is limited by the cores that are available in the subscription. - :type maximum: str - :param default: Required. the number of instances that will be set if metrics are not available + :vartype maximum: str + :ivar default: Required. the number of instances that will be set if metrics are not available for evaluation. The default is only used if the current instance count is lower than the default. - :type default: str + :vartype default: str """ _validation = { @@ -1204,6 +1585,17 @@ def __init__( self, **kwargs ): + """ + :keyword minimum: Required. the minimum number of instances for the resource. + :paramtype minimum: str + :keyword maximum: Required. the maximum number of instances for the resource. The actual + maximum number of instances is limited by the cores that are available in the subscription. + :paramtype maximum: str + :keyword default: Required. the number of instances that will be set if metrics are not + available for evaluation. The default is only used if the current instance count is lower than + the default. + :paramtype default: str + """ super(ScaleCapacity, self).__init__(**kwargs) self.minimum = kwargs['minimum'] self.maximum = kwargs['maximum'] @@ -1215,10 +1607,10 @@ class ScaleRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param metric_trigger: Required. the trigger that results in a scaling action. - :type metric_trigger: ~$(python-base-namespace).v2021_05_01_preview.models.MetricTrigger - :param scale_action: Required. the parameters for the scaling action. - :type scale_action: ~$(python-base-namespace).v2021_05_01_preview.models.ScaleAction + :ivar metric_trigger: Required. the trigger that results in a scaling action. + :vartype metric_trigger: ~$(python-base-namespace).v2021_05_01_preview.models.MetricTrigger + :ivar scale_action: Required. the parameters for the scaling action. + :vartype scale_action: ~$(python-base-namespace).v2021_05_01_preview.models.ScaleAction """ _validation = { @@ -1235,6 +1627,12 @@ def __init__( self, **kwargs ): + """ + :keyword metric_trigger: Required. the trigger that results in a scaling action. + :paramtype metric_trigger: ~$(python-base-namespace).v2021_05_01_preview.models.MetricTrigger + :keyword scale_action: Required. the parameters for the scaling action. + :paramtype scale_action: ~$(python-base-namespace).v2021_05_01_preview.models.ScaleAction + """ super(ScaleRule, self).__init__(**kwargs) self.metric_trigger = kwargs['metric_trigger'] self.scale_action = kwargs['scale_action'] @@ -1245,15 +1643,15 @@ class ScaleRuleMetricDimension(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param dimension_name: Required. Name of the dimension. - :type dimension_name: str - :param operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are supported. + :ivar dimension_name: Required. Name of the dimension. + :vartype dimension_name: str + :ivar operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values. Possible values include: "Equals", "NotEquals". - :type operator: str or + :vartype operator: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleRuleMetricDimensionOperationType - :param values: Required. list of dimension values. For example: ["App1","App2"]. - :type values: list[str] + :ivar values: Required. list of dimension values. For example: ["App1","App2"]. + :vartype values: list[str] """ _validation = { @@ -1272,6 +1670,17 @@ def __init__( self, **kwargs ): + """ + :keyword dimension_name: Required. Name of the dimension. + :paramtype dimension_name: str + :keyword operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are + supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the + values. Possible values include: "Equals", "NotEquals". + :paramtype operator: str or + ~$(python-base-namespace).v2021_05_01_preview.models.ScaleRuleMetricDimensionOperationType + :keyword values: Required. list of dimension values. For example: ["App1","App2"]. + :paramtype values: list[str] + """ super(ScaleRuleMetricDimension, self).__init__(**kwargs) self.dimension_name = kwargs['dimension_name'] self.operator = kwargs['operator'] @@ -1293,26 +1702,27 @@ class SubscriptionDiagnosticSettingsResource(Resource): :vartype type: str :ivar system_data: The system metadata related to this resource. :vartype system_data: ~$(python-base-namespace).v2021_05_01_preview.models.SystemData - :param storage_account_id: The resource ID of the storage account to which you would like to + :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. - :type service_bus_rule_id: str - :param event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :type event_hub_authorization_rule_id: str - :param event_hub_name: The name of the event hub. If none is specified, the default event hub + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :vartype event_hub_authorization_rule_id: str + :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub will be selected. - :type event_hub_name: str - :param logs: The list of logs settings. - :type logs: list[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionLogSettings] - :param workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would + :vartype event_hub_name: str + :ivar logs: The list of logs settings. + :vartype logs: + list[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionLogSettings] + :ivar workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str - :param marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which - you would like to send Diagnostic Logs. - :type marketplace_partner_id: str + :vartype workspace_id: str + :ivar marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which you + would like to send Diagnostic Logs. + :vartype marketplace_partner_id: str """ _validation = { @@ -1340,6 +1750,29 @@ def __init__( self, **kwargs ): + """ + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here + to maintain backwards compatibility. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub + will be selected. + :paramtype event_hub_name: str + :keyword logs: The list of logs settings. + :paramtype logs: + list[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionLogSettings] + :keyword workspace_id: The full ARM resource ID of the Log Analytics workspace to which you + would like to send Diagnostic Logs. Example: + /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + :paramtype workspace_id: str + :keyword marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which + you would like to send Diagnostic Logs. + :paramtype marketplace_partner_id: str + """ super(SubscriptionDiagnosticSettingsResource, self).__init__(**kwargs) self.system_data = None self.storage_account_id = kwargs.get('storage_account_id', None) @@ -1354,8 +1787,8 @@ def __init__( class SubscriptionDiagnosticSettingsResourceCollection(msrest.serialization.Model): """Represents a collection of subscription diagnostic settings resources. - :param value: The collection of subscription diagnostic settings resources. - :type value: + :ivar value: The collection of subscription diagnostic settings resources. + :vartype value: list[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource] """ @@ -1367,6 +1800,11 @@ def __init__( self, **kwargs ): + """ + :keyword value: The collection of subscription diagnostic settings resources. + :paramtype value: + list[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource] + """ super(SubscriptionDiagnosticSettingsResourceCollection, self).__init__(**kwargs) self.value = kwargs.get('value', None) @@ -1376,14 +1814,14 @@ class SubscriptionLogSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param category: Name of a Subscription Diagnostic Log category for a resource type this - setting is applied to. - :type category: str - :param category_group: Name of a Subscription Diagnostic Log category group for a resource type + :ivar category: Name of a Subscription Diagnostic Log category for a resource type this setting + is applied to. + :vartype category: str + :ivar category_group: Name of a Subscription Diagnostic Log category group for a resource type this setting is applied to. - :type category_group: str - :param enabled: Required. a value indicating whether this log is enabled. - :type enabled: bool + :vartype category_group: str + :ivar enabled: Required. a value indicating whether this log is enabled. + :vartype enabled: bool """ _validation = { @@ -1400,6 +1838,16 @@ def __init__( self, **kwargs ): + """ + :keyword category: Name of a Subscription Diagnostic Log category for a resource type this + setting is applied to. + :paramtype category: str + :keyword category_group: Name of a Subscription Diagnostic Log category group for a resource + type this setting is applied to. + :paramtype category_group: str + :keyword enabled: Required. a value indicating whether this log is enabled. + :paramtype enabled: bool + """ super(SubscriptionLogSettings, self).__init__(**kwargs) self.category = kwargs.get('category', None) self.category_group = kwargs.get('category_group', None) @@ -1409,22 +1857,22 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :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 ~$(python-base-namespace).v2021_05_01_preview.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :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 + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~$(python-base-namespace).v2021_05_01_preview.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -1440,6 +1888,24 @@ def __init__( self, **kwargs ): + """ + :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 + ~$(python-base-namespace).v2021_05_01_preview.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 + ~$(python-base-namespace).v2021_05_01_preview.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 = kwargs.get('created_by', None) self.created_by_type = kwargs.get('created_by_type', None) @@ -1454,7 +1920,7 @@ class TimeWindow(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_zone: the timezone of the start and end times for the profile. Some examples of + :ivar time_zone: the timezone of the start and end times for the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central @@ -1484,11 +1950,11 @@ class TimeWindow(msrest.serialization.Model): Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time. - :type time_zone: str - :param start: Required. the start time for the profile in ISO 8601 format. - :type start: ~datetime.datetime - :param end: Required. the end time for the profile in ISO 8601 format. - :type end: ~datetime.datetime + :vartype time_zone: str + :ivar start: Required. the start time for the profile in ISO 8601 format. + :vartype start: ~datetime.datetime + :ivar end: Required. the end time for the profile in ISO 8601 format. + :vartype end: ~datetime.datetime """ _validation = { @@ -1506,6 +1972,43 @@ def __init__( self, **kwargs ): + """ + :keyword time_zone: the timezone of the start and end times for the profile. Some examples of + valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard + Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, + Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central + Standard Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific + Standard Time, Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, + Paraguay Standard Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western + Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard + Time, Argentina Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo + Standard Time, Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, + Cape Verde Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard + Time, W. Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central + European Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard + Time, GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, + E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, + Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, + Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran + Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius + Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West + Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, + Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard + Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia + Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. + Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, + Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard + Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, + Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, + Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji + Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands + Standard Time. + :paramtype time_zone: str + :keyword start: Required. the start time for the profile in ISO 8601 format. + :paramtype start: ~datetime.datetime + :keyword end: Required. the end time for the profile in ISO 8601 format. + :paramtype end: ~datetime.datetime + """ super(TimeWindow, self).__init__(**kwargs) self.time_zone = kwargs.get('time_zone', None) self.start = kwargs['start'] @@ -1515,10 +2018,10 @@ def __init__( class WebhookNotification(msrest.serialization.Model): """Webhook notification of an autoscale event. - :param service_uri: the service address to receive the notification. - :type service_uri: str - :param properties: a property bag of settings. This value can be empty. - :type properties: dict[str, str] + :ivar service_uri: the service address to receive the notification. + :vartype service_uri: str + :ivar properties: a property bag of settings. This value can be empty. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1530,6 +2033,12 @@ def __init__( self, **kwargs ): + """ + :keyword service_uri: the service address to receive the notification. + :paramtype service_uri: str + :keyword properties: a property bag of settings. This value can be empty. + :paramtype properties: dict[str, str] + """ super(WebhookNotification, self).__init__(**kwargs) self.service_uri = kwargs.get('service_uri', None) self.properties = kwargs.get('properties', None) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models_py3.py index f2757e2b62c8e..d0019c4e672db 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_models_py3.py @@ -20,8 +20,9 @@ class AutoscaleErrorResponse(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param error: The error object. - :type error: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleErrorResponseError + :ivar error: The error object. + :vartype error: + ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleErrorResponseError :ivar system_data: The system metadata related to the response. :vartype system_data: ~$(python-base-namespace).v2021_05_01_preview.models.SystemData """ @@ -41,6 +42,11 @@ def __init__( error: Optional["AutoscaleErrorResponseError"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: + ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleErrorResponseError + """ super(AutoscaleErrorResponse, self).__init__(**kwargs) self.error = error self.system_data = None @@ -49,14 +55,14 @@ def __init__( class AutoscaleErrorResponseError(msrest.serialization.Model): """The error object. - :param code: One of a server-defined set of error codes. - :type code: str - :param message: A human-readable representation of the error. - :type message: str - :param target: The target of the particular error. - :type target: str - :param details: A human-readable representation of the error's details. - :type details: str + :ivar code: One of a server-defined set of error codes. + :vartype code: str + :ivar message: A human-readable representation of the error. + :vartype message: str + :ivar target: The target of the particular error. + :vartype target: str + :ivar details: A human-readable representation of the error's details. + :vartype details: str """ _attribute_map = { @@ -75,6 +81,16 @@ def __init__( details: Optional[str] = None, **kwargs ): + """ + :keyword code: One of a server-defined set of error codes. + :paramtype code: str + :keyword message: A human-readable representation of the error. + :paramtype message: str + :keyword target: The target of the particular error. + :paramtype target: str + :keyword details: A human-readable representation of the error's details. + :paramtype details: str + """ super(AutoscaleErrorResponseError, self).__init__(**kwargs) self.code = code self.message = message @@ -92,10 +108,11 @@ class AutoscaleNotification(msrest.serialization.Model): :ivar operation: the operation associated with the notification and its value must be "scale". Has constant value: "Scale". :vartype operation: str - :param email: the email notification. - :type email: ~$(python-base-namespace).v2021_05_01_preview.models.EmailNotification - :param webhooks: the collection of webhook notifications. - :type webhooks: list[~$(python-base-namespace).v2021_05_01_preview.models.WebhookNotification] + :ivar email: the email notification. + :vartype email: ~$(python-base-namespace).v2021_05_01_preview.models.EmailNotification + :ivar webhooks: the collection of webhook notifications. + :vartype webhooks: + list[~$(python-base-namespace).v2021_05_01_preview.models.WebhookNotification] """ _validation = { @@ -117,6 +134,13 @@ def __init__( webhooks: Optional[List["WebhookNotification"]] = None, **kwargs ): + """ + :keyword email: the email notification. + :paramtype email: ~$(python-base-namespace).v2021_05_01_preview.models.EmailNotification + :keyword webhooks: the collection of webhook notifications. + :paramtype webhooks: + list[~$(python-base-namespace).v2021_05_01_preview.models.WebhookNotification] + """ super(AutoscaleNotification, self).__init__(**kwargs) self.email = email self.webhooks = webhooks @@ -127,19 +151,19 @@ class AutoscaleProfile(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. the name of the profile. - :type name: str - :param capacity: Required. the number of instances that can be used during this profile. - :type capacity: ~$(python-base-namespace).v2021_05_01_preview.models.ScaleCapacity - :param rules: Required. the collection of rules that provide the triggers and parameters for - the scaling action. A maximum of 10 rules can be specified. - :type rules: list[~$(python-base-namespace).v2021_05_01_preview.models.ScaleRule] - :param fixed_date: the specific date-time for the profile. This element is not used if the + :ivar name: Required. the name of the profile. + :vartype name: str + :ivar capacity: Required. the number of instances that can be used during this profile. + :vartype capacity: ~$(python-base-namespace).v2021_05_01_preview.models.ScaleCapacity + :ivar rules: Required. the collection of rules that provide the triggers and parameters for the + scaling action. A maximum of 10 rules can be specified. + :vartype rules: list[~$(python-base-namespace).v2021_05_01_preview.models.ScaleRule] + :ivar fixed_date: the specific date-time for the profile. This element is not used if the Recurrence element is used. - :type fixed_date: ~$(python-base-namespace).v2021_05_01_preview.models.TimeWindow - :param recurrence: the repeating times at which this profile begins. This element is not used - if the FixedDate element is used. - :type recurrence: ~$(python-base-namespace).v2021_05_01_preview.models.Recurrence + :vartype fixed_date: ~$(python-base-namespace).v2021_05_01_preview.models.TimeWindow + :ivar recurrence: the repeating times at which this profile begins. This element is not used if + the FixedDate element is used. + :vartype recurrence: ~$(python-base-namespace).v2021_05_01_preview.models.Recurrence """ _validation = { @@ -166,6 +190,21 @@ def __init__( recurrence: Optional["Recurrence"] = None, **kwargs ): + """ + :keyword name: Required. the name of the profile. + :paramtype name: str + :keyword capacity: Required. the number of instances that can be used during this profile. + :paramtype capacity: ~$(python-base-namespace).v2021_05_01_preview.models.ScaleCapacity + :keyword rules: Required. the collection of rules that provide the triggers and parameters for + the scaling action. A maximum of 10 rules can be specified. + :paramtype rules: list[~$(python-base-namespace).v2021_05_01_preview.models.ScaleRule] + :keyword fixed_date: the specific date-time for the profile. This element is not used if the + Recurrence element is used. + :paramtype fixed_date: ~$(python-base-namespace).v2021_05_01_preview.models.TimeWindow + :keyword recurrence: the repeating times at which this profile begins. This element is not used + if the FixedDate element is used. + :paramtype recurrence: ~$(python-base-namespace).v2021_05_01_preview.models.Recurrence + """ super(AutoscaleProfile, self).__init__(**kwargs) self.name = name self.capacity = capacity @@ -187,35 +226,35 @@ class AutoscaleSettingResource(msrest.serialization.Model): :vartype name: str :ivar type: Azure resource type. :vartype type: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. These tags can be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in length than 128 characters and a value no greater in length than 256 characters. - :type tags: dict[str, str] + :vartype tags: dict[str, str] :ivar system_data: The system metadata related to the response. :vartype system_data: ~$(python-base-namespace).v2021_05_01_preview.models.SystemData - :param profiles: Required. the collection of automatic scaling profiles that specify different + :ivar profiles: Required. the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. - :type profiles: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleProfile] - :param notifications: the collection of notifications. - :type notifications: + :vartype profiles: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleProfile] + :ivar notifications: the collection of notifications. + :vartype notifications: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleNotification] - :param enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the resource. The default value is 'true'. - :type enabled: bool - :param predictive_autoscale_policy: the predictive autoscale policy mode. - :type predictive_autoscale_policy: + :vartype enabled: bool + :ivar predictive_autoscale_policy: the predictive autoscale policy mode. + :vartype predictive_autoscale_policy: ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveAutoscalePolicy - :param name_properties_name: the name of the autoscale setting. - :type name_properties_name: str - :param target_resource_uri: the resource identifier of the resource that the autoscale setting + :ivar name_properties_name: the name of the autoscale setting. + :vartype name_properties_name: str + :ivar target_resource_uri: the resource identifier of the resource that the autoscale setting should be added to. - :type target_resource_uri: str - :param target_resource_location: the location of the resource that the autoscale setting should + :vartype target_resource_uri: str + :ivar target_resource_location: the location of the resource that the autoscale setting should be added to. - :type target_resource_location: str + :vartype target_resource_location: str """ _validation = { @@ -257,6 +296,37 @@ def __init__( target_resource_location: Optional[str] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the + resource. These tags can be used in viewing and grouping this resource (across resource + groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no + greater in length than 128 characters and a value no greater in length than 256 characters. + :paramtype tags: dict[str, str] + :keyword profiles: Required. the collection of automatic scaling profiles that specify + different scaling parameters for different time periods. A maximum of 20 profiles can be + specified. + :paramtype profiles: + list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleProfile] + :keyword notifications: the collection of notifications. + :paramtype notifications: + list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleNotification] + :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + resource. The default value is 'true'. + :paramtype enabled: bool + :keyword predictive_autoscale_policy: the predictive autoscale policy mode. + :paramtype predictive_autoscale_policy: + ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveAutoscalePolicy + :keyword name_properties_name: the name of the autoscale setting. + :paramtype name_properties_name: str + :keyword target_resource_uri: the resource identifier of the resource that the autoscale + setting should be added to. + :paramtype target_resource_uri: str + :keyword target_resource_location: the location of the resource that the autoscale setting + should be added to. + :paramtype target_resource_location: str + """ super(AutoscaleSettingResource, self).__init__(**kwargs) self.id = None self.name = None @@ -278,11 +348,11 @@ class AutoscaleSettingResourceCollection(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. the values for the autoscale setting resources. - :type value: + :ivar value: Required. the values for the autoscale setting resources. + :vartype value: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource] - :param next_link: URL to get the next set of results. - :type next_link: str + :ivar next_link: URL to get the next set of results. + :vartype next_link: str """ _validation = { @@ -301,6 +371,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. the values for the autoscale setting resources. + :paramtype value: + list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource] + :keyword next_link: URL to get the next set of results. + :paramtype next_link: str + """ super(AutoscaleSettingResourceCollection, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -309,28 +386,28 @@ def __init__( class AutoscaleSettingResourcePatch(msrest.serialization.Model): """The autoscale setting object for patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param profiles: the collection of automatic scaling profiles that specify different scaling + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar profiles: the collection of automatic scaling profiles that specify different scaling parameters for different time periods. A maximum of 20 profiles can be specified. - :type profiles: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleProfile] - :param notifications: the collection of notifications. - :type notifications: + :vartype profiles: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleProfile] + :ivar notifications: the collection of notifications. + :vartype notifications: list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleNotification] - :param enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + :ivar enabled: the enabled flag. Specifies whether automatic scaling is enabled for the resource. The default value is 'true'. - :type enabled: bool - :param predictive_autoscale_policy: the predictive autoscale policy mode. - :type predictive_autoscale_policy: + :vartype enabled: bool + :ivar predictive_autoscale_policy: the predictive autoscale policy mode. + :vartype predictive_autoscale_policy: ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveAutoscalePolicy - :param name: the name of the autoscale setting. - :type name: str - :param target_resource_uri: the resource identifier of the resource that the autoscale setting + :ivar name: the name of the autoscale setting. + :vartype name: str + :ivar target_resource_uri: the resource identifier of the resource that the autoscale setting should be added to. - :type target_resource_uri: str - :param target_resource_location: the location of the resource that the autoscale setting should + :vartype target_resource_uri: str + :ivar target_resource_location: the location of the resource that the autoscale setting should be added to. - :type target_resource_location: str + :vartype target_resource_location: str """ _validation = { @@ -361,6 +438,31 @@ def __init__( target_resource_location: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword profiles: the collection of automatic scaling profiles that specify different scaling + parameters for different time periods. A maximum of 20 profiles can be specified. + :paramtype profiles: + list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleProfile] + :keyword notifications: the collection of notifications. + :paramtype notifications: + list[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleNotification] + :keyword enabled: the enabled flag. Specifies whether automatic scaling is enabled for the + resource. The default value is 'true'. + :paramtype enabled: bool + :keyword predictive_autoscale_policy: the predictive autoscale policy mode. + :paramtype predictive_autoscale_policy: + ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveAutoscalePolicy + :keyword name: the name of the autoscale setting. + :paramtype name: str + :keyword target_resource_uri: the resource identifier of the resource that the autoscale + setting should be added to. + :paramtype target_resource_uri: str + :keyword target_resource_location: the location of the resource that the autoscale setting + should be added to. + :paramtype target_resource_location: str + """ super(AutoscaleSettingResourcePatch, self).__init__(**kwargs) self.tags = tags self.profiles = profiles @@ -403,6 +505,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -424,11 +528,12 @@ class DiagnosticSettingsCategoryResource(Resource): :vartype type: str :ivar system_data: The system metadata related to this resource. :vartype system_data: ~$(python-base-namespace).v2021_05_01_preview.models.SystemData - :param category_type: The type of the diagnostic settings category. Possible values include: + :ivar category_type: The type of the diagnostic settings category. Possible values include: "Metrics", "Logs". - :type category_type: str or ~$(python-base-namespace).v2021_05_01_preview.models.CategoryType - :param category_groups: the collection of what category groups are supported. - :type category_groups: list[str] + :vartype category_type: str or + ~$(python-base-namespace).v2021_05_01_preview.models.CategoryType + :ivar category_groups: the collection of what category groups are supported. + :vartype category_groups: list[str] """ _validation = { @@ -454,6 +559,14 @@ def __init__( category_groups: Optional[List[str]] = None, **kwargs ): + """ + :keyword category_type: The type of the diagnostic settings category. Possible values include: + "Metrics", "Logs". + :paramtype category_type: str or + ~$(python-base-namespace).v2021_05_01_preview.models.CategoryType + :keyword category_groups: the collection of what category groups are supported. + :paramtype category_groups: list[str] + """ super(DiagnosticSettingsCategoryResource, self).__init__(**kwargs) self.system_data = None self.category_type = category_type @@ -463,8 +576,8 @@ def __init__( class DiagnosticSettingsCategoryResourceCollection(msrest.serialization.Model): """Represents a collection of diagnostic setting category resources. - :param value: The collection of diagnostic settings category resources. - :type value: + :ivar value: The collection of diagnostic settings category resources. + :vartype value: list[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResource] """ @@ -478,6 +591,11 @@ def __init__( value: Optional[List["DiagnosticSettingsCategoryResource"]] = None, **kwargs ): + """ + :keyword value: The collection of diagnostic settings category resources. + :paramtype value: + list[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResource] + """ super(DiagnosticSettingsCategoryResourceCollection, self).__init__(**kwargs) self.value = value @@ -497,33 +615,33 @@ class DiagnosticSettingsResource(Resource): :vartype type: str :ivar system_data: The system metadata related to this resource. :vartype system_data: ~$(python-base-namespace).v2021_05_01_preview.models.SystemData - :param storage_account_id: The resource ID of the storage account to which you would like to + :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. - :type service_bus_rule_id: str - :param event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :type event_hub_authorization_rule_id: str - :param event_hub_name: The name of the event hub. If none is specified, the default event hub + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :vartype event_hub_authorization_rule_id: str + :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub will be selected. - :type event_hub_name: str - :param metrics: The list of metric settings. - :type metrics: list[~$(python-base-namespace).v2021_05_01_preview.models.MetricSettings] - :param logs: The list of logs settings. - :type logs: list[~$(python-base-namespace).v2021_05_01_preview.models.LogSettings] - :param workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would + :vartype event_hub_name: str + :ivar metrics: The list of metric settings. + :vartype metrics: list[~$(python-base-namespace).v2021_05_01_preview.models.MetricSettings] + :ivar logs: The list of logs settings. + :vartype logs: list[~$(python-base-namespace).v2021_05_01_preview.models.LogSettings] + :ivar workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str - :param marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which - you would like to send Diagnostic Logs. - :type marketplace_partner_id: str - :param log_analytics_destination_type: A string indicating whether the export to Log Analytics + :vartype workspace_id: str + :ivar marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which you + would like to send Diagnostic Logs. + :vartype marketplace_partner_id: str + :ivar log_analytics_destination_type: A string indicating whether the export to Log Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination type constructed as follows: :code:``_:code:``. Possible values are: Dedicated and null (null is default.). - :type log_analytics_destination_type: str + :vartype log_analytics_destination_type: str """ _validation = { @@ -563,6 +681,35 @@ def __init__( log_analytics_destination_type: Optional[str] = None, **kwargs ): + """ + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here + to maintain backwards compatibility. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub + will be selected. + :paramtype event_hub_name: str + :keyword metrics: The list of metric settings. + :paramtype metrics: list[~$(python-base-namespace).v2021_05_01_preview.models.MetricSettings] + :keyword logs: The list of logs settings. + :paramtype logs: list[~$(python-base-namespace).v2021_05_01_preview.models.LogSettings] + :keyword workspace_id: The full ARM resource ID of the Log Analytics workspace to which you + would like to send Diagnostic Logs. Example: + /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + :paramtype workspace_id: str + :keyword marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which + you would like to send Diagnostic Logs. + :paramtype marketplace_partner_id: str + :keyword log_analytics_destination_type: A string indicating whether the export to Log + Analytics should use the default destination type, i.e. AzureDiagnostics, or use a destination + type constructed as follows: :code:``_:code:``. Possible values are: Dedicated and null (null is default.). + :paramtype log_analytics_destination_type: str + """ super(DiagnosticSettingsResource, self).__init__(**kwargs) self.system_data = None self.storage_account_id = storage_account_id @@ -579,8 +726,8 @@ def __init__( class DiagnosticSettingsResourceCollection(msrest.serialization.Model): """Represents a collection of alert rule resources. - :param value: The collection of diagnostic settings resources;. - :type value: + :ivar value: The collection of diagnostic settings resources;. + :vartype value: list[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource] """ @@ -594,6 +741,11 @@ def __init__( value: Optional[List["DiagnosticSettingsResource"]] = None, **kwargs ): + """ + :keyword value: The collection of diagnostic settings resources;. + :paramtype value: + list[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource] + """ super(DiagnosticSettingsResourceCollection, self).__init__(**kwargs) self.value = value @@ -601,15 +753,15 @@ def __init__( class EmailNotification(msrest.serialization.Model): """Email notification of an autoscale event. - :param send_to_subscription_administrator: a value indicating whether to send email to + :ivar send_to_subscription_administrator: a value indicating whether to send email to subscription administrator. - :type send_to_subscription_administrator: bool - :param send_to_subscription_co_administrators: a value indicating whether to send email to + :vartype send_to_subscription_administrator: bool + :ivar send_to_subscription_co_administrators: a value indicating whether to send email to subscription co-administrators. - :type send_to_subscription_co_administrators: bool - :param custom_emails: the custom e-mails list. This value can be null or empty, in which case + :vartype send_to_subscription_co_administrators: bool + :ivar custom_emails: the custom e-mails list. This value can be null or empty, in which case this attribute will be ignored. - :type custom_emails: list[str] + :vartype custom_emails: list[str] """ _attribute_map = { @@ -626,6 +778,17 @@ def __init__( custom_emails: Optional[List[str]] = None, **kwargs ): + """ + :keyword send_to_subscription_administrator: a value indicating whether to send email to + subscription administrator. + :paramtype send_to_subscription_administrator: bool + :keyword send_to_subscription_co_administrators: a value indicating whether to send email to + subscription co-administrators. + :paramtype send_to_subscription_co_administrators: bool + :keyword custom_emails: the custom e-mails list. This value can be null or empty, in which case + this attribute will be ignored. + :paramtype custom_emails: list[str] + """ super(EmailNotification, self).__init__(**kwargs) self.send_to_subscription_administrator = send_to_subscription_administrator self.send_to_subscription_co_administrators = send_to_subscription_co_administrators @@ -635,10 +798,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -653,6 +816,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -663,18 +832,18 @@ class LogSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param category: Name of a Diagnostic Log category for a resource type this setting is applied + :ivar category: Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. - :type category: str - :param category_group: Name of a Diagnostic Log category group for a resource type this setting + :vartype category: str + :ivar category_group: Name of a Diagnostic Log category group for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. - :type category_group: str - :param enabled: Required. a value indicating whether this log is enabled. - :type enabled: bool - :param retention_policy: the retention policy for this log. - :type retention_policy: ~$(python-base-namespace).v2021_05_01_preview.models.RetentionPolicy + :vartype category_group: str + :ivar enabled: Required. a value indicating whether this log is enabled. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this log. + :vartype retention_policy: ~$(python-base-namespace).v2021_05_01_preview.models.RetentionPolicy """ _validation = { @@ -697,6 +866,21 @@ def __init__( retention_policy: Optional["RetentionPolicy"] = None, **kwargs ): + """ + :keyword category: Name of a Diagnostic Log category for a resource type this setting is + applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET + diagnostic settings operation. + :paramtype category: str + :keyword category_group: Name of a Diagnostic Log category group for a resource type this + setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first + perform a GET diagnostic settings operation. + :paramtype category_group: str + :keyword enabled: Required. a value indicating whether this log is enabled. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this log. + :paramtype retention_policy: + ~$(python-base-namespace).v2021_05_01_preview.models.RetentionPolicy + """ super(LogSettings, self).__init__(**kwargs) self.category = category self.category_group = category_group @@ -719,27 +903,27 @@ class ManagementGroupDiagnosticSettingsResource(Resource): :vartype type: str :ivar system_data: The system metadata related to this resource. :vartype system_data: ~$(python-base-namespace).v2021_05_01_preview.models.SystemData - :param storage_account_id: The resource ID of the storage account to which you would like to + :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. - :type service_bus_rule_id: str - :param event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :type event_hub_authorization_rule_id: str - :param event_hub_name: The name of the event hub. If none is specified, the default event hub + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :vartype event_hub_authorization_rule_id: str + :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub will be selected. - :type event_hub_name: str - :param logs: The list of logs settings. - :type logs: + :vartype event_hub_name: str + :ivar logs: The list of logs settings. + :vartype logs: list[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupLogSettings] - :param workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would + :ivar workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str - :param marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which - you would like to send Diagnostic Logs. - :type marketplace_partner_id: str + :vartype workspace_id: str + :ivar marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which you + would like to send Diagnostic Logs. + :vartype marketplace_partner_id: str """ _validation = { @@ -775,6 +959,29 @@ def __init__( marketplace_partner_id: Optional[str] = None, **kwargs ): + """ + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here + to maintain backwards compatibility. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub + will be selected. + :paramtype event_hub_name: str + :keyword logs: The list of logs settings. + :paramtype logs: + list[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupLogSettings] + :keyword workspace_id: The full ARM resource ID of the Log Analytics workspace to which you + would like to send Diagnostic Logs. Example: + /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + :paramtype workspace_id: str + :keyword marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which + you would like to send Diagnostic Logs. + :paramtype marketplace_partner_id: str + """ super(ManagementGroupDiagnosticSettingsResource, self).__init__(**kwargs) self.system_data = None self.storage_account_id = storage_account_id @@ -789,8 +996,8 @@ def __init__( class ManagementGroupDiagnosticSettingsResourceCollection(msrest.serialization.Model): """Represents a collection of management group diagnostic settings resources. - :param value: The collection of management group diagnostic settings resources. - :type value: + :ivar value: The collection of management group diagnostic settings resources. + :vartype value: list[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource] """ @@ -804,6 +1011,11 @@ def __init__( value: Optional[List["ManagementGroupDiagnosticSettingsResource"]] = None, **kwargs ): + """ + :keyword value: The collection of management group diagnostic settings resources. + :paramtype value: + list[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource] + """ super(ManagementGroupDiagnosticSettingsResourceCollection, self).__init__(**kwargs) self.value = value @@ -813,14 +1025,14 @@ class ManagementGroupLogSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param category: Name of a Management Group Diagnostic Log category for a resource type this + :ivar category: Name of a Management Group Diagnostic Log category for a resource type this setting is applied to. - :type category: str - :param category_group: Name of a Management Group Diagnostic Log category group for a resource + :vartype category: str + :ivar category_group: Name of a Management Group Diagnostic Log category group for a resource type this setting is applied to. - :type category_group: str - :param enabled: Required. a value indicating whether this log is enabled. - :type enabled: bool + :vartype category_group: str + :ivar enabled: Required. a value indicating whether this log is enabled. + :vartype enabled: bool """ _validation = { @@ -841,6 +1053,16 @@ def __init__( category_group: Optional[str] = None, **kwargs ): + """ + :keyword category: Name of a Management Group Diagnostic Log category for a resource type this + setting is applied to. + :paramtype category: str + :keyword category_group: Name of a Management Group Diagnostic Log category group for a + resource type this setting is applied to. + :paramtype category_group: str + :keyword enabled: Required. a value indicating whether this log is enabled. + :paramtype enabled: bool + """ super(ManagementGroupLogSettings, self).__init__(**kwargs) self.category = category self.category_group = category_group @@ -852,16 +1074,16 @@ class MetricSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_grain: the timegrain of the metric in ISO8601 format. - :type time_grain: ~datetime.timedelta - :param category: Name of a Diagnostic Metric category for a resource type this setting is + :ivar time_grain: the timegrain of the metric in ISO8601 format. + :vartype time_grain: ~datetime.timedelta + :ivar category: Name of a Diagnostic Metric category for a resource type this setting is applied to. To obtain the list of Diagnostic metric categories for a resource, first perform a GET diagnostic settings operation. - :type category: str - :param enabled: Required. a value indicating whether this category is enabled. - :type enabled: bool - :param retention_policy: the retention policy for this category. - :type retention_policy: ~$(python-base-namespace).v2021_05_01_preview.models.RetentionPolicy + :vartype category: str + :ivar enabled: Required. a value indicating whether this category is enabled. + :vartype enabled: bool + :ivar retention_policy: the retention policy for this category. + :vartype retention_policy: ~$(python-base-namespace).v2021_05_01_preview.models.RetentionPolicy """ _validation = { @@ -884,6 +1106,19 @@ def __init__( retention_policy: Optional["RetentionPolicy"] = None, **kwargs ): + """ + :keyword time_grain: the timegrain of the metric in ISO8601 format. + :paramtype time_grain: ~datetime.timedelta + :keyword category: Name of a Diagnostic Metric category for a resource type this setting is + applied to. To obtain the list of Diagnostic metric categories for a resource, first perform a + GET diagnostic settings operation. + :paramtype category: str + :keyword enabled: Required. a value indicating whether this category is enabled. + :paramtype enabled: bool + :keyword retention_policy: the retention policy for this category. + :paramtype retention_policy: + ~$(python-base-namespace).v2021_05_01_preview.models.RetentionPolicy + """ super(MetricSettings, self).__init__(**kwargs) self.time_grain = time_grain self.category = category @@ -896,45 +1131,44 @@ class MetricTrigger(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param metric_name: Required. the name of the metric that defines what the rule monitors. - :type metric_name: str - :param metric_namespace: the namespace of the metric that defines what the rule monitors. - :type metric_namespace: str - :param metric_resource_uri: Required. the resource identifier of the resource the rule - monitors. - :type metric_resource_uri: str - :param metric_resource_location: the location of the resource the rule monitors. - :type metric_resource_location: str - :param time_grain: Required. the granularity of metrics the rule monitors. Must be one of the + :ivar metric_name: Required. the name of the metric that defines what the rule monitors. + :vartype metric_name: str + :ivar metric_namespace: the namespace of the metric that defines what the rule monitors. + :vartype metric_namespace: str + :ivar metric_resource_uri: Required. the resource identifier of the resource the rule monitors. + :vartype metric_resource_uri: str + :ivar metric_resource_location: the location of the resource the rule monitors. + :vartype metric_resource_location: str + :ivar time_grain: Required. the granularity of metrics the rule monitors. Must be one of the predefined values returned from metric definitions for the metric. Must be between 12 hours and 1 minute. - :type time_grain: ~datetime.timedelta - :param statistic: Required. the metric statistic type. How the metrics from multiple instances + :vartype time_grain: ~datetime.timedelta + :ivar statistic: Required. the metric statistic type. How the metrics from multiple instances are combined. Possible values include: "Average", "Min", "Max", "Sum", "Count". - :type statistic: str or + :vartype statistic: str or ~$(python-base-namespace).v2021_05_01_preview.models.MetricStatisticType - :param time_window: Required. the range of time in which instance data is collected. This value + :ivar time_window: Required. the range of time in which instance data is collected. This value must be greater than the delay in metric collection, which can vary from resource-to-resource. Must be between 12 hours and 5 minutes. - :type time_window: ~datetime.timedelta - :param time_aggregation: Required. time aggregation type. How the data that is collected should + :vartype time_window: ~datetime.timedelta + :ivar time_aggregation: Required. time aggregation type. How the data that is collected should be combined over time. The default value is Average. Possible values include: "Average", "Minimum", "Maximum", "Total", "Count", "Last". - :type time_aggregation: str or + :vartype time_aggregation: str or ~$(python-base-namespace).v2021_05_01_preview.models.TimeAggregationType - :param operator: Required. the operator that is used to compare the metric data and the + :ivar operator: Required. the operator that is used to compare the metric data and the threshold. Possible values include: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", "LessThan", "LessThanOrEqual". - :type operator: str or + :vartype operator: str or ~$(python-base-namespace).v2021_05_01_preview.models.ComparisonOperationType - :param threshold: Required. the threshold of the metric that triggers the scale action. - :type threshold: float - :param dimensions: List of dimension conditions. For example: + :ivar threshold: Required. the threshold of the metric that triggers the scale action. + :vartype threshold: float + :ivar dimensions: List of dimension conditions. For example: [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. - :type dimensions: + :vartype dimensions: list[~$(python-base-namespace).v2021_05_01_preview.models.ScaleRuleMetricDimension] - :param divide_per_instance: a value indicating whether metric should divide per instance. - :type divide_per_instance: bool + :ivar divide_per_instance: a value indicating whether metric should divide per instance. + :vartype divide_per_instance: bool """ _validation = { @@ -980,6 +1214,47 @@ def __init__( divide_per_instance: Optional[bool] = None, **kwargs ): + """ + :keyword metric_name: Required. the name of the metric that defines what the rule monitors. + :paramtype metric_name: str + :keyword metric_namespace: the namespace of the metric that defines what the rule monitors. + :paramtype metric_namespace: str + :keyword metric_resource_uri: Required. the resource identifier of the resource the rule + monitors. + :paramtype metric_resource_uri: str + :keyword metric_resource_location: the location of the resource the rule monitors. + :paramtype metric_resource_location: str + :keyword time_grain: Required. the granularity of metrics the rule monitors. Must be one of the + predefined values returned from metric definitions for the metric. Must be between 12 hours and + 1 minute. + :paramtype time_grain: ~datetime.timedelta + :keyword statistic: Required. the metric statistic type. How the metrics from multiple + instances are combined. Possible values include: "Average", "Min", "Max", "Sum", "Count". + :paramtype statistic: str or + ~$(python-base-namespace).v2021_05_01_preview.models.MetricStatisticType + :keyword time_window: Required. the range of time in which instance data is collected. This + value must be greater than the delay in metric collection, which can vary from + resource-to-resource. Must be between 12 hours and 5 minutes. + :paramtype time_window: ~datetime.timedelta + :keyword time_aggregation: Required. time aggregation type. How the data that is collected + should be combined over time. The default value is Average. Possible values include: "Average", + "Minimum", "Maximum", "Total", "Count", "Last". + :paramtype time_aggregation: str or + ~$(python-base-namespace).v2021_05_01_preview.models.TimeAggregationType + :keyword operator: Required. the operator that is used to compare the metric data and the + threshold. Possible values include: "Equals", "NotEquals", "GreaterThan", "GreaterThanOrEqual", + "LessThan", "LessThanOrEqual". + :paramtype operator: str or + ~$(python-base-namespace).v2021_05_01_preview.models.ComparisonOperationType + :keyword threshold: Required. the threshold of the metric that triggers the scale action. + :paramtype threshold: float + :keyword dimensions: List of dimension conditions. For example: + [{"DimensionName":"AppName","Operator":"Equals","Values":["App1"]},{"DimensionName":"Deployment","Operator":"Equals","Values":["default"]}]. + :paramtype dimensions: + list[~$(python-base-namespace).v2021_05_01_preview.models.ScaleRuleMetricDimension] + :keyword divide_per_instance: a value indicating whether metric should divide per instance. + :paramtype divide_per_instance: bool + """ super(MetricTrigger, self).__init__(**kwargs) self.metric_name = metric_name self.metric_namespace = metric_namespace @@ -1000,13 +1275,13 @@ class PredictiveAutoscalePolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param scale_mode: Required. the predictive autoscale mode. Possible values include: - "Disabled", "ForecastOnly", "Enabled". - :type scale_mode: str or + :ivar scale_mode: Required. the predictive autoscale mode. Possible values include: "Disabled", + "ForecastOnly", "Enabled". + :vartype scale_mode: str or ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveAutoscalePolicyScaleMode - :param scale_look_ahead_time: the amount of time to specify by which instances are launched in + :ivar scale_look_ahead_time: the amount of time to specify by which instances are launched in advance. It must be between 1 minute and 60 minutes in ISO 8601 format. - :type scale_look_ahead_time: ~datetime.timedelta + :vartype scale_look_ahead_time: ~datetime.timedelta """ _validation = { @@ -1025,6 +1300,15 @@ def __init__( scale_look_ahead_time: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword scale_mode: Required. the predictive autoscale mode. Possible values include: + "Disabled", "ForecastOnly", "Enabled". + :paramtype scale_mode: str or + ~$(python-base-namespace).v2021_05_01_preview.models.PredictiveAutoscalePolicyScaleMode + :keyword scale_look_ahead_time: the amount of time to specify by which instances are launched + in advance. It must be between 1 minute and 60 minutes in ISO 8601 format. + :paramtype scale_look_ahead_time: ~datetime.timedelta + """ super(PredictiveAutoscalePolicy, self).__init__(**kwargs) self.scale_mode = scale_mode self.scale_look_ahead_time = scale_look_ahead_time @@ -1033,20 +1317,20 @@ def __init__( class PredictiveResponse(msrest.serialization.Model): """The response to a metrics query. - :param timespan: The timespan for which the data was retrieved. Its value consists of two + :ivar timespan: The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back from what was originally requested. - :type timespan: str - :param interval: The interval (window size) for which the metric data was returned in. This - may be adjusted in the future and returned back from what was originally requested. This is - not present if a metadata request was made. - :type interval: ~datetime.timedelta - :param metric_name: The metrics being queried. - :type metric_name: str - :param target_resource_id: resource of the predictive metric. - :type target_resource_id: str - :param data: the value of the collection. - :type data: list[~$(python-base-namespace).v2021_05_01_preview.models.PredictiveValue] + :vartype timespan: str + :ivar interval: The interval (window size) for which the metric data was returned in. This may + be adjusted in the future and returned back from what was originally requested. This is not + present if a metadata request was made. + :vartype interval: ~datetime.timedelta + :ivar metric_name: The metrics being queried. + :vartype metric_name: str + :ivar target_resource_id: resource of the predictive metric. + :vartype target_resource_id: str + :ivar data: the value of the collection. + :vartype data: list[~$(python-base-namespace).v2021_05_01_preview.models.PredictiveValue] """ _attribute_map = { @@ -1067,6 +1351,22 @@ def __init__( data: Optional[List["PredictiveValue"]] = None, **kwargs ): + """ + :keyword timespan: The timespan for which the data was retrieved. Its value consists of two + datetimes concatenated, separated by '/'. This may be adjusted in the future and returned back + from what was originally requested. + :paramtype timespan: str + :keyword interval: The interval (window size) for which the metric data was returned in. This + may be adjusted in the future and returned back from what was originally requested. This is + not present if a metadata request was made. + :paramtype interval: ~datetime.timedelta + :keyword metric_name: The metrics being queried. + :paramtype metric_name: str + :keyword target_resource_id: resource of the predictive metric. + :paramtype target_resource_id: str + :keyword data: the value of the collection. + :paramtype data: list[~$(python-base-namespace).v2021_05_01_preview.models.PredictiveValue] + """ super(PredictiveResponse, self).__init__(**kwargs) self.timespan = timespan self.interval = interval @@ -1080,10 +1380,10 @@ class PredictiveValue(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_stamp: Required. the timestamp for the metric value in ISO 8601 format. - :type time_stamp: ~datetime.datetime - :param value: Required. Predictive value in this time bucket. - :type value: float + :ivar time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :vartype time_stamp: ~datetime.datetime + :ivar value: Required. Predictive value in this time bucket. + :vartype value: float """ _validation = { @@ -1103,6 +1403,12 @@ def __init__( value: float, **kwargs ): + """ + :keyword time_stamp: Required. the timestamp for the metric value in ISO 8601 format. + :paramtype time_stamp: ~datetime.datetime + :keyword value: Required. Predictive value in this time bucket. + :paramtype value: float + """ super(PredictiveValue, self).__init__(**kwargs) self.time_stamp = time_stamp self.value = value @@ -1113,15 +1419,15 @@ class Recurrence(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param frequency: Required. the recurrence frequency. How often the schedule profile should - take effect. This value must be Week, meaning each week will have the same set of profiles. For + :ivar frequency: Required. the recurrence frequency. How often the schedule profile should take + effect. This value must be Week, meaning each week will have the same set of profiles. For example, to set a daily schedule, set **schedule** to every day of the week. The frequency property specifies that the schedule is repeated weekly. Possible values include: "None", "Second", "Minute", "Hour", "Day", "Week", "Month", "Year". - :type frequency: str or + :vartype frequency: str or ~$(python-base-namespace).v2021_05_01_preview.models.RecurrenceFrequency - :param schedule: Required. the scheduling constraints for when the profile begins. - :type schedule: ~$(python-base-namespace).v2021_05_01_preview.models.RecurrentSchedule + :ivar schedule: Required. the scheduling constraints for when the profile begins. + :vartype schedule: ~$(python-base-namespace).v2021_05_01_preview.models.RecurrentSchedule """ _validation = { @@ -1141,6 +1447,17 @@ def __init__( schedule: "RecurrentSchedule", **kwargs ): + """ + :keyword frequency: Required. the recurrence frequency. How often the schedule profile should + take effect. This value must be Week, meaning each week will have the same set of profiles. For + example, to set a daily schedule, set **schedule** to every day of the week. The frequency + property specifies that the schedule is repeated weekly. Possible values include: "None", + "Second", "Minute", "Hour", "Day", "Week", "Month", "Year". + :paramtype frequency: str or + ~$(python-base-namespace).v2021_05_01_preview.models.RecurrenceFrequency + :keyword schedule: Required. the scheduling constraints for when the profile begins. + :paramtype schedule: ~$(python-base-namespace).v2021_05_01_preview.models.RecurrentSchedule + """ super(Recurrence, self).__init__(**kwargs) self.frequency = frequency self.schedule = schedule @@ -1151,7 +1468,7 @@ class RecurrentSchedule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_zone: Required. the timezone for the hours of the profile. Some examples of valid + :ivar time_zone: Required. the timezone for the hours of the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard @@ -1181,15 +1498,15 @@ class RecurrentSchedule(msrest.serialization.Model): Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time. - :type time_zone: str - :param days: Required. the collection of days that the profile takes effect on. Possible values + :vartype time_zone: str + :ivar days: Required. the collection of days that the profile takes effect on. Possible values are Sunday through Saturday. - :type days: list[str] - :param hours: Required. A collection of hours that the profile takes effect on. Values - supported are 0 to 23 on the 24-hour clock (AM/PM times are not supported). - :type hours: list[int] - :param minutes: Required. A collection of minutes at which the profile takes effect at. - :type minutes: list[int] + :vartype days: list[str] + :ivar hours: Required. A collection of hours that the profile takes effect on. Values supported + are 0 to 23 on the 24-hour clock (AM/PM times are not supported). + :vartype hours: list[int] + :ivar minutes: Required. A collection of minutes at which the profile takes effect at. + :vartype minutes: list[int] """ _validation = { @@ -1215,6 +1532,47 @@ def __init__( minutes: List[int], **kwargs ): + """ + :keyword time_zone: Required. the timezone for the hours of the profile. Some examples of valid + time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, + Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain + Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central Standard + Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific Standard Time, + Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, Paraguay Standard + Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western Standard Time, + Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard Time, Argentina + Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo Standard Time, + Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, Cape Verde + Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard Time, W. + Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central European + Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard Time, + GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, E. + Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, + Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, + Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran + Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius + Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West + Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, + Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard + Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia + Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. + Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, + Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard + Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, + Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, + Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji + Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands + Standard Time. + :paramtype time_zone: str + :keyword days: Required. the collection of days that the profile takes effect on. Possible + values are Sunday through Saturday. + :paramtype days: list[str] + :keyword hours: Required. A collection of hours that the profile takes effect on. Values + supported are 0 to 23 on the 24-hour clock (AM/PM times are not supported). + :paramtype hours: list[int] + :keyword minutes: Required. A collection of minutes at which the profile takes effect at. + :paramtype minutes: list[int] + """ super(RecurrentSchedule, self).__init__(**kwargs) self.time_zone = time_zone self.days = days @@ -1227,11 +1585,11 @@ class RetentionPolicy(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param enabled: Required. a value indicating whether the retention policy is enabled. - :type enabled: bool - :param days: Required. the number of days for the retention in days. A value of 0 will retain + :ivar enabled: Required. a value indicating whether the retention policy is enabled. + :vartype enabled: bool + :ivar days: Required. the number of days for the retention in days. A value of 0 will retain the events indefinitely. - :type days: int + :vartype days: int """ _validation = { @@ -1251,6 +1609,13 @@ def __init__( days: int, **kwargs ): + """ + :keyword enabled: Required. a value indicating whether the retention policy is enabled. + :paramtype enabled: bool + :keyword days: Required. the number of days for the retention in days. A value of 0 will retain + the events indefinitely. + :paramtype days: int + """ super(RetentionPolicy, self).__init__(**kwargs) self.enabled = enabled self.days = days @@ -1261,18 +1626,18 @@ class ScaleAction(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param direction: Required. the scale direction. Whether the scaling action increases or + :ivar direction: Required. the scale direction. Whether the scaling action increases or decreases the number of instances. Possible values include: "None", "Increase", "Decrease". - :type direction: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleDirection - :param type: Required. the type of action that should occur when the scale rule fires. Possible + :vartype direction: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleDirection + :ivar type: Required. the type of action that should occur when the scale rule fires. Possible values include: "ChangeCount", "PercentChangeCount", "ExactCount", "ServiceAllowedNextValue". - :type type: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleType - :param value: the number of instances that are involved in the scaling action. This value must + :vartype type: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleType + :ivar value: the number of instances that are involved in the scaling action. This value must be 1 or greater. The default value is 1. - :type value: str - :param cooldown: Required. the amount of time to wait since the last scaling action before this + :vartype value: str + :ivar cooldown: Required. the amount of time to wait since the last scaling action before this action occurs. It must be between 1 week and 1 minute in ISO 8601 format. - :type cooldown: ~datetime.timedelta + :vartype cooldown: ~datetime.timedelta """ _validation = { @@ -1297,6 +1662,22 @@ def __init__( value: Optional[str] = "1", **kwargs ): + """ + :keyword direction: Required. the scale direction. Whether the scaling action increases or + decreases the number of instances. Possible values include: "None", "Increase", "Decrease". + :paramtype direction: str or + ~$(python-base-namespace).v2021_05_01_preview.models.ScaleDirection + :keyword type: Required. the type of action that should occur when the scale rule fires. + Possible values include: "ChangeCount", "PercentChangeCount", "ExactCount", + "ServiceAllowedNextValue". + :paramtype type: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleType + :keyword value: the number of instances that are involved in the scaling action. This value + must be 1 or greater. The default value is 1. + :paramtype value: str + :keyword cooldown: Required. the amount of time to wait since the last scaling action before + this action occurs. It must be between 1 week and 1 minute in ISO 8601 format. + :paramtype cooldown: ~datetime.timedelta + """ super(ScaleAction, self).__init__(**kwargs) self.direction = direction self.type = type @@ -1309,15 +1690,15 @@ class ScaleCapacity(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param minimum: Required. the minimum number of instances for the resource. - :type minimum: str - :param maximum: Required. the maximum number of instances for the resource. The actual maximum + :ivar minimum: Required. the minimum number of instances for the resource. + :vartype minimum: str + :ivar maximum: Required. the maximum number of instances for the resource. The actual maximum number of instances is limited by the cores that are available in the subscription. - :type maximum: str - :param default: Required. the number of instances that will be set if metrics are not available + :vartype maximum: str + :ivar default: Required. the number of instances that will be set if metrics are not available for evaluation. The default is only used if the current instance count is lower than the default. - :type default: str + :vartype default: str """ _validation = { @@ -1340,6 +1721,17 @@ def __init__( default: str, **kwargs ): + """ + :keyword minimum: Required. the minimum number of instances for the resource. + :paramtype minimum: str + :keyword maximum: Required. the maximum number of instances for the resource. The actual + maximum number of instances is limited by the cores that are available in the subscription. + :paramtype maximum: str + :keyword default: Required. the number of instances that will be set if metrics are not + available for evaluation. The default is only used if the current instance count is lower than + the default. + :paramtype default: str + """ super(ScaleCapacity, self).__init__(**kwargs) self.minimum = minimum self.maximum = maximum @@ -1351,10 +1743,10 @@ class ScaleRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param metric_trigger: Required. the trigger that results in a scaling action. - :type metric_trigger: ~$(python-base-namespace).v2021_05_01_preview.models.MetricTrigger - :param scale_action: Required. the parameters for the scaling action. - :type scale_action: ~$(python-base-namespace).v2021_05_01_preview.models.ScaleAction + :ivar metric_trigger: Required. the trigger that results in a scaling action. + :vartype metric_trigger: ~$(python-base-namespace).v2021_05_01_preview.models.MetricTrigger + :ivar scale_action: Required. the parameters for the scaling action. + :vartype scale_action: ~$(python-base-namespace).v2021_05_01_preview.models.ScaleAction """ _validation = { @@ -1374,6 +1766,12 @@ def __init__( scale_action: "ScaleAction", **kwargs ): + """ + :keyword metric_trigger: Required. the trigger that results in a scaling action. + :paramtype metric_trigger: ~$(python-base-namespace).v2021_05_01_preview.models.MetricTrigger + :keyword scale_action: Required. the parameters for the scaling action. + :paramtype scale_action: ~$(python-base-namespace).v2021_05_01_preview.models.ScaleAction + """ super(ScaleRule, self).__init__(**kwargs) self.metric_trigger = metric_trigger self.scale_action = scale_action @@ -1384,15 +1782,15 @@ class ScaleRuleMetricDimension(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param dimension_name: Required. Name of the dimension. - :type dimension_name: str - :param operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are supported. + :ivar dimension_name: Required. Name of the dimension. + :vartype dimension_name: str + :ivar operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values. Possible values include: "Equals", "NotEquals". - :type operator: str or + :vartype operator: str or ~$(python-base-namespace).v2021_05_01_preview.models.ScaleRuleMetricDimensionOperationType - :param values: Required. list of dimension values. For example: ["App1","App2"]. - :type values: list[str] + :ivar values: Required. list of dimension values. For example: ["App1","App2"]. + :vartype values: list[str] """ _validation = { @@ -1415,6 +1813,17 @@ def __init__( values: List[str], **kwargs ): + """ + :keyword dimension_name: Required. Name of the dimension. + :paramtype dimension_name: str + :keyword operator: Required. the dimension operator. Only 'Equals' and 'NotEquals' are + supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the + values. Possible values include: "Equals", "NotEquals". + :paramtype operator: str or + ~$(python-base-namespace).v2021_05_01_preview.models.ScaleRuleMetricDimensionOperationType + :keyword values: Required. list of dimension values. For example: ["App1","App2"]. + :paramtype values: list[str] + """ super(ScaleRuleMetricDimension, self).__init__(**kwargs) self.dimension_name = dimension_name self.operator = operator @@ -1436,26 +1845,27 @@ class SubscriptionDiagnosticSettingsResource(Resource): :vartype type: str :ivar system_data: The system metadata related to this resource. :vartype system_data: ~$(python-base-namespace).v2021_05_01_preview.models.SystemData - :param storage_account_id: The resource ID of the storage account to which you would like to + :ivar storage_account_id: The resource ID of the storage account to which you would like to send Diagnostic Logs. - :type storage_account_id: str - :param service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to + :vartype storage_account_id: str + :ivar service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here to maintain backwards compatibility. - :type service_bus_rule_id: str - :param event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. - :type event_hub_authorization_rule_id: str - :param event_hub_name: The name of the event hub. If none is specified, the default event hub + :vartype service_bus_rule_id: str + :ivar event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :vartype event_hub_authorization_rule_id: str + :ivar event_hub_name: The name of the event hub. If none is specified, the default event hub will be selected. - :type event_hub_name: str - :param logs: The list of logs settings. - :type logs: list[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionLogSettings] - :param workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would + :vartype event_hub_name: str + :ivar logs: The list of logs settings. + :vartype logs: + list[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionLogSettings] + :ivar workspace_id: The full ARM resource ID of the Log Analytics workspace to which you would like to send Diagnostic Logs. Example: /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. - :type workspace_id: str - :param marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which - you would like to send Diagnostic Logs. - :type marketplace_partner_id: str + :vartype workspace_id: str + :ivar marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which you + would like to send Diagnostic Logs. + :vartype marketplace_partner_id: str """ _validation = { @@ -1491,6 +1901,29 @@ def __init__( marketplace_partner_id: Optional[str] = None, **kwargs ): + """ + :keyword storage_account_id: The resource ID of the storage account to which you would like to + send Diagnostic Logs. + :paramtype storage_account_id: str + :keyword service_bus_rule_id: The service bus rule Id of the diagnostic setting. This is here + to maintain backwards compatibility. + :paramtype service_bus_rule_id: str + :keyword event_hub_authorization_rule_id: The resource Id for the event hub authorization rule. + :paramtype event_hub_authorization_rule_id: str + :keyword event_hub_name: The name of the event hub. If none is specified, the default event hub + will be selected. + :paramtype event_hub_name: str + :keyword logs: The list of logs settings. + :paramtype logs: + list[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionLogSettings] + :keyword workspace_id: The full ARM resource ID of the Log Analytics workspace to which you + would like to send Diagnostic Logs. Example: + /subscriptions/4b9e8510-67ab-4e9a-95a9-e2f1e570ea9c/resourceGroups/insights-integration/providers/Microsoft.OperationalInsights/workspaces/viruela2. + :paramtype workspace_id: str + :keyword marketplace_partner_id: The full ARM resource ID of the Marketplace resource to which + you would like to send Diagnostic Logs. + :paramtype marketplace_partner_id: str + """ super(SubscriptionDiagnosticSettingsResource, self).__init__(**kwargs) self.system_data = None self.storage_account_id = storage_account_id @@ -1505,8 +1938,8 @@ def __init__( class SubscriptionDiagnosticSettingsResourceCollection(msrest.serialization.Model): """Represents a collection of subscription diagnostic settings resources. - :param value: The collection of subscription diagnostic settings resources. - :type value: + :ivar value: The collection of subscription diagnostic settings resources. + :vartype value: list[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource] """ @@ -1520,6 +1953,11 @@ def __init__( value: Optional[List["SubscriptionDiagnosticSettingsResource"]] = None, **kwargs ): + """ + :keyword value: The collection of subscription diagnostic settings resources. + :paramtype value: + list[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource] + """ super(SubscriptionDiagnosticSettingsResourceCollection, self).__init__(**kwargs) self.value = value @@ -1529,14 +1967,14 @@ class SubscriptionLogSettings(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param category: Name of a Subscription Diagnostic Log category for a resource type this - setting is applied to. - :type category: str - :param category_group: Name of a Subscription Diagnostic Log category group for a resource type + :ivar category: Name of a Subscription Diagnostic Log category for a resource type this setting + is applied to. + :vartype category: str + :ivar category_group: Name of a Subscription Diagnostic Log category group for a resource type this setting is applied to. - :type category_group: str - :param enabled: Required. a value indicating whether this log is enabled. - :type enabled: bool + :vartype category_group: str + :ivar enabled: Required. a value indicating whether this log is enabled. + :vartype enabled: bool """ _validation = { @@ -1557,6 +1995,16 @@ def __init__( category_group: Optional[str] = None, **kwargs ): + """ + :keyword category: Name of a Subscription Diagnostic Log category for a resource type this + setting is applied to. + :paramtype category: str + :keyword category_group: Name of a Subscription Diagnostic Log category group for a resource + type this setting is applied to. + :paramtype category_group: str + :keyword enabled: Required. a value indicating whether this log is enabled. + :paramtype enabled: bool + """ super(SubscriptionLogSettings, self).__init__(**kwargs) self.category = category self.category_group = category_group @@ -1566,22 +2014,22 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :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 ~$(python-base-namespace).v2021_05_01_preview.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :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 + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or + :vartype last_modified_by_type: str or ~$(python-base-namespace).v2021_05_01_preview.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -1604,6 +2052,24 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :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 + ~$(python-base-namespace).v2021_05_01_preview.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 + ~$(python-base-namespace).v2021_05_01_preview.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 @@ -1618,7 +2084,7 @@ class TimeWindow(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param time_zone: the timezone of the start and end times for the profile. Some examples of + :ivar time_zone: the timezone of the start and end times for the profile. Some examples of valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central @@ -1648,11 +2114,11 @@ class TimeWindow(msrest.serialization.Model): Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands Standard Time. - :type time_zone: str - :param start: Required. the start time for the profile in ISO 8601 format. - :type start: ~datetime.datetime - :param end: Required. the end time for the profile in ISO 8601 format. - :type end: ~datetime.datetime + :vartype time_zone: str + :ivar start: Required. the start time for the profile in ISO 8601 format. + :vartype start: ~datetime.datetime + :ivar end: Required. the end time for the profile in ISO 8601 format. + :vartype end: ~datetime.datetime """ _validation = { @@ -1674,6 +2140,43 @@ def __init__( time_zone: Optional[str] = None, **kwargs ): + """ + :keyword time_zone: the timezone of the start and end times for the profile. Some examples of + valid time zones are: Dateline Standard Time, UTC-11, Hawaiian Standard Time, Alaskan Standard + Time, Pacific Standard Time (Mexico), Pacific Standard Time, US Mountain Standard Time, + Mountain Standard Time (Mexico), Mountain Standard Time, Central America Standard Time, Central + Standard Time, Central Standard Time (Mexico), Canada Central Standard Time, SA Pacific + Standard Time, Eastern Standard Time, US Eastern Standard Time, Venezuela Standard Time, + Paraguay Standard Time, Atlantic Standard Time, Central Brazilian Standard Time, SA Western + Standard Time, Pacific SA Standard Time, Newfoundland Standard Time, E. South America Standard + Time, Argentina Standard Time, SA Eastern Standard Time, Greenland Standard Time, Montevideo + Standard Time, Bahia Standard Time, UTC-02, Mid-Atlantic Standard Time, Azores Standard Time, + Cape Verde Standard Time, Morocco Standard Time, UTC, GMT Standard Time, Greenwich Standard + Time, W. Europe Standard Time, Central Europe Standard Time, Romance Standard Time, Central + European Standard Time, W. Central Africa Standard Time, Namibia Standard Time, Jordan Standard + Time, GTB Standard Time, Middle East Standard Time, Egypt Standard Time, Syria Standard Time, + E. Europe Standard Time, South Africa Standard Time, FLE Standard Time, Turkey Standard Time, + Israel Standard Time, Kaliningrad Standard Time, Libya Standard Time, Arabic Standard Time, + Arab Standard Time, Belarus Standard Time, Russian Standard Time, E. Africa Standard Time, Iran + Standard Time, Arabian Standard Time, Azerbaijan Standard Time, Russia Time Zone 3, Mauritius + Standard Time, Georgian Standard Time, Caucasus Standard Time, Afghanistan Standard Time, West + Asia Standard Time, Ekaterinburg Standard Time, Pakistan Standard Time, India Standard Time, + Sri Lanka Standard Time, Nepal Standard Time, Central Asia Standard Time, Bangladesh Standard + Time, N. Central Asia Standard Time, Myanmar Standard Time, SE Asia Standard Time, North Asia + Standard Time, China Standard Time, North Asia East Standard Time, Singapore Standard Time, W. + Australia Standard Time, Taipei Standard Time, Ulaanbaatar Standard Time, Tokyo Standard Time, + Korea Standard Time, Yakutsk Standard Time, Cen. Australia Standard Time, AUS Central Standard + Time, E. Australia Standard Time, AUS Eastern Standard Time, West Pacific Standard Time, + Tasmania Standard Time, Magadan Standard Time, Vladivostok Standard Time, Russia Time Zone 10, + Central Pacific Standard Time, Russia Time Zone 11, New Zealand Standard Time, UTC+12, Fiji + Standard Time, Kamchatka Standard Time, Tonga Standard Time, Samoa Standard Time, Line Islands + Standard Time. + :paramtype time_zone: str + :keyword start: Required. the start time for the profile in ISO 8601 format. + :paramtype start: ~datetime.datetime + :keyword end: Required. the end time for the profile in ISO 8601 format. + :paramtype end: ~datetime.datetime + """ super(TimeWindow, self).__init__(**kwargs) self.time_zone = time_zone self.start = start @@ -1683,10 +2186,10 @@ def __init__( class WebhookNotification(msrest.serialization.Model): """Webhook notification of an autoscale event. - :param service_uri: the service address to receive the notification. - :type service_uri: str - :param properties: a property bag of settings. This value can be empty. - :type properties: dict[str, str] + :ivar service_uri: the service address to receive the notification. + :vartype service_uri: str + :ivar properties: a property bag of settings. This value can be empty. + :vartype properties: dict[str, str] """ _attribute_map = { @@ -1701,6 +2204,12 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword service_uri: the service address to receive the notification. + :paramtype service_uri: str + :keyword properties: a property bag of settings. This value can be empty. + :paramtype properties: dict[str, str] + """ super(WebhookNotification, self).__init__(**kwargs) self.service_uri = service_uri self.properties = properties diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_monitor_management_client_enums.py index e8d9429aee048..53feb41eb5e4e 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/models/_monitor_management_client_enums.py @@ -6,34 +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 CategoryType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CategoryType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the diagnostic settings category. """ METRICS = "Metrics" LOGS = "Logs" -class ComparisonOperationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ComparisonOperationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the operator that is used to compare the metric data and the threshold. """ @@ -44,7 +29,7 @@ class ComparisonOperationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum LESS_THAN = "LessThan" LESS_THAN_OR_EQUAL = "LessThanOrEqual" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -53,7 +38,7 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class MetricStatisticType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MetricStatisticType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the metric statistic type. How the metrics from multiple instances are combined. """ @@ -63,7 +48,7 @@ class MetricStatisticType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SUM = "Sum" COUNT = "Count" -class PredictiveAutoscalePolicyScaleMode(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PredictiveAutoscalePolicyScaleMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the predictive autoscale mode """ @@ -71,7 +56,7 @@ class PredictiveAutoscalePolicyScaleMode(with_metaclass(_CaseInsensitiveEnumMeta FORECAST_ONLY = "ForecastOnly" ENABLED = "Enabled" -class RecurrenceFrequency(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RecurrenceFrequency(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the recurrence frequency. How often the schedule profile should take effect. This value must be Week, meaning each week will have the same set of profiles. For example, to set a daily schedule, set **schedule** to every day of the week. The frequency property specifies that the @@ -87,7 +72,7 @@ class RecurrenceFrequency(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MONTH = "Month" YEAR = "Year" -class ScaleDirection(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ScaleDirection(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the scale direction. Whether the scaling action increases or decreases the number of instances. """ @@ -95,7 +80,7 @@ class ScaleDirection(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): INCREASE = "Increase" DECREASE = "Decrease" -class ScaleRuleMetricDimensionOperationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ScaleRuleMetricDimensionOperationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the dimension operator. Only 'Equals' and 'NotEquals' are supported. 'Equals' being equal to any of the values. 'NotEquals' being not equal to all of the values """ @@ -103,7 +88,7 @@ class ScaleRuleMetricDimensionOperationType(with_metaclass(_CaseInsensitiveEnumM EQUALS = "Equals" NOT_EQUALS = "NotEquals" -class ScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """the type of action that should occur when the scale rule fires. """ @@ -112,7 +97,7 @@ class ScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): EXACT_COUNT = "ExactCount" SERVICE_ALLOWED_NEXT_VALUE = "ServiceAllowedNextValue" -class TimeAggregationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TimeAggregationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """time aggregation type. How the data that is collected should be combined over time. The default value is Average. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_autoscale_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_autoscale_settings_operations.py index 2eb639b31c076..a7ae42df00258 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_autoscale_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_autoscale_settings_operations.py @@ -5,24 +5,250 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_by_resource_group_request( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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_create_or_update_request( + resource_group_name, # type: str + autoscale_setting_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), + "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] + 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, + **kwargs + ) + + +def build_delete_request( + resource_group_name, # type: str + autoscale_setting_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), + "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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + autoscale_setting_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), + "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_update_request( + subscription_id, # type: str + resource_group_name, # type: str + autoscale_setting_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_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, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/autoscalesettings') + 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 + ) + +# fmt: on class AutoscaleSettingsOperations(object): """AutoscaleSettingsOperations operations. @@ -45,6 +271,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -53,11 +280,13 @@ def list_by_resource_group( # type: (...) -> Iterable["_models.AutoscaleSettingResourceCollection"] """Lists the autoscale settings for a resource group. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :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 AutoscaleSettingResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourceCollection] + :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResourceCollection"] @@ -65,35 +294,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('AutoscaleSettingResourceCollection', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,17 +331,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, 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.Insights/autoscalesettings'} # type: ignore + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -127,7 +354,7 @@ def create_or_update( # type: (...) -> "_models.AutoscaleSettingResource" """Creates or updates an autoscale setting. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str @@ -143,38 +370,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - 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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'autoscaleSettingName': self._serialize.url("autoscale_setting_name", autoscale_setting_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'AutoscaleSettingResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_create_or_update_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'AutoscaleSettingResource') - 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.failsafe_deserialize(_models.AutoscaleErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -187,8 +404,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -198,7 +418,7 @@ def delete( # type: (...) -> None """Deletes and autoscale setting. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str @@ -212,33 +432,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'autoscaleSettingName': self._serialize.url("autoscale_setting_name", autoscale_setting_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.AutoscaleErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -246,6 +456,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -255,7 +467,7 @@ def get( # type: (...) -> "_models.AutoscaleSettingResource" """Gets an autoscale setting. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str @@ -269,33 +481,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'autoscaleSettingName': self._serialize.url("autoscale_setting_name", autoscale_setting_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.AutoscaleErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) @@ -304,8 +506,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -317,12 +522,13 @@ def update( """Updates an existing AutoscaleSettingsResource. To update other fields use the CreateOrUpdate method. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str :param autoscale_setting_resource: Parameters supplied to the operation. - :type autoscale_setting_resource: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourcePatch + :type autoscale_setting_resource: + ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourcePatch :keyword callable cls: A custom type or function that will be passed the direct response :return: AutoscaleSettingResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResource @@ -333,38 +539,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-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'), - 'autoscaleSettingName': self._serialize.url("autoscale_setting_name", autoscale_setting_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(autoscale_setting_resource, 'AutoscaleSettingResourcePatch') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(autoscale_setting_resource, 'AutoscaleSettingResourcePatch') - 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.failsafe_deserialize(_models.AutoscaleErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AutoscaleSettingResource', pipeline_response) @@ -373,8 +569,11 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}'} # type: ignore + + @distributed_trace def list_by_subscription( self, **kwargs # type: Any @@ -383,8 +582,10 @@ def list_by_subscription( """Lists the autoscale settings for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourceCollection] + :return: An iterator like instance of either AutoscaleSettingResourceCollection or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.AutoscaleSettingResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AutoscaleSettingResourceCollection"] @@ -392,34 +593,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-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] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + 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: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + 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('AutoscaleSettingResourceCollection', pipeline_response) + deserialized = self._deserialize("AutoscaleSettingResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -432,12 +628,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_category_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_category_operations.py index d6954cacf3447..24cb0b1dacfa4 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_category_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_category_operations.py @@ -5,24 +5,98 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + resource_uri, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "name": _SERIALIZER.url("name", 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_list_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + 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 + ) + +# fmt: on class DiagnosticSettingsCategoryOperations(object): """DiagnosticSettingsCategoryOperations operations. @@ -45,6 +119,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_uri, # type: str @@ -68,32 +143,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_get_request( + resource_uri=resource_uri, + name=name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DiagnosticSettingsCategoryResource', pipeline_response) @@ -102,8 +167,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettingsCategories/{name}'} # type: ignore + + @distributed_trace def list( self, resource_uri, # type: str @@ -115,8 +183,10 @@ def list( :param resource_uri: The identifier of the resource. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiagnosticSettingsCategoryResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResourceCollection] + :return: An iterator like instance of either DiagnosticSettingsCategoryResourceCollection or + the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsCategoryResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsCategoryResourceCollection"] @@ -124,34 +194,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-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 - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + template_url=self.list.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_list_request( + resource_uri=resource_uri, + 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('DiagnosticSettingsCategoryResourceCollection', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsCategoryResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -164,12 +229,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_operations.py index ba435b4c62074..15f6025058cfe 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_diagnostic_settings_operations.py @@ -5,24 +5,170 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + resource_uri, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "name": _SERIALIZER.url("name", 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( + resource_uri, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "name": _SERIALIZER.url("name", 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, + **kwargs + ) + + +def build_delete_request( + resource_uri, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + "name": _SERIALIZER.url("name", 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_list_request( + resource_uri, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + 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 + ) + +# fmt: on class DiagnosticSettingsOperations(object): """DiagnosticSettingsOperations operations. @@ -45,6 +191,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_uri, # type: str @@ -68,32 +215,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_get_request( + resource_uri=resource_uri, + name=name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DiagnosticSettingsResource', pipeline_response) @@ -102,8 +239,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def create_or_update( self, resource_uri, # type: str @@ -119,7 +259,8 @@ def create_or_update( :param name: The name of the diagnostic setting. :type name: str :param parameters: Parameters supplied to the operation. - :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource + :type parameters: + ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: DiagnosticSettingsResource, or the result of cls(response) :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResource @@ -130,37 +271,27 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - 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 = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'DiagnosticSettingsResource') + + request = build_create_or_update_request( + resource_uri=resource_uri, + name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'DiagnosticSettingsResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('DiagnosticSettingsResource', pipeline_response) @@ -169,8 +300,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def delete( self, resource_uri, # type: str @@ -194,32 +328,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_delete_request( + resource_uri=resource_uri, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -227,6 +351,8 @@ def delete( delete.metadata = {'url': '/{resourceUri}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def list( self, resource_uri, # type: str @@ -238,8 +364,10 @@ def list( :param resource_uri: The identifier of the resource. :type resource_uri: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DiagnosticSettingsResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResourceCollection] + :return: An iterator like instance of either DiagnosticSettingsResourceCollection or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.DiagnosticSettingsResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.DiagnosticSettingsResourceCollection"] @@ -247,34 +375,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-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 - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + template_url=self.list.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_list_request( + resource_uri=resource_uri, + 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('DiagnosticSettingsResourceCollection', pipeline_response) + deserialized = self._deserialize("DiagnosticSettingsResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -287,12 +410,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_management_group_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_management_group_diagnostic_settings_operations.py index 4c8c369237073..e166dd08c7400 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_management_group_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_management_group_diagnostic_settings_operations.py @@ -5,24 +5,170 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + management_group_id, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), + "name": _SERIALIZER.url("name", 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( + management_group_id, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), + "name": _SERIALIZER.url("name", 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, + **kwargs + ) + + +def build_delete_request( + management_group_id, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), + "name": _SERIALIZER.url("name", 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_list_request( + management_group_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings') + path_format_arguments = { + "managementGroupId": _SERIALIZER.url("management_group_id", management_group_id, 'str', skip_quote=True), + } + + 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 + ) + +# fmt: on class ManagementGroupDiagnosticSettingsOperations(object): """ManagementGroupDiagnosticSettingsOperations operations. @@ -45,6 +191,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, management_group_id, # type: str @@ -60,7 +207,8 @@ def get( :type name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementGroupDiagnosticSettingsResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource + :rtype: + ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResource"] @@ -68,32 +216,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_get_request( + management_group_id=management_group_id, + name=name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementGroupDiagnosticSettingsResource', pipeline_response) @@ -102,8 +240,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def create_or_update( self, management_group_id, # type: str @@ -119,10 +260,12 @@ def create_or_update( :param name: The name of the diagnostic setting. :type name: str :param parameters: Parameters supplied to the operation. - :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource + :type parameters: + ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: ManagementGroupDiagnosticSettingsResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource + :rtype: + ~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResource"] @@ -130,37 +273,27 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - 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 = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'ManagementGroupDiagnosticSettingsResource') + + request = build_create_or_update_request( + management_group_id=management_group_id, + name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'ManagementGroupDiagnosticSettingsResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ManagementGroupDiagnosticSettingsResource', pipeline_response) @@ -169,8 +302,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def delete( self, management_group_id, # type: str @@ -194,32 +330,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True), - 'name': self._serialize.url("name", 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 = build_delete_request( + management_group_id=management_group_id, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -227,6 +353,8 @@ def delete( delete.metadata = {'url': '/providers/Microsoft.Management/managementGroups/{managementGroupId}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def list( self, management_group_id, # type: str @@ -238,8 +366,10 @@ def list( :param management_group_id: The management group id. :type management_group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagementGroupDiagnosticSettingsResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResourceCollection] + :return: An iterator like instance of either + ManagementGroupDiagnosticSettingsResourceCollection or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.ManagementGroupDiagnosticSettingsResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagementGroupDiagnosticSettingsResourceCollection"] @@ -247,34 +377,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-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 - path_format_arguments = { - 'managementGroupId': self._serialize.url("management_group_id", management_group_id, 'str', skip_quote=True), - } - 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + management_group_id=management_group_id, + template_url=self.list.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_list_request( + management_group_id=management_group_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('ManagementGroupDiagnosticSettingsResourceCollection', pipeline_response) + deserialized = self._deserialize("ManagementGroupDiagnosticSettingsResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -287,12 +412,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_predictive_metric_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_predictive_metric_operations.py index 423b5f59072a4..677536c6f3d14 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_predictive_metric_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_predictive_metric_operations.py @@ -6,23 +6,78 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +import functools from typing import TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error 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 +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + autoscale_setting_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + timespan = kwargs.pop('timespan') # type: str + interval = kwargs.pop('interval') # type: datetime.timedelta + metric_namespace = kwargs.pop('metric_namespace') # type: str + metric_name = kwargs.pop('metric_name') # type: str + aggregation = kwargs.pop('aggregation') # type: str + + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "autoscaleSettingName": _SERIALIZER.url("autoscale_setting_name", autoscale_setting_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['timespan'] = _SERIALIZER.query("timespan", timespan, 'str') + query_parameters['interval'] = _SERIALIZER.query("interval", interval, 'duration') + query_parameters['metricNamespace'] = _SERIALIZER.query("metric_namespace", metric_namespace, 'str') + query_parameters['metricName'] = _SERIALIZER.query("metric_name", metric_name, 'str') + query_parameters['aggregation'] = _SERIALIZER.query("aggregation", aggregation, '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 + ) + +# fmt: on class PredictiveMetricOperations(object): """PredictiveMetricOperations operations. @@ -45,6 +100,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, resource_group_name, # type: str @@ -59,7 +115,7 @@ def get( # type: (...) -> "_models.PredictiveResponse" """get predictive autoscale metric future data. - :param resource_group_name: The name of the resource group. + :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :param autoscale_setting_name: The autoscale setting name. :type autoscale_setting_name: str @@ -86,38 +142,28 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - 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'), - 'autoscaleSettingName': self._serialize.url("autoscale_setting_name", autoscale_setting_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['timespan'] = self._serialize.query("timespan", timespan, 'str') - query_parameters['interval'] = self._serialize.query("interval", interval, 'duration') - query_parameters['metricNamespace'] = self._serialize.query("metric_namespace", metric_namespace, 'str') - query_parameters['metricName'] = self._serialize.query("metric_name", metric_name, 'str') - query_parameters['aggregation'] = self._serialize.query("aggregation", aggregation, '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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + autoscale_setting_name=autoscale_setting_name, + timespan=timespan, + interval=interval, + metric_namespace=metric_namespace, + metric_name=metric_name, + aggregation=aggregation, + template_url=self.get.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.AutoscaleErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.AutoscaleErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PredictiveResponse', pipeline_response) @@ -126,4 +172,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Insights/autoscalesettings/{autoscaleSettingName}/predictiveMetrics'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_subscription_diagnostic_settings_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_subscription_diagnostic_settings_operations.py index dbb63fa1f3fe2..d3dc9b42efd0d 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_subscription_diagnostic_settings_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_05_01_preview/operations/_subscription_diagnostic_settings_operations.py @@ -5,24 +5,170 @@ # 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 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.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 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_request( + subscription_id, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "name": _SERIALIZER.url("name", 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, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "name": _SERIALIZER.url("name", 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, + **kwargs + ) + + +def build_delete_request( + subscription_id, # type: str + name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "name": _SERIALIZER.url("name", 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_list_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-05-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings') + 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 + ) + +# fmt: on class SubscriptionDiagnosticSettingsOperations(object): """SubscriptionDiagnosticSettingsOperations operations. @@ -45,6 +191,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, name, # type: str @@ -57,7 +204,8 @@ def get( :type name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionDiagnosticSettingsResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :rtype: + ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResource"] @@ -65,32 +213,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - 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), - 'name': self._serialize.url("name", 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 = build_get_request( + subscription_id=self._config.subscription_id, + name=name, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SubscriptionDiagnosticSettingsResource', pipeline_response) @@ -99,8 +237,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def create_or_update( self, name, # type: str @@ -113,10 +254,12 @@ def create_or_update( :param name: The name of the diagnostic setting. :type name: str :param parameters: Parameters supplied to the operation. - :type parameters: ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :type parameters: + ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource :keyword callable cls: A custom type or function that will be passed the direct response :return: SubscriptionDiagnosticSettingsResource, or the result of cls(response) - :rtype: ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource + :rtype: + ~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResource :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResource"] @@ -124,37 +267,27 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-preview" - 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), - 'name': self._serialize.url("name", 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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(parameters, 'SubscriptionDiagnosticSettingsResource') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + name=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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(parameters, 'SubscriptionDiagnosticSettingsResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SubscriptionDiagnosticSettingsResource', pipeline_response) @@ -163,8 +296,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def delete( self, name, # type: str @@ -185,32 +321,22 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-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), - 'name': self._serialize.url("name", 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 = build_delete_request( + subscription_id=self._config.subscription_id, + name=name, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -218,6 +344,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/diagnosticSettings/{name}'} # type: ignore + + @distributed_trace def list( self, **kwargs # type: Any @@ -226,8 +354,10 @@ def list( """Gets the active subscription diagnostic settings list for the specified subscriptionId. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SubscriptionDiagnosticSettingsResourceCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResourceCollection] + :return: An iterator like instance of either SubscriptionDiagnosticSettingsResourceCollection + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_05_01_preview.models.SubscriptionDiagnosticSettingsResourceCollection] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SubscriptionDiagnosticSettingsResourceCollection"] @@ -235,34 +365,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-05-01-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 - 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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_list_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('SubscriptionDiagnosticSettingsResourceCollection', pipeline_response) + deserialized = self._deserialize("SubscriptionDiagnosticSettingsResourceCollection", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -275,12 +400,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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 ) diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/__init__.py index d824795100926..ec9090a57df09 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MonitorManagementClient'] -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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_configuration.py index f742fdfb40ed6..e1773a9423b97 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_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 ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -40,11 +40,11 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +68,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_metadata.json b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_metadata.json index ac502baf335c5..935381fe6e10f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_metadata.json +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_metadata.json @@ -5,13 +5,13 @@ "name": "MonitorManagementClient", "filename": "_monitor_management_client", "description": "Monitor Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "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\": [\"MonitorManagementClientConfiguration\"]}}, \"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\": [\"MonitorManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "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": { "action_groups": "ActionGroupsOperations" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_monitor_management_client.py index 68961c58818a5..01e7005c811b7 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_monitor_management_client.py @@ -6,22 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MonitorManagementClientConfiguration +from .operations import ActionGroupsOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MonitorManagementClientConfiguration -from .operations import ActionGroupsOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class MonitorManagementClient(object): """Monitor Management Client. @@ -32,48 +32,56 @@ class MonitorManagementClient(object): :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 - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential, # type: "TokenCredential" subscription_id, # type: str - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs # type: Any + ): + # type: (...) -> HttpResponse """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_vendor.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_vendor.py new file mode 100644 index 0000000000000..138f663c53a4e --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_version.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_version.py index cac9f5d10f8b7..e5754a47ce68f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_version.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "3.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/__init__.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/__init__.py index 96ce9b45c05b5..4eba911f1c6ec 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/__init__.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._monitor_management_client import MonitorManagementClient __all__ = ['MonitorManagementClient'] + +# `._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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_configuration.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_configuration.py index 97e0adedc21d5..2ae420e155183 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_configuration.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/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(MonitorManagementClientConfiguration, 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(MonitorManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_monitor_management_client.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_monitor_management_client.py index baf79082f016f..d852f15ba63d0 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_monitor_management_client.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_monitor_management_client.py @@ -6,70 +6,79 @@ # 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.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import MonitorManagementClientConfiguration from .operations import ActionGroupsOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class MonitorManagementClient(object): +class MonitorManagementClient: """Monitor Management Client. :ivar action_groups: ActionGroupsOperations operations - :vartype action_groups: $(python-base-namespace).v2021_09_01.aio.operations.ActionGroupsOperations + :vartype action_groups: + $(python-base-namespace).v2021_09_01.aio.operations.ActionGroupsOperations :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 - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ 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 = MonitorManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MonitorManagementClientConfiguration(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._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.action_groups = ActionGroupsOperations(self._client, self._config, self._serialize, self._deserialize) - self.action_groups = ActionGroupsOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + 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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_patch.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/_patch.py new file mode 100644 index 0000000000000..74e48ecd07cf3 --- /dev/null +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/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/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_action_groups_operations.py index 10a31edf786f5..769a807cdbc8f 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/aio/operations/_action_groups_operations.py @@ -5,19 +5,24 @@ # 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.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +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 azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._action_groups_operations import build_create_or_update_request, build_delete_request, build_enable_receiver_request, build_get_request, build_get_test_notifications_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_post_test_notifications_request_initial, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -68,38 +74,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group, 'ActionGroupResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group, 'ActionGroupResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -112,8 +108,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -136,33 +135,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -171,8 +160,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -195,33 +187,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -229,6 +211,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -254,38 +238,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - 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', max_length=90, min_length=1), - 'actionGroupName': self._serialize.url("action_group_name", action_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -294,8 +268,10 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}'} # type: ignore + async def _post_test_notifications_initial( self, notification_request: "_models.NotificationRequestBody", @@ -306,37 +282,26 @@ async def _post_test_notifications_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._post_test_notifications_initial.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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(notification_request, 'NotificationRequestBody') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_post_test_notifications_request_initial( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._post_test_notifications_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(notification_request, 'NotificationRequestBody') - body_content_kwargs['content'] = body_content - request = self._client.post(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 [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize('TestNotificationResponse', pipeline_response) @@ -344,8 +309,11 @@ async def _post_test_notifications_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _post_test_notifications_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications'} # type: ignore + + @distributed_trace_async async def begin_post_test_notifications( self, notification_request: "_models.NotificationRequestBody", @@ -354,18 +322,24 @@ async def begin_post_test_notifications( """Send test notifications to a set of provided receivers. :param notification_request: The notification request body which includes the contact details. - :type notification_request: ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody + :type notification_request: + ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either TestNotificationResponse or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationResponse] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either TestNotificationResponse or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationResponse] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.TestNotificationResponse"] lro_delay = kwargs.pop( 'polling_interval', @@ -375,25 +349,21 @@ async def begin_post_test_notifications( if cont_token is None: raw_result = await self._post_test_notifications_initial( notification_request=notification_request, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('TestNotificationResponse', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -405,8 +375,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_post_test_notifications.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications'} # type: ignore + @distributed_trace_async async def get_test_notifications( self, notification_id: str, @@ -426,32 +398,22 @@ async def get_test_notifications( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self.get_test_notifications.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'notificationId': self._serialize.url("notification_id", notification_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_test_notifications_request( + subscription_id=self._config.subscription_id, + notification_id=notification_id, + template_url=self.get_test_notifications.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) @@ -460,8 +422,11 @@ async def get_test_notifications( return cls(pipeline_response, deserialized, {}) return deserialized + get_test_notifications.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}'} # type: ignore + + @distributed_trace def list_by_subscription_id( self, **kwargs: Any @@ -470,7 +435,8 @@ def list_by_subscription_id( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ActionGroupList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -478,34 +444,29 @@ def list_by_subscription_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-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_subscription_id.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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription_id.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_list_by_subscription_id_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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -518,17 +479,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -540,7 +503,8 @@ def list_by_resource_group( :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 ActionGroupList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -548,35 +512,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -589,17 +549,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Insights/actionGroups'} # type: ignore + @distributed_trace_async async def enable_receiver( self, resource_group_name: str, @@ -626,41 +588,32 @@ async def enable_receiver( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.enable_receiver.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(enable_request, 'EnableRequest') + + request = build_enable_receiver_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.enable_receiver.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(enable_request, 'EnableRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) enable_receiver.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe'} # type: ignore + diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models.py index 66ef35c49301e..81002d98f8a79 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models.py @@ -13,18 +13,18 @@ class ActionDetail(msrest.serialization.Model): """The action detail. - :param mechanism_type: The mechanism type. - :type mechanism_type: str - :param name: The name of the action. - :type name: str - :param status: The status of the action. - :type status: str - :param sub_state: The substatus of the action. - :type sub_state: str - :param send_time: The send time. - :type send_time: str - :param detail: The detail of the friendly error message. - :type detail: str + :ivar mechanism_type: The mechanism type. + :vartype mechanism_type: str + :ivar name: The name of the action. + :vartype name: str + :ivar status: The status of the action. + :vartype status: str + :ivar sub_state: The substatus of the action. + :vartype sub_state: str + :ivar send_time: The send time. + :vartype send_time: str + :ivar detail: The detail of the friendly error message. + :vartype detail: str """ _attribute_map = { @@ -40,6 +40,20 @@ def __init__( self, **kwargs ): + """ + :keyword mechanism_type: The mechanism type. + :paramtype mechanism_type: str + :keyword name: The name of the action. + :paramtype name: str + :keyword status: The status of the action. + :paramtype status: str + :keyword sub_state: The substatus of the action. + :paramtype sub_state: str + :keyword send_time: The send time. + :paramtype send_time: str + :keyword detail: The detail of the friendly error message. + :paramtype detail: str + """ super(ActionDetail, self).__init__(**kwargs) self.mechanism_type = kwargs.get('mechanism_type', None) self.name = kwargs.get('name', None) @@ -52,10 +66,10 @@ def __init__( class ActionGroupList(msrest.serialization.Model): """A list of action groups. - :param value: The list of action groups. - :type value: list[~$(python-base-namespace).v2021_09_01.models.ActionGroupResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar value: The list of action groups. + :vartype value: list[~$(python-base-namespace).v2021_09_01.models.ActionGroupResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -67,6 +81,12 @@ def __init__( self, **kwargs ): + """ + :keyword value: The list of action groups. + :paramtype value: list[~$(python-base-namespace).v2021_09_01.models.ActionGroupResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(ActionGroupList, self).__init__(**kwargs) self.value = kwargs.get('value', None) self.next_link = kwargs.get('next_link', None) @@ -75,11 +95,11 @@ def __init__( class ActionGroupPatchBody(msrest.serialization.Model): """An action group object for the body of patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. - :type enabled: bool + :vartype enabled: bool """ _attribute_map = { @@ -91,6 +111,13 @@ def __init__( self, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ super(ActionGroupPatchBody, self).__init__(**kwargs) self.tags = kwargs.get('tags', None) self.enabled = kwargs.get('enabled', True) @@ -113,10 +140,10 @@ class AzureResource(msrest.serialization.Model): :vartype kind: str :ivar identity: Azure resource identity. :vartype identity: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -142,6 +169,12 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(AzureResource, self).__init__(**kwargs) self.id = None self.name = None @@ -169,44 +202,46 @@ class ActionGroupResource(AzureResource): :vartype kind: str :ivar identity: Azure resource identity. :vartype identity: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param group_short_name: The short name of the action group. This will be used in SMS messages. - :type group_short_name: str - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar group_short_name: The short name of the action group. This will be used in SMS messages. + :vartype group_short_name: str + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. - :type enabled: bool - :param email_receivers: The list of email receivers that are part of this action group. - :type email_receivers: list[~$(python-base-namespace).v2021_09_01.models.EmailReceiver] - :param sms_receivers: The list of SMS receivers that are part of this action group. - :type sms_receivers: list[~$(python-base-namespace).v2021_09_01.models.SmsReceiver] - :param webhook_receivers: The list of webhook receivers that are part of this action group. - :type webhook_receivers: list[~$(python-base-namespace).v2021_09_01.models.WebhookReceiver] - :param itsm_receivers: The list of ITSM receivers that are part of this action group. - :type itsm_receivers: list[~$(python-base-namespace).v2021_09_01.models.ItsmReceiver] - :param azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :type azure_app_push_receivers: + :vartype enabled: bool + :ivar email_receivers: The list of email receivers that are part of this action group. + :vartype email_receivers: list[~$(python-base-namespace).v2021_09_01.models.EmailReceiver] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~$(python-base-namespace).v2021_09_01.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~$(python-base-namespace).v2021_09_01.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~$(python-base-namespace).v2021_09_01.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: list[~$(python-base-namespace).v2021_09_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of this action group. - :type automation_runbook_receivers: + :vartype automation_runbook_receivers: list[~$(python-base-namespace).v2021_09_01.models.AutomationRunbookReceiver] - :param voice_receivers: The list of voice receivers that are part of this action group. - :type voice_receivers: list[~$(python-base-namespace).v2021_09_01.models.VoiceReceiver] - :param logic_app_receivers: The list of logic app receivers that are part of this action group. - :type logic_app_receivers: list[~$(python-base-namespace).v2021_09_01.models.LogicAppReceiver] - :param azure_function_receivers: The list of azure function receivers that are part of this + :ivar voice_receivers: The list of voice receivers that are part of this action group. + :vartype voice_receivers: list[~$(python-base-namespace).v2021_09_01.models.VoiceReceiver] + :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. + :vartype logic_app_receivers: + list[~$(python-base-namespace).v2021_09_01.models.LogicAppReceiver] + :ivar azure_function_receivers: The list of azure function receivers that are part of this action group. - :type azure_function_receivers: + :vartype azure_function_receivers: list[~$(python-base-namespace).v2021_09_01.models.AzureFunctionReceiver] - :param arm_role_receivers: The list of ARM role receivers that are part of this action group. + :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. Roles are Azure RBAC roles and only built-in roles are supported. - :type arm_role_receivers: list[~$(python-base-namespace).v2021_09_01.models.ArmRoleReceiver] - :param event_hub_receivers: The list of event hub receivers that are part of this action group. - :type event_hub_receivers: list[~$(python-base-namespace).v2021_09_01.models.EventHubReceiver] + :vartype arm_role_receivers: list[~$(python-base-namespace).v2021_09_01.models.ArmRoleReceiver] + :ivar event_hub_receivers: The list of event hub receivers that are part of this action group. + :vartype event_hub_receivers: + list[~$(python-base-namespace).v2021_09_01.models.EventHubReceiver] """ _validation = { @@ -246,6 +281,53 @@ def __init__( self, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword group_short_name: The short name of the action group. This will be used in SMS + messages. + :paramtype group_short_name: str + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its receivers will receive communications. + :paramtype enabled: bool + :keyword email_receivers: The list of email receivers that are part of this action group. + :paramtype email_receivers: list[~$(python-base-namespace).v2021_09_01.models.EmailReceiver] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~$(python-base-namespace).v2021_09_01.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: + list[~$(python-base-namespace).v2021_09_01.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~$(python-base-namespace).v2021_09_01.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: + list[~$(python-base-namespace).v2021_09_01.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~$(python-base-namespace).v2021_09_01.models.AutomationRunbookReceiver] + :keyword voice_receivers: The list of voice receivers that are part of this action group. + :paramtype voice_receivers: list[~$(python-base-namespace).v2021_09_01.models.VoiceReceiver] + :keyword logic_app_receivers: The list of logic app receivers that are part of this action + group. + :paramtype logic_app_receivers: + list[~$(python-base-namespace).v2021_09_01.models.LogicAppReceiver] + :keyword azure_function_receivers: The list of azure function receivers that are part of this + action group. + :paramtype azure_function_receivers: + list[~$(python-base-namespace).v2021_09_01.models.AzureFunctionReceiver] + :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :paramtype arm_role_receivers: + list[~$(python-base-namespace).v2021_09_01.models.ArmRoleReceiver] + :keyword event_hub_receivers: The list of event hub receivers that are part of this action + group. + :paramtype event_hub_receivers: + list[~$(python-base-namespace).v2021_09_01.models.EventHubReceiver] + """ super(ActionGroupResource, self).__init__(**kwargs) self.group_short_name = kwargs.get('group_short_name', None) self.enabled = kwargs.get('enabled', True) @@ -267,13 +349,13 @@ class ArmRoleReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the arm role receiver. Names must be unique across all + :ivar name: Required. The name of the arm role receiver. Names must be unique across all receivers within an action group. - :type name: str - :param role_id: Required. The arm role id. - :type role_id: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar role_id: Required. The arm role id. + :vartype role_id: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -291,6 +373,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the arm role receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword role_id: Required. The arm role id. + :paramtype role_id: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(ArmRoleReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.role_id = kwargs['role_id'] @@ -302,21 +393,21 @@ class AutomationRunbookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. - :type automation_account_id: str - :param runbook_name: Required. The name for this runbook. - :type runbook_name: str - :param webhook_resource_id: Required. The resource id for webhook linked to this runbook. - :type webhook_resource_id: str - :param is_global_runbook: Required. Indicates whether this instance is global runbook. - :type is_global_runbook: bool - :param name: Indicates name of the webhook. - :type name: str - :param service_uri: The URI where webhooks should be sent. - :type service_uri: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook + and authenticate to Azure resource. + :vartype automation_account_id: str + :ivar runbook_name: Required. The name for this runbook. + :vartype runbook_name: str + :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :vartype webhook_resource_id: str + :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :vartype is_global_runbook: bool + :ivar name: Indicates name of the webhook. + :vartype name: str + :ivar service_uri: The URI where webhooks should be sent. + :vartype service_uri: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -340,6 +431,23 @@ def __init__( self, **kwargs ): + """ + :keyword automation_account_id: Required. The Azure automation account Id which holds this + runbook and authenticate to Azure resource. + :paramtype automation_account_id: str + :keyword runbook_name: Required. The name for this runbook. + :paramtype runbook_name: str + :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :paramtype webhook_resource_id: str + :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :paramtype is_global_runbook: bool + :keyword name: Indicates name of the webhook. + :paramtype name: str + :keyword service_uri: The URI where webhooks should be sent. + :paramtype service_uri: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(AutomationRunbookReceiver, self).__init__(**kwargs) self.automation_account_id = kwargs['automation_account_id'] self.runbook_name = kwargs['runbook_name'] @@ -355,11 +463,11 @@ class AzureAppPushReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Azure mobile app push receiver. Names must be unique + :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. - :type name: str - :param email_address: Required. The email address registered for the Azure mobile app. - :type email_address: str + :vartype name: str + :ivar email_address: Required. The email address registered for the Azure mobile app. + :vartype email_address: str """ _validation = { @@ -376,6 +484,13 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique + across all receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address registered for the Azure mobile app. + :paramtype email_address: str + """ super(AzureAppPushReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.email_address = kwargs['email_address'] @@ -386,17 +501,17 @@ class AzureFunctionReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the azure function receiver. Names must be unique across all + :ivar name: Required. The name of the azure function receiver. Names must be unique across all receivers within an action group. - :type name: str - :param function_app_resource_id: Required. The azure resource id of the function app. - :type function_app_resource_id: str - :param function_name: Required. The function name in the function app. - :type function_name: str - :param http_trigger_url: Required. The http trigger url where http request sent to. - :type http_trigger_url: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar function_app_resource_id: Required. The azure resource id of the function app. + :vartype function_app_resource_id: str + :ivar function_name: Required. The function name in the function app. + :vartype function_name: str + :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :vartype http_trigger_url: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -418,6 +533,19 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the azure function receiver. Names must be unique across + all receivers within an action group. + :paramtype name: str + :keyword function_app_resource_id: Required. The azure resource id of the function app. + :paramtype function_app_resource_id: str + :keyword function_name: Required. The function name in the function app. + :paramtype function_name: str + :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :paramtype http_trigger_url: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(AzureFunctionReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.function_app_resource_id = kwargs['function_app_resource_id'] @@ -429,10 +557,10 @@ def __init__( class Context(msrest.serialization.Model): """The context info. - :param notification_source: The source of the notification request. - :type notification_source: str - :param context_type: The context id type. - :type context_type: str + :ivar notification_source: The source of the notification request. + :vartype notification_source: str + :ivar context_type: The context id type. + :vartype context_type: str """ _attribute_map = { @@ -444,6 +572,12 @@ def __init__( self, **kwargs ): + """ + :keyword notification_source: The source of the notification request. + :paramtype notification_source: str + :keyword context_type: The context id type. + :paramtype context_type: str + """ super(Context, self).__init__(**kwargs) self.notification_source = kwargs.get('notification_source', None) self.context_type = kwargs.get('context_type', None) @@ -456,13 +590,13 @@ class EmailReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param email_address: Required. The email address of this receiver. - :type email_address: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :ivar name: Required. The name of the email receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar email_address: Required. The email address of this receiver. + :vartype email_address: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool :ivar status: The receiver status of the e-mail. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2021_09_01.models.ReceiverStatus @@ -485,6 +619,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the email receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address of this receiver. + :paramtype email_address: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(EmailReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.email_address = kwargs['email_address'] @@ -497,8 +640,8 @@ class EnableRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param receiver_name: Required. The name of the receiver to resubscribe. - :type receiver_name: str + :ivar receiver_name: Required. The name of the receiver to resubscribe. + :vartype receiver_name: str """ _validation = { @@ -513,6 +656,10 @@ def __init__( self, **kwargs ): + """ + :keyword receiver_name: Required. The name of the receiver to resubscribe. + :paramtype receiver_name: str + """ super(EnableRequest, self).__init__(**kwargs) self.receiver_name = kwargs['receiver_name'] @@ -520,10 +667,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -535,6 +682,12 @@ def __init__( self, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -545,19 +698,19 @@ class EventHubReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Event hub receiver. Names must be unique across all + :ivar name: Required. The name of the Event hub receiver. Names must be unique across all receivers within an action group. - :type name: str - :param event_hub_name_space: Required. The Event Hub namespace. - :type event_hub_name_space: str - :param event_hub_name: Required. The name of the specific Event Hub queue. - :type event_hub_name: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool - :param tenant_id: The tenant Id for the subscription containing this event hub. - :type tenant_id: str - :param subscription_id: Required. The Id for the subscription containing this event hub. - :type subscription_id: str + :vartype name: str + :ivar event_hub_name_space: Required. The Event Hub namespace. + :vartype event_hub_name_space: str + :ivar event_hub_name: Required. The name of the specific Event Hub queue. + :vartype event_hub_name: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + :ivar tenant_id: The tenant Id for the subscription containing this event hub. + :vartype tenant_id: str + :ivar subscription_id: Required. The Id for the subscription containing this event hub. + :vartype subscription_id: str """ _validation = { @@ -580,6 +733,21 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the Event hub receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword event_hub_name_space: Required. The Event Hub namespace. + :paramtype event_hub_name_space: str + :keyword event_hub_name: Required. The name of the specific Event Hub queue. + :paramtype event_hub_name: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + :keyword tenant_id: The tenant Id for the subscription containing this event hub. + :paramtype tenant_id: str + :keyword subscription_id: Required. The Id for the subscription containing this event hub. + :paramtype subscription_id: str + """ super(EventHubReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.event_hub_name_space = kwargs['event_hub_name_space'] @@ -594,20 +762,20 @@ class ItsmReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Itsm receiver. Names must be unique across all receivers + :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers within an action group. - :type name: str - :param workspace_id: Required. OMS LA instance identifier. - :type workspace_id: str - :param connection_id: Required. Unique identification of ITSM connection among multiple defined + :vartype name: str + :ivar workspace_id: Required. OMS LA instance identifier. + :vartype workspace_id: str + :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined in above workspace. - :type connection_id: str - :param ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + :vartype connection_id: str + :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as well. - :type ticket_configuration: str - :param region: Required. Region in which workspace resides. Supported + :vartype ticket_configuration: str + :ivar region: Required. Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - :type region: str + :vartype region: str """ _validation = { @@ -630,6 +798,22 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the Itsm receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword workspace_id: Required. OMS LA instance identifier. + :paramtype workspace_id: str + :keyword connection_id: Required. Unique identification of ITSM connection among multiple + defined in above workspace. + :paramtype connection_id: str + :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. + :paramtype ticket_configuration: str + :keyword region: Required. Region in which workspace resides. Supported + values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + :paramtype region: str + """ super(ItsmReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.workspace_id = kwargs['workspace_id'] @@ -643,15 +827,15 @@ class LogicAppReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the logic app receiver. Names must be unique across all + :ivar name: Required. The name of the logic app receiver. Names must be unique across all receivers within an action group. - :type name: str - :param resource_id: Required. The azure resource id of the logic app receiver. - :type resource_id: str - :param callback_url: Required. The callback url where http request sent to. - :type callback_url: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar resource_id: Required. The azure resource id of the logic app receiver. + :vartype resource_id: str + :ivar callback_url: Required. The callback url where http request sent to. + :vartype callback_url: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -671,6 +855,17 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the logic app receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword resource_id: Required. The azure resource id of the logic app receiver. + :paramtype resource_id: str + :keyword callback_url: Required. The callback url where http request sent to. + :paramtype callback_url: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(LogicAppReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.resource_id = kwargs['resource_id'] @@ -683,37 +878,39 @@ class NotificationRequestBody(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param alert_type: Required. The name of the supported alert type. - :type alert_type: str - :param email_receivers: The list of email receivers that are part of this action group. - :type email_receivers: list[~$(python-base-namespace).v2021_09_01.models.EmailReceiver] - :param sms_receivers: The list of SMS receivers that are part of this action group. - :type sms_receivers: list[~$(python-base-namespace).v2021_09_01.models.SmsReceiver] - :param webhook_receivers: The list of webhook receivers that are part of this action group. - :type webhook_receivers: list[~$(python-base-namespace).v2021_09_01.models.WebhookReceiver] - :param itsm_receivers: The list of ITSM receivers that are part of this action group. - :type itsm_receivers: list[~$(python-base-namespace).v2021_09_01.models.ItsmReceiver] - :param azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :type azure_app_push_receivers: + :ivar alert_type: Required. The name of the supported alert type. + :vartype alert_type: str + :ivar email_receivers: The list of email receivers that are part of this action group. + :vartype email_receivers: list[~$(python-base-namespace).v2021_09_01.models.EmailReceiver] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~$(python-base-namespace).v2021_09_01.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~$(python-base-namespace).v2021_09_01.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~$(python-base-namespace).v2021_09_01.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: list[~$(python-base-namespace).v2021_09_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of this action group. - :type automation_runbook_receivers: + :vartype automation_runbook_receivers: list[~$(python-base-namespace).v2021_09_01.models.AutomationRunbookReceiver] - :param voice_receivers: The list of voice receivers that are part of this action group. - :type voice_receivers: list[~$(python-base-namespace).v2021_09_01.models.VoiceReceiver] - :param logic_app_receivers: The list of logic app receivers that are part of this action group. - :type logic_app_receivers: list[~$(python-base-namespace).v2021_09_01.models.LogicAppReceiver] - :param azure_function_receivers: The list of azure function receivers that are part of this + :ivar voice_receivers: The list of voice receivers that are part of this action group. + :vartype voice_receivers: list[~$(python-base-namespace).v2021_09_01.models.VoiceReceiver] + :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. + :vartype logic_app_receivers: + list[~$(python-base-namespace).v2021_09_01.models.LogicAppReceiver] + :ivar azure_function_receivers: The list of azure function receivers that are part of this action group. - :type azure_function_receivers: + :vartype azure_function_receivers: list[~$(python-base-namespace).v2021_09_01.models.AzureFunctionReceiver] - :param arm_role_receivers: The list of ARM role receivers that are part of this action group. + :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. Roles are Azure RBAC roles and only built-in roles are supported. - :type arm_role_receivers: list[~$(python-base-namespace).v2021_09_01.models.ArmRoleReceiver] - :param event_hub_receivers: The list of event hub receivers that are part of this action group. - :type event_hub_receivers: list[~$(python-base-namespace).v2021_09_01.models.EventHubReceiver] + :vartype arm_role_receivers: list[~$(python-base-namespace).v2021_09_01.models.ArmRoleReceiver] + :ivar event_hub_receivers: The list of event hub receivers that are part of this action group. + :vartype event_hub_receivers: + list[~$(python-base-namespace).v2021_09_01.models.EventHubReceiver] """ _validation = { @@ -739,6 +936,45 @@ def __init__( self, **kwargs ): + """ + :keyword alert_type: Required. The name of the supported alert type. + :paramtype alert_type: str + :keyword email_receivers: The list of email receivers that are part of this action group. + :paramtype email_receivers: list[~$(python-base-namespace).v2021_09_01.models.EmailReceiver] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~$(python-base-namespace).v2021_09_01.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: + list[~$(python-base-namespace).v2021_09_01.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~$(python-base-namespace).v2021_09_01.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: + list[~$(python-base-namespace).v2021_09_01.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~$(python-base-namespace).v2021_09_01.models.AutomationRunbookReceiver] + :keyword voice_receivers: The list of voice receivers that are part of this action group. + :paramtype voice_receivers: list[~$(python-base-namespace).v2021_09_01.models.VoiceReceiver] + :keyword logic_app_receivers: The list of logic app receivers that are part of this action + group. + :paramtype logic_app_receivers: + list[~$(python-base-namespace).v2021_09_01.models.LogicAppReceiver] + :keyword azure_function_receivers: The list of azure function receivers that are part of this + action group. + :paramtype azure_function_receivers: + list[~$(python-base-namespace).v2021_09_01.models.AzureFunctionReceiver] + :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :paramtype arm_role_receivers: + list[~$(python-base-namespace).v2021_09_01.models.ArmRoleReceiver] + :keyword event_hub_receivers: The list of event hub receivers that are part of this action + group. + :paramtype event_hub_receivers: + list[~$(python-base-namespace).v2021_09_01.models.EventHubReceiver] + """ super(NotificationRequestBody, self).__init__(**kwargs) self.alert_type = kwargs['alert_type'] self.email_receivers = kwargs.get('email_receivers', None) @@ -761,13 +997,13 @@ class SmsReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SMS receiver. Names must be unique across all receivers + :ivar name: Required. The name of the SMS receiver. Names must be unique across all receivers within an action group. - :type name: str - :param country_code: Required. The country code of the SMS receiver. - :type country_code: str - :param phone_number: Required. The phone number of the SMS receiver. - :type phone_number: str + :vartype name: str + :ivar country_code: Required. The country code of the SMS receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the SMS receiver. + :vartype phone_number: str :ivar status: The status of the receiver. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2021_09_01.models.ReceiverStatus @@ -791,6 +1027,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the SMS receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the SMS receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the SMS receiver. + :paramtype phone_number: str + """ super(SmsReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.country_code = kwargs['country_code'] @@ -803,16 +1048,16 @@ class TestNotificationDetailsResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param context: The context info. - :type context: ~$(python-base-namespace).v2021_09_01.models.Context - :param state: Required. The overall state. - :type state: str - :param completed_time: The completed time. - :type completed_time: str - :param created_time: The created time. - :type created_time: str - :param action_details: The list of action detail. - :type action_details: list[~$(python-base-namespace).v2021_09_01.models.ActionDetail] + :ivar context: The context info. + :vartype context: ~$(python-base-namespace).v2021_09_01.models.Context + :ivar state: Required. The overall state. + :vartype state: str + :ivar completed_time: The completed time. + :vartype completed_time: str + :ivar created_time: The created time. + :vartype created_time: str + :ivar action_details: The list of action detail. + :vartype action_details: list[~$(python-base-namespace).v2021_09_01.models.ActionDetail] """ _validation = { @@ -831,6 +1076,18 @@ def __init__( self, **kwargs ): + """ + :keyword context: The context info. + :paramtype context: ~$(python-base-namespace).v2021_09_01.models.Context + :keyword state: Required. The overall state. + :paramtype state: str + :keyword completed_time: The completed time. + :paramtype completed_time: str + :keyword created_time: The created time. + :paramtype created_time: str + :keyword action_details: The list of action detail. + :paramtype action_details: list[~$(python-base-namespace).v2021_09_01.models.ActionDetail] + """ super(TestNotificationDetailsResponse, self).__init__(**kwargs) self.context = kwargs.get('context', None) self.state = kwargs['state'] @@ -844,12 +1101,12 @@ class TestNotificationResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param notification_id: Required. The notification id. - :type notification_id: str - :param correlation_id: Required. The correlation id. - :type correlation_id: str - :param created_time: Required. The created time. - :type created_time: str + :ivar notification_id: Required. The notification id. + :vartype notification_id: str + :ivar correlation_id: Required. The correlation id. + :vartype correlation_id: str + :ivar created_time: Required. The created time. + :vartype created_time: str """ _validation = { @@ -868,6 +1125,14 @@ def __init__( self, **kwargs ): + """ + :keyword notification_id: Required. The notification id. + :paramtype notification_id: str + :keyword correlation_id: Required. The correlation id. + :paramtype correlation_id: str + :keyword created_time: Required. The created time. + :paramtype created_time: str + """ super(TestNotificationResponse, self).__init__(**kwargs) self.notification_id = kwargs['notification_id'] self.correlation_id = kwargs['correlation_id'] @@ -879,13 +1144,13 @@ class VoiceReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the voice receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param country_code: Required. The country code of the voice receiver. - :type country_code: str - :param phone_number: Required. The phone number of the voice receiver. - :type phone_number: str + :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar country_code: Required. The country code of the voice receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the voice receiver. + :vartype phone_number: str """ _validation = { @@ -904,6 +1169,15 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the voice receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the voice receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the voice receiver. + :paramtype phone_number: str + """ super(VoiceReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.country_code = kwargs['country_code'] @@ -915,21 +1189,21 @@ class WebhookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the webhook receiver. Names must be unique across all + :ivar name: Required. The name of the webhook receiver. Names must be unique across all receivers within an action group. - :type name: str - :param service_uri: Required. The URI where webhooks should be sent. - :type service_uri: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool - :param use_aad_auth: Indicates whether or not use AAD authentication. - :type use_aad_auth: bool - :param object_id: Indicates the webhook app object Id for aad auth. - :type object_id: str - :param identifier_uri: Indicates the identifier uri for aad auth. - :type identifier_uri: str - :param tenant_id: Indicates the tenant id for aad auth. - :type tenant_id: str + :vartype name: str + :ivar service_uri: Required. The URI where webhooks should be sent. + :vartype service_uri: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + :ivar use_aad_auth: Indicates whether or not use AAD authentication. + :vartype use_aad_auth: bool + :ivar object_id: Indicates the webhook app object Id for aad auth. + :vartype object_id: str + :ivar identifier_uri: Indicates the identifier uri for aad auth. + :vartype identifier_uri: str + :ivar tenant_id: Indicates the tenant id for aad auth. + :vartype tenant_id: str """ _validation = { @@ -951,6 +1225,23 @@ def __init__( self, **kwargs ): + """ + :keyword name: Required. The name of the webhook receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword service_uri: Required. The URI where webhooks should be sent. + :paramtype service_uri: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + :keyword use_aad_auth: Indicates whether or not use AAD authentication. + :paramtype use_aad_auth: bool + :keyword object_id: Indicates the webhook app object Id for aad auth. + :paramtype object_id: str + :keyword identifier_uri: Indicates the identifier uri for aad auth. + :paramtype identifier_uri: str + :keyword tenant_id: Indicates the tenant id for aad auth. + :paramtype tenant_id: str + """ super(WebhookReceiver, self).__init__(**kwargs) self.name = kwargs['name'] self.service_uri = kwargs['service_uri'] diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models_py3.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models_py3.py index 2f5c11e9c6844..f4bb3bb6ba738 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models_py3.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_models_py3.py @@ -15,18 +15,18 @@ class ActionDetail(msrest.serialization.Model): """The action detail. - :param mechanism_type: The mechanism type. - :type mechanism_type: str - :param name: The name of the action. - :type name: str - :param status: The status of the action. - :type status: str - :param sub_state: The substatus of the action. - :type sub_state: str - :param send_time: The send time. - :type send_time: str - :param detail: The detail of the friendly error message. - :type detail: str + :ivar mechanism_type: The mechanism type. + :vartype mechanism_type: str + :ivar name: The name of the action. + :vartype name: str + :ivar status: The status of the action. + :vartype status: str + :ivar sub_state: The substatus of the action. + :vartype sub_state: str + :ivar send_time: The send time. + :vartype send_time: str + :ivar detail: The detail of the friendly error message. + :vartype detail: str """ _attribute_map = { @@ -49,6 +49,20 @@ def __init__( detail: Optional[str] = None, **kwargs ): + """ + :keyword mechanism_type: The mechanism type. + :paramtype mechanism_type: str + :keyword name: The name of the action. + :paramtype name: str + :keyword status: The status of the action. + :paramtype status: str + :keyword sub_state: The substatus of the action. + :paramtype sub_state: str + :keyword send_time: The send time. + :paramtype send_time: str + :keyword detail: The detail of the friendly error message. + :paramtype detail: str + """ super(ActionDetail, self).__init__(**kwargs) self.mechanism_type = mechanism_type self.name = name @@ -61,10 +75,10 @@ def __init__( class ActionGroupList(msrest.serialization.Model): """A list of action groups. - :param value: The list of action groups. - :type value: list[~$(python-base-namespace).v2021_09_01.models.ActionGroupResource] - :param next_link: Provides the link to retrieve the next set of elements. - :type next_link: str + :ivar value: The list of action groups. + :vartype value: list[~$(python-base-namespace).v2021_09_01.models.ActionGroupResource] + :ivar next_link: Provides the link to retrieve the next set of elements. + :vartype next_link: str """ _attribute_map = { @@ -79,6 +93,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of action groups. + :paramtype value: list[~$(python-base-namespace).v2021_09_01.models.ActionGroupResource] + :keyword next_link: Provides the link to retrieve the next set of elements. + :paramtype next_link: str + """ super(ActionGroupList, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -87,11 +107,11 @@ def __init__( class ActionGroupPatchBody(msrest.serialization.Model): """An action group object for the body of patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its actions will be activated. - :type enabled: bool + :vartype enabled: bool """ _attribute_map = { @@ -106,6 +126,13 @@ def __init__( enabled: Optional[bool] = True, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its actions will be activated. + :paramtype enabled: bool + """ super(ActionGroupPatchBody, self).__init__(**kwargs) self.tags = tags self.enabled = enabled @@ -128,10 +155,10 @@ class AzureResource(msrest.serialization.Model): :vartype kind: str :ivar identity: Azure resource identity. :vartype identity: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. 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 = { @@ -160,6 +187,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(AzureResource, self).__init__(**kwargs) self.id = None self.name = None @@ -187,44 +220,46 @@ class ActionGroupResource(AzureResource): :vartype kind: str :ivar identity: Azure resource identity. :vartype identity: str - :param location: Required. Resource location. - :type location: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param group_short_name: The short name of the action group. This will be used in SMS messages. - :type group_short_name: str - :param enabled: Indicates whether this action group is enabled. If an action group is not + :ivar location: Required. Resource location. + :vartype location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar group_short_name: The short name of the action group. This will be used in SMS messages. + :vartype group_short_name: str + :ivar enabled: Indicates whether this action group is enabled. If an action group is not enabled, then none of its receivers will receive communications. - :type enabled: bool - :param email_receivers: The list of email receivers that are part of this action group. - :type email_receivers: list[~$(python-base-namespace).v2021_09_01.models.EmailReceiver] - :param sms_receivers: The list of SMS receivers that are part of this action group. - :type sms_receivers: list[~$(python-base-namespace).v2021_09_01.models.SmsReceiver] - :param webhook_receivers: The list of webhook receivers that are part of this action group. - :type webhook_receivers: list[~$(python-base-namespace).v2021_09_01.models.WebhookReceiver] - :param itsm_receivers: The list of ITSM receivers that are part of this action group. - :type itsm_receivers: list[~$(python-base-namespace).v2021_09_01.models.ItsmReceiver] - :param azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :type azure_app_push_receivers: + :vartype enabled: bool + :ivar email_receivers: The list of email receivers that are part of this action group. + :vartype email_receivers: list[~$(python-base-namespace).v2021_09_01.models.EmailReceiver] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~$(python-base-namespace).v2021_09_01.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~$(python-base-namespace).v2021_09_01.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~$(python-base-namespace).v2021_09_01.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: list[~$(python-base-namespace).v2021_09_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of this action group. - :type automation_runbook_receivers: + :vartype automation_runbook_receivers: list[~$(python-base-namespace).v2021_09_01.models.AutomationRunbookReceiver] - :param voice_receivers: The list of voice receivers that are part of this action group. - :type voice_receivers: list[~$(python-base-namespace).v2021_09_01.models.VoiceReceiver] - :param logic_app_receivers: The list of logic app receivers that are part of this action group. - :type logic_app_receivers: list[~$(python-base-namespace).v2021_09_01.models.LogicAppReceiver] - :param azure_function_receivers: The list of azure function receivers that are part of this + :ivar voice_receivers: The list of voice receivers that are part of this action group. + :vartype voice_receivers: list[~$(python-base-namespace).v2021_09_01.models.VoiceReceiver] + :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. + :vartype logic_app_receivers: + list[~$(python-base-namespace).v2021_09_01.models.LogicAppReceiver] + :ivar azure_function_receivers: The list of azure function receivers that are part of this action group. - :type azure_function_receivers: + :vartype azure_function_receivers: list[~$(python-base-namespace).v2021_09_01.models.AzureFunctionReceiver] - :param arm_role_receivers: The list of ARM role receivers that are part of this action group. + :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. Roles are Azure RBAC roles and only built-in roles are supported. - :type arm_role_receivers: list[~$(python-base-namespace).v2021_09_01.models.ArmRoleReceiver] - :param event_hub_receivers: The list of event hub receivers that are part of this action group. - :type event_hub_receivers: list[~$(python-base-namespace).v2021_09_01.models.EventHubReceiver] + :vartype arm_role_receivers: list[~$(python-base-namespace).v2021_09_01.models.ArmRoleReceiver] + :ivar event_hub_receivers: The list of event hub receivers that are part of this action group. + :vartype event_hub_receivers: + list[~$(python-base-namespace).v2021_09_01.models.EventHubReceiver] """ _validation = { @@ -280,6 +315,53 @@ def __init__( event_hub_receivers: Optional[List["EventHubReceiver"]] = None, **kwargs ): + """ + :keyword location: Required. Resource location. + :paramtype location: str + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword group_short_name: The short name of the action group. This will be used in SMS + messages. + :paramtype group_short_name: str + :keyword enabled: Indicates whether this action group is enabled. If an action group is not + enabled, then none of its receivers will receive communications. + :paramtype enabled: bool + :keyword email_receivers: The list of email receivers that are part of this action group. + :paramtype email_receivers: list[~$(python-base-namespace).v2021_09_01.models.EmailReceiver] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~$(python-base-namespace).v2021_09_01.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: + list[~$(python-base-namespace).v2021_09_01.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~$(python-base-namespace).v2021_09_01.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: + list[~$(python-base-namespace).v2021_09_01.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~$(python-base-namespace).v2021_09_01.models.AutomationRunbookReceiver] + :keyword voice_receivers: The list of voice receivers that are part of this action group. + :paramtype voice_receivers: list[~$(python-base-namespace).v2021_09_01.models.VoiceReceiver] + :keyword logic_app_receivers: The list of logic app receivers that are part of this action + group. + :paramtype logic_app_receivers: + list[~$(python-base-namespace).v2021_09_01.models.LogicAppReceiver] + :keyword azure_function_receivers: The list of azure function receivers that are part of this + action group. + :paramtype azure_function_receivers: + list[~$(python-base-namespace).v2021_09_01.models.AzureFunctionReceiver] + :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :paramtype arm_role_receivers: + list[~$(python-base-namespace).v2021_09_01.models.ArmRoleReceiver] + :keyword event_hub_receivers: The list of event hub receivers that are part of this action + group. + :paramtype event_hub_receivers: + list[~$(python-base-namespace).v2021_09_01.models.EventHubReceiver] + """ super(ActionGroupResource, self).__init__(location=location, tags=tags, **kwargs) self.group_short_name = group_short_name self.enabled = enabled @@ -301,13 +383,13 @@ class ArmRoleReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the arm role receiver. Names must be unique across all + :ivar name: Required. The name of the arm role receiver. Names must be unique across all receivers within an action group. - :type name: str - :param role_id: Required. The arm role id. - :type role_id: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar role_id: Required. The arm role id. + :vartype role_id: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -329,6 +411,15 @@ def __init__( use_common_alert_schema: Optional[bool] = False, **kwargs ): + """ + :keyword name: Required. The name of the arm role receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword role_id: Required. The arm role id. + :paramtype role_id: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(ArmRoleReceiver, self).__init__(**kwargs) self.name = name self.role_id = role_id @@ -340,21 +431,21 @@ class AutomationRunbookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param automation_account_id: Required. The Azure automation account Id which holds this - runbook and authenticate to Azure resource. - :type automation_account_id: str - :param runbook_name: Required. The name for this runbook. - :type runbook_name: str - :param webhook_resource_id: Required. The resource id for webhook linked to this runbook. - :type webhook_resource_id: str - :param is_global_runbook: Required. Indicates whether this instance is global runbook. - :type is_global_runbook: bool - :param name: Indicates name of the webhook. - :type name: str - :param service_uri: The URI where webhooks should be sent. - :type service_uri: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :ivar automation_account_id: Required. The Azure automation account Id which holds this runbook + and authenticate to Azure resource. + :vartype automation_account_id: str + :ivar runbook_name: Required. The name for this runbook. + :vartype runbook_name: str + :ivar webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :vartype webhook_resource_id: str + :ivar is_global_runbook: Required. Indicates whether this instance is global runbook. + :vartype is_global_runbook: bool + :ivar name: Indicates name of the webhook. + :vartype name: str + :ivar service_uri: The URI where webhooks should be sent. + :vartype service_uri: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -386,6 +477,23 @@ def __init__( use_common_alert_schema: Optional[bool] = False, **kwargs ): + """ + :keyword automation_account_id: Required. The Azure automation account Id which holds this + runbook and authenticate to Azure resource. + :paramtype automation_account_id: str + :keyword runbook_name: Required. The name for this runbook. + :paramtype runbook_name: str + :keyword webhook_resource_id: Required. The resource id for webhook linked to this runbook. + :paramtype webhook_resource_id: str + :keyword is_global_runbook: Required. Indicates whether this instance is global runbook. + :paramtype is_global_runbook: bool + :keyword name: Indicates name of the webhook. + :paramtype name: str + :keyword service_uri: The URI where webhooks should be sent. + :paramtype service_uri: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(AutomationRunbookReceiver, self).__init__(**kwargs) self.automation_account_id = automation_account_id self.runbook_name = runbook_name @@ -401,11 +509,11 @@ class AzureAppPushReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Azure mobile app push receiver. Names must be unique + :ivar name: Required. The name of the Azure mobile app push receiver. Names must be unique across all receivers within an action group. - :type name: str - :param email_address: Required. The email address registered for the Azure mobile app. - :type email_address: str + :vartype name: str + :ivar email_address: Required. The email address registered for the Azure mobile app. + :vartype email_address: str """ _validation = { @@ -425,6 +533,13 @@ def __init__( email_address: str, **kwargs ): + """ + :keyword name: Required. The name of the Azure mobile app push receiver. Names must be unique + across all receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address registered for the Azure mobile app. + :paramtype email_address: str + """ super(AzureAppPushReceiver, self).__init__(**kwargs) self.name = name self.email_address = email_address @@ -435,17 +550,17 @@ class AzureFunctionReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the azure function receiver. Names must be unique across all + :ivar name: Required. The name of the azure function receiver. Names must be unique across all receivers within an action group. - :type name: str - :param function_app_resource_id: Required. The azure resource id of the function app. - :type function_app_resource_id: str - :param function_name: Required. The function name in the function app. - :type function_name: str - :param http_trigger_url: Required. The http trigger url where http request sent to. - :type http_trigger_url: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar function_app_resource_id: Required. The azure resource id of the function app. + :vartype function_app_resource_id: str + :ivar function_name: Required. The function name in the function app. + :vartype function_name: str + :ivar http_trigger_url: Required. The http trigger url where http request sent to. + :vartype http_trigger_url: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -473,6 +588,19 @@ def __init__( use_common_alert_schema: Optional[bool] = False, **kwargs ): + """ + :keyword name: Required. The name of the azure function receiver. Names must be unique across + all receivers within an action group. + :paramtype name: str + :keyword function_app_resource_id: Required. The azure resource id of the function app. + :paramtype function_app_resource_id: str + :keyword function_name: Required. The function name in the function app. + :paramtype function_name: str + :keyword http_trigger_url: Required. The http trigger url where http request sent to. + :paramtype http_trigger_url: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(AzureFunctionReceiver, self).__init__(**kwargs) self.name = name self.function_app_resource_id = function_app_resource_id @@ -484,10 +612,10 @@ def __init__( class Context(msrest.serialization.Model): """The context info. - :param notification_source: The source of the notification request. - :type notification_source: str - :param context_type: The context id type. - :type context_type: str + :ivar notification_source: The source of the notification request. + :vartype notification_source: str + :ivar context_type: The context id type. + :vartype context_type: str """ _attribute_map = { @@ -502,6 +630,12 @@ def __init__( context_type: Optional[str] = None, **kwargs ): + """ + :keyword notification_source: The source of the notification request. + :paramtype notification_source: str + :keyword context_type: The context id type. + :paramtype context_type: str + """ super(Context, self).__init__(**kwargs) self.notification_source = notification_source self.context_type = context_type @@ -514,13 +648,13 @@ class EmailReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the email receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param email_address: Required. The email address of this receiver. - :type email_address: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :ivar name: Required. The name of the email receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar email_address: Required. The email address of this receiver. + :vartype email_address: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool :ivar status: The receiver status of the e-mail. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2021_09_01.models.ReceiverStatus @@ -547,6 +681,15 @@ def __init__( use_common_alert_schema: Optional[bool] = False, **kwargs ): + """ + :keyword name: Required. The name of the email receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword email_address: Required. The email address of this receiver. + :paramtype email_address: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(EmailReceiver, self).__init__(**kwargs) self.name = name self.email_address = email_address @@ -559,8 +702,8 @@ class EnableRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param receiver_name: Required. The name of the receiver to resubscribe. - :type receiver_name: str + :ivar receiver_name: Required. The name of the receiver to resubscribe. + :vartype receiver_name: str """ _validation = { @@ -577,6 +720,10 @@ def __init__( receiver_name: str, **kwargs ): + """ + :keyword receiver_name: Required. The name of the receiver to resubscribe. + :paramtype receiver_name: str + """ super(EnableRequest, self).__init__(**kwargs) self.receiver_name = receiver_name @@ -584,10 +731,10 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Describes the format of Error response. - :param code: Error code. - :type code: str - :param message: Error message indicating why the operation failed. - :type message: str + :ivar code: Error code. + :vartype code: str + :ivar message: Error message indicating why the operation failed. + :vartype message: str """ _attribute_map = { @@ -602,6 +749,12 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Error code. + :paramtype code: str + :keyword message: Error message indicating why the operation failed. + :paramtype message: str + """ super(ErrorResponse, self).__init__(**kwargs) self.code = code self.message = message @@ -612,19 +765,19 @@ class EventHubReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Event hub receiver. Names must be unique across all + :ivar name: Required. The name of the Event hub receiver. Names must be unique across all receivers within an action group. - :type name: str - :param event_hub_name_space: Required. The Event Hub namespace. - :type event_hub_name_space: str - :param event_hub_name: Required. The name of the specific Event Hub queue. - :type event_hub_name: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool - :param tenant_id: The tenant Id for the subscription containing this event hub. - :type tenant_id: str - :param subscription_id: Required. The Id for the subscription containing this event hub. - :type subscription_id: str + :vartype name: str + :ivar event_hub_name_space: Required. The Event Hub namespace. + :vartype event_hub_name_space: str + :ivar event_hub_name: Required. The name of the specific Event Hub queue. + :vartype event_hub_name: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + :ivar tenant_id: The tenant Id for the subscription containing this event hub. + :vartype tenant_id: str + :ivar subscription_id: Required. The Id for the subscription containing this event hub. + :vartype subscription_id: str """ _validation = { @@ -654,6 +807,21 @@ def __init__( tenant_id: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. The name of the Event hub receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword event_hub_name_space: Required. The Event Hub namespace. + :paramtype event_hub_name_space: str + :keyword event_hub_name: Required. The name of the specific Event Hub queue. + :paramtype event_hub_name: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + :keyword tenant_id: The tenant Id for the subscription containing this event hub. + :paramtype tenant_id: str + :keyword subscription_id: Required. The Id for the subscription containing this event hub. + :paramtype subscription_id: str + """ super(EventHubReceiver, self).__init__(**kwargs) self.name = name self.event_hub_name_space = event_hub_name_space @@ -668,20 +836,20 @@ class ItsmReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the Itsm receiver. Names must be unique across all receivers + :ivar name: Required. The name of the Itsm receiver. Names must be unique across all receivers within an action group. - :type name: str - :param workspace_id: Required. OMS LA instance identifier. - :type workspace_id: str - :param connection_id: Required. Unique identification of ITSM connection among multiple defined + :vartype name: str + :ivar workspace_id: Required. OMS LA instance identifier. + :vartype workspace_id: str + :ivar connection_id: Required. Unique identification of ITSM connection among multiple defined in above workspace. - :type connection_id: str - :param ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + :vartype connection_id: str + :ivar ticket_configuration: Required. JSON blob for the configurations of the ITSM action. CreateMultipleWorkItems option will be part of this blob as well. - :type ticket_configuration: str - :param region: Required. Region in which workspace resides. Supported + :vartype ticket_configuration: str + :ivar region: Required. Region in which workspace resides. Supported values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. - :type region: str + :vartype region: str """ _validation = { @@ -710,6 +878,22 @@ def __init__( region: str, **kwargs ): + """ + :keyword name: Required. The name of the Itsm receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword workspace_id: Required. OMS LA instance identifier. + :paramtype workspace_id: str + :keyword connection_id: Required. Unique identification of ITSM connection among multiple + defined in above workspace. + :paramtype connection_id: str + :keyword ticket_configuration: Required. JSON blob for the configurations of the ITSM action. + CreateMultipleWorkItems option will be part of this blob as well. + :paramtype ticket_configuration: str + :keyword region: Required. Region in which workspace resides. Supported + values:'centralindia','japaneast','southeastasia','australiasoutheast','uksouth','westcentralus','canadacentral','eastus','westeurope'. + :paramtype region: str + """ super(ItsmReceiver, self).__init__(**kwargs) self.name = name self.workspace_id = workspace_id @@ -723,15 +907,15 @@ class LogicAppReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the logic app receiver. Names must be unique across all + :ivar name: Required. The name of the logic app receiver. Names must be unique across all receivers within an action group. - :type name: str - :param resource_id: Required. The azure resource id of the logic app receiver. - :type resource_id: str - :param callback_url: Required. The callback url where http request sent to. - :type callback_url: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool + :vartype name: str + :ivar resource_id: Required. The azure resource id of the logic app receiver. + :vartype resource_id: str + :ivar callback_url: Required. The callback url where http request sent to. + :vartype callback_url: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool """ _validation = { @@ -756,6 +940,17 @@ def __init__( use_common_alert_schema: Optional[bool] = False, **kwargs ): + """ + :keyword name: Required. The name of the logic app receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword resource_id: Required. The azure resource id of the logic app receiver. + :paramtype resource_id: str + :keyword callback_url: Required. The callback url where http request sent to. + :paramtype callback_url: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + """ super(LogicAppReceiver, self).__init__(**kwargs) self.name = name self.resource_id = resource_id @@ -768,37 +963,39 @@ class NotificationRequestBody(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param alert_type: Required. The name of the supported alert type. - :type alert_type: str - :param email_receivers: The list of email receivers that are part of this action group. - :type email_receivers: list[~$(python-base-namespace).v2021_09_01.models.EmailReceiver] - :param sms_receivers: The list of SMS receivers that are part of this action group. - :type sms_receivers: list[~$(python-base-namespace).v2021_09_01.models.SmsReceiver] - :param webhook_receivers: The list of webhook receivers that are part of this action group. - :type webhook_receivers: list[~$(python-base-namespace).v2021_09_01.models.WebhookReceiver] - :param itsm_receivers: The list of ITSM receivers that are part of this action group. - :type itsm_receivers: list[~$(python-base-namespace).v2021_09_01.models.ItsmReceiver] - :param azure_app_push_receivers: The list of AzureAppPush receivers that are part of this - action group. - :type azure_app_push_receivers: + :ivar alert_type: Required. The name of the supported alert type. + :vartype alert_type: str + :ivar email_receivers: The list of email receivers that are part of this action group. + :vartype email_receivers: list[~$(python-base-namespace).v2021_09_01.models.EmailReceiver] + :ivar sms_receivers: The list of SMS receivers that are part of this action group. + :vartype sms_receivers: list[~$(python-base-namespace).v2021_09_01.models.SmsReceiver] + :ivar webhook_receivers: The list of webhook receivers that are part of this action group. + :vartype webhook_receivers: list[~$(python-base-namespace).v2021_09_01.models.WebhookReceiver] + :ivar itsm_receivers: The list of ITSM receivers that are part of this action group. + :vartype itsm_receivers: list[~$(python-base-namespace).v2021_09_01.models.ItsmReceiver] + :ivar azure_app_push_receivers: The list of AzureAppPush receivers that are part of this action + group. + :vartype azure_app_push_receivers: list[~$(python-base-namespace).v2021_09_01.models.AzureAppPushReceiver] - :param automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + :ivar automation_runbook_receivers: The list of AutomationRunbook receivers that are part of this action group. - :type automation_runbook_receivers: + :vartype automation_runbook_receivers: list[~$(python-base-namespace).v2021_09_01.models.AutomationRunbookReceiver] - :param voice_receivers: The list of voice receivers that are part of this action group. - :type voice_receivers: list[~$(python-base-namespace).v2021_09_01.models.VoiceReceiver] - :param logic_app_receivers: The list of logic app receivers that are part of this action group. - :type logic_app_receivers: list[~$(python-base-namespace).v2021_09_01.models.LogicAppReceiver] - :param azure_function_receivers: The list of azure function receivers that are part of this + :ivar voice_receivers: The list of voice receivers that are part of this action group. + :vartype voice_receivers: list[~$(python-base-namespace).v2021_09_01.models.VoiceReceiver] + :ivar logic_app_receivers: The list of logic app receivers that are part of this action group. + :vartype logic_app_receivers: + list[~$(python-base-namespace).v2021_09_01.models.LogicAppReceiver] + :ivar azure_function_receivers: The list of azure function receivers that are part of this action group. - :type azure_function_receivers: + :vartype azure_function_receivers: list[~$(python-base-namespace).v2021_09_01.models.AzureFunctionReceiver] - :param arm_role_receivers: The list of ARM role receivers that are part of this action group. + :ivar arm_role_receivers: The list of ARM role receivers that are part of this action group. Roles are Azure RBAC roles and only built-in roles are supported. - :type arm_role_receivers: list[~$(python-base-namespace).v2021_09_01.models.ArmRoleReceiver] - :param event_hub_receivers: The list of event hub receivers that are part of this action group. - :type event_hub_receivers: list[~$(python-base-namespace).v2021_09_01.models.EventHubReceiver] + :vartype arm_role_receivers: list[~$(python-base-namespace).v2021_09_01.models.ArmRoleReceiver] + :ivar event_hub_receivers: The list of event hub receivers that are part of this action group. + :vartype event_hub_receivers: + list[~$(python-base-namespace).v2021_09_01.models.EventHubReceiver] """ _validation = { @@ -837,6 +1034,45 @@ def __init__( event_hub_receivers: Optional[List["EventHubReceiver"]] = None, **kwargs ): + """ + :keyword alert_type: Required. The name of the supported alert type. + :paramtype alert_type: str + :keyword email_receivers: The list of email receivers that are part of this action group. + :paramtype email_receivers: list[~$(python-base-namespace).v2021_09_01.models.EmailReceiver] + :keyword sms_receivers: The list of SMS receivers that are part of this action group. + :paramtype sms_receivers: list[~$(python-base-namespace).v2021_09_01.models.SmsReceiver] + :keyword webhook_receivers: The list of webhook receivers that are part of this action group. + :paramtype webhook_receivers: + list[~$(python-base-namespace).v2021_09_01.models.WebhookReceiver] + :keyword itsm_receivers: The list of ITSM receivers that are part of this action group. + :paramtype itsm_receivers: list[~$(python-base-namespace).v2021_09_01.models.ItsmReceiver] + :keyword azure_app_push_receivers: The list of AzureAppPush receivers that are part of this + action group. + :paramtype azure_app_push_receivers: + list[~$(python-base-namespace).v2021_09_01.models.AzureAppPushReceiver] + :keyword automation_runbook_receivers: The list of AutomationRunbook receivers that are part of + this action group. + :paramtype automation_runbook_receivers: + list[~$(python-base-namespace).v2021_09_01.models.AutomationRunbookReceiver] + :keyword voice_receivers: The list of voice receivers that are part of this action group. + :paramtype voice_receivers: list[~$(python-base-namespace).v2021_09_01.models.VoiceReceiver] + :keyword logic_app_receivers: The list of logic app receivers that are part of this action + group. + :paramtype logic_app_receivers: + list[~$(python-base-namespace).v2021_09_01.models.LogicAppReceiver] + :keyword azure_function_receivers: The list of azure function receivers that are part of this + action group. + :paramtype azure_function_receivers: + list[~$(python-base-namespace).v2021_09_01.models.AzureFunctionReceiver] + :keyword arm_role_receivers: The list of ARM role receivers that are part of this action group. + Roles are Azure RBAC roles and only built-in roles are supported. + :paramtype arm_role_receivers: + list[~$(python-base-namespace).v2021_09_01.models.ArmRoleReceiver] + :keyword event_hub_receivers: The list of event hub receivers that are part of this action + group. + :paramtype event_hub_receivers: + list[~$(python-base-namespace).v2021_09_01.models.EventHubReceiver] + """ super(NotificationRequestBody, self).__init__(**kwargs) self.alert_type = alert_type self.email_receivers = email_receivers @@ -859,13 +1095,13 @@ class SmsReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SMS receiver. Names must be unique across all receivers + :ivar name: Required. The name of the SMS receiver. Names must be unique across all receivers within an action group. - :type name: str - :param country_code: Required. The country code of the SMS receiver. - :type country_code: str - :param phone_number: Required. The phone number of the SMS receiver. - :type phone_number: str + :vartype name: str + :ivar country_code: Required. The country code of the SMS receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the SMS receiver. + :vartype phone_number: str :ivar status: The status of the receiver. Possible values include: "NotSpecified", "Enabled", "Disabled". :vartype status: str or ~$(python-base-namespace).v2021_09_01.models.ReceiverStatus @@ -893,6 +1129,15 @@ def __init__( phone_number: str, **kwargs ): + """ + :keyword name: Required. The name of the SMS receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the SMS receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the SMS receiver. + :paramtype phone_number: str + """ super(SmsReceiver, self).__init__(**kwargs) self.name = name self.country_code = country_code @@ -905,16 +1150,16 @@ class TestNotificationDetailsResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param context: The context info. - :type context: ~$(python-base-namespace).v2021_09_01.models.Context - :param state: Required. The overall state. - :type state: str - :param completed_time: The completed time. - :type completed_time: str - :param created_time: The created time. - :type created_time: str - :param action_details: The list of action detail. - :type action_details: list[~$(python-base-namespace).v2021_09_01.models.ActionDetail] + :ivar context: The context info. + :vartype context: ~$(python-base-namespace).v2021_09_01.models.Context + :ivar state: Required. The overall state. + :vartype state: str + :ivar completed_time: The completed time. + :vartype completed_time: str + :ivar created_time: The created time. + :vartype created_time: str + :ivar action_details: The list of action detail. + :vartype action_details: list[~$(python-base-namespace).v2021_09_01.models.ActionDetail] """ _validation = { @@ -939,6 +1184,18 @@ def __init__( action_details: Optional[List["ActionDetail"]] = None, **kwargs ): + """ + :keyword context: The context info. + :paramtype context: ~$(python-base-namespace).v2021_09_01.models.Context + :keyword state: Required. The overall state. + :paramtype state: str + :keyword completed_time: The completed time. + :paramtype completed_time: str + :keyword created_time: The created time. + :paramtype created_time: str + :keyword action_details: The list of action detail. + :paramtype action_details: list[~$(python-base-namespace).v2021_09_01.models.ActionDetail] + """ super(TestNotificationDetailsResponse, self).__init__(**kwargs) self.context = context self.state = state @@ -952,12 +1209,12 @@ class TestNotificationResponse(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param notification_id: Required. The notification id. - :type notification_id: str - :param correlation_id: Required. The correlation id. - :type correlation_id: str - :param created_time: Required. The created time. - :type created_time: str + :ivar notification_id: Required. The notification id. + :vartype notification_id: str + :ivar correlation_id: Required. The correlation id. + :vartype correlation_id: str + :ivar created_time: Required. The created time. + :vartype created_time: str """ _validation = { @@ -980,6 +1237,14 @@ def __init__( created_time: str, **kwargs ): + """ + :keyword notification_id: Required. The notification id. + :paramtype notification_id: str + :keyword correlation_id: Required. The correlation id. + :paramtype correlation_id: str + :keyword created_time: Required. The created time. + :paramtype created_time: str + """ super(TestNotificationResponse, self).__init__(**kwargs) self.notification_id = notification_id self.correlation_id = correlation_id @@ -991,13 +1256,13 @@ class VoiceReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the voice receiver. Names must be unique across all - receivers within an action group. - :type name: str - :param country_code: Required. The country code of the voice receiver. - :type country_code: str - :param phone_number: Required. The phone number of the voice receiver. - :type phone_number: str + :ivar name: Required. The name of the voice receiver. Names must be unique across all receivers + within an action group. + :vartype name: str + :ivar country_code: Required. The country code of the voice receiver. + :vartype country_code: str + :ivar phone_number: Required. The phone number of the voice receiver. + :vartype phone_number: str """ _validation = { @@ -1020,6 +1285,15 @@ def __init__( phone_number: str, **kwargs ): + """ + :keyword name: Required. The name of the voice receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword country_code: Required. The country code of the voice receiver. + :paramtype country_code: str + :keyword phone_number: Required. The phone number of the voice receiver. + :paramtype phone_number: str + """ super(VoiceReceiver, self).__init__(**kwargs) self.name = name self.country_code = country_code @@ -1031,21 +1305,21 @@ class WebhookReceiver(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the webhook receiver. Names must be unique across all + :ivar name: Required. The name of the webhook receiver. Names must be unique across all receivers within an action group. - :type name: str - :param service_uri: Required. The URI where webhooks should be sent. - :type service_uri: str - :param use_common_alert_schema: Indicates whether to use common alert schema. - :type use_common_alert_schema: bool - :param use_aad_auth: Indicates whether or not use AAD authentication. - :type use_aad_auth: bool - :param object_id: Indicates the webhook app object Id for aad auth. - :type object_id: str - :param identifier_uri: Indicates the identifier uri for aad auth. - :type identifier_uri: str - :param tenant_id: Indicates the tenant id for aad auth. - :type tenant_id: str + :vartype name: str + :ivar service_uri: Required. The URI where webhooks should be sent. + :vartype service_uri: str + :ivar use_common_alert_schema: Indicates whether to use common alert schema. + :vartype use_common_alert_schema: bool + :ivar use_aad_auth: Indicates whether or not use AAD authentication. + :vartype use_aad_auth: bool + :ivar object_id: Indicates the webhook app object Id for aad auth. + :vartype object_id: str + :ivar identifier_uri: Indicates the identifier uri for aad auth. + :vartype identifier_uri: str + :ivar tenant_id: Indicates the tenant id for aad auth. + :vartype tenant_id: str """ _validation = { @@ -1075,6 +1349,23 @@ def __init__( tenant_id: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. The name of the webhook receiver. Names must be unique across all + receivers within an action group. + :paramtype name: str + :keyword service_uri: Required. The URI where webhooks should be sent. + :paramtype service_uri: str + :keyword use_common_alert_schema: Indicates whether to use common alert schema. + :paramtype use_common_alert_schema: bool + :keyword use_aad_auth: Indicates whether or not use AAD authentication. + :paramtype use_aad_auth: bool + :keyword object_id: Indicates the webhook app object Id for aad auth. + :paramtype object_id: str + :keyword identifier_uri: Indicates the identifier uri for aad auth. + :paramtype identifier_uri: str + :keyword tenant_id: Indicates the tenant id for aad auth. + :paramtype tenant_id: str + """ super(WebhookReceiver, self).__init__(**kwargs) self.name = name self.service_uri = service_uri diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_monitor_management_client_enums.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_monitor_management_client_enums.py index 238df22ea2f0b..5e8a759db49cf 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_monitor_management_client_enums.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/models/_monitor_management_client_enums.py @@ -6,27 +6,12 @@ # 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 ReceiverStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReceiverStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Indicates the status of the receiver. Receivers that are not Enabled will not receive any communications. """ diff --git a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_action_groups_operations.py b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_action_groups_operations.py index 8c710ee5b3cce..996796117e123 100644 --- a/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_action_groups_operations.py +++ b/sdk/monitor/azure-mgmt-monitor/azure/mgmt/monitor/v2021_09_01/operations/_action_groups_operations.py @@ -5,26 +5,362 @@ # 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 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.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_create_or_update_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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] + 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, + **kwargs + ) + + +def build_get_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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_delete_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + subscription_id, # type: str + resource_group_name, # type: str + action_group_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_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] + 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, + **kwargs + ) + + +def build_post_test_notifications_request_initial( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications') + 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] + 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_test_notifications_request( + subscription_id, # type: str + notification_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "notificationId": _SERIALIZER.url("notification_id", notification_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_list_by_subscription_id_request( + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups') + 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( + resource_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + api_version = "2021-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "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_enable_receiver_request( + resource_group_name, # type: str + action_group_name, # type: str + subscription_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-09-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "actionGroupName": _SERIALIZER.url("action_group_name", action_group_name, 'str'), + "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] + 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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +# fmt: on class ActionGroupsOperations(object): """ActionGroupsOperations operations. @@ -47,6 +383,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def create_or_update( self, resource_group_name, # type: str @@ -73,38 +410,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group, 'ActionGroupResource') + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + 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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group, 'ActionGroupResource') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -117,8 +444,11 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def get( self, resource_group_name, # type: str @@ -142,33 +472,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.get.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -177,8 +497,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def delete( self, resource_group_name, # type: str @@ -202,33 +525,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -236,6 +549,8 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}'} # type: ignore + + @distributed_trace def update( self, resource_group_name, # type: str @@ -262,38 +577,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - 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', max_length=90, min_length=1), - 'actionGroupName': self._serialize.url("action_group_name", action_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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + action_group_name=action_group_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) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(action_group_patch, 'ActionGroupPatchBody') - 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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ActionGroupResource', pipeline_response) @@ -302,8 +607,10 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}'} # type: ignore + def _post_test_notifications_initial( self, notification_request, # type: "_models.NotificationRequestBody" @@ -315,37 +622,26 @@ def _post_test_notifications_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._post_test_notifications_initial.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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(notification_request, 'NotificationRequestBody') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_post_test_notifications_request_initial( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self._post_test_notifications_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(notification_request, 'NotificationRequestBody') - body_content_kwargs['content'] = body_content - request = self._client.post(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 [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = self._deserialize('TestNotificationResponse', pipeline_response) @@ -353,8 +649,11 @@ def _post_test_notifications_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _post_test_notifications_initial.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications'} # type: ignore + + @distributed_trace def begin_post_test_notifications( self, notification_request, # type: "_models.NotificationRequestBody" @@ -364,18 +663,24 @@ def begin_post_test_notifications( """Send test notifications to a set of provided receivers. :param notification_request: The notification request body which includes the contact details. - :type notification_request: ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody + :type notification_request: + ~$(python-base-namespace).v2021_09_01.models.NotificationRequestBody :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either TestNotificationResponse or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationResponse] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either TestNotificationResponse or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~$(python-base-namespace).v2021_09_01.models.TestNotificationResponse] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.TestNotificationResponse"] lro_delay = kwargs.pop( 'polling_interval', @@ -385,25 +690,21 @@ def begin_post_test_notifications( if cont_token is None: raw_result = self._post_test_notifications_initial( notification_request=notification_request, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('TestNotificationResponse', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'location'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -415,8 +716,10 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_post_test_notifications.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/createNotifications'} # type: ignore + @distributed_trace def get_test_notifications( self, notification_id, # type: str @@ -437,32 +740,22 @@ def get_test_notifications( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - accept = "application/json" - - # Construct URL - url = self.get_test_notifications.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'notificationId': self._serialize.url("notification_id", notification_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_test_notifications_request( + subscription_id=self._config.subscription_id, + notification_id=notification_id, + template_url=self.get_test_notifications.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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestNotificationDetailsResponse', pipeline_response) @@ -471,8 +764,11 @@ def get_test_notifications( return cls(pipeline_response, deserialized, {}) return deserialized + get_test_notifications.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/notificationStatus/{notificationId}'} # type: ignore + + @distributed_trace def list_by_subscription_id( self, **kwargs # type: Any @@ -482,7 +778,8 @@ def list_by_subscription_id( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ActionGroupList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupList] + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -490,34 +787,29 @@ def list_by_subscription_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-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_subscription_id.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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription_id.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_list_by_subscription_id_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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -530,17 +822,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Insights/actionGroups'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name, # type: str @@ -553,7 +847,8 @@ def list_by_resource_group( :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 ActionGroupList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupList] + :rtype: + ~azure.core.paging.ItemPaged[~$(python-base-namespace).v2021_09_01.models.ActionGroupList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ActionGroupList"] @@ -561,35 +856,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-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 = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - '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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + template_url=self.list_by_resource_group.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_list_by_resource_group_request( + resource_group_name=resource_group_name, + 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('ActionGroupList', pipeline_response) + deserialized = self._deserialize("ActionGroupList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -602,17 +893,19 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) 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.Insights/actionGroups'} # type: ignore + @distributed_trace def enable_receiver( self, resource_group_name, # type: str @@ -640,41 +933,32 @@ def enable_receiver( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.enable_receiver.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'actionGroupName': self._serialize.url("action_group_name", action_group_name, 'str'), - '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[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') + _json = self._serialize.body(enable_request, 'EnableRequest') + + request = build_enable_receiver_request( + resource_group_name=resource_group_name, + action_group_name=action_group_name, + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.enable_receiver.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(enable_request, 'EnableRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(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.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) enable_receiver.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/actionGroups/{actionGroupName}/subscribe'} # type: ignore +